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';
28 parent::__construct();
30 require_once
'Modules/TestQuestionPool/classes/class.assKprimChoice.php';
34 $this->
object->loadFromDb($qId);
40 return array(
'uploadImage',
'removeImage');
50 $this->tpl->addCss(
'Modules/Test/templates/default/ta.css');
52 $this->tpl->setVariable(
"QUESTION_DATA", $this->ctrl->getHTML(
$form));
60 $this->
object->saveToDb();
67 $position = key(
$_POST[
'cmd'][
'removeImage']);
68 $this->
object->removeAnswerImage($position);
70 $this->
object->saveToDb();
76 if (isset(
$_POST[
'cmd'][__FUNCTION__]) && count(
$_POST[
'cmd'][__FUNCTION__])) {
77 $this->
object->moveAnswerDown(key(
$_POST[
'cmd'][__FUNCTION__]));
78 $this->
object->saveToDb();
86 if (isset(
$_POST[
'cmd'][__FUNCTION__]) && count(
$_POST[
'cmd'][__FUNCTION__])) {
87 $this->
object->moveAnswerUp(key(
$_POST[
'cmd'][__FUNCTION__]));
88 $this->
object->saveToDb();
100 $form->setValuesByPost();
103 $answersInput =
$form->getItemByPostVar(
'kprim_answers');
104 $answersInput->setIgnoreMissingUploadsEnabled(
true);
106 if (!$answersInput->checkUploads(
$_POST[$answersInput->getPostVar()])) {
112 $answersInput->collectValidFiles();
113 } elseif (!
$form->checkInput()) {
154 $shuffleAnswers =
new ilCheckboxInputGUI($this->lng->txt(
"shuffle_answers"),
"shuffle_answers_enabled");
156 $form->
addItem($shuffleAnswers);
158 if (!$this->
object->getSelfAssessmentEditingMode()) {
160 $answerType =
new ilSelectInputGUI($this->lng->txt(
'answer_types'),
'answer_type');
161 $answerType->
setOptions($this->
object->getAnswerTypeSelectOptions($this->lng));
162 $answerType->setValue($this->
object->getAnswerType());
166 if (!$this->
object->getSelfAssessmentEditingMode() && $this->
object->isSingleLineAnswerType($this->
object->getAnswerType())) {
168 $thumbSize =
new ilNumberInputGUI($this->lng->txt(
'thumb_size'),
'thumb_size');
169 $thumbSize->
setSuffix($this->lng->txt(
"thumb_size_unit_pixel"));
170 $thumbSize->setInfo($this->lng->txt(
'thumb_size_info'));
171 $thumbSize->setDecimals(
false);
172 $thumbSize->setMinValue(20);
173 $thumbSize->setSize(6);
174 $thumbSize->setValue($this->
object->getThumbSize());
180 $optionLabel->
setInfo($this->lng->txt(
'option_label_info'));
181 $optionLabel->setRequired(
true);
182 $optionLabel->setValue($this->
object->getOptionLabel());
183 foreach ($this->
object->getValidOptionLabelsTranslated($this->lng) as $labelValue => $labelText) {
185 $optionLabel->addOption($option);
187 if ($this->
object->isCustomOptionLabel($labelValue)) {
189 $this->lng->txt(
'option_label_custom_true'),
190 'option_label_custom_true' 192 $customLabelTrue->
setValue($this->
object->getCustomTrueOptionLabel());
193 $option->addSubItem($customLabelTrue);
196 $this->lng->txt(
'option_label_custom_false'),
197 'option_label_custom_false' 199 $customLabelFalse->
setValue($this->
object->getCustomFalseOptionLabel());
200 $option->addSubItem($customLabelFalse);
209 $points->allowDecimals(
true);
210 $points->setMinValue(0);
211 $points->setMinvalueShouldBeGreater(
true);
212 $points->setValue($this->
object->getPoints());
216 $scorePartialSolution =
new ilCheckboxInputGUI($this->lng->txt(
'score_partsol_enabled'),
'score_partsol_enabled');
217 $scorePartialSolution->
setInfo($this->lng->txt(
'score_partsol_enabled_info'));
218 $scorePartialSolution->setChecked($this->
object->isScorePartialSolutionEnabled());
219 $form->
addItem($scorePartialSolution);
229 $oldAnswerType = $this->
object->getAnswerType();
231 $this->
object->setShuffleAnswersEnabled($form->
getItemByPostVar(
'shuffle_answers_enabled')->getChecked());
233 if (!$this->
object->getSelfAssessmentEditingMode()) {
234 $this->
object->setAnswerType($form->
getItemByPostVar(
'answer_type')->getValue());
239 if (!$this->
object->getSelfAssessmentEditingMode() && $this->
object->isSingleLineAnswerType($oldAnswerType)) {
240 $this->
object->setThumbSize($form->
getItemByPostVar(
'thumb_size')->getValue());
243 $this->
object->setOptionLabel($form->
getItemByPostVar(
'option_label')->getValue());
245 if ($this->
object->isCustomOptionLabel($this->object->getOptionLabel())) {
246 $this->
object->setCustomTrueOptionLabel(strip_tags(
249 $this->
object->setCustomFalseOptionLabel(strip_tags(
256 $this->
object->setScorePartialSolutionEnabled($form->
getItemByPostVar(
'score_partsol_enabled')->getChecked());
265 require_once
'Modules/TestQuestionPool/classes/class.ilKprimChoiceWizardInputGUI.php';
267 $kprimAnswers->
setInfo($this->lng->txt(
'kprim_answers_info'));
268 $kprimAnswers->setSize(64);
269 $kprimAnswers->setMaxLength(1000);
270 $kprimAnswers->setRequired(
true);
271 $kprimAnswers->setAllowMove(
true);
272 $kprimAnswers->setQuestionObject($this->
object);
273 if (!$this->
object->getSelfAssessmentEditingMode()) {
274 $kprimAnswers->setSingleline($this->
object->isSingleLineAnswerType($this->object->getAnswerType()));
276 $kprimAnswers->setSingleline(
false);
278 $kprimAnswers->setValues($this->
object->getAnswers());
293 $this->
object->handleFileUploads($answers,
$files);
294 $this->
object->setAnswers($answers);
303 foreach ($answers as
$key => $answer) {
334 $is_postponed =
false,
335 $use_post_solutions =
false,
336 $showInlineFeedback =
false 342 $user_solution =
array();
346 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 347 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 349 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 351 $solutions = $this->
object->getTestOutputSolutions($active_id,
$pass);
353 foreach ($solutions as $idx => $solution_value) {
354 $user_solution[$solution_value[
"value1"]] = $solution_value[
"value2"];
359 include_once
"./Services/UICore/classes/class.ilTemplate.php";
360 $template =
new ilTemplate(
"tpl.il_as_qpl_mc_kprim_output.html",
true,
true,
"Modules/TestQuestionPool");
362 foreach (
$keys as $answer_id) {
363 $answer = $this->
object->getAnswer($answer_id);
364 if (strlen($answer->getImageFile())) {
365 if ($this->
object->getThumbSize()) {
367 $template->setVariable(
"URL_PREVIEW", $answer->getImageWebPath());
368 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
370 $template->setVariable(
"ANSWER_IMAGE_URL", $answer->getThumbWebPath());
371 list($width, $height,
$type, $attr) = getimagesize($answer->getImageFsPath());
372 $alt = $answer->getImageFile();
373 if (strlen($answer->getAnswertext())) {
374 $alt = $answer->getAnswertext();
376 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
381 $template->setCurrentBlock(
"answer_image");
382 $template->setVariable(
"ANSWER_IMAGE_URL", $answer->getImageWebPath());
383 list($width, $height,
$type, $attr) = getimagesize($answer->getImageFsPath());
384 $alt = $answer->getImageFile();
385 if (strlen($answer->getAnswertext())) {
386 $alt = $answer->getAnswertext();
388 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
396 if ($showInlineFeedback) {
400 $template->setCurrentBlock(
"answer_row");
401 $template->setVariable(
"ANSWER_ID", $answer_id);
402 $template->setVariable(
"ANSWER_TEXT", $this->
object->prepareTextareaOutput($answer->getAnswertext(),
true));
404 $template->setVariable(
'VALUE_FALSE', 0);
406 if (isset($user_solution[$answer->getPosition()])) {
407 $tplVar = $user_solution[$answer->getPosition()] ?
'CHECKED_ANSWER_TRUE' :
'CHECKED_ANSWER_FALSE';
408 $template->setVariable($tplVar,
" checked=\"checked\"");
414 $questiontext = $this->
object->getQuestion();
415 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext,
true));
417 $template->setVariable(
"INSTRUCTIONTEXT", $this->
object->getInstructionTextTranslation(
419 $this->object->getOptionLabel()
422 $template->setVariable(
"OPTION_LABEL_TRUE", $this->
object->getTrueOptionLabelTranslation(
424 $this->object->getOptionLabel()
427 $template->setVariable(
"OPTION_LABEL_FALSE", $this->
object->getFalseOptionLabelTranslation(
429 $this->object->getOptionLabel()
433 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
441 public function getPreview($show_question_only =
false, $showInlineFeedback =
false)
448 include_once
"./Services/UICore/classes/class.ilTemplate.php";
449 $template =
new ilTemplate(
"tpl.il_as_qpl_mc_kprim_output.html",
true,
true,
"Modules/TestQuestionPool");
451 foreach (
$keys as $answer_id) {
452 $answer = $this->
object->getAnswer($answer_id);
453 if (strlen($answer->getImageFile())) {
454 if ($this->
object->getThumbSize()) {
456 $template->setVariable(
"URL_PREVIEW", $answer->getImageWebPath());
457 $template->setVariable(
"TEXT_PREVIEW", $this->lng->txt(
'preview'));
459 $template->setVariable(
"ANSWER_IMAGE_URL", $answer->getThumbWebPath());
460 list($width, $height,
$type, $attr) = getimagesize($answer->getImageFsPath());
461 $alt = $answer->getImageFile();
462 if (strlen($answer->getAnswertext())) {
463 $alt = $answer->getAnswertext();
465 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
470 $template->setCurrentBlock(
"answer_image");
471 $template->setVariable(
"ANSWER_IMAGE_URL", $answer->getImageWebPath());
472 list($width, $height,
$type, $attr) = getimagesize($answer->getImageFsPath());
473 $alt = $answer->getImageFile();
474 if (strlen($answer->getAnswertext())) {
475 $alt = $answer->getAnswertext();
477 $alt = preg_replace(
"/<[^>]*?>/",
"", $alt);
485 if ($showInlineFeedback) {
489 $template->setCurrentBlock(
"answer_row");
490 $template->setVariable(
"ANSWER_ID", $answer_id);
491 $template->setVariable(
"ANSWER_TEXT", $this->
object->prepareTextareaOutput($answer->getAnswertext(),
true));
493 $template->setVariable(
'VALUE_FALSE', 0);
495 if (isset($user_solution[$answer->getPosition()])) {
496 $tplVar = $user_solution[$answer->getPosition()] ?
'CHECKED_ANSWER_TRUE' :
'CHECKED_ANSWER_FALSE';
497 $template->setVariable($tplVar,
" checked=\"checked\"");
502 $questiontext = $this->
object->getQuestion();
503 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext,
true));
505 $template->setVariable(
"INSTRUCTIONTEXT", $this->
object->getInstructionTextTranslation(
507 $this->object->getOptionLabel()
510 $template->setVariable(
"OPTION_LABEL_TRUE", $this->
object->getTrueOptionLabelTranslation(
512 $this->object->getOptionLabel()
515 $template->setVariable(
"OPTION_LABEL_FALSE", $this->
object->getFalseOptionLabelTranslation(
517 $this->object->getOptionLabel()
521 if (!$show_question_only) {
525 return $questionoutput;
542 $graphicalOutput =
false,
543 $result_output =
false,
544 $show_question_only =
true,
545 $show_feedback =
false,
546 $show_correct_solution =
false,
547 $show_manual_scoring =
false,
548 $show_question_text =
true 554 $user_solution =
array();
555 if (($active_id > 0) && (!$show_correct_solution)) {
556 $solutions =&$this->
object->getSolutionValues($active_id,
$pass);
557 foreach ($solutions as $idx => $solution_value) {
558 $user_solution[$solution_value[
'value1']] = $solution_value[
'value2'];
562 foreach ($this->
object->getAnswers() as $answer) {
563 $user_solution[$answer->getPosition()] = $answer->getCorrectness();
568 $template =
new ilTemplate(
"tpl.il_as_qpl_mc_kprim_output_solution.html",
true,
true,
"Modules/TestQuestionPool");
570 foreach (
$keys as $answer_id) {
571 $answer = $this->
object->getAnswer($answer_id);
573 if (($active_id > 0) && (!$show_correct_solution)) {
574 if ($graphicalOutput) {
577 if ($user_solution[$answer->getPosition()] == $answer->getCorrectness()) {
580 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
585 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
590 if (strlen($answer->getImageFile())) {
591 $template->setCurrentBlock(
"answer_image");
592 if ($this->
object->getThumbSize()) {
593 $template->setVariable(
"ANSWER_IMAGE_URL", $answer->getThumbWebPath());
595 $template->setVariable(
"ANSWER_IMAGE_URL", $answer->getImageWebPath());
603 if ($show_feedback) {
607 $template->setCurrentBlock(
"answer_row");
608 $template->setVariable(
"ANSWER_TEXT", $this->
object->prepareTextareaOutput($answer->getAnswertext(),
true));
611 if (isset($user_solution[$answer->getPosition()])) {
612 if ($user_solution[$answer->getPosition()]) {
614 $template->setVariable(
"SOLUTION_ALT_TRUE", $this->lng->txt(
"checked"));
616 $template->setVariable(
"SOLUTION_ALT_FALSE", $this->lng->txt(
"unchecked"));
619 $template->setVariable(
"SOLUTION_ALT_TRUE", $this->lng->txt(
"unchecked"));
621 $template->setVariable(
"SOLUTION_ALT_FALSE", $this->lng->txt(
"checked"));
625 $template->setVariable(
"SOLUTION_ALT_TRUE", $this->lng->txt(
"unchecked"));
627 $template->setVariable(
"SOLUTION_ALT_FALSE", $this->lng->txt(
"unchecked"));
631 $template->setVariable(
'SOL_SUFFIX', $show_correct_solution ?
'bestsolution' :
'usersolution');
632 $template->setVariable(
'SOL_POSITION', $answer->getPosition());
634 $template->setVariable(
'SOL_TRUE_VALUE', 1);
635 $template->setVariable(
'SOL_FALSE_VALUE', 0);
637 if (isset($user_solution[$answer->getPosition()])) {
638 if ($user_solution[$answer->getPosition()]) {
639 $template->setVariable(
'SOL_TRUE_CHECKED',
'checked');
641 $template->setVariable(
'SOL_FALSE_CHECKED',
'checked');
649 if ($show_question_text==
true) {
650 $questiontext = $this->
object->getQuestion();
651 $template->setVariable(
"QUESTIONTEXT", $this->
object->prepareTextareaOutput($questiontext,
true));
653 $template->setVariable(
"INSTRUCTIONTEXT", $this->
object->getInstructionTextTranslation(
655 $this->object->getOptionLabel()
659 $template->setVariable(
"OPTION_LABEL_TRUE", $this->
object->getTrueOptionLabelTranslation(
661 $this->object->getOptionLabel()
664 $template->setVariable(
"OPTION_LABEL_FALSE", $this->
object->getFalseOptionLabelTranslation(
666 $this->object->getOptionLabel()
673 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",
true,
true,
"Modules/TestQuestionPool");
675 if (strlen($feedback)) {
681 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
682 $solutiontemplate->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput($feedback,
true));
685 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
687 $solutionoutput = $solutiontemplate->get();
689 if (!$show_question_only) {
693 return $solutionoutput;
698 $choiceKeys = array_keys($this->
object->getAnswers());
700 if ($this->
object->isShuffleAnswersEnabled()) {
701 $choiceKeys = $this->
object->getShuffler()->shuffle($choiceKeys);
709 require_once
'Modules/TestQuestionPool/classes/feedback/class.ilAssConfigurableMultiOptionQuestionFeedback.php';
712 if ($user_solution[$answer_id]) {
713 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->
object->getId(), $answer_id);
716 $template->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput($fb,
true));
723 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->
object->getId(), $answer_id);
726 $template->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput($fb,
true));
732 $answer = $this->
object->getAnswer($answer_id);
734 if ($answer->getCorrectness()) {
735 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation($this->
object->getId(), $answer_id);
738 $template->setVariable(
"FEEDBACK", $this->
object->prepareTextareaOutput($fb,
true));
787 return '<pre>' . print_r($relevant_answers, 1) .
'</pre>';
792 $trueOptionLabel = $this->
object->getTrueOptionLabelTranslation($this->lng, $this->
object->getOptionLabel());
793 $falseOptionLabel = $this->
object->getFalseOptionLabelTranslation($this->lng, $this->
object->getOptionLabel());
795 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_kprim_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
797 foreach ($aggregate as $lineData) {
798 $tpl->setCurrentBlock(
'aggregaterow');
799 $tpl->setVariable(
'OPTION', $lineData[
'answertext']);
800 $tpl->setVariable(
'COUNT_TRUE', $lineData[
'count_true']);
801 $tpl->setVariable(
'COUNT_FALSE', $lineData[
'count_false']);
802 $tpl->parseCurrentBlock();
805 $tpl->setVariable(
'OPTION_HEAD', $this->lng->txt(
'answers'));
806 $tpl->setVariable(
'COUNT_TRUE_HEAD', $trueOptionLabel);
807 $tpl->setVariable(
'COUNT_FALSE_HEAD', $falseOptionLabel);
814 $aggregate =
array();
816 foreach ($answers as $answer) {
818 'answertext' => $answer->getAnswerText(),
'count_true' => 0,
'count_false' => 0
821 foreach ($rawSolutionData as $solutionRecord) {
822 if ($solutionRecord[
'value1'] == $answer->getPosition()) {
823 if ($solutionRecord[
'value2']) {
824 $answerAgg[
'count_true']++;
826 $answerAgg[
'count_false']++;
831 $aggregate[] = $answerAgg;
isTestPresentationContext()
getSpecificFeedbackOutput($active_id, $pass)
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
hasCorrectSolution($activeId, $passIndex)
This class represents an option in a radio group.
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
buildBasicEditFormObject()
populateAnswerSpecificFormPart(ilPropertyFormGUI $form)
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
const FEEDBACK_SETTING_CHECKED
getPreview($show_question_only=false, $showInlineFeedback=false)
populateTaxonomyFormSection(ilPropertyFormGUI $form)
getAdditionalEditQuestionCommands()
handleAnswerTextsSubmit($answers)
const ANSWER_TYPE_MULTI_LINE
writePostData($upload=false)
{}
writeQuestionGenericPostData()
const FEEDBACK_SETTING_CORRECT
getTestOutput( $active_id, $pass, $is_postponed=false, $use_post_solutions=false, $showInlineFeedback=false)
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
renderAggregateView($aggregate)
This class represents a text property in a property form.
writeAnswerSpecificPostData(ilPropertyFormGUI $form)
const CSS_CLASS_FEEDBACK_WRONG
Basic GUI class for assessment questions.
static getHtmlPath($relative_path)
get url of path
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
getAfterParticipationSuppressionAnswerPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
saveTaxonomyAssignments()
Create new PHPExcel object
obj_idprivate
const FEEDBACK_SETTING_ALL
editQuestion(ilPropertyFormGUI $form=null)
static secureString($a_str, $a_strip_html=true, $a_allow="")
Remove unsecure tags.
isRenderPurposePrintPdf()
Interface ilGuiAnswerScoringAdjustable.
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
aggregateAnswers($rawSolutionData, $answers)
getGenericFeedbackOutput($active_id, $pass)
Returns the answer specific feedback for the question.
Interface ilGuiQuestionScoringAdjustable.
setValue($a_value)
Set Value.
getSolutionOutput( $active_id, $pass=null, $graphicalOutput=false, $result_output=false, $show_question_only=true, $show_feedback=false, $show_correct_solution=false, $show_manual_scoring=false, $show_question_text=true)
populateSpecificFeedbackInline($user_solution, $answer_id, $template)
getParticipantsAnswerKeySequence()
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
renderPurposeSupportsFormHtml()