24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
25 include_once
'Modules/Test/classes/class.ilTestExpressPage.php';
79 $this->ctrl->saveParameter($this,
"q_id");
80 $this->ctrl->saveParameter($this,
"prev_qid");
81 $this->ctrl->saveParameter($this,
"calling_test");
82 $this->ctrl->saveParameterByClass(
'ilPageObjectGUI',
'test_express_mode');
83 $this->ctrl->saveParameterByClass(
'ilobjquestionpoolgui',
'test_express_mode');
85 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
86 $this->errormessage = $this->lng->txt(
"fill_out_all_required_fields");
88 $this->selfassessmenteditingmode =
false;
89 $this->new_id_listeners = array();
90 $this->new_id_listener_cnt = 0;
98 $cmd = $this->ctrl->getCmd(
"editQuestion");
99 $next_class = $this->ctrl->getNextClass($this);
140 $this->tpl->addBlockFile(
"CONTENT",
"content",
"tpl.il_as_qpl_content.html",
"Modules/TestQuestionPool");
141 $this->tpl->addBlockFile(
"STATUSLINE",
"statusline",
"tpl.statusline.html");
143 $total_of_answers = $this->
object->getTotalAnswers();
145 $color_class = array(
"tblrow1",
"tblrow2");
146 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_as_qpl_assessment_of_questions.html",
"Modules/TestQuestionPool");
147 if (!$total_of_answers)
149 $this->tpl->setCurrentBlock(
"emptyrow");
150 $this->tpl->setVariable(
"TXT_NO_ASSESSMENT", $this->lng->txt(
"qpl_assessment_no_assessment_of_questions"));
151 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
152 $this->tpl->parseCurrentBlock();
156 $this->tpl->setCurrentBlock(
"row");
157 $this->tpl->setVariable(
"TXT_RESULT", $this->lng->txt(
"qpl_assessment_total_of_answers"));
158 $this->tpl->setVariable(
"TXT_VALUE", $total_of_answers);
159 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
161 $this->tpl->parseCurrentBlock();
162 $this->tpl->setCurrentBlock(
"row");
163 $this->tpl->setVariable(
"TXT_RESULT", $this->lng->txt(
"qpl_assessment_total_of_right_answers"));
164 $this->tpl->setVariable(
"TXT_VALUE", sprintf(
"%2.2f", $this->object->_getTotalRightAnswers(
$_GET[
"q_id"]) * 100.0) .
" %");
165 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
166 $this->tpl->parseCurrentBlock();
169 $instances =& $this->
object->getInstances();
171 foreach ($instances as $instance)
173 if (is_array($instance[
"refs"]))
175 foreach ($instance[
"refs"] as
$ref_id)
177 $this->tpl->setCurrentBlock(
"references");
178 $this->tpl->setVariable(
"GOTO",
"./goto.php?target=tst_" . $ref_id);
179 $this->tpl->setVariable(
"TEXT_GOTO", $this->lng->txt(
"perma_link"));
180 $this->tpl->parseCurrentBlock();
183 $this->tpl->setCurrentBlock(
"instance_row");
184 $this->tpl->setVariable(
"TEST_TITLE", $instance[
"title"]);
185 $this->tpl->setVariable(
"TEST_AUTHOR", $instance[
"author"]);
186 $this->tpl->setVariable(
"QUESTION_ID", $instance[
"question_id"]);
187 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
189 $this->tpl->parseCurrentBlock();
191 $this->tpl->setCurrentBlock(
"instances");
192 $this->tpl->setVariable(
"TEXT_TEST_TITLE", $this->lng->txt(
"title"));
193 $this->tpl->setVariable(
"TEXT_TEST_AUTHOR", $this->lng->txt(
"author"));
194 $this->tpl->setVariable(
"TEXT_TEST_LOCATION", $this->lng->txt(
"location"));
195 $this->tpl->setVariable(
"INSTANCES_TITLE", $this->lng->txt(
"question_instances_title"));
196 $this->tpl->parseCurrentBlock();
198 $this->tpl->setCurrentBlock(
"adm_content");
199 $this->tpl->setVariable(
"TXT_QUESTION_TITLE", $this->lng->txt(
"question_cumulated_statistics"));
200 $this->tpl->setVariable(
"TXT_RESULT", $this->lng->txt(
"result"));
201 $this->tpl->setVariable(
"TXT_VALUE", $this->lng->txt(
"value"));
202 $this->tpl->parseCurrentBlock();
216 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
217 if ((!$question_type) and ($question_id > 0))
221 if (strlen($question_type) == 0)
return NULL;
222 $question_type_gui = $question_type .
"GUI";
224 $question =&
new $question_type_gui();
225 if ($question_id > 0)
227 $question->object->loadFromDb($question_id);
234 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
235 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
243 return $q_type .
"GUI";
258 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
267 $this->tpl->addBlockFile(
"CONTENT",
"content",
"tpl.il_as_qpl_content.html",
"Modules/TestQuestionPool");
268 $this->tpl->addBlockFile(
"STATUSLINE",
"statusline",
"tpl.statusline.html");
269 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_as_question.html",
"Modules/TestQuestionPool");
280 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
281 include_once(
"./Services/COPage/classes/class.ilPageObjectGUI.php");
285 $page_gui->setEnabledInternalLinks(
false);
286 $page_gui->setQuestionHTML(array($this->object->getId() => $html));
287 $page_gui->setFileDownloadLink(
"ilias.php?baseClass=ilObjTestGUI&cmd=downloadFile".
288 "&ref_id=".
$_GET[
"ref_id"]);
289 $page_gui->setFullscreenLink(
"ilias.php?baseClass=ilObjTestGUI&cmd=fullscreen".
290 "&ref_id=".
$_GET[
"ref_id"]);
291 $page_gui->setSourcecodeDownloadScript(
"ilias.php?baseClass=ilObjTestGUI&ref_id=".
$_GET[
"ref_id"]);
292 $page_gui->setEnabledPageFocus(
false);
293 $page_gui->setOutputMode(
"presentation");
294 $page_gui->setPresentationTitle(
"");
295 $presentation = $page_gui->presentation();
297 $presentation = preg_replace(
"/src=\".\\//ims",
"src=\"" . ILIAS_HTTP_PATH .
"/", $presentation);
298 return $presentation;
304 function outQuestionPage($a_temp_var, $a_postponed =
false, $active_id =
"", $html =
"")
309 $postponed =
" (" . $this->lng->txt(
"postponed") .
")";
312 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
313 include_once(
"./Services/COPage/classes/class.ilPageObjectGUI.php");
314 $this->lng->loadLanguageModule(
"content");
318 $page_gui->setFileDownloadLink(
"ilias.php?baseClass=ilObjTestGUI&cmd=downloadFile".
319 "&ref_id=".
$_GET[
"ref_id"]);
320 $page_gui->setFullscreenLink(
"ilias.php?baseClass=ilObjTestGUI&cmd=fullscreen".
321 "&ref_id=".
$_GET[
"ref_id"]);
322 $page_gui->setEnabledPageFocus(
false);
325 $page_gui->setQuestionHTML(array($this->object->getId() => $html));
327 $page_gui->setSourcecodeDownloadScript(
"ilias.php?baseClass=ilObjTestGUI&ref_id=".
$_GET[
"ref_id"]);
328 $page_gui->setOutputMode(
"presentation");
330 include_once
"./Modules/Test/classes/class.ilObjTest.php";
332 switch ($title_output)
335 $page_gui->setPresentationTitle(sprintf($this->lng->txt(
"tst_position"), $this->
getSequenceNumber(), $this->
getQuestionCount()).
" - ".$this->object->getTitle().$postponed);
342 $maxpoints = $this->
object->getMaximumPoints();
345 $maxpoints =
" (".$maxpoints.
" ".$this->lng->txt(
"point").
")";
349 $maxpoints =
" (".$maxpoints.
" ".$this->lng->txt(
"points").
")";
351 $page_gui->setPresentationTitle(sprintf($this->lng->txt(
"tst_position"), $this->
getSequenceNumber(), $this->
getQuestionCount()).
" - ".$this->object->getTitle().$postponed.$maxpoints);
354 $presentation = $page_gui->presentation();
355 if (strlen($maxpoints)) $presentation = str_replace($maxpoints,
"<em>$maxpoints</em>", $presentation);
357 $presentation = preg_replace(
"/src=\".\\//ims",
"src=\"" . ILIAS_HTTP_PATH .
"/", $presentation);
358 return $presentation;
366 if (
$_GET[
"calling_test"])
371 elseif (
$_GET[
"test_ref_id"])
378 if (
$_GET[
"q_id"] > 0)
380 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
381 $this->ctrl->redirectByClass(
"ilpageobjectgui",
"edit");
385 $this->ctrl->redirectByClass(
"ilobjquestionpoolgui",
"questions");
392 if (strlen($return_to))
394 $this->ctrl->setParameter($this,
"return_to", $return_to);
397 $this->ctrl->setParameter($this,
"return_to",
$_REQUEST[
'return_to']);
399 $template =
new ilTemplate(
"tpl.il_as_qpl_sync_original.html",TRUE, TRUE,
"Modules/TestQuestionPool");
400 $template->setVariable(
"BUTTON_YES", $this->lng->txt(
"yes"));
401 $template->setVariable(
"BUTTON_NO", $this->lng->txt(
"no"));
402 $template->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
403 $template->setVariable(
"TEXT_SYNC", $this->lng->txt(
"confirm_sync_questions"));
404 $this->tpl->setVariable(
"ADM_CONTENT", $template->get());
409 $original_id = $this->
object->original_id;
412 $this->
object->syncWithOriginal();
414 if (strlen(
$_GET[
"return_to"]))
416 $this->ctrl->redirect($this,
$_GET[
"return_to"]);
427 if (strlen(
$_GET[
"return_to"]))
429 $this->ctrl->redirect($this,
$_GET[
"return_to"]);
449 $originalexists = $this->
object->_questionExistsInPool($this->object->original_id);
450 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
472 $ilUser->setPref(
"tst_lastquestiontype", $this->object->getQuestionType());
473 $ilUser->writePref(
"tst_lastquestiontype", $this->object->getQuestionType());
474 $this->
object->saveToDb();
475 $originalexists = $this->
object->_questionExists($this->object->original_id);
476 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
479 $this->ctrl->redirect($this,
"originalSyncForm");
481 elseif (
$_GET[
"calling_test"])
487 elseif (
$_GET[
"test_ref_id"])
489 include_once (
"./Modules/Test/classes/class.ilObjTest.php");
492 $test->insertQuestion($this->object->getId());
497 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
498 $this->editQuestion();
507 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id", $this->object->getId());
508 $this->ctrl->redirectByClass(
"ilpageobjectgui",
"edit");
519 $old_id =
$_GET[
"q_id"];
524 $ilUser->setPref(
"tst_lastquestiontype", $this->object->getQuestionType());
525 $ilUser->writePref(
"tst_lastquestiontype", $this->object->getQuestionType());
526 $this->
object->saveToDb();
527 $originalexists = $this->
object->_questionExistsInPool($this->object->original_id);
531 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
534 $this->ctrl->setParameter($this,
'return_to',
'editQuestion');
535 $this->ctrl->redirect($this,
"originalSyncForm");
538 elseif (
$_GET[
"calling_test"])
540 require_once
'Modules/Test/classes/class.ilObjTest.php';
544 include_once (
"./Modules/Test/classes/class.ilObjTest.php");
547 $new_id =
$test->insertQuestion($this->object->getId());
550 $test->moveQuestionAfter($this->object->getId() + 1,
$_REQUEST[
'prev_qid']);
553 $this->ctrl->setParameter($this,
'q_id', $new_id);
554 $this->ctrl->setParameter($this,
'calling_test',
$_GET[
'calling_test']);
555 #$this->ctrl->setParameter($this, 'test_ref_id', false);
557 $this->ctrl->redirect($this,
'editQuestion');
564 if ($this->object->getId() != $old_id)
567 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"],
"q_id", $this->object->getId());
568 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"],
"sel_question_types",
$_GET[
"sel_question_types"]);
576 $test->moveQuestionAfter(
$_REQUEST[
'prev_qid'], $this->object->getId());
580 include_once (
"./Modules/Test/classes/class.ilObjTest.php");
582 $test->insertQuestion($this->object->getId());
583 require_once
'Modules/Test/classes/class.ilTestExpressPage.php';
584 $_REQUEST[
'q_id'] = $this->
object->getId();
588 $this->ctrl->redirectByClass(
$_GET[
"cmdClass"],
"editQuestion");
598 $this->ctrl->redirect($this,
'editQuestion');
609 $old_id =
$_GET[
"q_id"];
613 $ilUser->setPref(
"tst_lastquestiontype", $this->object->getQuestionType());
614 $ilUser->writePref(
"tst_lastquestiontype", $this->object->getQuestionType());
615 $this->
object->saveToDb();
616 $originalexists = $this->
object->_questionExistsInPool($this->object->original_id);
617 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
620 $this->ctrl->redirect($this,
"originalSyncForm");
623 elseif (
$_GET[
"calling_test"])
625 require_once
'Modules/Test/classes/class.ilObjTest.php';
627 #var_dump(assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId()));
628 $q_id = $this->
object->getId();
631 include_once (
"./Modules/Test/classes/class.ilObjTest.php");
634 $new_id =
$test->insertQuestion($this->object->getId());
637 $test->moveQuestionAfter($this->object->getId() + 1,
$_REQUEST[
'prev_qid']);
640 $this->ctrl->setParameter($this,
'q_id', $new_id);
641 $this->ctrl->setParameter($this,
'calling_test',
$_GET[
'calling_test']);
642 #$this->ctrl->setParameter($this, 'test_ref_id', false);
656 if ($this->object->getId() != $old_id)
660 $this->ctrl->redirectByClass(
"ilobjquestionpoolgui",
"questions");
670 $this->ctrl->redirectByClass(
"ilobjquestionpoolgui",
"questions");
681 $this->
object->saveToDb();
682 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
683 $this->editQuestion();
696 $tmpPath = $cont_obj->getLMTree()->getPathFull($a_endnode_id, $a_startnode_id);
699 for ($i = 1; $i < (count($tmpPath) - 1); $i++)
706 $path .= $tmpPath[$i][
"title"];
714 $this->sequence_no = $nr;
724 $this->question_count = $a_question_count;
744 $this->errormessage .= ((strlen($this->errormessage)) ?
"<br />" :
"") .
$errormessage;
761 return $this->
object->getQuestionType();
774 if (strlen($a_value))
776 $result =
" value=\"$a_value\" ";
788 $cnt = $this->new_id_listener_cnt;
789 $this->new_id_listeners[$cnt][
"object"] =& $a_object;
790 $this->new_id_listeners[$cnt][
"method"] = $a_method;
791 $this->new_id_listeners[$cnt][
"parameters"] = $a_parameters;
792 $this->new_id_listener_cnt++;
801 for ($i=0; $i<$this->new_id_listener_cnt; $i++)
803 $this->new_id_listeners[$i][
"parameters"][
"new_id"] = $a_new_id;
804 $object =& $this->new_id_listeners[$i][
"object"];
805 $method = $this->new_id_listeners[$i][
"method"];
806 $parameters = $this->new_id_listeners[$i][
"parameters"];
822 $this->selfassessmenteditingmode = $a_selfassessmenteditingmode;
832 return $this->selfassessmenteditingmode;
842 $this->prevent_rte_usage = $a_val;
862 $this->defaultnroftries = $a_defaultnroftries;
872 return $this->defaultnroftries;
883 $form->addCommandButton(
"saveReturn", $this->lng->txt(
"save_return"));
885 $form->addCommandButton(
"save", $this->lng->txt(
"save"));
898 $title->setValue($this->object->getTitle());
899 $title->setRequired(TRUE);
905 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
906 $author->
setValue($this->object->getAuthor());
907 $author->setRequired(TRUE);
908 $form->addItem($author);
911 $description =
new ilTextInputGUI($this->lng->txt(
"description"),
"comment");
912 $description->
setValue($this->object->getComment());
913 $description->setRequired(FALSE);
914 $form->addItem($description);
921 if (trim($author) ==
"")
925 $hi->setValue($author);
932 $question->
setValue($this->object->prepareTextareaOutput($this->object->getQuestion()));
933 $question->setRequired(TRUE);
934 $question->setRows(10);
935 $question->setCols(80);
938 $question->setUseRte(TRUE);
939 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
941 $question->addPlugin(
"latex");
942 $question->addButton(
"latex");
943 $question->addButton(
"pastelatex");
944 $question->setRTESupport($this->object->getId(),
"qpl",
"assessment");
948 $question->setRteTags(self::getSelfAssessmentTags());
949 $question->setUseTagsForRteOnly(
false);
951 $form->addItem($question);
958 $duration->setShowMinutes(TRUE);
959 $duration->setShowSeconds(TRUE);
960 $ewt = $this->
object->getEstimatedWorkingTime();
961 $duration->setHours($ewt[
"h"]);
962 $duration->setMinutes($ewt[
"m"]);
963 $duration->setSeconds($ewt[
"s"]);
964 $duration->setRequired(FALSE);
965 $form->addItem($duration);
970 if (strlen($this->object->getNrOfTries()))
972 $nr_tries = $this->
object->getNrOfTries();
988 $ni =
new ilNumberInputGUI($this->lng->txt(
"qst_nr_of_tries"),
"nr_of_tries");
993 $ni->setMaxLength(5);
994 $ni->setRequired(
true);
1010 $not_supported = array(
"img",
"p");
1014 if (!in_array($s, $not_supported))
1037 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1039 if (strlen($manual_feedback))
1041 return $manual_feedback;
1043 $correct_feedback = $this->
object->getFeedbackGeneric(1);
1044 $incorrect_feedback = $this->
object->getFeedbackGeneric(0);
1045 if (strlen($correct_feedback.$incorrect_feedback))
1047 $reached_points = $this->
object->calculateReachedPoints($active_id,
$pass);
1048 $max_points = $this->
object->getMaximumPoints();
1049 if ($reached_points == $max_points)
1051 $output = $correct_feedback;
1055 $output = $incorrect_feedback;
1058 return $this->
object->prepareTextareaOutput($output, TRUE);
1068 $save = (strcmp($this->ctrl->getCmd(),
"saveFeedback") == 0) ? TRUE : FALSE;
1069 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1071 $form->setFormAction($this->ctrl->getFormAction($this));
1072 $form->setTitle($this->lng->txt(
'feedback_answers'));
1073 $form->setTableWidth(
"100%");
1074 $form->setId(
"feedback");
1076 $complete =
new ilTextAreaInputGUI($this->lng->txt(
"feedback_complete_solution"),
"feedback_complete");
1077 $complete->
setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)));
1078 $complete->setRequired(
false);
1079 $complete->setRows(10);
1080 $complete->setCols(80);
1083 $complete->setUseRte(
true);
1085 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1087 $complete->addPlugin(
"latex");
1088 $complete->addButton(
"latex");
1089 $complete->addButton(
"pastelatex");
1090 $complete->setRTESupport($this->object->getId(),
"qpl",
"assessment");
1091 $form->addItem($complete);
1093 $incomplete =
new ilTextAreaInputGUI($this->lng->txt(
"feedback_incomplete_solution"),
"feedback_incomplete");
1094 $incomplete->
setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)));
1095 $incomplete->setRequired(
false);
1096 $incomplete->setRows(10);
1097 $incomplete->setCols(80);
1100 $incomplete->setUseRte(
true);
1102 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1104 $incomplete->addPlugin(
"latex");
1105 $incomplete->addButton(
"latex");
1106 $incomplete->addButton(
"pastelatex");
1107 $incomplete->setRTESupport($this->object->getId(),
"qpl",
"assessment");
1108 $form->addItem($incomplete);
1113 $form->addCommandButton(
"saveFeedback", $this->lng->txt(
"save"));
1118 $form->setValuesByPost();
1119 $errors = !$form->checkInput();
1120 $form->setValuesByPost();
1122 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
1128 include_once
"./classes/class.ilTemplate.php";
1129 $template =
new ilTemplate(
"tpl.il_as_qpl_questiontype.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1130 $count = $this->
object->isInUse();
1134 if ($rbacsystem->checkAccess(
"write",
$_GET[
"ref_id"]))
1136 $template->setCurrentBlock(
"infosign");
1138 $template->setVariable(
"INFO_IMG_ALT", sprintf($this->lng->txt(
"qpl_question_is_in_use"), $count));
1139 $template->setVariable(
"INFO_IMG_TITLE", sprintf($this->lng->txt(
"qpl_question_is_in_use"), $count));
1140 $template->parseCurrentBlock();
1144 return $template->get();
1157 if (
$_POST[
"deleteSuggestedSolution"] == 1)
1159 $this->
object->deleteSuggestedSolutions();
1161 $this->ctrl->redirect($this,
"suggestedsolution");
1164 $save = (is_array(
$_POST[
"cmd"]) && array_key_exists(
"suggestedsolution",
$_POST[
"cmd"])) ? TRUE : FALSE;
1166 $solution_array = $this->
object->getSuggestedSolution(0);
1168 "lm" => $this->lng->txt(
"obj_lm"),
1169 "st" => $this->lng->txt(
"obj_st"),
1170 "pg" => $this->lng->txt(
"obj_pg"),
1171 "git" => $this->lng->txt(
"glossary_term"),
1172 "file" => $this->lng->txt(
"fileDownload"),
1173 "text" => $this->lng->txt(
"solutionText")
1176 if ((strcmp(
$_POST[
"solutiontype"],
"file") == 0) && (strcmp($solution_array[
"type"],
"file") != 0))
1178 $solution_array = array(
1182 elseif ((strcmp(
$_POST[
"solutiontype"],
"text") == 0) && (strcmp($solution_array[
"type"],
"text") != 0))
1184 $solution_array = array(
1186 "value" => $this->getSolutionOutput(0, NULL, FALSE, FALSE, TRUE, FALSE, TRUE)
1189 if ($save && strlen(
$_POST[
"filename"]))
1191 $solution_array[
"value"][
"filename"] =
$_POST[
"filename"];
1193 if ($save && strlen(
$_POST[
"solutiontext"]))
1195 $solution_array[
"value"] =
$_POST[
"solutiontext"];
1197 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1198 if (count($solution_array))
1201 $form->setFormAction($this->ctrl->getFormAction($this));
1202 $form->setTitle($this->lng->txt(
"solution_hint"));
1203 $form->setMultipart(TRUE);
1204 $form->setTableWidth(
"100%");
1205 $form->setId(
"suggestedsolutiondisplay");
1208 include_once
"./Modules/TestQuestionPool/classes/class.ilSolutionTitleInputGUI.php";
1210 $template =
new ilTemplate(
"tpl.il_as_qpl_suggested_solution_input_presentation.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1211 if (strlen($solution_array[
"internal_link"]))
1214 $template->setCurrentBlock(
"preview");
1215 $template->setVariable(
"TEXT_SOLUTION", $this->lng->txt(
"solution_hint"));
1216 $template->setVariable(
"VALUE_SOLUTION",
" <a href=\"$href\" target=\"content\">" . $this->lng->txt(
"view").
"</a> ");
1217 $template->parseCurrentBlock();
1219 elseif ((strcmp($solution_array[
"type"],
"file") == 0) && (is_array($solution_array[
"value"])))
1221 $href = $this->
object->getSuggestedSolutionPathWeb() . $solution_array[
"value"][
"name"];
1222 $template->setCurrentBlock(
"preview");
1223 $template->setVariable(
"TEXT_SOLUTION", $this->lng->txt(
"solution_hint"));
1224 $template->setVariable(
"VALUE_SOLUTION",
" <a href=\"$href\" target=\"content\">" .
ilUtil::prepareFormOutput((strlen($solution_array[
"value"][
"filename"])) ? $solution_array[
"value"][
"filename"] : $solution_array[
"value"][
"name"]).
"</a> ");
1225 $template->parseCurrentBlock();
1227 $template->setVariable(
"TEXT_TYPE", $this->lng->txt(
"type"));
1228 $template->setVariable(
"VALUE_TYPE", $options[$solution_array[
"type"]]);
1229 $title->setHtml($template->get());
1231 $deletesolution->setOptionTitle($this->lng->txt(
"deleteSuggestedSolution"));
1232 $title->addSubItem($deletesolution);
1235 if (strcmp($solution_array[
"type"],
"file") == 0)
1239 $file->setRequired(TRUE);
1240 $file->enableFileNameSelection(
"filename");
1242 if ($_FILES[
"file"][
"tmp_name"])
1244 if (!file_exists($this->object->getSuggestedSolutionPath()))
ilUtil::makeDirParents($this->object->getSuggestedSolutionPath());
1245 $res =
ilUtil::moveUploadedFile($_FILES[
"file"][
"tmp_name"], $_FILES[
"file"][
"name"], $this->object->getSuggestedSolutionPath() . $_FILES[
"file"][
"name"]);
1249 if (is_array($solution_array[
"value"])) @unlink($this->object->getSuggestedSolutionPath() . $solution_array[
"value"][
"name"]);
1250 $file->setValue($_FILES[
"file"][
"name"]);
1251 $this->
object->saveSuggestedSolution(
"file",
"", 0, array(
"name" => $_FILES[
"file"][
"name"],
"type" => $_FILES[
"file"][
"type"],
"size" => $_FILES[
"file"][
"size"],
"filename" =>
$_POST[
"filename"]));
1252 $originalexists = $this->
object->_questionExistsInPool($this->object->original_id);
1260 $this->ctrl->redirect($this,
"suggestedsolution");
1270 if (is_array($solution_array[
"value"]))
1272 $file->setValue($solution_array[
"value"][
"name"]);
1273 $file->setFilename((strlen($solution_array[
"value"][
"filename"])) ? $solution_array[
"value"][
"filename"] : $solution_array[
"value"][
"name"]);
1276 $form->addItem(
$file);
1278 $hidden->setValue(
"file");
1279 $form->addItem($hidden);
1281 else if (strcmp($solution_array[
"type"],
"text") == 0)
1284 $question->
setValue($this->object->prepareTextareaOutput($solution_array[
"value"]));
1285 $question->setRequired(TRUE);
1286 $question->setRows(10);
1287 $question->setCols(80);
1288 $question->setUseRte(TRUE);
1289 $question->addPlugin(
"latex");
1290 $question->addButton(
"latex");
1291 $question->setRTESupport($this->object->getId(),
"qpl",
"assessment");
1293 $hidden->setValue(
"text");
1294 $form->addItem($hidden);
1295 $form->addItem($question);
1297 if ($ilAccess->checkAccess(
"write",
"",
$_GET[
'ref_id'])) $form->addCommandButton(
"suggestedsolution", $this->lng->txt(
"save"));
1301 if ($form->checkInput())
1303 switch ($solution_array[
"type"])
1306 $this->
object->saveSuggestedSolution(
"file",
"", 0, array(
"name" => $solution_array[
"value"][
"name"],
"type" => $solution_array[
"value"][
"type"],
"size" => $solution_array[
"value"][
"size"],
"filename" =>
$_POST[
"filename"]));
1309 $this->
object->saveSuggestedSolution(
"text",
"", 0, $solution_array[
"value"]);
1312 $originalexists = $this->
object->_questionExistsInPool($this->object->original_id);
1320 $this->ctrl->redirect($this,
"suggestedsolution");
1324 $output = $form->getHTML();
1327 $savechange = (strcmp($this->ctrl->getCmd(),
"saveSuggestedSolution") == 0) ? TRUE : FALSE;
1330 if ($ilAccess->checkAccess(
"write",
"",
$_GET[
'ref_id']))
1333 $formchange->setFormAction($this->ctrl->getFormAction($this));
1334 $formchange->setTitle((count($solution_array)) ? $this->lng->txt(
"changeSuggestedSolution") : $this->lng->txt(
"addSuggestedSolution"));
1335 $formchange->setMultipart(FALSE);
1336 $formchange->setTableWidth(
"100%");
1337 $formchange->setId(
"suggestedsolution");
1339 $solutiontype =
new ilRadioMatrixInputGUI($this->lng->txt(
"suggestedSolutionType"),
"solutiontype");
1341 if (count($solution_array))
1343 $solutiontype->setValue($solution_array[
"type"]);
1345 $solutiontype->setRequired(TRUE);
1346 $formchange->addItem($solutiontype);
1348 $formchange->addCommandButton(
"saveSuggestedSolution", $this->lng->txt(
"select"));
1352 $formchange->checkInput();
1354 $changeoutput = $formchange->getHTML();
1357 $this->tpl->setVariable(
"ADM_CONTENT", $changeoutput . $output);
1364 include_once(
"./Modules/TestQuestionPool/classes/class.ilSolutionExplorer.php");
1365 $type =
$_GET[
"link_new_type"];
1366 $search =
$_GET[
"search_link_type"];
1367 $this->ctrl->setParameter($this,
"link_new_type", $type);
1368 $this->ctrl->setParameter($this,
"search_link_type", $search);
1369 $this->ctrl->saveParameter($this, array(
"subquestion_index",
"link_new_type",
"search_link_type"));
1373 $parent_ref_id = $tree->getParentId(
$_GET[
"ref_id"]);
1374 $exp =
new ilSolutionExplorer($this->ctrl->getLinkTarget($this,
'suggestedsolution'), get_class($this));
1376 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,
'outSolutionExplorer'));
1377 $exp->setTargetGet(
"ref_id");
1378 $exp->setRefId(
$_GET[
"ref_id"]);
1379 $exp->addFilter($type);
1380 $exp->setSelectableType($type);
1381 if(isset(
$_GET[
'expandCurrentPath']) &&
$_GET[
'expandCurrentPath'])
1383 $exp->expandPathByRefId($parent_ref_id);
1389 $template =
new ilTemplate(
"tpl.il_as_qpl_explorer.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1390 $template->setVariable(
"EXPLORER_TREE",$exp->getOutput());
1391 $template->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
1392 $template->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this,
"suggestedsolution"));
1393 $this->tpl->setVariable(
"ADM_CONTENT", $template->get());
1400 include_once(
"./Modules/TestQuestionPool/classes/class.ilSolutionExplorer.php");
1401 switch (
$_POST[
"solutiontype"])
1427 if(isset(
$_POST[
'solutiontype']))
1429 $this->ctrl->setParameter($this,
'expandCurrentPath', 1);
1431 $this->ctrl->setParameter($this,
"link_new_type", $type);
1432 $this->ctrl->setParameter($this,
"search_link_type", $search);
1433 $this->ctrl->redirect($this,
"outSolutionExplorer");
1438 $this->ctrl->redirect($this,
"suggestedsolution");
1443 include_once
"./Modules/LearningModule/classes/class.ilLMPageObject.php";
1444 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1446 $cont_obj = $cont_obj_gui->object;
1448 $shownpages = array();
1449 $tree = $cont_obj->getLMTree();
1450 $chapters = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
1451 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
1452 $color_class = array(
"tblrow1",
"tblrow2");
1454 $template =
new ilTemplate(
"tpl.il_as_qpl_internallink_selection.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1455 foreach ($chapters as $chapter)
1457 $chapterpages = $tree->getChildsByType($chapter[
"obj_id"],
"pg");
1458 foreach ($chapterpages as $page)
1460 if($page[
"type"] ==
$_GET[
"search_link_type"])
1462 array_push($shownpages, $page[
"obj_id"]);
1463 $template->setCurrentBlock(
"linktable_row");
1464 $template->setVariable(
"TEXT_LINK", $page[
"title"]);
1465 $template->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
1466 $template->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this),
"add" . strtoupper($page[
"type"])) .
"&" . $page[
"type"] .
"=" . $page[
"obj_id"]);
1467 $template->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
1468 if ($tree->isInTree($page[
"obj_id"]))
1477 $template->parseCurrentBlock();
1482 foreach ($pages as $page)
1484 if (!in_array($page[
"obj_id"], $shownpages))
1486 $template->setCurrentBlock(
"linktable_row");
1487 $template->setVariable(
"TEXT_LINK", $page[
"title"]);
1488 $template->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
1489 $template->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this),
"add" . strtoupper($page[
"type"])) .
"&" . $page[
"type"] .
"=" . $page[
"obj_id"]);
1490 $template->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
1493 $template->parseCurrentBlock();
1497 $template->setCurrentBlock(
"link_selection");
1498 $template->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
1499 $template->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"obj_" .
$_GET[
"search_link_type"]));
1500 $template->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this,
"cancelExplorer"));
1501 $template->parseCurrentBlock();
1502 $this->tpl->setVariable(
"ADM_CONTENT", $template->get());
1507 $template =
new ilTemplate(
"tpl.il_as_qpl_internallink_selection.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1508 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
1509 $color_class = array(
"tblrow1",
"tblrow2");
1511 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1513 $cont_obj = $cont_obj_gui->object;
1515 $ctree =& $cont_obj->getLMTree();
1516 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
1517 foreach($nodes as $node)
1519 if($node[
"type"] ==
$_GET[
"search_link_type"])
1521 $template->setCurrentBlock(
"linktable_row");
1522 $template->setVariable(
"TEXT_LINK", $node[
"title"]);
1523 $template->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
1524 $template->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this),
"add" . strtoupper($node[
"type"])) .
"&" . $node[
"type"] .
"=" . $node[
"obj_id"]);
1525 $template->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
1526 $template->parseCurrentBlock();
1530 $template->setCurrentBlock(
"link_selection");
1531 $template->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
1532 $template->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"obj_" .
$_GET[
"search_link_type"]));
1533 $template->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this,
"cancelExplorer"));
1534 $template->parseCurrentBlock();
1535 $this->tpl->setVariable(
"ADM_CONTENT", $template->get());
1540 $template =
new ilTemplate(
"tpl.il_as_qpl_internallink_selection.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1541 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
1542 $color_class = array(
"tblrow1",
"tblrow2");
1544 include_once
"./Modules/Glossary/classes/class.ilObjGlossary.php";
1547 $terms = $glossary->getTermList();
1548 foreach($terms as $term)
1550 $template->setCurrentBlock(
"linktable_row");
1551 $template->setVariable(
"TEXT_LINK", $term[
"term"]);
1552 $template->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
1553 $template->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this),
"addGIT") .
"&git=" . $term[
"id"]);
1554 $template->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
1555 $template->parseCurrentBlock();
1558 $template->setCurrentBlock(
"link_selection");
1559 $template->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
1560 $template->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"glossary_term"));
1561 $template->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this,
"cancelExplorer"));
1562 $template->parseCurrentBlock();
1563 $this->tpl->setVariable(
"ADM_CONTENT", $template->get());
1568 $this->ctrl->saveParameter($this, array(
"subquestion_index",
"link_new_type",
"search_link_type"));
1569 switch (
$_GET[
"search_link_type"])
1581 $subquestion_index = (
$_GET[
"subquestion_index"] > 0) ?
$_GET[
"subquestion_index"] : 0;
1582 $this->
object->saveSuggestedSolution(
"lm",
"il__lm_" .
$_GET[
"source_id"], $subquestion_index);
1584 $this->ctrl->redirect($this,
"suggestedsolution");
1591 $subquestion_index = 0;
1592 if (strlen(
$_GET[
"subquestion_index"]) &&
$_GET[
"subquestion_index"] >= 0)
1594 $subquestion_index =
$_GET[
"subquestion_index"];
1596 $this->
object->saveSuggestedSolution(
"pg",
"il__pg_" .
$_GET[
"pg"], $subquestion_index);
1598 $this->ctrl->redirect($this,
"suggestedsolution");
1603 $subquestion_index = 0;
1604 if (strlen(
$_GET[
"subquestion_index"]) &&
$_GET[
"subquestion_index"] >= 0)
1606 $subquestion_index =
$_GET[
"subquestion_index"];
1608 $this->
object->saveSuggestedSolution(
"st",
"il__st_" .
$_GET[
"st"], $subquestion_index);
1610 $this->ctrl->redirect($this,
"suggestedsolution");
1615 $subquestion_index = 0;
1616 if (strlen(
$_GET[
"subquestion_index"]) &&
$_GET[
"subquestion_index"] >= 0)
1618 $subquestion_index =
$_GET[
"subquestion_index"];
1620 $this->
object->saveSuggestedSolution(
"git",
"il__git_" .
$_GET[
"git"], $subquestion_index);
1622 $this->ctrl->redirect($this,
"suggestedsolution");
1627 return in_array($this->ctrl->getCmd(), array(
'save',
'saveEdit',
'saveReturn'));