24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
25 include_once
'Modules/Test/classes/class.ilTestExpressPage.php';
80 $this->ctrl->saveParameter($this,
"q_id");
81 $this->ctrl->saveParameter($this,
"prev_qid");
82 $this->ctrl->saveParameter($this,
"calling_test");
83 $this->ctrl->saveParameterByClass(
'ilPageObjectGUI',
'test_express_mode');
84 $this->ctrl->saveParameterByClass(
'ilobjquestionpoolgui',
'test_express_mode');
86 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
87 $this->errormessage = $this->lng->txt(
"fill_out_all_required_fields");
89 $this->selfassessmenteditingmode =
false;
90 $this->new_id_listeners = array();
91 $this->new_id_listener_cnt = 0;
99 $cmd = $this->ctrl->getCmd(
"editQuestion");
100 $next_class = $this->ctrl->getNextClass($this);
141 $this->tpl->addBlockFile(
"CONTENT",
"content",
"tpl.il_as_qpl_content.html",
"Modules/TestQuestionPool");
142 $this->tpl->addBlockFile(
"STATUSLINE",
"statusline",
"tpl.statusline.html");
144 $total_of_answers = $this->
object->getTotalAnswers();
146 $color_class = array(
"tblrow1",
"tblrow2");
147 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_as_qpl_assessment_of_questions.html",
"Modules/TestQuestionPool");
148 if (!$total_of_answers)
150 $this->tpl->setCurrentBlock(
"emptyrow");
151 $this->tpl->setVariable(
"TXT_NO_ASSESSMENT", $this->lng->txt(
"qpl_assessment_no_assessment_of_questions"));
152 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
153 $this->tpl->parseCurrentBlock();
157 $this->tpl->setCurrentBlock(
"row");
158 $this->tpl->setVariable(
"TXT_RESULT", $this->lng->txt(
"qpl_assessment_total_of_answers"));
159 $this->tpl->setVariable(
"TXT_VALUE", $total_of_answers);
160 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
162 $this->tpl->parseCurrentBlock();
163 $this->tpl->setCurrentBlock(
"row");
164 $this->tpl->setVariable(
"TXT_RESULT", $this->lng->txt(
"qpl_assessment_total_of_right_answers"));
165 $this->tpl->setVariable(
"TXT_VALUE", sprintf(
"%2.2f", $this->object->_getTotalRightAnswers(
$_GET[
"q_id"]) * 100.0) .
" %");
166 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
167 $this->tpl->parseCurrentBlock();
170 $instances =& $this->
object->getInstances();
172 foreach ($instances as $instance)
174 if (is_array($instance[
"refs"]))
176 foreach ($instance[
"refs"] as
$ref_id)
178 $this->tpl->setCurrentBlock(
"references");
179 $this->tpl->setVariable(
"GOTO",
"./goto.php?target=tst_" . $ref_id);
180 $this->tpl->setVariable(
"TEXT_GOTO", $this->lng->txt(
"perma_link"));
181 $this->tpl->parseCurrentBlock();
184 $this->tpl->setCurrentBlock(
"instance_row");
185 $this->tpl->setVariable(
"TEST_TITLE", $instance[
"title"]);
186 $this->tpl->setVariable(
"TEST_AUTHOR", $instance[
"author"]);
187 $this->tpl->setVariable(
"QUESTION_ID", $instance[
"question_id"]);
188 $this->tpl->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
190 $this->tpl->parseCurrentBlock();
192 $this->tpl->setCurrentBlock(
"instances");
193 $this->tpl->setVariable(
"TEXT_TEST_TITLE", $this->lng->txt(
"title"));
194 $this->tpl->setVariable(
"TEXT_TEST_AUTHOR", $this->lng->txt(
"author"));
195 $this->tpl->setVariable(
"TEXT_TEST_LOCATION", $this->lng->txt(
"location"));
196 $this->tpl->setVariable(
"INSTANCES_TITLE", $this->lng->txt(
"question_instances_title"));
197 $this->tpl->parseCurrentBlock();
199 $this->tpl->setCurrentBlock(
"adm_content");
200 $this->tpl->setVariable(
"TXT_QUESTION_TITLE", $this->lng->txt(
"question_cumulated_statistics"));
201 $this->tpl->setVariable(
"TXT_RESULT", $this->lng->txt(
"result"));
202 $this->tpl->setVariable(
"TXT_VALUE", $this->lng->txt(
"value"));
203 $this->tpl->parseCurrentBlock();
217 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
218 if ((!$question_type) and ($question_id > 0))
222 if (strlen($question_type) == 0)
return NULL;
223 $question_type_gui = $question_type .
"GUI";
225 $question =&
new $question_type_gui();
226 if ($question_id > 0)
228 $question->object->loadFromDb($question_id);
235 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
236 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
244 return $q_type .
"GUI";
259 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
268 $this->tpl->addBlockFile(
"CONTENT",
"content",
"tpl.il_as_qpl_content.html",
"Modules/TestQuestionPool");
269 $this->tpl->addBlockFile(
"STATUSLINE",
"statusline",
"tpl.statusline.html");
270 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_as_question.html",
"Modules/TestQuestionPool");
281 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
282 include_once(
"./Services/COPage/classes/class.ilPageObjectGUI.php");
286 $page_gui->setEnabledInternalLinks(
false);
287 $page_gui->setQuestionHTML(array($this->object->getId() => $html));
288 $page_gui->setFileDownloadLink(
"ilias.php?baseClass=ilObjTestGUI&cmd=downloadFile".
289 "&ref_id=".
$_GET[
"ref_id"]);
290 $page_gui->setFullscreenLink(
"ilias.php?baseClass=ilObjTestGUI&cmd=fullscreen".
291 "&ref_id=".
$_GET[
"ref_id"]);
292 $page_gui->setSourcecodeDownloadScript(
"ilias.php?baseClass=ilObjTestGUI&ref_id=".
$_GET[
"ref_id"]);
293 $page_gui->setEnabledPageFocus(
false);
294 $page_gui->setOutputMode(
"presentation");
295 $page_gui->setPresentationTitle(
"");
296 $presentation = $page_gui->presentation();
298 $presentation = preg_replace(
"/src=\".\\//ims",
"src=\"" . ILIAS_HTTP_PATH .
"/", $presentation);
299 return $presentation;
305 function outQuestionPage($a_temp_var, $a_postponed =
false, $active_id =
"", $html =
"")
310 $postponed =
" (" . $this->lng->txt(
"postponed") .
")";
313 include_once(
"./Services/COPage/classes/class.ilPageObject.php");
314 include_once(
"./Services/COPage/classes/class.ilPageObjectGUI.php");
315 $this->lng->loadLanguageModule(
"content");
319 $page_gui->setFileDownloadLink(
"ilias.php?baseClass=ilObjTestGUI&cmd=downloadFile".
320 "&ref_id=".
$_GET[
"ref_id"]);
321 $page_gui->setFullscreenLink(
"ilias.php?baseClass=ilObjTestGUI&cmd=fullscreen".
322 "&ref_id=".
$_GET[
"ref_id"]);
323 $page_gui->setEnabledPageFocus(
false);
326 $page_gui->setQuestionHTML(array($this->object->getId() => $html));
328 $page_gui->setSourcecodeDownloadScript(
"ilias.php?baseClass=ilObjTestGUI&ref_id=".
$_GET[
"ref_id"]);
329 $page_gui->setOutputMode(
"presentation");
331 include_once
"./Modules/Test/classes/class.ilObjTest.php";
336 $obligatoryString =
'([-_-])';
340 $obligatoryString =
'';
343 switch ($title_output)
346 $page_gui->setPresentationTitle(sprintf($this->lng->txt(
"tst_position"), $this->
getSequenceNumber(), $this->
getQuestionCount()).
" - ".$this->object->getTitle().$postponed . $obligatoryString);
353 $maxpoints = $this->
object->getMaximumPoints();
356 $maxpoints =
" (".$maxpoints.
" ".$this->lng->txt(
"point").
")";
360 $maxpoints =
" (".$maxpoints.
" ".$this->lng->txt(
"points").
")";
362 $page_gui->setPresentationTitle(sprintf($this->lng->txt(
"tst_position"), $this->
getSequenceNumber(), $this->
getQuestionCount()).
" - ".$this->object->getTitle().$postponed.$maxpoints . $obligatoryString);
365 $presentation = $page_gui->presentation();
366 if (strlen($maxpoints)) $presentation = str_replace($maxpoints,
"<em>$maxpoints</em>", $presentation);
367 if (strlen($obligatoryString))
369 $replacement =
'<br><span class="obligatory" style="font-size:small">'.
370 $this->lng->txt(
"tst_you_have_to_answer_this_question").
'</span>';
371 $presentation = str_replace($obligatoryString, $replacement, $presentation);
374 $presentation = preg_replace(
"/src=\".\\//ims",
"src=\"" . ILIAS_HTTP_PATH .
"/", $presentation);
375 return $presentation;
383 if (
$_GET[
"calling_test"])
388 elseif (
$_GET[
"test_ref_id"])
395 if (
$_GET[
"q_id"] > 0)
397 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
398 $this->ctrl->redirectByClass(
"ilpageobjectgui",
"edit");
402 $this->ctrl->redirectByClass(
"ilobjquestionpoolgui",
"questions");
409 if (strlen($return_to))
411 $this->ctrl->setParameter($this,
"return_to", $return_to);
414 $this->ctrl->setParameter($this,
"return_to",
$_REQUEST[
'return_to']);
416 $template =
new ilTemplate(
"tpl.il_as_qpl_sync_original.html",TRUE, TRUE,
"Modules/TestQuestionPool");
417 $template->setVariable(
"BUTTON_YES", $this->lng->txt(
"yes"));
418 $template->setVariable(
"BUTTON_NO", $this->lng->txt(
"no"));
419 $template->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
420 $template->setVariable(
"TEXT_SYNC", $this->lng->txt(
"confirm_sync_questions"));
421 $this->tpl->setVariable(
"ADM_CONTENT", $template->get());
426 $original_id = $this->
object->original_id;
429 $this->
object->syncWithOriginal();
431 if (strlen(
$_GET[
"return_to"]))
433 $this->ctrl->redirect($this,
$_GET[
"return_to"]);
444 if (strlen(
$_GET[
"return_to"]))
446 $this->ctrl->redirect($this,
$_GET[
"return_to"]);
466 $originalexists = $this->
object->_questionExistsInPool($this->object->original_id);
467 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
489 $ilUser->setPref(
"tst_lastquestiontype", $this->object->getQuestionType());
490 $ilUser->writePref(
"tst_lastquestiontype", $this->object->getQuestionType());
491 $this->
object->saveToDb();
492 $originalexists = $this->
object->_questionExists($this->object->original_id);
493 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
496 $this->ctrl->redirect($this,
"originalSyncForm");
498 elseif (
$_GET[
"calling_test"])
504 elseif (
$_GET[
"test_ref_id"])
506 include_once (
"./Modules/Test/classes/class.ilObjTest.php");
509 $test->insertQuestion($this->object->getId());
514 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
515 $this->editQuestion();
524 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id", $this->object->getId());
525 $this->ctrl->redirectByClass(
"ilpageobjectgui",
"edit");
536 $old_id =
$_GET[
"q_id"];
541 $ilUser->setPref(
"tst_lastquestiontype", $this->object->getQuestionType());
542 $ilUser->writePref(
"tst_lastquestiontype", $this->object->getQuestionType());
543 $this->
object->saveToDb();
544 $originalexists = $this->
object->_questionExistsInPool($this->object->original_id);
548 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
551 $this->ctrl->setParameter($this,
'return_to',
'editQuestion');
552 $this->ctrl->redirect($this,
"originalSyncForm");
555 elseif (
$_GET[
"calling_test"])
557 require_once
'Modules/Test/classes/class.ilObjTest.php';
561 include_once (
"./Modules/Test/classes/class.ilObjTest.php");
564 $new_id =
$test->insertQuestion($this->object->getId());
567 $test->moveQuestionAfter($this->object->getId() + 1,
$_REQUEST[
'prev_qid']);
570 $this->ctrl->setParameter($this,
'q_id', $new_id);
571 $this->ctrl->setParameter($this,
'calling_test',
$_GET[
'calling_test']);
572 #$this->ctrl->setParameter($this, 'test_ref_id', false);
574 $this->ctrl->redirect($this,
'editQuestion');
581 if ($this->object->getId() != $old_id)
584 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"],
"q_id", $this->object->getId());
585 $this->ctrl->setParameterByClass(
$_GET[
"cmdClass"],
"sel_question_types",
$_GET[
"sel_question_types"]);
593 $test->moveQuestionAfter(
$_REQUEST[
'prev_qid'], $this->object->getId());
597 include_once (
"./Modules/Test/classes/class.ilObjTest.php");
599 $test->insertQuestion($this->object->getId());
600 require_once
'Modules/Test/classes/class.ilTestExpressPage.php';
601 $_REQUEST[
'q_id'] = $this->
object->getId();
605 $this->ctrl->redirectByClass(
$_GET[
"cmdClass"],
"editQuestion");
615 $this->ctrl->redirect($this,
'editQuestion');
626 $old_id =
$_GET[
"q_id"];
630 $ilUser->setPref(
"tst_lastquestiontype", $this->object->getQuestionType());
631 $ilUser->writePref(
"tst_lastquestiontype", $this->object->getQuestionType());
632 $this->
object->saveToDb();
633 $originalexists = $this->
object->_questionExistsInPool($this->object->original_id);
634 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
637 $this->ctrl->redirect($this,
"originalSyncForm");
640 elseif (
$_GET[
"calling_test"])
642 require_once
'Modules/Test/classes/class.ilObjTest.php';
644 #var_dump(assQuestion::_questionExistsInTest($this->object->getId(), $test->getTestId()));
645 $q_id = $this->
object->getId();
648 include_once (
"./Modules/Test/classes/class.ilObjTest.php");
651 $new_id =
$test->insertQuestion($this->object->getId());
654 $test->moveQuestionAfter($this->object->getId() + 1,
$_REQUEST[
'prev_qid']);
657 $this->ctrl->setParameter($this,
'q_id', $new_id);
658 $this->ctrl->setParameter($this,
'calling_test',
$_GET[
'calling_test']);
659 #$this->ctrl->setParameter($this, 'test_ref_id', false);
673 if ($this->object->getId() != $old_id)
677 $this->ctrl->redirectByClass(
"ilobjquestionpoolgui",
"questions");
687 $this->ctrl->redirectByClass(
"ilobjquestionpoolgui",
"questions");
698 $this->
object->saveToDb();
699 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
700 $this->editQuestion();
713 $tmpPath = $cont_obj->getLMTree()->getPathFull($a_endnode_id, $a_startnode_id);
716 for ($i = 1; $i < (count($tmpPath) - 1); $i++)
723 $path .= $tmpPath[$i][
"title"];
731 $this->sequence_no = $nr;
741 $this->question_count = $a_question_count;
761 $this->errormessage .= ((strlen($this->errormessage)) ?
"<br />" :
"") .
$errormessage;
778 return $this->
object->getQuestionType();
791 if (strlen($a_value))
793 $result =
" value=\"$a_value\" ";
805 $cnt = $this->new_id_listener_cnt;
806 $this->new_id_listeners[$cnt][
"object"] =& $a_object;
807 $this->new_id_listeners[$cnt][
"method"] = $a_method;
808 $this->new_id_listeners[$cnt][
"parameters"] = $a_parameters;
809 $this->new_id_listener_cnt++;
818 for ($i=0; $i<$this->new_id_listener_cnt; $i++)
820 $this->new_id_listeners[$i][
"parameters"][
"new_id"] = $a_new_id;
821 $object =& $this->new_id_listeners[$i][
"object"];
822 $method = $this->new_id_listeners[$i][
"method"];
823 $parameters = $this->new_id_listeners[$i][
"parameters"];
839 $this->selfassessmenteditingmode = $a_selfassessmenteditingmode;
849 return $this->selfassessmenteditingmode;
859 $this->prevent_rte_usage = $a_val;
879 $this->defaultnroftries = $a_defaultnroftries;
889 return $this->defaultnroftries;
900 $form->addCommandButton(
"saveReturn", $this->lng->txt(
"save_return"));
902 $form->addCommandButton(
"save", $this->lng->txt(
"save"));
915 $title->setValue($this->object->getTitle());
916 $title->setRequired(TRUE);
922 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
923 $author->
setValue($this->object->getAuthor());
924 $author->setRequired(TRUE);
925 $form->addItem($author);
928 $description =
new ilTextInputGUI($this->lng->txt(
"description"),
"comment");
929 $description->
setValue($this->object->getComment());
930 $description->setRequired(FALSE);
931 $form->addItem($description);
938 if (trim($author) ==
"")
942 $hi->setValue($author);
949 $question->
setValue($this->object->prepareTextareaOutput($this->object->getQuestion()));
950 $question->setRequired(TRUE);
951 $question->setRows(10);
952 $question->setCols(80);
955 $question->setUseRte(TRUE);
956 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
958 $question->addPlugin(
"latex");
959 $question->addButton(
"latex");
960 $question->addButton(
"pastelatex");
961 $question->setRTESupport($this->object->getId(),
"qpl",
"assessment", null,
false,
'3.4.7');
965 $question->setRteTags(self::getSelfAssessmentTags());
966 $question->setUseTagsForRteOnly(
false);
968 $form->addItem($question);
975 $duration->setShowMinutes(TRUE);
976 $duration->setShowSeconds(TRUE);
977 $ewt = $this->
object->getEstimatedWorkingTime();
978 $duration->setHours($ewt[
"h"]);
979 $duration->setMinutes($ewt[
"m"]);
980 $duration->setSeconds($ewt[
"s"]);
981 $duration->setRequired(FALSE);
982 $form->addItem($duration);
987 if (strlen($this->object->getNrOfTries()))
989 $nr_tries = $this->
object->getNrOfTries();
1005 $ni =
new ilNumberInputGUI($this->lng->txt(
"qst_nr_of_tries"),
"nr_of_tries");
1008 $ni->setMinValue(0);
1010 $ni->setMaxLength(5);
1011 $ni->setRequired(
true);
1012 $form->addItem($ni);
1027 $not_supported = array(
"img",
"p");
1031 if (!in_array($s, $not_supported))
1053 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1055 if (strlen($manual_feedback))
1057 return $manual_feedback;
1059 $correct_feedback = $this->
object->getFeedbackGeneric(1);
1060 $incorrect_feedback = $this->
object->getFeedbackGeneric(0);
1061 if (strlen($correct_feedback.$incorrect_feedback))
1063 $reached_points = $this->
object->calculateReachedPoints($active_id,
$pass);
1064 $max_points = $this->
object->getMaximumPoints();
1065 if ($reached_points == $max_points)
1067 $output = $correct_feedback;
1071 $output = $incorrect_feedback;
1074 return $this->
object->prepareTextareaOutput($output, TRUE);
1089 include_once
"./Modules/Test/classes/class.ilObjTest.php";
1091 if (strlen($manual_feedback))
1093 return $manual_feedback;
1095 $correct_feedback = $this->
object->getFeedbackGeneric(1);
1096 $incorrect_feedback = $this->
object->getFeedbackGeneric(0);
1097 if (strlen($correct_feedback.$incorrect_feedback))
1099 $reached_points = $this->
object->calculateReachedPoints($active_id,
$pass);
1100 $max_points = $this->
object->getMaximumPoints();
1101 if ($reached_points == $max_points)
1103 $output = $correct_feedback;
1107 $output = $incorrect_feedback;
1110 return $this->
object->prepareTextareaOutput($output, TRUE);
1133 $save = (strcmp($this->ctrl->getCmd(),
"saveFeedback") == 0) ? TRUE : FALSE;
1134 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1136 $form->setFormAction($this->ctrl->getFormAction($this));
1137 $form->setTitle($this->lng->txt(
'feedback_answers'));
1138 $form->setTableWidth(
"100%");
1139 $form->setId(
"feedback");
1141 $complete =
new ilTextAreaInputGUI($this->lng->txt(
"feedback_complete_solution"),
"feedback_complete");
1142 $complete->
setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)));
1143 $complete->setRequired(
false);
1144 $complete->setRows(10);
1145 $complete->setCols(80);
1148 $complete->setUseRte(
true);
1150 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1152 $complete->addPlugin(
"latex");
1153 $complete->addButton(
"latex");
1154 $complete->addButton(
"pastelatex");
1155 $complete->setRTESupport($this->object->getId(),
"qpl",
"assessment", null,
false,
'3.4.7');
1156 $form->addItem($complete);
1158 $incomplete =
new ilTextAreaInputGUI($this->lng->txt(
"feedback_incomplete_solution"),
"feedback_incomplete");
1159 $incomplete->
setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)));
1160 $incomplete->setRequired(
false);
1161 $incomplete->setRows(10);
1162 $incomplete->setCols(80);
1165 $incomplete->setUseRte(
true);
1167 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1169 $incomplete->addPlugin(
"latex");
1170 $incomplete->addButton(
"latex");
1171 $incomplete->addButton(
"pastelatex");
1172 $incomplete->setRTESupport($this->object->getId(),
"qpl",
"assessment", null,
false,
'3.4.7');
1173 $form->addItem($incomplete);
1178 $form->addCommandButton(
"saveFeedback", $this->lng->txt(
"save"));
1183 $form->setValuesByPost();
1184 $errors = !$form->checkInput();
1185 $form->setValuesByPost();
1187 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
1193 include_once
"./Services/UICore/classes/class.ilTemplate.php";
1194 $template =
new ilTemplate(
"tpl.il_as_qpl_questiontype.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1195 $count = $this->
object->isInUse();
1199 if ($rbacsystem->checkAccess(
"write",
$_GET[
"ref_id"]))
1201 $template->setCurrentBlock(
"infosign");
1203 $template->setVariable(
"INFO_IMG_ALT", sprintf($this->lng->txt(
"qpl_question_is_in_use"), $count));
1204 $template->setVariable(
"INFO_IMG_TITLE", sprintf($this->lng->txt(
"qpl_question_is_in_use"), $count));
1205 $template->parseCurrentBlock();
1209 return $template->get();
1222 if (
$_POST[
"deleteSuggestedSolution"] == 1)
1224 $this->
object->deleteSuggestedSolutions();
1226 $this->ctrl->redirect($this,
"suggestedsolution");
1229 $save = (is_array(
$_POST[
"cmd"]) && array_key_exists(
"suggestedsolution",
$_POST[
"cmd"])) ? TRUE : FALSE;
1231 $solution_array = $this->
object->getSuggestedSolution(0);
1233 "lm" => $this->lng->txt(
"obj_lm"),
1234 "st" => $this->lng->txt(
"obj_st"),
1235 "pg" => $this->lng->txt(
"obj_pg"),
1236 "git" => $this->lng->txt(
"glossary_term"),
1237 "file" => $this->lng->txt(
"fileDownload"),
1238 "text" => $this->lng->txt(
"solutionText")
1241 if ((strcmp(
$_POST[
"solutiontype"],
"file") == 0) && (strcmp($solution_array[
"type"],
"file") != 0))
1243 $solution_array = array(
1247 elseif ((strcmp(
$_POST[
"solutiontype"],
"text") == 0) && (strcmp($solution_array[
"type"],
"text") != 0))
1249 $solution_array = array(
1254 if ($save && strlen(
$_POST[
"filename"]))
1256 $solution_array[
"value"][
"filename"] =
$_POST[
"filename"];
1258 if ($save && strlen(
$_POST[
"solutiontext"]))
1260 $solution_array[
"value"] =
$_POST[
"solutiontext"];
1262 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
1263 if (count($solution_array))
1266 $form->setFormAction($this->ctrl->getFormAction($this));
1267 $form->setTitle($this->lng->txt(
"solution_hint"));
1268 $form->setMultipart(TRUE);
1269 $form->setTableWidth(
"100%");
1270 $form->setId(
"suggestedsolutiondisplay");
1273 include_once
"./Modules/TestQuestionPool/classes/class.ilSolutionTitleInputGUI.php";
1275 $template =
new ilTemplate(
"tpl.il_as_qpl_suggested_solution_input_presentation.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1276 if (strlen($solution_array[
"internal_link"]))
1279 $template->setCurrentBlock(
"preview");
1280 $template->setVariable(
"TEXT_SOLUTION", $this->lng->txt(
"solution_hint"));
1281 $template->setVariable(
"VALUE_SOLUTION",
" <a href=\"$href\" target=\"content\">" . $this->lng->txt(
"view").
"</a> ");
1282 $template->parseCurrentBlock();
1284 elseif ((strcmp($solution_array[
"type"],
"file") == 0) && (is_array($solution_array[
"value"])))
1286 $href = $this->
object->getSuggestedSolutionPathWeb() . $solution_array[
"value"][
"name"];
1287 $template->setCurrentBlock(
"preview");
1288 $template->setVariable(
"TEXT_SOLUTION", $this->lng->txt(
"solution_hint"));
1289 $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> ");
1290 $template->parseCurrentBlock();
1292 $template->setVariable(
"TEXT_TYPE", $this->lng->txt(
"type"));
1293 $template->setVariable(
"VALUE_TYPE", $options[$solution_array[
"type"]]);
1294 $title->setHtml($template->get());
1296 $deletesolution->setOptionTitle($this->lng->txt(
"deleteSuggestedSolution"));
1297 $title->addSubItem($deletesolution);
1300 if (strcmp($solution_array[
"type"],
"file") == 0)
1304 $file->setRequired(TRUE);
1305 $file->enableFileNameSelection(
"filename");
1307 if( $_FILES[
"file"][
"tmp_name"] &&
$file->checkInput() )
1309 if (!file_exists($this->object->getSuggestedSolutionPath()))
ilUtil::makeDirParents($this->object->getSuggestedSolutionPath());
1311 $res =
ilUtil::moveUploadedFile($_FILES[
"file"][
"tmp_name"], $_FILES[
"file"][
"name"], $this->object->getSuggestedSolutionPath() . $_FILES[
"file"][
"name"]);
1317 if (is_array($solution_array[
"value"])) @unlink($this->object->getSuggestedSolutionPath() . $solution_array[
"value"][
"name"]);
1318 $file->setValue($_FILES[
"file"][
"name"]);
1319 $this->
object->saveSuggestedSolution(
"file",
"", 0, array(
"name" => $_FILES[
"file"][
"name"],
"type" => $_FILES[
"file"][
"type"],
"size" => $_FILES[
"file"][
"size"],
"filename" =>
$_POST[
"filename"]));
1320 $originalexists = $this->
object->_questionExistsInPool($this->object->original_id);
1328 $this->ctrl->redirect($this,
"suggestedsolution");
1339 if (is_array($solution_array[
"value"]))
1341 $file->setValue($solution_array[
"value"][
"name"]);
1342 $file->setFilename((strlen($solution_array[
"value"][
"filename"])) ? $solution_array[
"value"][
"filename"] : $solution_array[
"value"][
"name"]);
1345 $form->addItem(
$file);
1347 $hidden->setValue(
"file");
1348 $form->addItem($hidden);
1350 else if (strcmp($solution_array[
"type"],
"text") == 0)
1353 $question->
setValue($this->object->prepareTextareaOutput($solution_array[
"value"]));
1354 $question->setRequired(TRUE);
1355 $question->setRows(10);
1356 $question->setCols(80);
1357 $question->setUseRte(TRUE);
1358 $question->addPlugin(
"latex");
1359 $question->addButton(
"latex");
1360 $question->setRTESupport($this->object->getId(),
"qpl",
"assessment", null,
false,
'3.4.7');
1362 $hidden->setValue(
"text");
1363 $form->addItem($hidden);
1364 $form->addItem($question);
1366 if ($ilAccess->checkAccess(
"write",
"",
$_GET[
'ref_id'])) $form->addCommandButton(
"suggestedsolution", $this->lng->txt(
"save"));
1370 if ($form->checkInput())
1372 switch ($solution_array[
"type"])
1375 $this->
object->saveSuggestedSolution(
"file",
"", 0, array(
"name" => $solution_array[
"value"][
"name"],
"type" => $solution_array[
"value"][
"type"],
"size" => $solution_array[
"value"][
"size"],
"filename" =>
$_POST[
"filename"]));
1378 $this->
object->saveSuggestedSolution(
"text",
"", 0, $solution_array[
"value"]);
1381 $originalexists = $this->
object->_questionExistsInPool($this->object->original_id);
1389 $this->ctrl->redirect($this,
"suggestedsolution");
1393 $output = $form->getHTML();
1396 $savechange = (strcmp($this->ctrl->getCmd(),
"saveSuggestedSolution") == 0) ? TRUE : FALSE;
1399 if ($ilAccess->checkAccess(
"write",
"",
$_GET[
'ref_id']))
1402 $formchange->setFormAction($this->ctrl->getFormAction($this));
1403 $formchange->setTitle((count($solution_array)) ? $this->lng->txt(
"changeSuggestedSolution") : $this->lng->txt(
"addSuggestedSolution"));
1404 $formchange->setMultipart(FALSE);
1405 $formchange->setTableWidth(
"100%");
1406 $formchange->setId(
"suggestedsolution");
1408 $solutiontype =
new ilRadioMatrixInputGUI($this->lng->txt(
"suggestedSolutionType"),
"solutiontype");
1410 if (count($solution_array))
1412 $solutiontype->setValue($solution_array[
"type"]);
1414 $solutiontype->setRequired(TRUE);
1415 $formchange->addItem($solutiontype);
1417 $formchange->addCommandButton(
"saveSuggestedSolution", $this->lng->txt(
"select"));
1421 $formchange->checkInput();
1423 $changeoutput = $formchange->getHTML();
1426 $this->tpl->setVariable(
"ADM_CONTENT", $changeoutput . $output);
1433 include_once(
"./Modules/TestQuestionPool/classes/class.ilSolutionExplorer.php");
1434 $type =
$_GET[
"link_new_type"];
1435 $search =
$_GET[
"search_link_type"];
1436 $this->ctrl->setParameter($this,
"link_new_type", $type);
1437 $this->ctrl->setParameter($this,
"search_link_type", $search);
1438 $this->ctrl->saveParameter($this, array(
"subquestion_index",
"link_new_type",
"search_link_type"));
1442 $parent_ref_id = $tree->getParentId(
$_GET[
"ref_id"]);
1443 $exp =
new ilSolutionExplorer($this->ctrl->getLinkTarget($this,
'suggestedsolution'), get_class($this));
1445 $exp->setExpandTarget($this->ctrl->getLinkTarget($this,
'outSolutionExplorer'));
1446 $exp->setTargetGet(
"ref_id");
1447 $exp->setRefId(
$_GET[
"ref_id"]);
1448 $exp->addFilter($type);
1449 $exp->setSelectableType($type);
1450 if(isset(
$_GET[
'expandCurrentPath']) &&
$_GET[
'expandCurrentPath'])
1452 $exp->expandPathByRefId($parent_ref_id);
1458 $template =
new ilTemplate(
"tpl.il_as_qpl_explorer.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1459 $template->setVariable(
"EXPLORER_TREE",$exp->getOutput());
1460 $template->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
1461 $template->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this,
"suggestedsolution"));
1462 $this->tpl->setVariable(
"ADM_CONTENT", $template->get());
1469 include_once(
"./Modules/TestQuestionPool/classes/class.ilSolutionExplorer.php");
1470 switch (
$_POST[
"solutiontype"])
1496 if(isset(
$_POST[
'solutiontype']))
1498 $this->ctrl->setParameter($this,
'expandCurrentPath', 1);
1500 $this->ctrl->setParameter($this,
"link_new_type", $type);
1501 $this->ctrl->setParameter($this,
"search_link_type", $search);
1502 $this->ctrl->redirect($this,
"outSolutionExplorer");
1507 $this->ctrl->redirect($this,
"suggestedsolution");
1512 include_once
"./Modules/LearningModule/classes/class.ilLMPageObject.php";
1513 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1515 $cont_obj = $cont_obj_gui->object;
1517 $shownpages = array();
1518 $tree = $cont_obj->getLMTree();
1519 $chapters = $tree->getSubtree($tree->getNodeData($tree->getRootId()));
1520 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
1521 $color_class = array(
"tblrow1",
"tblrow2");
1523 $template =
new ilTemplate(
"tpl.il_as_qpl_internallink_selection.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1524 foreach ($chapters as $chapter)
1526 $chapterpages = $tree->getChildsByType($chapter[
"obj_id"],
"pg");
1527 foreach ($chapterpages as $page)
1529 if($page[
"type"] ==
$_GET[
"search_link_type"])
1531 array_push($shownpages, $page[
"obj_id"]);
1532 $template->setCurrentBlock(
"linktable_row");
1533 $template->setVariable(
"TEXT_LINK", $page[
"title"]);
1534 $template->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
1535 $template->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this),
"add" . strtoupper($page[
"type"])) .
"&" . $page[
"type"] .
"=" . $page[
"obj_id"]);
1536 $template->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
1537 if ($tree->isInTree($page[
"obj_id"]))
1546 $template->parseCurrentBlock();
1551 foreach ($pages as $page)
1553 if (!in_array($page[
"obj_id"], $shownpages))
1555 $template->setCurrentBlock(
"linktable_row");
1556 $template->setVariable(
"TEXT_LINK", $page[
"title"]);
1557 $template->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
1558 $template->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this),
"add" . strtoupper($page[
"type"])) .
"&" . $page[
"type"] .
"=" . $page[
"obj_id"]);
1559 $template->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
1562 $template->parseCurrentBlock();
1566 $template->setCurrentBlock(
"link_selection");
1567 $template->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
1568 $template->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"obj_" .
$_GET[
"search_link_type"]));
1569 $template->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this,
"cancelExplorer"));
1570 $template->parseCurrentBlock();
1571 $this->tpl->setVariable(
"ADM_CONTENT", $template->get());
1576 $template =
new ilTemplate(
"tpl.il_as_qpl_internallink_selection.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1577 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
1578 $color_class = array(
"tblrow1",
"tblrow2");
1580 include_once(
"./Modules/LearningModule/classes/class.ilObjContentObjectGUI.php");
1582 $cont_obj = $cont_obj_gui->object;
1584 $ctree =& $cont_obj->getLMTree();
1585 $nodes = $ctree->getSubtree($ctree->getNodeData($ctree->getRootId()));
1586 foreach($nodes as $node)
1588 if($node[
"type"] ==
$_GET[
"search_link_type"])
1590 $template->setCurrentBlock(
"linktable_row");
1591 $template->setVariable(
"TEXT_LINK", $node[
"title"]);
1592 $template->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
1593 $template->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this),
"add" . strtoupper($node[
"type"])) .
"&" . $node[
"type"] .
"=" . $node[
"obj_id"]);
1594 $template->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
1595 $template->parseCurrentBlock();
1599 $template->setCurrentBlock(
"link_selection");
1600 $template->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
1601 $template->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"obj_" .
$_GET[
"search_link_type"]));
1602 $template->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this,
"cancelExplorer"));
1603 $template->parseCurrentBlock();
1604 $this->tpl->setVariable(
"ADM_CONTENT", $template->get());
1609 $template =
new ilTemplate(
"tpl.il_as_qpl_internallink_selection.html", TRUE, TRUE,
"Modules/TestQuestionPool");
1610 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
1611 $color_class = array(
"tblrow1",
"tblrow2");
1613 include_once
"./Modules/Glossary/classes/class.ilObjGlossary.php";
1616 $terms = $glossary->getTermList();
1617 foreach($terms as $term)
1619 $template->setCurrentBlock(
"linktable_row");
1620 $template->setVariable(
"TEXT_LINK", $term[
"term"]);
1621 $template->setVariable(
"TEXT_ADD", $this->lng->txt(
"add"));
1622 $template->setVariable(
"LINK_HREF", $this->ctrl->getLinkTargetByClass(get_class($this),
"addGIT") .
"&git=" . $term[
"id"]);
1623 $template->setVariable(
"COLOR_CLASS", $color_class[$counter % 2]);
1624 $template->parseCurrentBlock();
1627 $template->setCurrentBlock(
"link_selection");
1628 $template->setVariable(
"BUTTON_CANCEL",$this->lng->txt(
"cancel"));
1629 $template->setVariable(
"TEXT_LINK_TYPE", $this->lng->txt(
"glossary_term"));
1630 $template->setVariable(
"FORMACTION",$this->ctrl->getFormAction($this,
"cancelExplorer"));
1631 $template->parseCurrentBlock();
1632 $this->tpl->setVariable(
"ADM_CONTENT", $template->get());
1637 $this->ctrl->saveParameter($this, array(
"subquestion_index",
"link_new_type",
"search_link_type"));
1638 switch (
$_GET[
"search_link_type"])
1650 $subquestion_index = (
$_GET[
"subquestion_index"] > 0) ?
$_GET[
"subquestion_index"] : 0;
1651 $this->
object->saveSuggestedSolution(
"lm",
"il__lm_" .
$_GET[
"source_id"], $subquestion_index);
1653 $this->ctrl->redirect($this,
"suggestedsolution");
1660 $subquestion_index = 0;
1661 if (strlen(
$_GET[
"subquestion_index"]) &&
$_GET[
"subquestion_index"] >= 0)
1663 $subquestion_index =
$_GET[
"subquestion_index"];
1665 $this->
object->saveSuggestedSolution(
"pg",
"il__pg_" .
$_GET[
"pg"], $subquestion_index);
1667 $this->ctrl->redirect($this,
"suggestedsolution");
1672 $subquestion_index = 0;
1673 if (strlen(
$_GET[
"subquestion_index"]) &&
$_GET[
"subquestion_index"] >= 0)
1675 $subquestion_index =
$_GET[
"subquestion_index"];
1677 $this->
object->saveSuggestedSolution(
"st",
"il__st_" .
$_GET[
"st"], $subquestion_index);
1679 $this->ctrl->redirect($this,
"suggestedsolution");
1684 $subquestion_index = 0;
1685 if (strlen(
$_GET[
"subquestion_index"]) &&
$_GET[
"subquestion_index"] >= 0)
1687 $subquestion_index =
$_GET[
"subquestion_index"];
1689 $this->
object->saveSuggestedSolution(
"git",
"il__git_" .
$_GET[
"git"], $subquestion_index);
1691 $this->ctrl->redirect($this,
"suggestedsolution");
1696 return in_array($this->ctrl->getCmd(), array(
'save',
'saveEdit',
'saveReturn'));
1713 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsGUI.php';
1715 $reflectionClass = null;
1717 switch( $ilCtrl->getCmdClass() )
1719 case 'ilassquestionhintsgui':
1721 $reflectionClass =
new ReflectionClass(
'ilAssQuestionHintsGUI');
1724 case 'ilassquestionhintgui':
1726 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintGUI.php';
1727 $reflectionClass =
new ReflectionClass(
'ilAssQuestionHintGUI');
1731 $tabCommands = array();
1733 if( $reflectionClass instanceof ReflectionClass )
1734 foreach($reflectionClass->getConstants() as $constName => $constValue)
1735 if( substr($constName, 0, strlen(
'CMD_')) ==
'CMD_' ) $tabCommands[] = $constValue;
1739 $tabs->
addTarget(
'tst_question_hints_tab', $tabLink, $tabCommands, $ilCtrl->getCmdClass(),
'');
1745 $graphicalOutput = FALSE,
1746 $result_output = FALSE,
1747 $show_question_only = TRUE,
1748 $show_feedback = FALSE,
1749 $show_correct_solution = FALSE,
1750 $show_manual_scoring = FALSE,
1751 $show_question_text = TRUE
1756 return $this->
object->isAutosaveable();