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';
22 parent::__construct();
23 include_once
'./Modules/TestQuestionPool/classes/class.assLongMenu.php';
27 $this->
object->loadFromDb($id);
42 $user_solution = array();
47 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 48 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 50 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 54 foreach($solutions as $idx => $solution_value)
56 $user_solution[$solution_value[
"value1"]] = $solution_value[
"value2"];
58 return $user_solution;
60 return $user_solution;
79 $form->setValuesByPost();
82 $custom_check = $this->
object->checkQuestionCustomPart();
83 if( !$form->checkInput() || !$custom_check)
102 $this->
object->setQuestion(
$_POST[
'question']);
103 $this->
object->setLongMenuTextValue(
$_POST[
"longmenu_text"]);
104 $this->
object->setMinAutoComplete((
int)
$_POST[
"min_auto_complete"]);
116 $this->tpl->addCss(
'Modules/Test/templates/default/ta.css');
118 $this->tpl->setVariable(
"QUESTION_DATA", $this->ctrl->getHTML($form));
144 $long_menu_text =
new ilTextAreaInputGUI($this->lng->txt(
"longmenu_text"),
'longmenu_text');
147 $long_menu_text->setRows( 10 );
148 $long_menu_text->setCols( 80 );
149 if (!$this->object->getSelfAssessmentEditingMode())
153 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
155 $long_menu_text->addPlugin(
"latex");
156 $long_menu_text->addButton(
"latex");
157 $long_menu_text->addButton(
"pastelatex");
158 $long_menu_text->setRTESupport($this->object->getId(),
"qpl",
"assessment");
159 $long_menu_text->setUseRte(TRUE);
164 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
166 $long_menu_text->setUseTagsForRteOnly(
false);
169 $long_menu_text->setValue($this->object->prepareTextareaOutput($this->object->getLongMenuTextValue()));
170 $form->
addItem($long_menu_text);
172 $tpl =
new ilTemplate(
"tpl.il_as_qpl_cloze_gap_button_code.html", TRUE, TRUE,
"Modules/TestQuestionPool");
173 $tpl->setVariable(
'INSERT_GAP', $this->lng->txt(
'insert_gap'));
174 $tpl->parseCurrentBlock();
176 $button->setHtml(
$tpl->get());
179 require_once(
"./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
181 $modal->setHeading(
'');
182 $modal->setId(
"ilGapModal");
186 $min_auto_complete =
new ilNumberInputGUI($this->lng->txt(
"min_auto_complete"),
'min_auto_complete');
188 $auto_complete = $this->
object->getMinAutoComplete();
189 if($auto_complete == 0)
193 $min_auto_complete->setValue($auto_complete);
194 $min_auto_complete->setMinValue(1);
195 $min_auto_complete->setMaxValue(99);
196 $min_auto_complete->setSize(5);
197 $form->
addItem($min_auto_complete);
203 $form->
addItem($hidden_correct);
205 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_gap.html", TRUE, TRUE,
"Modules/TestQuestionPool");
206 if(is_array(
$_POST) && array_key_exists(
'hidden_text_files',
$_POST))
208 $tpl->setVariable(
'CORRECT_ANSWERS',
$_POST[
'hidden_correct_answers']);
209 $tpl->setVariable(
'ALL_ANSWERS',
$_POST[
'hidden_text_files']);
213 $tpl->setVariable(
'CORRECT_ANSWERS', $this->object->getJsonStructure());
214 $tpl->setVariable(
'ALL_ANSWERS', $this->object->getAnswersObject());
218 $tpl->setVariable(
'SELECT_BOX', $this->lng->txt(
'insert_gap'));
219 $tpl->setVariable(
"SELECT", $this->lng->txt(
'answers_select'));
220 $tpl->setVariable(
"TEXT", $this->lng->txt(
'answers_text_box'));
221 $tpl->setVariable(
"POINTS", $this->lng->txt(
'points'));
222 $tpl->setVariable(
"INFO_TEXT_UPLOAD", $this->lng->txt(
'info_text_upload'));
223 $tpl->setVariable(
"MANUAL_EDITING", $this->lng->txt(
'manual_editing'));
224 $tpl->setVariable(
"CORRECT_ANSWER_TXT", $this->lng->txt(
'correct_answers'));
225 $tpl->setVariable(
"ANSWER_OPTIONS_TXT", $this->lng->txt(
'answer_options'));
226 $tpl->setVariable(
"ANSWERS_TXT", $this->lng->txt(
'answers'));
227 $tpl->setVariable(
"TYPE_TXT", $this->lng->txt(
'type'));
228 $tpl->setVariable(
"EDIT_TXT", $this->lng->txt(
'edit'));
229 $tpl->setVariable(
"ADD_ANSWER_TXT", $this->lng->txt(
'add_answers'));
230 $tpl->setVariable(
'POINTS_ERROR', $this->lng->txt(
'enter_enough_positive_points'));
231 $tpl->setVariable(
'AUTOCOMPLETE_ERROR', $this->lng->txt(
'autocomplete_error'));
232 $tpl->setVariable(
'MISSING_VALUE', $this->lng->txt(
'msg_input_is_required'));
233 $tpl->setVariable(
'SAVE', $this->lng->txt(
'save'));
234 $tpl->setVariable(
'CANCEL', $this->lng->txt(
'cancel'));
235 require_once(
"Services/Form/classes/class.ilTagInputGUI.php");
237 $tag_input->setTypeAhead(
true);
238 $tag_input->setPostVar(
'taggable');
239 $tag_input->setJsSelfInit(
false);
240 $tag_input->setTypeAheadMinLength(1);
241 $tpl->setVariable(
"TAGGING_PROTOTYPE", $tag_input->render(
''));
243 $tpl->setVariable(
"MY_MODAL", $modal->getHTML());
245 $tpl->parseCurrentBlock();
247 $button->setHtml(
$tpl->get());
277 $graphicalOutput = FALSE,
278 $result_output = FALSE,
279 $show_question_only = TRUE,
280 $show_feedback = FALSE,
281 $show_correct_solution = FALSE,
282 $show_manual_scoring = FALSE,
283 $show_question_text = TRUE
286 include_once
"./Services/UICore/classes/class.ilTemplate.php";
287 $template =
new ilTemplate(
"tpl.il_as_qpl_lome_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
289 if($show_question_text)
291 $question_text = $this->
object->getQuestion();
292 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($question_text, TRUE));
294 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();
311 $feedback .= strlen($fb) ? $fb :
'';
315 $feedback .= strlen($fb) ? $fb :
'';
317 if (strlen($feedback))
323 $solution_template->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
324 $solution_template->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
327 $solution_template->setVariable(
"SOLUTION_OUTPUT", $question_output);
329 $solution_output = $solution_template->get();
331 if (!$show_question_only)
333 $solution_output = $this->
getILIASPage($solution_output);
336 return $solution_output;
339 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
342 $user_solution = array_values($user_solution);
344 include_once
"./Services/UICore/classes/class.ilTemplate.php";
345 $template =
new ilTemplate(
"tpl.il_as_qpl_longmenu_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
347 $question_text = $this->
object->getQuestion();
348 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($question_text, TRUE));
349 $template->setVariable(
"ANSWER_OPTIONS_JSON", json_encode($this->object->getAvailableAnswerOptions()));
350 $template->setVariable(
'AUTOCOMPLETE_LENGTH',$this->object->getMinAutoComplete());
353 $question_output = $template->get();
354 if (!$show_question_only)
356 $question_output = $this->
getILIASPage($question_output);
358 return $question_output;
367 $is_postponed = FALSE,
368 $use_post_solutions = FALSE,
369 $show_feedback = FALSE
372 $user_solution = array();
376 include_once
"./Modules/Test/classes/class.ilObjTest.php";
381 $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id,
$pass);
382 foreach ($solutions as $idx => $solution_value)
384 $user_solution[$solution_value[
"value1"]] = $solution_value[
"value2"];
388 include_once
"./Services/UICore/classes/class.ilTemplate.php";
389 $template =
new ilTemplate(
"tpl.il_as_qpl_longmenu_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
391 $question_text = $this->
object->getQuestion();
392 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($question_text, TRUE));
393 $template->setVariable(
"ANSWER_OPTIONS_JSON", json_encode($this->object->getAvailableAnswerOptions()));
395 $template->setVariable(
'AUTOCOMPLETE_LENGTH',$this->object->getMinAutoComplete());
396 $question_output = $template->get();
397 $page_output = $this->
outQuestionPage(
"", $is_postponed, $active_id, $question_output);
409 $this->ilTabs->clearTargets();
411 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
412 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
413 $q_type = $this->
object->getQuestionType();
417 $classname = $q_type .
"GUI";
418 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
419 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
424 if ($this->rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
427 $this->ilTabs->addTarget(
"edit_page",
428 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
429 array(
"edit",
"insert",
"exec_pg"),
430 "",
"", $force_active);
436 $force_active =
false;
437 if ($this->rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
440 if ($classname)
$url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
441 $commands =
$_POST[
"cmd"];
442 if (is_array($commands))
444 foreach ($commands as $key => $value)
446 if (preg_match(
"/^delete_.*/", $key, $matches))
448 $force_active =
true;
453 $this->ilTabs->addTarget(
"edit_question",
455 array(
"editQuestion",
"save",
"saveEdit",
"addkvp",
"removekvp",
"originalSyncForm"),
456 $classname,
"", $force_active);
471 $this->ilTabs->addTarget(
"statistics",
472 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
482 if( !$this->object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0) )
487 $feedback =
'<table class="test_specific_feedback"><tbody>';
488 $gaps = $this->
object->getCorrectAnswers();
489 foreach ($gaps as $index => $answer)
492 $caption .= $index + 1 .
': ';
494 $feedback .=
'<tr><td>';
496 $feedback .= $caption .
'</td><td>';
497 $feedback .= $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
498 $this->object->getId(), $index
501 $feedback .=
'</tbody></table>';
502 return $this->
object->prepareTextareaOutput($feedback, TRUE);
531 $aggregation = array();
532 foreach ($relevant_answers as $answer)
534 $overview[$answer[
'active_fi']][$answer[
'pass']][$answer[
'value1']] = $answer[
'value2'];
537 foreach($overview as $active)
539 foreach ($active as $answer)
541 foreach ($answer as $option => $value)
543 $aggregation[$option][$value] = $aggregation[$option][$value] + 1;
547 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_long_menu_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
548 $json = json_decode($this->object->getJsonStructure());
549 foreach ($json as $key => $value)
551 $tpl->setVariable(
'TITLE',
'Longmenu '. ($key+1));
552 if(array_key_exists($key, $aggregation))
554 $aggregate = $aggregation[$key];
555 foreach($aggregate as $answer => $counts)
557 $tpl->setVariable(
'OPTION',$answer);
558 $tpl->setVariable(
'COUNT',$counts);
559 $tpl->parseCurrentBlock();
571 $correct_answers = $this->
object->getCorrectAnswers();
572 $answers = $this->
object->getAnswers();
573 foreach($text_array as $key => $value)
575 $answer_is_correct =
false;
577 $return_value .= $value;
578 if($key <
sizeof($text_array) - 1 )
582 if(array_key_exists($key,$user_solution))
584 $user_value = $user_solution[$key];
585 if(in_array($user_value, $correct_answers[$key][0]))
587 $answer_is_correct =
true;
591 $return_value .= $this->
getTextGapTemplate($key, $user_value, $solution, $answer_is_correct, $graphical);
595 if(array_key_exists($key,$user_solution))
597 $user_value = $user_solution[$key];
598 if(in_array($user_value, $correct_answers[$key][0]))
600 $answer_is_correct =
true;
603 $return_value .= $this->
getSelectGapTemplate($key, $answers[$key], $user_value, $solution, $answer_is_correct, $graphical);
607 return $return_value;
612 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_text_gap.html", TRUE, TRUE,
"Modules/TestQuestionPool");
615 $tpl->setVariable(
'DISABLED',
'disabled');
616 $tpl->setVariable(
'JS_IGNORE',
'_ignore');
622 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
627 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_wrong"));
631 $tpl->setVariable(
'VALUE', $value);
632 $tpl->setVariable(
'KEY', $key);
639 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_select_gap.html", TRUE, TRUE,
"Modules/TestQuestionPool");
640 $tpl->setVariable(
'KEY', $key);
643 $tpl->setVariable(
'DISABLED',
'disabled');
644 $tpl->setVariable(
'JS_IGNORE',
'_ignore');
645 $tpl->setCurrentBlock(
'best_solution');
646 if($user_value == -1)
648 $tpl->setVariable(
"SOLUTION", $this->lng->txt(
"please_select"));
652 $tpl->setVariable(
'SOLUTION', $user_value);
659 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
664 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_wrong"));
667 $tpl->parseCurrentBlock();
671 $tpl->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
672 foreach($answers as $value)
674 $tpl->setCurrentBlock(
'select_option');
675 $tpl->setVariable(
'VALUE', $value);
676 if($value == $user_value)
678 $tpl->setVariable(
'SELECTED',
'selected');
680 $tpl->parseCurrentBlock();
isTestPresentationContext()
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
buildBasicEditFormObject()
getTestOutputSolutions($activeId, $pass)
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
populateTaxonomyFormSection(ilPropertyFormGUI $form)
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)
special template class to simplify handling of ITX/PEAR
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.
_getUsePreviousAnswers($active_id, $user_active_user_setting=false)
Returns if the previous results should be hidden for a learner.
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()
& _getUsedHTMLTags($a_module="")
Returns an array of all allowed HTML tags for text editing.
This class represents a text area property in a property form.
addBackTab(ilTabsGUI $ilTabs)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Interface ilGuiQuestionScoringAdjustable.
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.