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); 52 $solutions = $this->
object->getTestOutputSolutions($active_id,
$pass);
54 foreach($solutions as $idx => $solution_value)
56 $user_solution[$solution_value[
"value1"]] = $solution_value[
"value2"];
58 return $user_solution;
60 return $user_solution;
74 $form->setValuesByPost();
77 $custom_check = $this->
object->checkQuestionCustomPart();
78 if( !$form->checkInput() || !$custom_check)
97 $this->
object->setQuestion(
$_POST[
'question']);
98 $this->
object->setLongMenuTextValue(
$_POST[
"longmenu_text"]);
99 $this->
object->setMinAutoComplete((
int)
$_POST[
"min_auto_complete"]);
111 $this->tpl->addCss(
'Modules/Test/templates/default/ta.css');
113 $this->tpl->setVariable(
"QUESTION_DATA", $this->ctrl->getHTML($form));
139 $long_menu_text =
new ilTextAreaInputGUI($this->lng->txt(
"longmenu_text"),
'longmenu_text');
142 $long_menu_text->setRows( 10 );
143 $long_menu_text->setCols( 80 );
144 if (!$this->
object->getSelfAssessmentEditingMode())
148 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
150 $long_menu_text->addPlugin(
"latex");
151 $long_menu_text->addButton(
"latex");
152 $long_menu_text->addButton(
"pastelatex");
153 $long_menu_text->setRTESupport($this->
object->getId(),
"qpl",
"assessment");
154 $long_menu_text->setUseRte(TRUE);
159 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
161 $long_menu_text->setUseTagsForRteOnly(
false);
164 $long_menu_text->setValue($this->
object->prepareTextareaOutput($this->object->getLongMenuTextValue()));
165 $form->
addItem($long_menu_text);
167 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_gap_button_code.html", TRUE, TRUE,
"Modules/TestQuestionPool");
168 $tpl->setVariable(
'INSERT_GAP', $this->lng->txt(
'insert_gap'));
169 $tpl->parseCurrentBlock();
171 $button->setHtml(
$tpl->get());
174 require_once(
"./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
176 $modal->setHeading(
'');
177 $modal->setId(
"ilGapModal");
181 $min_auto_complete =
new ilNumberInputGUI($this->lng->txt(
"min_auto_complete"),
'min_auto_complete');
183 $auto_complete = $this->
object->getMinAutoComplete();
184 if($auto_complete == 0)
188 $min_auto_complete->setValue($auto_complete);
189 $min_auto_complete->setMinValue(1);
190 $min_auto_complete->setMaxValue(99);
191 $min_auto_complete->setSize(5);
192 $form->
addItem($min_auto_complete);
198 $form->
addItem($hidden_correct);
200 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_gap.html", TRUE, TRUE,
"Modules/TestQuestionPool");
201 if(is_array(
$_POST) && array_key_exists(
'hidden_text_files',
$_POST))
203 $tpl->setVariable(
'CORRECT_ANSWERS',
$_POST[
'hidden_correct_answers']);
204 $tpl->setVariable(
'ALL_ANSWERS',
$_POST[
'hidden_text_files']);
208 $tpl->setVariable(
'CORRECT_ANSWERS', $this->
object->getJsonStructure());
209 $tpl->setVariable(
'ALL_ANSWERS', $this->
object->getAnswersObject());
213 $tpl->setVariable(
'SELECT_BOX', $this->lng->txt(
'insert_gap'));
214 $tpl->setVariable(
"SELECT", $this->lng->txt(
'answers_select'));
215 $tpl->setVariable(
"TEXT", $this->lng->txt(
'answers_text_box'));
216 $tpl->setVariable(
"POINTS", $this->lng->txt(
'points'));
217 $tpl->setVariable(
"INFO_TEXT_UPLOAD", $this->lng->txt(
'info_text_upload'));
218 $tpl->setVariable(
"TXT_BROWSE", $this->lng->txt(
'select_file'));
219 $tpl->setVariable(
"MANUAL_EDITING", $this->lng->txt(
'manual_editing'));
220 $tpl->setVariable(
"CORRECT_ANSWER_TXT", $this->lng->txt(
'correct_answers'));
221 $tpl->setVariable(
"ANSWER_OPTIONS_TXT", $this->lng->txt(
'answer_options'));
222 $tpl->setVariable(
"ANSWERS_TXT", $this->lng->txt(
'answers'));
223 $tpl->setVariable(
"TYPE_TXT", $this->lng->txt(
'type'));
224 $tpl->setVariable(
"EDIT_TXT", $this->lng->txt(
'edit'));
225 $tpl->setVariable(
"ADD_ANSWER_TXT", $this->lng->txt(
'add_answers'));
226 $tpl->setVariable(
'POINTS_ERROR', $this->lng->txt(
'enter_enough_positive_points'));
227 $tpl->setVariable(
'AUTOCOMPLETE_ERROR', $this->lng->txt(
'autocomplete_error'));
228 $tpl->setVariable(
'MISSING_VALUE', $this->lng->txt(
'msg_input_is_required'));
229 $tpl->setVariable(
'SAVE', $this->lng->txt(
'save'));
230 $tpl->setVariable(
'CANCEL', $this->lng->txt(
'cancel'));
231 require_once(
"Services/Form/classes/class.ilTagInputGUI.php");
233 $tag_input->setTypeAhead(
true);
234 $tag_input->setPostVar(
'taggable');
235 $tag_input->setJsSelfInit(
false);
236 $tag_input->setTypeAheadMinLength(1);
237 $tpl->setVariable(
"TAGGING_PROTOTYPE", $tag_input->render(
''));
239 $tpl->setVariable(
"MY_MODAL", $modal->getHTML());
241 $tpl->parseCurrentBlock();
243 $button->setHtml(
$tpl->get());
273 $graphicalOutput = FALSE,
274 $result_output = FALSE,
275 $show_question_only = TRUE,
276 $show_feedback = FALSE,
277 $show_correct_solution = FALSE,
278 $show_manual_scoring = FALSE,
279 $show_question_text = TRUE
282 include_once
"./Services/UICore/classes/class.ilTemplate.php";
283 $template =
new ilTemplate(
"tpl.il_as_qpl_lome_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
285 if($show_question_text)
287 $question_text = $this->
object->getQuestion();
288 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($question_text, TRUE));
290 if (($active_id > 0) && (!$show_correct_solution))
296 $correct_solution = $this->
object->getCorrectAnswersForQuestionSolution($this->
object->getId());
299 $solution_template =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
300 $question_output = $template->get();
307 $feedback .= strlen($fb) ? $fb :
'';
311 $feedback .= strlen($fb) ? $fb :
'';
313 if (strlen($feedback))
319 $solution_template->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
320 $solution_template->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput( $feedback,
true ));
323 $solution_template->setVariable(
"SOLUTION_OUTPUT", $question_output);
325 $solution_output = $solution_template->get();
327 if (!$show_question_only)
329 $solution_output = $this->
getILIASPage($solution_output);
332 return $solution_output;
335 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
338 $user_solution = array_values($user_solution);
340 include_once
"./Services/UICore/classes/class.ilTemplate.php";
341 $template =
new ilTemplate(
"tpl.il_as_qpl_longmenu_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
343 $question_text = $this->
object->getQuestion();
344 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($question_text, TRUE));
345 $template->setVariable(
"ANSWER_OPTIONS_JSON", json_encode($this->
object->getAvailableAnswerOptions()));
346 $template->setVariable(
'AUTOCOMPLETE_LENGTH',$this->
object->getMinAutoComplete());
349 $question_output = $template->get();
350 if (!$show_question_only)
352 $question_output = $this->
getILIASPage($question_output);
354 return $question_output;
363 $is_postponed = FALSE,
364 $use_post_solutions = FALSE,
365 $show_feedback = FALSE
368 $user_solution =
array();
372 include_once
"./Modules/Test/classes/class.ilObjTest.php";
377 $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id,
$pass);
378 foreach ($solutions as $idx => $solution_value)
380 $user_solution[$solution_value[
"value1"]] = $solution_value[
"value2"];
385 include_once
"./Services/UICore/classes/class.ilTemplate.php";
386 $template =
new ilTemplate(
"tpl.il_as_qpl_longmenu_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
388 $question_text = $this->
object->getQuestion();
389 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($question_text, TRUE));
390 $template->setVariable(
"ANSWER_OPTIONS_JSON", json_encode($this->
object->getAvailableAnswerOptions()));
392 $template->setVariable(
'AUTOCOMPLETE_LENGTH',$this->
object->getMinAutoComplete());
393 $question_output = $template->get();
394 $page_output = $this->
outQuestionPage(
"", $is_postponed, $active_id, $question_output);
406 $this->ilTabs->clearTargets();
408 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
409 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
410 $q_type = $this->
object->getQuestionType();
414 $classname = $q_type .
"GUI";
415 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
416 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
421 if ($this->rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
424 $this->ilTabs->addTarget(
"edit_page",
425 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
426 array(
"edit",
"insert",
"exec_pg"),
427 "",
"", $force_active);
433 $force_active =
false;
434 if ($this->rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
437 if ($classname)
$url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
438 $commands =
$_POST[
"cmd"];
439 if (is_array($commands))
441 foreach ($commands as $key => $value)
443 if (preg_match(
"/^delete_.*/", $key, $matches))
445 $force_active =
true;
450 $this->ilTabs->addTarget(
"edit_question",
452 array(
"editQuestion",
"save",
"saveEdit",
"addkvp",
"removekvp",
"originalSyncForm"),
453 $classname,
"", $force_active);
468 $this->ilTabs->addTarget(
"statistics",
469 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
479 if( !$this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0) )
484 $feedback =
'<table class="test_specific_feedback"><tbody>';
485 $gaps = $this->
object->getCorrectAnswers();
486 foreach ($gaps as $index => $answer)
489 $caption .= $index + 1 .
': ';
491 $feedback .=
'<tr><td>';
493 $feedback .= $caption .
'</td><td>';
494 $feedback .= $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
495 $this->
object->getId(), $index
498 $feedback .=
'</tbody></table>';
499 return $this->
object->prepareTextareaOutput($feedback, TRUE);
528 $aggregation =
array();
529 foreach ($relevant_answers as $answer)
531 $overview[$answer[
'active_fi']][$answer[
'pass']][$answer[
'value1']] = $answer[
'value2'];
534 foreach($overview as $active)
536 foreach ($active as $answer)
538 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)
548 $tpl->setVariable(
'TITLE',
'Longmenu '. ($key+1));
549 if(array_key_exists($key, $aggregation))
551 $aggregate = $aggregation[$key];
552 foreach($aggregate as $answer => $counts)
554 $tpl->setVariable(
'OPTION',$answer);
555 $tpl->setVariable(
'COUNT',$counts);
556 $tpl->parseCurrentBlock();
568 $correct_answers = $this->
object->getCorrectAnswers();
569 $answers = $this->
object->getAnswers();
570 foreach($text_array as $key => $value)
572 $answer_is_correct =
false;
574 $return_value .= $value;
575 if($key <
sizeof($text_array) - 1 )
579 if(array_key_exists($key,$user_solution))
581 $user_value = $user_solution[$key];
582 if(in_array($user_value, $correct_answers[$key][0]))
584 $answer_is_correct =
true;
588 $return_value .= $this->
getTextGapTemplate($key, $user_value, $solution, $answer_is_correct, $graphical);
592 if(array_key_exists($key,$user_solution))
594 $user_value = $user_solution[$key];
595 if(in_array($user_value, $correct_answers[$key][0]))
597 $answer_is_correct =
true;
600 $return_value .= $this->
getSelectGapTemplate($key, $answers[$key], $user_value, $solution, $answer_is_correct, $graphical);
604 return $return_value;
609 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_text_gap.html", TRUE, TRUE,
"Modules/TestQuestionPool");
612 $tpl->setVariable(
'DISABLED',
'disabled');
613 $tpl->setVariable(
'JS_IGNORE',
'_ignore');
619 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
624 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_wrong"));
628 $tpl->setVariable(
'VALUE', $value);
629 $tpl->setVariable(
'KEY', $key);
636 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_select_gap.html", TRUE, TRUE,
"Modules/TestQuestionPool");
637 $tpl->setVariable(
'KEY', $key);
640 $tpl->setVariable(
'DISABLED',
'disabled');
641 $tpl->setVariable(
'JS_IGNORE',
'_ignore');
642 $tpl->setCurrentBlock(
'best_solution');
643 if($user_value == -1)
645 $tpl->setVariable(
"SOLUTION", $this->lng->txt(
"please_select"));
649 $tpl->setVariable(
'SOLUTION', $user_value);
656 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
661 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_wrong"));
664 $tpl->parseCurrentBlock();
668 $tpl->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
669 foreach($answers as $value)
671 $tpl->setCurrentBlock(
'select_option');
672 $tpl->setVariable(
'VALUE', $value);
673 if($value == $user_value)
675 $tpl->setVariable(
'SELECTED',
'selected');
677 $tpl->parseCurrentBlock();
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)
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.
Create styles array
The data for the language used.
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()
Create new PHPExcel object
obj_idprivate
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.
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.