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());
129 $points->setRequired(TRUE);
131 $points->setMinValue(0.0);
132 $points->setMinvalueShouldBeGreater(
true);
133 $form->addItem($points);
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 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
150 $text_options = array(
151 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
152 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
153 "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1"),
154 "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2"),
155 "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3"),
156 "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4"),
157 "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5")
159 $textrating->setOptions($text_options);
160 $textrating->setValue($this->object->getTextRating());
161 $form->addItem($textrating);
169 $form->setValuesByPost();
170 $errors = !$form->checkInput();
171 $form->setValuesByPost();
172 if (
$errors) $checkonly =
false;
175 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
181 if ($this->object->getMaxNumOfChars() > 0)
183 $this->tpl->addBlockFile(
"CONTENT_BLOCK",
"charcounter",
"tpl.charcounter.html",
"Modules/TestQuestionPool");
184 $this->tpl->setCurrentBlock(
"charcounter");
185 $this->tpl->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
186 $this->tpl->parseCurrentBlock();
192 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
193 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
194 $this->tpl->setVariable(
"FORMACTION", $formaction);
195 include_once
"./Services/RTE/classes/class.ilRTE.php";
197 include_once
"./Services/RTE/classes/class.$rtestring.php";
198 $rte =
new $rtestring();
199 include_once
"./classes/class.ilObject.php";
202 $rte->addUserTextEditor(
"textinput");
222 $graphicalOutput = FALSE,
223 $result_output = FALSE,
224 $show_question_only = TRUE,
225 $show_feedback = FALSE,
226 $show_correct_solution = FALSE,
227 $show_manual_scoring = FALSE
232 if (($active_id > 0) && (!$show_correct_solution))
234 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
235 foreach ($solutions as $idx => $solution_value)
237 $user_solution = $solution_value[
"value1"];
242 $keywords = $this->
object->getKeywordList();
243 if (count($keywords))
245 $user_solution = $this->lng->txt(
"solution_may_contain_keywords") .
": " . join(
",", $keywords);
250 include_once
"./classes/class.ilTemplate.php";
251 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
252 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
253 $template->setVariable(
"ESSAY", $this->object->prepareTextareaOutput($user_solution, TRUE));
254 $questiontext = $this->
object->getQuestion();
255 $max_no_of_chars = $this->
object->getMaxNumOfChars();
256 $act_no_of_chars = strlen(strip_tags($user_solution));
257 $template->setVariable(
"CHARACTER_INFO",
'<b>' . $max_no_of_chars .
'</b>' . $this->lng->txt(
'answer_characters') .
' <b>' . $act_no_of_chars .
'</b>');
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 #mbecker: No such block. $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 #mbecker: No such block. $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"));