4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiAnswerScoringAdjustable.php';
7 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
36 include_once
"./Modules/TestQuestionPool/classes/class.assSingleChoice.php";
40 $this->
object->loadFromDb($id);
53 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
74 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
76 $form->setFormAction($this->ctrl->getFormAction($this));
78 $isSingleline = ($this->
object->lastChange == 0 && !array_key_exists(
'types',
$_POST)) ? (($this->object->getMultilineAnswerSetting()) ?
false :
true) : $this->
object->isSingleline;
79 if ($checkonly) $isSingleline = (
$_POST[
'types'] == 0) ?
true :
false;
82 $form->setMultipart(TRUE);
86 $form->setMultipart(FALSE);
88 $form->setTableWidth(
"100%");
89 $form->setId(
"asssinglechoice");
104 $form->setValuesByPost();
105 $errors = !$form->checkInput();
106 $form->setValuesByPost();
107 if (
$errors) $checkonly =
false;
110 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
120 $position = key(
$_POST[
'cmd'][
'uploadchoice']);
130 $position = key(
$_POST[
'cmd'][
'removeimagechoice']);
132 $this->
object->removeAnswerImage($position);
142 $position = key(
$_POST[
'cmd'][
'addchoice']);
143 $this->
object->addAnswer(
"", 0, $position+1);
153 $position = key(
$_POST[
'cmd'][
'removechoice']);
154 $this->
object->deleteAnswer($position);
159 $user_post_solutions = FALSE, $show_inline_specific_feedback = FALSE)
164 $is_question_postponed,
165 $user_post_solutions,
166 $show_inline_specific_feedback
169 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
170 $this->tpl->setVariable(
"FORMACTION", $formaction);
189 $graphicalOutput = FALSE,
190 $result_output = FALSE,
191 $show_question_only = TRUE,
192 $show_feedback = FALSE,
193 $show_correct_solution = FALSE,
194 $show_manual_scoring = FALSE,
195 $show_question_text = TRUE
203 if (($active_id > 0) && (!$show_correct_solution))
205 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
206 foreach ($solutions as $idx => $solution_value)
208 $user_solution = $solution_value[
"value1"];
215 foreach ($this->object->answers as $index => $answer)
217 if ($answer->getPoints() > $max_points)
219 $max_points = $answer->getPoints();
220 $found_index = $index;
223 $user_solution = $found_index;
226 include_once
"./Services/UICore/classes/class.ilTemplate.php";
227 $template =
new ilTemplate(
"tpl.il_as_qpl_mc_sr_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
228 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
229 foreach ($keys as $answer_id)
231 $answer = $this->
object->answers[$answer_id];
232 if (($active_id > 0) && (!$show_correct_solution))
234 if ($graphicalOutput)
238 if (strcmp($user_solution, $answer_id) == 0)
240 if ($answer->getPoints() == $this->
object->getMaximumPoints())
250 $template->setCurrentBlock(
"icon_ok");
252 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
253 $template->parseCurrentBlock();
257 $template->setCurrentBlock(
"icon_not_ok");
258 if ($answer->getPoints() > 0)
261 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
266 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
268 $template->parseCurrentBlock();
271 if (strlen($user_solution) == 0)
273 $template->setCurrentBlock(
"icon_not_ok");
275 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
276 $template->parseCurrentBlock();
280 if (strlen($answer->getImage()))
282 $template->setCurrentBlock(
"answer_image");
283 if ($this->object->getThumbSize())
285 $template->setVariable(
"ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $answer->getImage());
289 $template->setVariable(
"ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
291 $alt = $answer->getImage();
292 if (strlen($answer->getAnswertext()))
294 $alt = $answer->getAnswertext();
296 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
299 $template->parseCurrentBlock();
303 $feedbackOutputRequired =
false;
305 switch( $this->object->getSpecificFeedbackSetting() )
308 $feedbackOutputRequired =
true;
312 if (strcmp($user_solution, $answer_id) == 0)
314 $feedbackOutputRequired =
true;
319 if ($this->object->getAnswer($answer_id)->getPoints() > 0)
321 $feedbackOutputRequired =
true;
326 if($feedbackOutputRequired)
328 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
329 $this->object->getId(), $answer_id
333 $template->setCurrentBlock(
"feedback");
334 $template->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $fb,
true ));
335 $template->parseCurrentBlock();
339 $template->setCurrentBlock(
"answer_row");
340 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
341 if (strcmp($user_solution, $answer_id) == 0)
344 $template->setVariable(
"SOLUTION_ALT", $this->lng->txt(
"checked"));
349 $template->setVariable(
"SOLUTION_ALT", $this->lng->txt(
"unchecked"));
353 $points = $this->
object->answers[$answer_id]->getPoints();
354 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
355 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
357 $template->parseCurrentBlock();
359 $questiontext = $this->
object->getQuestion();
360 if ($show_question_text==
true)
362 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
364 $questionoutput = $template->get();
366 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
367 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
369 $solutionoutput = $solutiontemplate->get();
370 if (!$show_question_only)
373 $solutionoutput =
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
375 return $solutionoutput;
383 include_once
"./Services/UICore/classes/class.ilTemplate.php";
384 $template =
new ilTemplate(
"tpl.il_as_qpl_mc_sr_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
385 foreach ($keys as $answer_id)
387 $answer = $this->
object->answers[$answer_id];
388 if (strlen($answer->getImage()))
390 if ($this->object->getThumbSize())
392 $template->setCurrentBlock(
"preview");
393 $template->setVariable(
"URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
394 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
396 $template->setVariable(
"ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $answer->getImage());
397 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
398 $alt = $answer->getImage();
399 if (strlen($answer->getAnswertext()))
401 $alt = $answer->getAnswertext();
403 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
406 $template->parseCurrentBlock();
410 $template->setCurrentBlock(
"answer_image");
411 $template->setVariable(
"ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
412 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
413 $alt = $answer->getImage();
414 if (strlen($answer->getAnswertext()))
416 $alt = $answer->getAnswertext();
418 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
419 $template->setVariable(
"ATTR", $attr);
422 $template->parseCurrentBlock();
425 $template->setCurrentBlock(
"answer_row");
426 $template->setVariable(
"QID", $this->object->getId().
'ID');
427 $template->setVariable(
"ANSWER_ID", $answer_id);
428 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
429 $template->parseCurrentBlock();
431 $questiontext = $this->
object->getQuestion();
432 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
433 $questionoutput = $template->get();
434 if (!$show_question_only)
439 return $questionoutput;
442 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
451 include_once
"./Modules/Test/classes/class.ilObjTest.php";
456 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
457 foreach ($solutions as $idx => $solution_value)
459 $user_solution = $solution_value[
"value1"];
464 include_once
"./Services/UICore/classes/class.ilTemplate.php";
465 $template =
new ilTemplate(
"tpl.il_as_qpl_mc_sr_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
466 foreach ($keys as $answer_id)
468 $answer = $this->
object->answers[$answer_id];
469 if (strlen($answer->getImage()))
471 if ($this->object->getThumbSize())
473 $template->setCurrentBlock(
"preview");
474 $template->setVariable(
"URL_PREVIEW", $this->object->getImagePathWeb() . $answer->getImage());
475 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
477 $template->setVariable(
"ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $this->
object->getThumbPrefix() . $answer->getImage());
478 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
479 $alt = $answer->getImage();
480 if (strlen($answer->getAnswertext()))
482 $alt = $answer->getAnswertext();
484 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
487 $template->parseCurrentBlock();
491 $template->setCurrentBlock(
"answer_image");
492 $template->setVariable(
"ANSWER_IMAGE_URL", $this->object->getImagePathWeb() . $answer->getImage());
493 list($width, $height, $type, $attr) = getimagesize($this->object->getImagePath() . $answer->getImage());
494 $alt = $answer->getImage();
495 if (strlen($answer->getAnswertext()))
497 $alt = $answer->getAnswertext();
499 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
500 $template->setVariable(
"ATTR", $attr);
503 $template->parseCurrentBlock();
508 $feedbackOutputRequired =
false;
510 switch( $this->object->getSpecificFeedbackSetting() )
513 $feedbackOutputRequired =
true;
517 if (strcmp($user_solution, $answer_id) == 0)
519 $feedbackOutputRequired =
true;
524 if ($this->object->getAnswer($answer_id)->getPoints() > 0)
526 $feedbackOutputRequired =
true;
531 if($feedbackOutputRequired)
533 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
534 $this->object->getId(), $answer_id
538 $template->setCurrentBlock(
"feedback");
539 $template->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $fb,
true ));
540 $template->parseCurrentBlock();
544 $template->setCurrentBlock(
"answer_row");
545 $template->setVariable(
"ANSWER_ID", $answer_id);
546 $template->setVariable(
"ANSWER_TEXT", $this->object->prepareTextareaOutput($answer->getAnswertext(), TRUE));
547 if (strcmp($user_solution, $answer_id) == 0)
549 $template->setVariable(
"CHECKED_ANSWER",
" checked=\"checked\"");
551 $template->parseCurrentBlock();
553 $questiontext = $this->
object->getQuestion();
554 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
555 $questionoutput = $template->get();
556 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
569 global $rbacsystem, $ilTabs;
571 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
572 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
573 $q_type = $this->
object->getQuestionType();
577 $classname = $q_type .
"GUI";
578 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
579 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
584 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
587 $ilTabs->addTarget(
"edit_page",
588 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
589 array(
"edit",
"insert",
"exec_pg"),
590 "",
"", $force_active);
594 $ilTabs->addTarget(
"preview",
595 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"preview"),
597 "ilAssQuestionPageGUI",
"", $force_active);
600 $force_active =
false;
601 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
604 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
606 $ilTabs->addTarget(
"edit_question",
608 array(
"editQuestion",
"save",
"saveEdit",
"addchoice",
"removechoice",
"removeimagechoice",
"uploadchoice",
"originalSyncForm"),
609 $classname,
"", $force_active);
620 $ilTabs->addTarget(
"solution_hint",
621 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
622 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
623 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
633 $ilTabs->addTarget(
"statistics",
634 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
639 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
644 global $___test_express_mode;
646 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
647 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
651 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
656 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
667 if (strcmp(
$_GET[
"activecommand"],
"directfeedback") == 0)
671 if (!is_array($this->choiceKeys))
673 $this->choiceKeys = array_keys($this->object->answers);
674 if ($this->object->getShuffle())
676 $this->choiceKeys = $this->
object->pcArrayShuffle($this->choiceKeys);
687 return $this->
object->prepareTextareaOutput($output, TRUE);
692 $this->
object->setShuffle(
$_POST[
"shuffle"] );
693 $this->
object->setMultilineAnswerSetting(
$_POST[
"types"] );
694 if (is_array(
$_POST[
'choice'][
'imagename'] ) &&
$_POST[
"types"] == 1)
696 $this->
object->isSingleline =
true;
701 $this->
object->isSingleline = (
$_POST[
"types"] == 0) ?
true :
false;
703 $this->
object->setThumbSize( (strlen(
$_POST[
"thumb_size"] )) ?
$_POST[
"thumb_size"] :
"" );
708 $isSingleline = ($this->
object->lastChange == 0 && !array_key_exists(
'types',
$_POST)) ? (($this->object->getMultilineAnswerSetting()) ?
false :
true) : $this->
object->isSingleline;
712 $shuffle->setChecked( $this->object->getShuffle() );
713 $shuffle->setRequired( FALSE );
716 if ($this->object->getId())
719 $hidden->setValue( $this->object->getId() );
723 if (!$this->object->getSelfAssessmentEditingMode())
728 $types->setValue( ($isSingleline) ? 0 : 1 );
729 $types->setOptions( array(
730 0 => $this->lng->txt(
'answers_singleline' ),
731 1 => $this->lng->txt(
'answers_multiline' ),
740 $thumb_size =
new ilNumberInputGUI($this->lng->txt(
"thumb_size" ),
"thumb_size");
741 $thumb_size->
setSuffix($this->lng->txt(
"thumb_size_unit_pixel"));
742 $thumb_size->setMinValue( 20 );
743 $thumb_size->setDecimals( 0 );
744 $thumb_size->setSize( 6 );
745 $thumb_size->setInfo( $this->lng->txt(
'thumb_size_info' ) );
746 $thumb_size->setValue( $this->object->getThumbSize() );
747 $thumb_size->setRequired(
false );
764 return array(
'shuffle',
'types',
'thumb_size');
770 $this->
object->flushAnswers();
771 if ($this->object->isSingleline)
773 foreach (
$_POST[
'choice'][
'answer'] as $index => $answertext)
775 $picturefile =
$_POST[
'choice'][
'imagename'][$index];
776 $file_org_name = $_FILES[
'choice'][
'name'][
'image'][$index];
777 $file_temp_name = $_FILES[
'choice'][
'tmp_name'][
'image'][$index];
779 if (strlen( $file_temp_name ))
782 $suffix = strtolower( array_pop( explode(
".", $file_org_name ) ) );
783 if (in_array( $suffix, array(
"jpg",
"jpeg",
"png",
"gif" ) ))
786 $filename = $this->
object->createNewImageFileName( $file_org_name );
787 if ($this->object->setImageFile(
$filename, $file_temp_name ) == 0)
794 $this->
object->addAnswer( $answertext,
$_POST[
'choice'][
'points'][$index], $index, $picturefile );
799 foreach (
$_POST[
'choice'][
'answer'] as $index => $answer)
801 $answertext = $answer;
802 $this->
object->addAnswer( $answertext,
$_POST[
'choice'][
'points'][$index], $index );
809 $isSingleline = ($this->
object->lastChange == 0 && !array_key_exists(
'types',
$_POST)) ? (($this->object->getMultilineAnswerSetting()) ?
false :
true) : $this->
object->isSingleline;
812 include_once
"./Modules/TestQuestionPool/classes/class.ilSingleChoiceWizardInputGUI.php";
815 $choices->setQuestionObject( $this->
object );
816 $choices->setSingleline( $isSingleline );
817 $choices->setAllowMove(
false );
818 if ($this->object->getSelfAssessmentEditingMode())
820 $choices->setSize( 40 );
821 $choices->setMaxLength( 800 );
823 if ($this->object->getAnswerCount() == 0)
824 $this->object->addAnswer(
"", 0, 0 );
825 $choices->setValues( $this->object->getAnswers() );
847 $singlechoice_wizardinputgui->setDisableUpload(
true);
848 $singlechoice_wizardinputgui->setDisableActions(
true);
849 $singlechoice_wizardinputgui->setDisableText(
true);
863 $passcount = count($relevant_answers);
864 foreach($relevant_answers as
$pass)
866 $actives[$pass[
'active_fi']] = $pass[
'active_fi'];
868 $usercount = count($actives);
869 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_header.html',
true,
true,
"Modules/TestQuestionPool");
870 $tpl->setVariable(
'HEADERTEXT', $this->lng->txt(
'overview'));
871 $tpl->setVariable(
'NUMBER_OF_USERS_INFO', $this->lng->txt(
'number_of_users'));
872 $tpl->setVariable(
'NUMBER_OF_USERS', $usercount);
873 $tpl->setVariable(
'NUMBER_OF_PASSES_INFO', $this->lng->txt(
'number_of_passes'));
874 $tpl->setVariable(
'NUMBER_OF_PASSES', $passcount);
877 $this->
aggregateAnswers( $relevant_answers, $this->object->getAnswers() ) )->get();
882 $aggregate = array();
883 foreach ($answers_defined_on_question as $answer)
885 $aggregated_info_for_answer = array();
886 $aggregated_info_for_answer[
'answertext'] = $answer->getAnswerText();
887 $aggregated_info_for_answer[
'count_checked'] = 0;
889 foreach ($relevant_answers_chosen as $relevant_answer)
891 if ($relevant_answer[
'value1'] == $answer->getOrder())
893 $aggregated_info_for_answer[
'count_checked']++;
896 $aggregated_info_for_answer[
'count_unchecked'] =
897 ceil(count($relevant_answers_chosen) / count($answers_defined_on_question))
898 - $aggregated_info_for_answer[
'count_checked'];
900 $aggregate[] = $aggregated_info_for_answer;
912 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
913 $tpl->setVariable(
'OPTION_HEADER', $this->lng->txt(
'option') );
914 $tpl->setVariable(
'COUNT_HEADER', $this->lng->txt(
'count') );
915 $tpl->setVariable(
'AGGREGATION_HEADER', $this->lng->txt(
'aggregated_answers_header') );
916 foreach ($aggregate as $line_data)
918 $tpl->setCurrentBlock(
'aggregaterow' );
919 $tpl->setVariable(
'OPTION', $line_data[
'answertext'] );
920 $tpl->setVariable(
'COUNT', $line_data[
'count_checked'] );
921 $tpl->parseCurrentBlock();