24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
52 include_once
"./Modules/TestQuestionPool/classes/class.assTextQuestion.php";
56 $this->
object->loadFromDb($id);
67 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0) || (strcmp($this->ctrl->getCmd(),
"saveEdit") == 0) || (strcmp($this->ctrl->getCmd(),
"addSuggestedSolution") == 0)) ? TRUE : FALSE;
69 $this->tpl->addJavascript(
"./Services/JavaScript/js/Basic.js");
72 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
74 $form->setFormAction($this->ctrl->getFormAction($this));
75 $form->setTitle($this->lng->txt(
"assTextQuestion"));
76 $form->setMultipart(TRUE);
77 $form->setTableWidth(
"100%");
78 $form->setId(
"flash");
82 $title->setValue($this->object->getTitle());
87 $author->
setValue($this->object->getAuthor());
88 $author->setRequired(TRUE);
89 $form->addItem($author);
91 $description =
new ilTextInputGUI($this->lng->txt(
"description"),
"comment");
92 $description->
setValue($this->object->getComment());
93 $description->setRequired(FALSE);
94 $form->addItem($description);
97 $question->
setValue($this->object->prepareTextareaOutput($this->object->getQuestion()));
98 $question->setRequired(TRUE);
99 $question->setRows(10);
100 $question->setCols(80);
101 $question->setUseRte(TRUE);
102 $question->addPlugin(
"latex");
103 $question->addButton(
"latex");
104 $question->setRTESupport($this->object->getId(),
"qpl",
"assessment");
105 $form->addItem($question);
107 $maxchars =
new ilTextInputGUI($this->lng->txt(
"maxchars"),
"maxchars");
109 if ($this->object->getMaxNumOfChars() > 0) $maxchars->setValue($this->object->getMaxNumOfChars());
110 $maxchars->setInfo($this->lng->txt(
"description_maxchars"));
111 $form->addItem($maxchars);
115 $duration->setShowMinutes(TRUE);
116 $duration->setShowSeconds(TRUE);
117 $ewt = $this->
object->getEstimatedWorkingTime();
118 $duration->setHours($ewt[
"h"]);
119 $duration->setMinutes($ewt[
"m"]);
120 $duration->setSeconds($ewt[
"s"]);
121 $duration->setRequired(FALSE);
122 $form->addItem($duration);
124 include_once
"./Modules/TestQuestionPool/classes/class.ilSuggestedSolutionSelectorGUI.php";
126 $internallinks = array(
127 "lm" => $this->lng->txt(
"obj_lm"),
128 "st" => $this->lng->txt(
"obj_st"),
129 "pg" => $this->lng->txt(
"obj_pg"),
130 "glo" => $this->lng->txt(
"glossary_term")
133 $solution->setAddCommand(
"addSuggestedSolution");
134 $solution_array = $this->
object->getSuggestedSolution(0);
135 if ($solution_array[
"internal_link"])
138 $solution->setInternalLinkText($this->lng->txt(
"solution_hint"));
140 $form->addItem($solution);
143 $points->
setValue($this->object->getPoints());
144 $points->setRequired(TRUE);
146 $points->setMinValue(0.0);
147 $form->addItem($points);
150 $header->setTitle($this->lng->txt(
"optional_keywords"));
151 $form->addItem($header);
156 $keywords->setRequired(FALSE);
157 $keywords->setInfo($this->lng->txt(
"keywords_hint"));
158 $keywords->setRows(10);
159 $keywords->setCols(40);
160 $keywords->setUseRte(FALSE);
161 $form->addItem($keywords);
163 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
164 $text_options = array(
165 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
166 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
167 "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1"),
168 "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2"),
169 "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3"),
170 "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4"),
171 "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5")
173 $textrating->setOptions($text_options);
174 $textrating->setValue($this->object->getTextRating());
175 $form->addItem($textrating);
176 $form->addCommandButton(
"save", $this->lng->txt(
"save"));
177 $form->addCommandButton(
"saveEdit", $this->lng->txt(
"save_edit"));
178 $form->addCommandButton(
"cancel", $this->lng->txt(
"cancel"));
183 $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
191 $cmd = $this->ctrl->getCmd();
193 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"question"]) or (strlen($_POST[
"points"]) == 0))
211 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"question"]) or (strlen($_POST[
"points"]) == 0))
219 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
221 $this->
object->setQuestion($questiontext);
222 $this->
object->setPoints($_POST[
"points"]);
223 if ($_POST[
"points"] < 0)
226 $this->
setErrorMessage($this->lng->txt(
"negative_points_not_allowed"));
228 $this->
object->setSuggestedSolution($_POST[
"solution_hint"], 0);
229 $this->
object->setMaxNumOfChars($_POST[
"maxchars"]);
231 $this->
object->setTextRating($_POST[
"text_rating"]);
232 $this->
object->setEstimatedWorkingTime(
239 if ($_POST[
"text_question_id"] > 0)
241 $this->
object->setId($_POST[
"text_question_id"]);
249 if ($this->object->getMaxNumOfChars() > 0)
251 $this->tpl->addBlockFile(
"CONTENT_BLOCK",
"charcounter",
"tpl.charcounter.html",
"Modules/TestQuestionPool");
252 $this->tpl->setCurrentBlock(
"charcounter");
253 $this->tpl->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
254 $this->tpl->parseCurrentBlock();
260 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
261 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
262 $this->tpl->setVariable(
"FORMACTION", $formaction);
263 include_once
"./Services/RTE/classes/class.ilRTE.php";
265 include_once
"./Services/RTE/classes/class.$rtestring.php";
266 $rte =
new $rtestring();
267 include_once
"./classes/class.ilObject.php";
270 $rte->addUserTextEditor(
"textinput");
274 function getSolutionOutput($active_id,
$pass = NULL, $graphicalOutput = FALSE, $result_output = FALSE, $show_question_only = TRUE, $show_feedback = FALSE, $show_correct_solution = FALSE)
278 if (($active_id > 0) && (!$show_correct_solution))
280 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
281 foreach ($solutions as $idx => $solution_value)
283 $user_solution = $solution_value[
"value1"];
288 $keywords = $this->
object->getKeywordList();
289 if (count($keywords))
291 $user_solution = $this->lng->txt(
"solution_may_contain_keywords") .
": " . join(
",", $keywords);
296 include_once
"./classes/class.ilTemplate.php";
297 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
298 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
299 $template->setVariable(
"ESSAY", $this->object->prepareTextareaOutput($user_solution));
300 $questiontext = $this->
object->getQuestion();
301 if (($active_id > 0) && (!$show_correct_solution))
303 if ($graphicalOutput)
306 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
307 if ($reached_points == $this->object->getMaximumPoints())
309 $template->setCurrentBlock(
"icon_ok");
311 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
312 $template->parseCurrentBlock();
316 $template->setCurrentBlock(
"icon_ok");
317 if ($reached_points > 0)
320 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
325 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
327 $template->parseCurrentBlock();
331 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
332 $questionoutput = $template->get();
334 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
335 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
337 $solutionoutput = $solutiontemplate->get();
338 if (!$show_question_only)
343 return $solutionoutput;
349 include_once
"./classes/class.ilTemplate.php";
350 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
351 if ($this->object->getMaxNumOfChars())
353 $template->setCurrentBlock(
"maximum_char_hint");
354 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
355 $template->parseCurrentBlock();
356 $template->setCurrentBlock(
"has_maxchars");
357 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
358 $template->parseCurrentBlock();
359 $template->setCurrentBlock(
"maxchars_counter");
360 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
361 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
362 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
363 $template->parseCurrentBlock();
365 $questiontext = $this->
object->getQuestion();
366 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
367 $questionoutput = $template->get();
368 if (!$show_question_only)
373 return $questionoutput;
383 include_once
"./Modules/Test/classes/class.ilObjTest.php";
388 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
389 foreach ($solutions as $idx => $solution_value)
391 $user_solution = $solution_value[
"value1"];
396 include_once
"./classes/class.ilTemplate.php";
397 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
398 if ($this->object->getMaxNumOfChars())
400 $template->setCurrentBlock(
"maximum_char_hint");
401 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
402 $template->parseCurrentBlock();
403 $template->setCurrentBlock(
"has_maxchars");
404 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
405 $template->parseCurrentBlock();
406 $template->setCurrentBlock(
"maxchars_counter");
407 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
408 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
409 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
410 $template->parseCurrentBlock();
413 $questiontext = $this->
object->getQuestion();
414 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
415 $questionoutput = $template->get();
416 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
417 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
425 if ($_POST[
"cmd"][
"addSuggestedSolution"])
435 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
440 $this->
object->saveToDb();
441 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
442 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
456 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
459 $this->
object->cleanupMediaObjectUsage();
472 $this->tpl->addBlockFile(
"ADM_CONTENT",
"feedback",
"tpl.il_as_qpl_text_question_feedback.html",
"Modules/TestQuestionPool");
473 $this->tpl->setVariable(
"FEEDBACK_TEXT", $this->lng->txt(
"feedback"));
474 $this->tpl->setVariable(
"FEEDBACK_COMPLETE", $this->lng->txt(
"feedback_complete_solution"));
475 $this->tpl->setVariable(
"VALUE_FEEDBACK_COMPLETE",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)), FALSE));
476 $this->tpl->setVariable(
"FEEDBACK_INCOMPLETE", $this->lng->txt(
"feedback_incomplete_solution"));
477 $this->tpl->setVariable(
"VALUE_FEEDBACK_INCOMPLETE",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)), FALSE));
479 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
481 $this->tpl->setVariable(
"SAVE", $this->lng->txt(
"save"));
483 $this->tpl->setVariable(
"FORMACTION", $this->ctrl->getFormAction($this));
485 include_once
"./Services/RTE/classes/class.ilRTE.php";
487 include_once
"./Services/RTE/classes/class.$rtestring.php";
488 $rte =
new $rtestring();
489 $rte->addPlugin(
"latex");
490 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
491 include_once
"./classes/class.ilObject.php";
492 $obj_id =
$_GET[
"q_id"];
494 $rte->addRTESupport($obj_id, $obj_type,
"assessment");
506 global $rbacsystem, $ilTabs;
508 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
509 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
510 $q_type = $this->
object->getQuestionType();
514 $classname = $q_type .
"GUI";
515 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
516 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
521 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
524 $ilTabs->addTarget(
"edit_content",
525 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
526 array(
"edit",
"insert",
"exec_pg"),
527 "",
"", $force_active);
531 $ilTabs->addTarget(
"preview",
532 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
534 "ilPageObjectGUI",
"", $force_active);
537 $force_active =
false;
538 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
541 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
543 $ilTabs->addTarget(
"edit_properties",
545 array(
"editQuestion",
"save",
"cancel",
"addSuggestedSolution",
546 "cancelExplorer",
"linkChilds",
"removeSuggestedSolution",
548 $classname,
"", $force_active);
553 $ilTabs->addTarget(
"feedback",
554 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
555 array(
"feedback",
"saveFeedback"),
562 $ilTabs->addTarget(
"statistics",
563 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
568 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
572 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
576 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));