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';
23 parent::__construct();
24 include_once
'./Modules/TestQuestionPool/classes/class.assLongMenu.php';
27 $this->
object->loadFromDb(
$id);
42 $user_solution =
array();
46 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 47 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 49 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 51 $solutions = $this->
object->getTestOutputSolutions($active_id,
$pass);
53 foreach ($solutions as $idx => $solution_value) {
54 $user_solution[$solution_value[
"value1"]] = $solution_value[
"value2"];
56 return $user_solution;
58 return $user_solution;
72 $form->setValuesByPost();
75 $custom_check = $this->
object->checkQuestionCustomPart();
76 if (!
$form->checkInput() || !$custom_check) {
93 $this->
object->setQuestion(
$_POST[
'question']);
94 $this->
object->setLongMenuTextValue(
$_POST[
"longmenu_text"]);
95 $this->
object->setMinAutoComplete((
int)
$_POST[
"min_auto_complete"]);
101 if (
$form === null) {
106 $this->tpl->addCss(
'Modules/Test/templates/default/ta.css');
108 $this->tpl->setVariable(
"QUESTION_DATA", $this->ctrl->getHTML(
$form));
134 $long_menu_text =
new ilTextAreaInputGUI($this->lng->txt(
"longmenu_text"),
'longmenu_text');
137 $long_menu_text->setRows(10);
138 $long_menu_text->setCols(80);
139 if (!$this->
object->getSelfAssessmentEditingMode()) {
141 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
143 $long_menu_text->addPlugin(
"latex");
144 $long_menu_text->addButton(
"latex");
145 $long_menu_text->addButton(
"pastelatex");
146 $long_menu_text->setRTESupport($this->
object->getId(),
"qpl",
"assessment");
147 $long_menu_text->setUseRte(
true);
150 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssSelfAssessmentQuestionFormatter.php';
152 $long_menu_text->setUseTagsForRteOnly(
false);
155 $long_menu_text->setValue($this->
object->prepareTextareaOutput($this->object->getLongMenuTextValue()));
156 $form->
addItem($long_menu_text);
158 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_gap_button_code.html",
true,
true,
"Modules/TestQuestionPool");
159 $tpl->setVariable(
'INSERT_GAP', $this->lng->txt(
'insert_gap'));
160 $tpl->parseCurrentBlock();
162 $button->setHtml(
$tpl->get());
165 require_once(
"./Services/UIComponent/Modal/classes/class.ilModalGUI.php");
167 $modal->setHeading(
'');
168 $modal->setId(
"ilGapModal");
172 $min_auto_complete =
new ilNumberInputGUI($this->lng->txt(
"min_auto_complete"),
'min_auto_complete');
174 $auto_complete = $this->
object->getMinAutoComplete();
175 if ($auto_complete == 0) {
178 $min_auto_complete->setValue($auto_complete);
179 $min_auto_complete->setMinValue(1);
180 $min_auto_complete->setMaxValue(99);
181 $min_auto_complete->setSize(5);
182 $form->
addItem($min_auto_complete);
188 $form->
addItem($hidden_correct);
190 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_gap.html",
true,
true,
"Modules/TestQuestionPool");
191 if (is_array(
$_POST) && array_key_exists(
'hidden_text_files',
$_POST)) {
192 $tpl->setVariable(
'CORRECT_ANSWERS',
$_POST[
'hidden_correct_answers']);
193 $tpl->setVariable(
'ALL_ANSWERS',
$_POST[
'hidden_text_files']);
195 $tpl->setVariable(
'CORRECT_ANSWERS', $this->
object->getJsonStructure());
196 $tpl->setVariable(
'ALL_ANSWERS', $this->
object->getAnswersObject());
200 $tpl->setVariable(
'SELECT_BOX', $this->lng->txt(
'insert_gap'));
201 $tpl->setVariable(
"SELECT", $this->lng->txt(
'answers_select'));
202 $tpl->setVariable(
"TEXT", $this->lng->txt(
'answers_text_box'));
203 $tpl->setVariable(
"POINTS", $this->lng->txt(
'points'));
204 $tpl->setVariable(
"INFO_TEXT_UPLOAD", $this->lng->txt(
'info_text_upload'));
205 $tpl->setVariable(
"TXT_BROWSE", $this->lng->txt(
'select_file'));
206 $tpl->setVariable(
"MANUAL_EDITING", $this->lng->txt(
'manual_editing'));
207 $tpl->setVariable(
"CORRECT_ANSWER_TXT", $this->lng->txt(
'correct_answers'));
208 $tpl->setVariable(
"ANSWER_OPTIONS_TXT", $this->lng->txt(
'answer_options'));
209 $tpl->setVariable(
"ANSWERS_TXT", $this->lng->txt(
'answers'));
210 $tpl->setVariable(
"TYPE_TXT", $this->lng->txt(
'type'));
211 $tpl->setVariable(
"EDIT_TXT", $this->lng->txt(
'edit'));
212 $tpl->setVariable(
"ADD_ANSWER_TXT", $this->lng->txt(
'add_answers'));
213 $tpl->setVariable(
'POINTS_ERROR', $this->lng->txt(
'enter_enough_positive_points'));
214 $tpl->setVariable(
'AUTOCOMPLETE_ERROR', $this->lng->txt(
'autocomplete_error'));
215 $tpl->setVariable(
'MISSING_VALUE', $this->lng->txt(
'msg_input_is_required'));
216 $tpl->setVariable(
'SAVE', $this->lng->txt(
'save'));
217 $tpl->setVariable(
'CANCEL', $this->lng->txt(
'cancel'));
218 require_once(
"Services/Form/classes/class.ilTagInputGUI.php");
220 $tag_input->setTypeAhead(
true);
221 $tag_input->setPostVar(
'taggable');
222 $tag_input->setJsSelfInit(
false);
223 $tag_input->setTypeAheadMinLength(1);
224 $tpl->setVariable(
"TAGGING_PROTOTYPE", $tag_input->render(
''));
226 $tpl->setVariable(
"MY_MODAL", $modal->getHTML());
228 $tpl->parseCurrentBlock();
230 $button->setHtml(
$tpl->get());
260 $graphicalOutput =
false,
261 $result_output =
false,
262 $show_question_only =
true,
263 $show_feedback =
false,
264 $show_correct_solution =
false,
265 $show_manual_scoring =
false,
266 $show_question_text =
true 268 include_once
"./Services/UICore/classes/class.ilTemplate.php";
269 $template =
new ilTemplate(
"tpl.il_as_qpl_lome_question_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
271 if ($show_question_text) {
272 $question_text = $this->
object->getQuestion();
273 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($question_text,
true));
275 if (($active_id > 0) && (!$show_correct_solution)) {
278 $correct_solution = $this->
object->getCorrectAnswersForQuestionSolution($this->
object->getId());
281 $solution_template =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
284 if ($show_feedback) {
287 $feedback .= strlen($fb) ? $fb :
'';
291 $feedback .= strlen($fb) ? $fb :
'';
293 if (strlen($feedback)) {
299 $solution_template->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
300 $solution_template->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput($feedback,
true));
303 $solution_template->setVariable(
"SOLUTION_OUTPUT", $question_output);
305 $solution_output = $solution_template->get();
307 if (!$show_question_only) {
308 $solution_output = $this->
getILIASPage($solution_output);
311 return $solution_output;
314 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
317 $user_solution = array_values($user_solution);
319 include_once
"./Services/UICore/classes/class.ilTemplate.php";
320 $template =
new ilTemplate(
"tpl.il_as_qpl_longmenu_output.html",
true,
true,
"Modules/TestQuestionPool");
322 $question_text = $this->
object->getQuestion();
323 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($question_text,
true));
324 $template->setVariable(
"ANSWER_OPTIONS_JSON", json_encode($this->
object->getAvailableAnswerOptions()));
325 $template->setVariable(
'AUTOCOMPLETE_LENGTH', $this->
object->getMinAutoComplete());
329 if (!$show_question_only) {
330 $question_output = $this->
getILIASPage($question_output);
332 return $question_output;
342 $is_postponed =
false,
343 $use_post_solutions =
false,
344 $show_feedback =
false 346 $user_solution =
array();
349 include_once
"./Modules/Test/classes/class.ilObjTest.php";
351 if (is_null(
$pass)) {
355 $solutions = $this->
object->getUserSolutionPreferingIntermediate($active_id,
$pass);
356 foreach ($solutions as $idx => $solution_value) {
357 $user_solution[$solution_value[
"value1"]] = $solution_value[
"value2"];
362 include_once
"./Services/UICore/classes/class.ilTemplate.php";
363 $template =
new ilTemplate(
"tpl.il_as_qpl_longmenu_output.html",
true,
true,
"Modules/TestQuestionPool");
365 $question_text = $this->
object->getQuestion();
366 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($question_text,
true));
367 $template->setVariable(
"ANSWER_OPTIONS_JSON", json_encode($this->
object->getAvailableAnswerOptions()));
369 $template->setVariable(
'AUTOCOMPLETE_LENGTH', $this->
object->getMinAutoComplete());
371 $page_output = $this->
outQuestionPage(
"", $is_postponed, $active_id, $question_output);
383 $this->ilTabs->clearTargets();
385 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
386 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
387 $q_type = $this->
object->getQuestionType();
389 if (strlen($q_type)) {
390 $classname = $q_type .
"GUI";
391 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
392 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
396 if ($this->rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
398 $this->ilTabs->addTarget(
400 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
401 array(
"edit",
"insert",
"exec_pg"),
411 $force_active =
false;
412 if ($this->rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"])) {
415 $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
417 $commands =
$_POST[
"cmd"];
418 if (is_array($commands)) {
419 foreach ($commands as
$key => $value) {
420 if (preg_match(
"/^delete_.*/",
$key, $matches)) {
421 $force_active =
true;
426 $this->ilTabs->addTarget(
429 array(
"editQuestion",
"save",
"saveEdit",
"addkvp",
"removekvp",
"originalSyncForm"),
447 $this->ilTabs->addTarget(
449 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
461 if (!$this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->object->getId(), 0)) {
465 $feedback =
'<table class="test_specific_feedback"><tbody>';
466 $gaps = $this->
object->getCorrectAnswers();
467 foreach ($gaps as
$index => $answer) {
469 $caption .=
$index + 1 .
': ';
471 $feedback .=
'<tr><td>';
473 $feedback .= $caption .
'</td><td>';
474 $feedback .= $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
479 $feedback .=
'</tbody></table>';
480 return $this->
object->prepareTextareaOutput($feedback,
true);
509 $aggregation =
array();
510 foreach ($relevant_answers as $answer) {
511 $overview[$answer[
'active_fi']][$answer[
'pass']][$answer[
'value1']] = $answer[
'value2'];
514 foreach ($overview as $active) {
515 foreach ($active as $answer) {
516 foreach ($answer as $option => $value) {
517 $aggregation[$option][$value] = $aggregation[$option][$value] + 1;
521 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_long_menu_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
522 $json = json_decode($this->
object->getJsonStructure());
523 foreach ($json as
$key => $value) {
524 $tpl->setVariable(
'TITLE',
'Longmenu ' . (
$key+1));
525 if (array_key_exists(
$key, $aggregation)) {
526 $aggregate = $aggregation[
$key];
527 foreach ($aggregate as $answer => $counts) {
528 $tpl->setVariable(
'OPTION', $answer);
529 $tpl->setVariable(
'COUNT', $counts);
530 $tpl->parseCurrentBlock();
542 $correct_answers = $this->
object->getCorrectAnswers();
543 $answers = $this->
object->getAnswers();
544 foreach ($text_array as
$key => $value) {
545 $answer_is_correct =
false;
547 $return_value .= $value;
548 if (
$key <
sizeof($text_array) - 1) {
550 if (array_key_exists(
$key, $user_solution)) {
551 $user_value = $user_solution[
$key];
552 if (in_array($user_value, $correct_answers[
$key][0])) {
553 $answer_is_correct =
true;
559 if (array_key_exists(
$key, $user_solution)) {
560 $user_value = $user_solution[
$key];
561 if (in_array($user_value, $correct_answers[
$key][0])) {
562 $answer_is_correct =
true;
569 return $return_value;
574 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_text_gap.html",
true,
true,
"Modules/TestQuestionPool");
576 $tpl->setVariable(
'DISABLED',
'disabled');
577 $tpl->setVariable(
'JS_IGNORE',
'_ignore');
581 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
584 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_wrong"));
588 $tpl->setVariable(
'VALUE', $value);
596 $tpl =
new ilTemplate(
"tpl.il_as_qpl_long_menu_select_gap.html",
true,
true,
"Modules/TestQuestionPool");
599 $tpl->setVariable(
'DISABLED',
'disabled');
600 $tpl->setVariable(
'JS_IGNORE',
'_ignore');
601 $tpl->setCurrentBlock(
'best_solution');
602 if ($user_value == -1) {
603 $tpl->setVariable(
"SOLUTION", $this->lng->txt(
"please_select"));
605 $tpl->setVariable(
'SOLUTION', $user_value);
610 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
613 $tpl->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_wrong"));
616 $tpl->parseCurrentBlock();
618 $tpl->setVariable(
"PLEASE_SELECT", $this->lng->txt(
"please_select"));
619 foreach ($answers as $value) {
620 $tpl->setCurrentBlock(
'select_option');
621 $tpl->setVariable(
'VALUE', $value);
622 if ($value == $user_value) {
623 $tpl->setVariable(
'SELECTED',
'selected');
625 $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.
if(!array_key_exists('StateId', $_REQUEST)) $id
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
populateTaxonomyFormSection(ilPropertyFormGUI $form)
writeQuestionGenericPostData()
if(isset($_POST['submit'])) $form
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.