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());
132 $points->setMinvalueShouldBeGreater(
true);
136 $header->setTitle($this->lng->txt(
"optional_keywords"));
137 $form->addItem($header);
142 $keywords->setRequired(FALSE);
143 $keywords->setInfo($this->lng->txt(
"keywords_hint"));
144 $keywords->setRows(10);
145 $keywords->setCols(40);
146 $keywords->setUseRte(FALSE);
147 $form->addItem($keywords);
149 include_once(
"./Services/Form/classes/class.ilAdditionalCharactersGUI.php");
152 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
153 $text_options = array(
154 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
155 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
156 "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1"),
157 "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2"),
158 "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3"),
159 "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4"),
160 "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5")
162 $textrating->setOptions($text_options);
163 $textrating->setValue($this->object->getTextRating());
164 $form->addItem($textrating);
172 $form->setValuesByPost();
173 $errors = !$form->checkInput();
174 $form->setValuesByPost();
175 if (
$errors) $checkonly =
false;
178 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
184 if ($this->object->getMaxNumOfChars() > 0)
186 $this->tpl->addBlockFile(
"CONTENT_BLOCK",
"charcounter",
"tpl.charcounter.html",
"Modules/TestQuestionPool");
187 $this->tpl->setCurrentBlock(
"charcounter");
188 $this->tpl->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
189 $this->tpl->parseCurrentBlock();
195 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
196 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
197 $this->tpl->setVariable(
"FORMACTION", $formaction);
198 include_once
"./Services/RTE/classes/class.ilRTE.php";
200 include_once
"./Services/RTE/classes/class.$rtestring.php";
201 $rte =
new $rtestring();
202 include_once
"./classes/class.ilObject.php";
205 $rte->addUserTextEditor(
"textinput");
225 $graphicalOutput = FALSE,
226 $result_output = FALSE,
227 $show_question_only = TRUE,
228 $show_feedback = FALSE,
229 $show_correct_solution = FALSE,
230 $show_manual_scoring = FALSE
235 if (($active_id > 0) && (!$show_correct_solution))
237 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
238 foreach ($solutions as $idx => $solution_value)
240 $user_solution = $solution_value[
"value1"];
245 $keywords = $this->
object->getKeywordList();
246 if (count($keywords))
248 $user_solution = $this->lng->txt(
"solution_may_contain_keywords") .
": " . join(
",", $keywords);
253 include_once
"./classes/class.ilTemplate.php";
254 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
255 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
256 $template->setVariable(
"ESSAY", $this->object->prepareTextareaOutput($user_solution));
257 $questiontext = $this->
object->getQuestion();
258 if (($active_id > 0) && (!$show_correct_solution))
260 if ($graphicalOutput)
263 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
264 if ($reached_points == $this->object->getMaximumPoints())
266 $template->setCurrentBlock(
"icon_ok");
268 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
269 $template->parseCurrentBlock();
273 $template->setCurrentBlock(
"icon_ok");
274 if ($reached_points > 0)
277 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
282 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
284 $template->parseCurrentBlock();
288 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
289 $questionoutput = $template->get();
291 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
292 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
294 $solutionoutput = $solutiontemplate->get();
295 if (!$show_question_only)
300 return $solutionoutput;
306 include_once
"./classes/class.ilTemplate.php";
307 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
308 if ($this->object->getMaxNumOfChars())
310 $template->setCurrentBlock(
"maximum_char_hint");
311 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
312 $template->parseCurrentBlock();
313 $template->setCurrentBlock(
"has_maxchars");
314 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
315 $template->parseCurrentBlock();
316 $template->setCurrentBlock(
"maxchars_counter");
317 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
318 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
319 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
320 $template->parseCurrentBlock();
322 $questiontext = $this->
object->getQuestion();
323 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
324 $questionoutput = $template->get();
325 if (!$show_question_only)
330 return $questionoutput;
340 include_once
"./Modules/Test/classes/class.ilObjTest.php";
345 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
346 foreach ($solutions as $idx => $solution_value)
348 $user_solution = $solution_value[
"value1"];
353 include_once
"./classes/class.ilTemplate.php";
354 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
355 if ($this->object->getMaxNumOfChars())
357 $template->setCurrentBlock(
"maximum_char_hint");
358 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
359 $template->parseCurrentBlock();
360 $template->setCurrentBlock(
"has_maxchars");
361 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
362 $template->parseCurrentBlock();
363 $template->setCurrentBlock(
"maxchars_counter");
364 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
365 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
366 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
367 $template->parseCurrentBlock();
370 $questiontext = $this->
object->getQuestion();
371 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
372 $questionoutput = $template->get();
373 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
374 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
382 if (
$_POST[
"cmd"][
"addSuggestedSolution"])
390 if (!$this->checkInput())
392 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
397 $this->
object->saveToDb();
398 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
399 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
411 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
413 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
414 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
415 $this->
object->cleanupMediaObjectUsage();
426 global $rbacsystem, $ilTabs;
428 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
429 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
430 $q_type = $this->
object->getQuestionType();
434 $classname = $q_type .
"GUI";
435 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
436 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
441 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
444 $ilTabs->addTarget(
"edit_content",
445 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
446 array(
"edit",
"insert",
"exec_pg"),
447 "",
"", $force_active);
451 $ilTabs->addTarget(
"preview",
452 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
454 "ilPageObjectGUI",
"", $force_active);
457 $force_active =
false;
458 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
461 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
463 $ilTabs->addTarget(
"edit_properties",
465 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
466 $classname,
"", $force_active);
471 $ilTabs->addTarget(
"feedback",
472 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
473 array(
"feedback",
"saveFeedback"),
479 $ilTabs->addTarget(
"solution_hint",
480 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
481 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
482 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
492 $ilTabs->addTarget(
"statistics",
493 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
498 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
502 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
506 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));