24 include_once
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
25 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
50 include_once
"./Modules/TestQuestionPool/classes/class.assTextQuestion.php";
54 $this->
object->loadFromDb($id);
66 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
69 $this->
object->setTitle(
$_POST[
"title"]);
70 $this->
object->setAuthor(
$_POST[
"author"]);
71 $this->
object->setComment(
$_POST[
"comment"]);
72 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
73 $questiontext =
$_POST[
"question"];
74 $this->
object->setQuestion($questiontext);
75 $this->
object->setPoints(
$_POST[
"points"]);
76 $this->
object->setMaxNumOfChars(
$_POST[
"maxchars"]);
77 $this->
object->setKeywords(
$_POST[
"keywords"]);
78 $this->
object->setTextRating(
$_POST[
"text_rating"]);
81 $this->
object->setNrOfTries(
$_POST[
'nr_of_tries']);
83 $this->
object->setEstimatedWorkingTime(
103 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0) || (strcmp($this->ctrl->getCmd(),
"saveEdit") == 0)) ? TRUE : FALSE;
106 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
108 $form->setFormAction($this->ctrl->getFormAction($this));
110 $form->setMultipart(TRUE);
111 $form->setTableWidth(
"100%");
112 $form->setId(
"asstextquestion");
120 if ($this->object->getMaxNumOfChars() > 0) $maxchars->setValue($this->object->getMaxNumOfChars());
121 $maxchars->setInfo($this->lng->txt(
"description_maxchars"));
122 $form->addItem($maxchars);
128 $points->setValue($this->object->getPoints());
135 $header->setTitle($this->lng->txt(
"optional_keywords"));
136 $form->addItem($header);
141 $keywords->setRequired(FALSE);
142 $keywords->setInfo($this->lng->txt(
"keywords_hint"));
143 $keywords->setRows(10);
144 $keywords->setCols(40);
145 $keywords->setUseRte(FALSE);
146 $form->addItem($keywords);
148 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
149 $text_options = array(
150 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
151 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
152 "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1"),
153 "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2"),
154 "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3"),
155 "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4"),
156 "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5")
158 $textrating->setOptions($text_options);
159 $textrating->setValue($this->object->getTextRating());
160 $form->addItem($textrating);
168 $form->setValuesByPost();
169 $errors = !$form->checkInput();
170 $form->setValuesByPost();
171 if (
$errors) $checkonly =
false;
174 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
180 if ($this->object->getMaxNumOfChars() > 0)
182 $this->tpl->addBlockFile(
"CONTENT_BLOCK",
"charcounter",
"tpl.charcounter.html",
"Modules/TestQuestionPool");
183 $this->tpl->setCurrentBlock(
"charcounter");
184 $this->tpl->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
185 $this->tpl->parseCurrentBlock();
191 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
192 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
193 $this->tpl->setVariable(
"FORMACTION", $formaction);
194 include_once
"./Services/RTE/classes/class.ilRTE.php";
196 include_once
"./Services/RTE/classes/class.$rtestring.php";
197 $rte =
new $rtestring();
198 include_once
"./classes/class.ilObject.php";
201 $rte->addUserTextEditor(
"textinput");
221 $graphicalOutput = FALSE,
222 $result_output = FALSE,
223 $show_question_only = TRUE,
224 $show_feedback = FALSE,
225 $show_correct_solution = FALSE,
226 $show_manual_scoring = FALSE
231 if (($active_id > 0) && (!$show_correct_solution))
233 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
234 foreach ($solutions as $idx => $solution_value)
236 $user_solution = $solution_value[
"value1"];
241 $keywords = $this->
object->getKeywordList();
242 if (count($keywords))
244 $user_solution = $this->lng->txt(
"solution_may_contain_keywords") .
": " . join(
",", $keywords);
249 include_once
"./classes/class.ilTemplate.php";
250 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
251 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
252 $template->setVariable(
"ESSAY", $this->object->prepareTextareaOutput($user_solution));
253 $questiontext = $this->
object->getQuestion();
254 if (($active_id > 0) && (!$show_correct_solution))
256 if ($graphicalOutput)
259 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
260 if ($reached_points == $this->object->getMaximumPoints())
262 $template->setCurrentBlock(
"icon_ok");
264 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
265 $template->parseCurrentBlock();
269 $template->setCurrentBlock(
"icon_ok");
270 if ($reached_points > 0)
273 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
278 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
280 $template->parseCurrentBlock();
284 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
285 $questionoutput = $template->get();
287 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
288 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
290 $solutionoutput = $solutiontemplate->get();
291 if (!$show_question_only)
296 return $solutionoutput;
302 include_once
"./classes/class.ilTemplate.php";
303 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
304 if ($this->object->getMaxNumOfChars())
306 $template->setCurrentBlock(
"maximum_char_hint");
307 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
308 $template->parseCurrentBlock();
309 $template->setCurrentBlock(
"has_maxchars");
310 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
311 $template->parseCurrentBlock();
312 $template->setCurrentBlock(
"maxchars_counter");
313 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
314 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
315 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
316 $template->parseCurrentBlock();
318 $questiontext = $this->
object->getQuestion();
319 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
320 $questionoutput = $template->get();
321 if (!$show_question_only)
326 return $questionoutput;
336 include_once
"./Modules/Test/classes/class.ilObjTest.php";
341 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
342 foreach ($solutions as $idx => $solution_value)
344 $user_solution = $solution_value[
"value1"];
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();
366 $questiontext = $this->
object->getQuestion();
367 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
368 $questionoutput = $template->get();
369 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
370 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
378 if (
$_POST[
"cmd"][
"addSuggestedSolution"])
386 if (!$this->checkInput())
388 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
393 $this->
object->saveToDb();
394 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
395 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
407 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
409 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
410 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
411 $this->
object->cleanupMediaObjectUsage();
422 global $rbacsystem, $ilTabs;
424 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
425 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
426 $q_type = $this->
object->getQuestionType();
430 $classname = $q_type .
"GUI";
431 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
432 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
437 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
440 $ilTabs->addTarget(
"edit_content",
441 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
442 array(
"edit",
"insert",
"exec_pg"),
443 "",
"", $force_active);
447 $ilTabs->addTarget(
"preview",
448 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
450 "ilPageObjectGUI",
"", $force_active);
453 $force_active =
false;
454 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
457 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
459 $ilTabs->addTarget(
"edit_properties",
461 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
462 $classname,
"", $force_active);
467 $ilTabs->addTarget(
"feedback",
468 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
469 array(
"feedback",
"saveFeedback"),
475 $ilTabs->addTarget(
"solution_hint",
476 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
477 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
478 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
488 $ilTabs->addTarget(
"statistics",
489 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
494 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
498 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
502 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));