4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6 include_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
24 include_once
'./Modules/TestQuestionPool/classes/class.assLongMenu.php';
27 $this->
object->loadFromDb($id);
45 $user_solution = array();
49 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 50 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 52 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 57 foreach ($solutions as $idx => $solution_value) {
58 $user_solution[$solution_value[
"value1"]] = $solution_value[
"value2"];
60 return $user_solution;
62 return $user_solution;
76 $form->setValuesByPost();
77 $check = $form->checkInput();
80 $custom_check = $this->
object->checkQuestionCustomPart($form);
81 if (!$check || !$custom_check) {
98 $this->
object->setQuestion(
$_POST[
'question']);
99 $this->
object->setLongMenuTextValue(
$_POST[
"longmenu_text"]);
100 $this->
object->setMinAutoComplete((
int)
$_POST[
"min_auto_complete"]);
101 $this->
object->setIdenticalScoring((
int) $_POST[
"identical_scoring"]);
107 if ($form === null) {
112 $this->tpl->addCss(
'Modules/Test/templates/default/ta.css');
114 $this->tpl->setVariable(
"QUESTION_DATA", $this->ctrl->getHTML($form));
140 $long_menu_text =
new ilTextAreaInputGUI($this->lng->txt(
"longmenu_text"),
'longmenu_text');
143 $long_menu_text->setRows(10);
144 $long_menu_text->setCols(80);
145 if (!$this->object->getSelfAssessmentEditingMode()) {
147 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
149 $long_menu_text->addPlugin(
"latex");
150 $long_menu_text->addButton(
"latex");
151 $long_menu_text->addButton(
"pastelatex");
152 $long_menu_text->setRTESupport($this->object->getId(),
"qpl",
"assessment");
153 $long_menu_text->setUseRte(
true);
156 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
158 $long_menu_text->setUseTagsForRteOnly(
false);
161 $long_menu_text->setValue($this->object->prepareTextareaOutput($this->object->getLongMenuTextValue()));
162 $form->
addItem($long_menu_text);
164 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_gap_button_code.html",
true,
true,
"Modules/TestQuestionPool");
165 $tpl->setVariable(
'INSERT_GAP', $this->lng->txt(
'insert_gap'));
166 $tpl->parseCurrentBlock();
168 $button->setHtml(
$tpl->get());
171 require_once(
"./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
173 $modal->setHeading(
'');
174 $modal->setId(
"ilGapModal");
178 $min_auto_complete =
new ilNumberInputGUI($this->lng->txt(
"min_auto_complete"),
'min_auto_complete');
180 $auto_complete = $this->
object->getMinAutoComplete();
181 if ($auto_complete == 0) {
184 $min_auto_complete->setValue($auto_complete);
185 $min_auto_complete->setMinValue(1);
186 $min_auto_complete->setMaxValue(99);
187 $min_auto_complete->setSize(5);
188 $form->
addItem($min_auto_complete);
190 $identical_scoring =
new ilCheckboxInputGUI($this->lng->txt(
"identical_scoring"),
"identical_scoring");
192 $identical_scoring->setChecked($this->object->getIdenticalScoring());
193 $identical_scoring->setInfo($this->lng->txt(
'identical_scoring_desc'));
194 $identical_scoring->setRequired(
false);
195 $form->
addItem($identical_scoring);
200 $form->
addItem($hidden_correct);
202 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_gap.html",
true,
true,
"Modules/TestQuestionPool");
203 if (is_array(
$_POST) && array_key_exists(
'hidden_text_files',
$_POST)) {
204 $tpl->setVariable(
'CORRECT_ANSWERS',
$_POST[
'hidden_correct_answers']);
205 $tpl->setVariable(
'ALL_ANSWERS',
$_POST[
'hidden_text_files']);
207 $tpl->setVariable(
'CORRECT_ANSWERS', $this->object->getJsonStructure());
208 $tpl->setVariable(
'ALL_ANSWERS', $this->object->getAnswersObject());
212 $tpl->setVariable(
'SELECT_BOX', $this->lng->txt(
'insert_gap'));
213 $tpl->setVariable(
"SELECT", $this->lng->txt(
'answers_select'));
214 $tpl->setVariable(
"TEXT", $this->lng->txt(
'answers_text_box'));
215 $tpl->setVariable(
"POINTS", $this->lng->txt(
'points'));
216 $tpl->setVariable(
"INFO_TEXT_UPLOAD", $this->lng->txt(
'info_text_upload'));
217 $tpl->setVariable(
"TXT_BROWSE", $this->lng->txt(
'select_file'));
218 $tpl->setVariable(
"MANUAL_EDITING", $this->lng->txt(
'manual_editing'));
219 $tpl->setVariable(
"CORRECT_ANSWER_TXT", $this->lng->txt(
'correct_answers'));
220 $tpl->setVariable(
"ANSWER_OPTIONS_TXT", $this->lng->txt(
'answer_options'));
221 $tpl->setVariable(
"ANSWERS_TXT", $this->lng->txt(
'answers'));
222 $tpl->setVariable(
"TYPE_TXT", $this->lng->txt(
'type'));
223 $tpl->setVariable(
"EDIT_TXT", $this->lng->txt(
'edit'));
224 $tpl->setVariable(
"ADD_ANSWER_TXT", $this->lng->txt(
'add_answers'));
225 $tpl->setVariable(
'POINTS_ERROR', $this->lng->txt(
'enter_enough_positive_points'));
226 $tpl->setVariable(
'AUTOCOMPLETE_ERROR', $this->lng->txt(
'autocomplete_error'));
227 $tpl->setVariable(
'MISSING_VALUE', $this->lng->txt(
'msg_input_is_required'));
228 $tpl->setVariable(
'SAVE', $this->lng->txt(
'save'));
229 $tpl->setVariable(
'CANCEL', $this->lng->txt(
'cancel'));
230 require_once(
"Services/Form/classes/class.ilTagInputGUI.php");
232 $tag_input->setTypeAhead(
true);
233 $tag_input->setPostVar(
'taggable');
234 $tag_input->setJsSelfInit(
false);
235 $tag_input->setTypeAheadMinLength(1);
236 $tpl->setVariable(
"TAGGING_PROTOTYPE", $tag_input->render(
''));
238 $tpl->setVariable(
"MY_MODAL", $modal->getHTML());
240 $tpl->parseCurrentBlock();
242 $button->setHtml(
$tpl->get());
282 $graphicalOutput =
false,
283 $result_output =
false,
284 $show_question_only =
true,
285 $show_feedback =
false,
286 $show_correct_solution =
false,
287 $show_manual_scoring =
false,
288 $show_question_text =
true 290 include_once
"./Services/UICore/classes/class.ilTemplate.php";
291 $template =
new ilTemplate(
"tpl.il_as_qpl_lome_question_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
293 if ($show_question_text) {
294 $question_text = $this->
object->getQuestion();
295 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($question_text,
true));
297 if (($active_id > 0) && (!$show_correct_solution)) {
300 $correct_solution = $this->
object->getCorrectAnswersForQuestionSolution($this->object->getId());
303 $solution_template =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
304 $question_output = $template->get();
306 if ($show_feedback) {
309 $feedback .= strlen($fb) ? $fb :
'';
313 $feedback .= strlen($fb) ? $fb :
'';
315 if (strlen($feedback)) {
321 $solution_template->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
322 $solution_template->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
325 $solution_template->setVariable(
"SOLUTION_OUTPUT", $question_output);
327 $solution_output = $solution_template->get();
329 if (!$show_question_only) {
330 $solution_output = $this->
getILIASPage($solution_output);
333 return $solution_output;
336 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
339 $user_solution = array_values($user_solution);
341 include_once
"./Services/UICore/classes/class.ilTemplate.php";
342 $template =
new ilTemplate(
"tpl.il_as_qpl_longmenu_output.html",
true,
true,
"Modules/TestQuestionPool");
344 $question_text = $this->
object->getQuestion();
345 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($question_text,
true));
346 $template->setVariable(
"ANSWER_OPTIONS_JSON", json_encode($this->object->getAvailableAnswerOptions()));
347 $template->setVariable(
'AUTOCOMPLETE_LENGTH', $this->object->getMinAutoComplete());
350 $question_output = $template->get();
351 if (!$show_question_only) {
352 $question_output = $this->
getILIASPage($question_output);
354 return $question_output;
364 $is_postponed =
false,
365 $use_post_solutions =
false,
366 $show_feedback =
false 368 $user_solution = array();
371 include_once
"./Modules/Test/classes/class.ilObjTest.php";
373 if (is_null(
$pass)) {
377 $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id,
$pass);
378 foreach ($solutions as $idx => $solution_value) {
379 $user_solution[$solution_value[
"value1"]] = $solution_value[
"value2"];
384 include_once
"./Services/UICore/classes/class.ilTemplate.php";
385 $template =
new ilTemplate(
"tpl.il_as_qpl_longmenu_output.html",
true,
true,
"Modules/TestQuestionPool");
387 $question_text = $this->
object->getQuestion();
388 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($question_text,
true));
389 $template->setVariable(
"ANSWER_OPTIONS_JSON", json_encode($this->object->getAvailableAnswerOptions()));
391 $template->setVariable(
'AUTOCOMPLETE_LENGTH', $this->object->getMinAutoComplete());
392 $question_output = $template->get();
393 $page_output = $this->
outQuestionPage(
"", $is_postponed, $active_id, $question_output);
405 $this->ilTabs->clearTargets();
407 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
408 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
409 $q_type = $this->
object->getQuestionType();
411 if (strlen($q_type)) {
412 $classname = $q_type .
"GUI";
413 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
414 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
418 if ($this->rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
420 $this->ilTabs->addTarget(
422 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
423 array(
"edit",
"insert",
"exec_pg"),
433 $force_active =
false;
434 if ($this->rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
437 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
439 $commands =
$_POST[
"cmd"];
440 if (is_array($commands)) {
441 foreach ($commands as $key => $value) {
442 if (preg_match(
"/^delete_.*/", $key, $matches)) {
443 $force_active =
true;
448 $this->ilTabs->addTarget(
451 array(
"editQuestion",
"save",
"saveEdit",
"addkvp",
"removekvp",
"originalSyncForm"),
469 $this->ilTabs->addTarget(
471 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
483 if (!$this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0, 0)) {
487 $feedback =
'<table class="test_specific_feedback"><tbody>';
488 $gaps = $this->
object->getCorrectAnswers();
489 foreach ($gaps as
$index => $answer) {
491 $caption .=
$index + 1 .
': ';
493 $feedback .=
'<tr><td>';
495 $feedback .= $caption .
'</td><td>';
496 $feedback .= $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
497 $this->object->getId(),
502 $feedback .=
'</tbody></table>';
503 return $this->
object->prepareTextareaOutput($feedback,
true);
532 $aggregation = array();
533 foreach ($relevant_answers as $answer) {
534 $overview[$answer[
'active_fi']][$answer[
'pass']][$answer[
'value1']] = $answer[
'value2'];
537 foreach ($overview as $active) {
538 foreach ($active as $answer) {
539 foreach ($answer as $option => $value) {
540 $aggregation[$option][$value] = $aggregation[$option][$value] + 1;
544 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_long_menu_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
545 $json = json_decode($this->object->getJsonStructure());
546 foreach ($json as $key => $value) {
547 $tpl->setVariable(
'TITLE',
'Longmenu ' . ($key + 1));
548 if (array_key_exists($key, $aggregation)) {
549 $aggregate = $aggregation[$key];
550 foreach ($aggregate as $answer => $counts) {
551 $tpl->setVariable(
'OPTION', $answer);
552 $tpl->setVariable(
'COUNT', $counts);
553 $tpl->parseCurrentBlock();
565 $correct_answers = $this->
object->getCorrectAnswers();
566 $answers = $this->
object->getAnswers();
567 foreach ($text_array as $key => $value) {
568 $answer_is_correct =
false;
570 $return_value .= $value;
571 if ($key <
sizeof($text_array) - 1) {
573 if (array_key_exists($key, $user_solution)) {
574 $user_value = $user_solution[$key];
575 if (in_array($user_value, $correct_answers[$key][0])) {
576 $answer_is_correct =
true;
580 $return_value .= $this->
getTextGapTemplate($key, $user_value, $solution, $answer_is_correct, $graphical);
582 if (array_key_exists($key, $user_solution)) {
583 $user_value = $user_solution[$key];
584 if (in_array($user_value, $correct_answers[$key][0])) {
585 $answer_is_correct =
true;
588 $return_value .= $this->
getSelectGapTemplate($key, $answers[$key], $user_value, $solution, $answer_is_correct, $graphical);
592 return $return_value;
597 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_text_gap.html",
true,
true,
"Modules/TestQuestionPool");
599 $tpl->setVariable(
'DISABLED',
'disabled');
600 $tpl->setVariable(
'JS_IGNORE',
'_ignore');
604 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
607 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_wrong"));
611 $tpl->setVariable(
'VALUE', $value);
612 $tpl->setVariable(
'KEY', $key);
619 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_select_gap.html",
true,
true,
"Modules/TestQuestionPool");
620 $tpl->setVariable(
'KEY', $key);
622 $tpl->setVariable(
'DISABLED',
'disabled');
623 $tpl->setVariable(
'JS_IGNORE',
'_ignore');
624 $tpl->setCurrentBlock(
'best_solution');
625 if ($user_value == -1) {
626 $tpl->setVariable(
"SOLUTION", $this->lng->txt(
"please_select"));
628 $tpl->setVariable(
'SOLUTION', $user_value);
633 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
636 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_wrong"));
639 $tpl->parseCurrentBlock();
641 $tpl->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
642 foreach ($answers as $value) {
643 $tpl->setCurrentBlock(
'select_option');
644 $tpl->setVariable(
'VALUE', $value);
645 if ($value == $user_value) {
646 $tpl->setVariable(
'SELECTED',
'selected');
648 $tpl->parseCurrentBlock();
656 return array_keys($this->object->getAnswers());
663 foreach ($relevant_answers as $row) {
664 if ($row[
'value1'] != $questionIndex) {
668 if (!isset($answers[$row[
'value2']])) {
671 $answers[$row[
'value2']] = array(
672 'answer' => $row[
'value2'],
'frequency' => 0
676 $answers[$row[
'value2']][
'frequency']++;
686 $table = parent::getAnswerFrequencyTableGUI(
693 $table->setTitle(sprintf(
694 $DIC->language()->txt(
'tst_corrections_answers_tbl_subindex'),
695 $DIC->language()->txt(
'longmenu') .
' ' . ($questionIndex + 1)
703 $correctAnswers = $this->
object->getCorrectAnswers();
705 foreach ($this->object->getAnswers() as $lmIndex => $lm) {
707 'answers_all' => array(0 => $lm),
708 'answers_all_count' => count($lm),
709 'answers_correct' => $correctAnswers[$lmIndex][0]
712 $lmPoints = $correctAnswers[$lmIndex][1];
715 $section->setTitle($this->lng->txt(
'longmenu') .
' ' . ($lmIndex + 1));
719 $this->lng->txt(
'answers'),
720 'longmenu_' . $lmIndex
725 $lmInput->setValues($lmValues);
729 $pointsInp =
new ilNumberInputGUI($this->lng->txt(
"points"),
'points_' . $lmIndex);
731 $pointsInp->allowDecimals(
true);
732 $pointsInp->setSize(4);
733 $pointsInp->setMinValue(0);
734 $pointsInp->setMinvalueShouldBeGreater(
false);
735 $pointsInp->setValue($lmPoints);
745 $correctAnswers = $this->
object->getCorrectAnswers();
747 foreach ($this->object->getAnswers() as $lmIndex => $lm) {
748 $pointsInput = (float) $form->
getInput(
'points_' . $lmIndex);
749 $correctAnswersInput = (array) $form->
getInput(
'longmenu_' . $lmIndex .
'_tags');
751 foreach ($correctAnswersInput as $idx => $answer) {
752 if (in_array($answer, $lm)) {
756 unset($correctAnswersInput[$idx]);
759 $correctAnswersInput = array_values($correctAnswersInput);
761 $correctAnswers[$lmIndex][0] = $correctAnswersInput;
762 $correctAnswers[$lmIndex][1] = $pointsInput;
765 $this->
object->setCorrectAnswers($correctAnswers);
isTestPresentationContext()
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
buildBasicEditFormObject()
static _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
populateTaxonomyFormSection(ilPropertyFormGUI $form)
getUseIntermediateSolution()
Get if intermediate solution should be used for solution output.
writeQuestionGenericPostData()
getILIASPage($html="")
Returns the ILIAS Page around a question.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
const CSS_CLASS_FEEDBACK_WRONG
Basic GUI class for assessment questions.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT
constant for additional content editing mode "default"
static getInstance()
Get instance.
saveTaxonomyAssignments()
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
output question page
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
addBackTab(ilTabsGUI $ilTabs)
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Interface ilGuiQuestionScoringAdjustable.
static _getUsePreviousAnswers($active_id, $user_active_user_setting=false)
Returns if the previous results should be hidden for a learner.
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.