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';
34 include_once
"./Modules/TestQuestionPool/classes/class.assTextQuestion.php";
38 $this->
object->loadFromDb($id);
51 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
73 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
75 $form->setFormAction($this->ctrl->getFormAction($this));
77 $form->setMultipart(TRUE);
78 $form->setTableWidth(
"100%");
79 $form->setId(
"asstextquestion");
94 $form->setValuesByPost();
96 $form->setValuesByPost();
97 if (
$errors) $checkonly =
false;
100 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
106 $answerTexts = array();
108 foreach($answers as $answer)
110 $answerTexts[] = $answer->getAnswertext();
118 if ($this->object->getMaxNumOfChars() > 0)
120 $this->tpl->addBlockFile(
"CONTENT_BLOCK",
"charcounter",
"tpl.charcounter.html",
"Modules/TestQuestionPool");
121 $this->tpl->setCurrentBlock(
"charcounter");
122 $this->tpl->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
123 $this->tpl->parseCurrentBlock();
129 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
130 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
131 $this->tpl->setVariable(
"FORMACTION", $formaction);
132 include_once
"./Services/RTE/classes/class.ilRTE.php";
134 include_once
"./Services/RTE/classes/class.$rtestring.php";
135 $rte =
new $rtestring();
136 include_once
"./Services/Object/classes/class.ilObject.php";
139 $rte->addUserTextEditor(
"textinput");
159 $graphicalOutput = FALSE,
160 $result_output = FALSE,
161 $show_question_only = TRUE,
162 $show_feedback = FALSE,
163 $show_correct_solution = FALSE,
164 $show_manual_scoring = FALSE,
165 $show_question_text = TRUE
172 if (($active_id > 0) && (!$show_correct_solution))
174 $solution = $user_solution;
182 include_once
"./Services/UICore/classes/class.ilTemplate.php";
183 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
184 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
186 $solution = $this->
object->getHtmlUserSolutionPurifier()->purify($solution);
187 $template->setVariable(
"ESSAY", $this->object->prepareTextareaOutput($solution, TRUE));
189 $questiontext = $this->
object->getQuestion();
191 if (!$show_correct_solution)
193 $max_no_of_chars = $this->
object->getMaxNumOfChars();
195 if ($max_no_of_chars == 0)
197 $max_no_of_chars = ucfirst($this->lng->txt(
'unlimited'));
200 $act_no_of_chars = strlen($user_solution);
201 $template->setVariable(
"CHARACTER_INFO",
'<b>' . $max_no_of_chars .
'</b>' .
202 $this->lng->txt(
'answer_characters') .
' <b>' . $act_no_of_chars .
'</b>');
204 if (($active_id > 0) && (!$show_correct_solution))
206 if ($graphicalOutput)
209 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
210 if ($reached_points == $this->object->getMaximumPoints())
212 $template->setCurrentBlock(
"icon_ok");
214 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
215 $template->parseCurrentBlock();
219 $template->setCurrentBlock(
"icon_ok");
220 if ($reached_points > 0)
223 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
228 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
230 $template->parseCurrentBlock();
234 if ($show_question_text==
true)
236 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
238 $questionoutput = $template->get();
244 $feedback .= strlen($fb) ? $fb :
'';
247 $feedback .= strlen($fb) ? $fb :
'';
249 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
251 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
253 $solutionoutput = $solutiontemplate->get();
254 if (!$show_question_only)
257 $solutionoutput =
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
259 return $solutionoutput;
264 $answers = $this->
object->getAnswers();
265 if (count( $answers ))
267 $user_solution = $this->lng->txt(
"solution_contain_keywords" ) .
"<ul>";
269 foreach ($answers as $answer)
271 $user_solution .=
'<li>'. $answer->getAnswertext();
275 $user_solution .=
' ' . $this->lng->txt(
'for') .
' ';
276 $user_solution .= $answer->getPoints() .
' ' . $this->lng->txt(
'points') .
'</li>';
279 $user_solution .=
'</ul>';
281 $user_solution .= $this->lng->txt(
'essay_scoring_mode') .
': ';
283 switch( $this->object->getKeywordRelation() )
286 $user_solution .= $this->lng->txt(
'essay_scoring_mode_keyword_relation_any');
289 $user_solution .= $this->lng->txt(
'essay_scoring_mode_keyword_relation_all');
292 $user_solution .= $this->lng->txt(
'essay_scoring_mode_keyword_relation_one');
296 return $user_solution;
302 $solutions = $this->
object->getSolutionValues( $active_id,
$pass );
303 foreach ($solutions as $idx => $solution_value)
305 $user_solution = $solution_value[
"value1"];
307 return $user_solution;
313 include_once
"./Services/UICore/classes/class.ilTemplate.php";
314 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
315 if ($this->object->getMaxNumOfChars())
317 $template->setCurrentBlock(
"maximum_char_hint");
318 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
319 $template->parseCurrentBlock();
320 #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
321 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
322 $template->parseCurrentBlock();
323 $template->setCurrentBlock(
"maxchars_counter");
324 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
325 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
326 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
327 $template->parseCurrentBlock();
329 $questiontext = $this->
object->getQuestion();
330 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
331 $questionoutput = $template->get();
332 if (!$show_question_only)
337 return $questionoutput;
347 include_once
"./Modules/Test/classes/class.ilObjTest.php";
352 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
353 foreach ($solutions as $idx => $solution_value)
355 $user_solution = $solution_value[
"value1"];
360 include_once
"./Services/UICore/classes/class.ilTemplate.php";
361 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
362 if ($this->object->getMaxNumOfChars())
364 $template->setCurrentBlock(
"maximum_char_hint");
365 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
366 $template->parseCurrentBlock();
367 #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
368 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
369 $template->parseCurrentBlock();
370 $template->setCurrentBlock(
"maxchars_counter");
371 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
372 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
373 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
374 $template->parseCurrentBlock();
377 $questiontext = $this->
object->getQuestion();
378 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
379 $questionoutput = $template->get();
380 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
381 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
389 if (
$_POST[
"cmd"][
"addSuggestedSolution"])
397 if (!$this->checkInput())
399 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
404 $this->
object->saveToDb();
405 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
406 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
420 global $rbacsystem, $ilTabs;
422 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
423 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
424 $q_type = $this->
object->getQuestionType();
428 $classname = $q_type .
"GUI";
429 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
430 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
435 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
438 $ilTabs->addTarget(
"edit_page",
439 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
440 array(
"edit",
"insert",
"exec_pg"),
441 "",
"", $force_active);
445 $ilTabs->addTarget(
"preview",
446 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"preview"),
448 "ilAssQuestionPageGUI",
"", $force_active);
451 $force_active =
false;
452 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
455 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
457 $ilTabs->addTarget(
"edit_question",
459 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
460 $classname,
"", $force_active);
471 $ilTabs->addTarget(
"solution_hint",
472 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
473 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
474 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
484 $ilTabs->addTarget(
"statistics",
485 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
490 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
495 global $___test_express_mode;
497 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
498 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
502 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
507 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
513 $feedback =
'<table><tbody>';
514 $user_answers = $this->
object->getSolutionValues($active_id);
515 $user_answer =
' '. $user_answers[0][
'value1'];
517 foreach ($this->object->getAnswers() as $idx => $ans)
519 if ($this->object->isKeywordMatching($user_answer, $ans->getAnswertext() ))
521 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
522 $this->object->getId(), $idx
524 $feedback .=
'<tr><td><b><i>' . $ans->getAnswertext() .
'</i></b></td><td>';
525 $feedback .= $fb .
'</td> </tr>';
529 $feedback .=
'</tbody></table>';
530 return $this->
object->prepareTextareaOutput($feedback, TRUE);
535 $this->
object->setMaxNumOfChars(
$_POST[
"maxchars"] );
536 $this->
object->setTextRating(
$_POST[
"text_rating"] );
537 $this->
object->setKeywordRelation(
$_POST[
'scoring_mode'] );
542 switch ($this->object->getKeywordRelation())
545 $this->
object->setAnswers( array() );
546 $this->
object->setPoints(
$_POST[
'non_keyword_points'] );
549 $this->
object->setAnswers(
$_POST[
'any_keyword'] );
550 $this->
object->setPoints( $this->object->getMaximumPoints() );
553 $this->
object->setAnswers(
$_POST[
'all_keyword'] );
554 $this->
object->setPoints(
$_POST[
'all_keyword_points'] );
557 $this->
object->setAnswers(
$_POST[
'one_keyword'] );
558 $this->
object->setPoints(
$_POST[
'one_keyword_points'] );
566 $maxchars =
new ilNumberInputGUI($this->lng->txt(
"maxchars" ),
"maxchars");
568 if ($this->object->getMaxNumOfChars() > 0)
569 $maxchars->setValue( $this->object->getMaxNumOfChars() );
570 $maxchars->setInfo( $this->lng->txt(
"description_maxchars" ) );
574 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
575 $text_options = array(
576 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
577 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
578 "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1"),
579 "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2"),
580 "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3"),
581 "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4"),
582 "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5")
584 $textrating->setOptions($text_options);
585 $textrating->setValue($this->object->getTextRating());
594 $this->lng->txt(
'essay_scoring_mode' ),
'scoring_mode'
597 $scoringOptionNone =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_without_keywords' ),
598 'non', $this->lng->txt(
'essay_scoring_mode_without_keywords_desc'
601 $scoringOptionAnyKeyword =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_keyword_relation_any' ),
602 'any', $this->lng->txt(
'essay_scoring_mode_keyword_relation_any_desc'
605 $scoringOptionAllKeyword =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_keyword_relation_all' ),
606 'all', $this->lng->txt(
'essay_scoring_mode_keyword_relation_all_desc'
609 $scoringOptionOneKeyword =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_keyword_relation_one' ),
610 'one', $this->lng->txt(
'essay_scoring_mode_keyword_relation_one_desc'
614 $scoringMode->addOption( $scoringOptionNone );
615 $scoringMode->addOption( $scoringOptionAnyKeyword );
616 $scoringMode->addOption( $scoringOptionAllKeyword );
617 $scoringMode->addOption( $scoringOptionOneKeyword );
618 $scoringMode->setRequired(
true );
619 $scoringMode->
setValue( strlen( $this->object->getKeywordRelation() ) ? $this->object->getKeywordRelation(
623 if ($this->object->getAnswerCount() == 0)
625 $this->
object->addAnswer(
"", 1, 0, 0 );
627 require_once
"./Modules/TestQuestionPool/classes/class.ilEssayKeywordWizardInputGUI.php";
630 $nonKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points" ),
"non_keyword_points");
631 $nonKeywordPoints->
setValue( $this->object->getPoints() );
632 $nonKeywordPoints->setRequired( TRUE );
633 $nonKeywordPoints->setSize( 3 );
634 $nonKeywordPoints->setMinValue( 0.0 );
635 $nonKeywordPoints->setMinvalueShouldBeGreater(
true );
636 $scoringOptionNone->
addSubItem( $nonKeywordPoints );
641 $anyKeyword->setQuestionObject( $this->
object );
642 $anyKeyword->setSingleline( TRUE );
643 $anyKeyword->setValues( $this->object->getAnswers() );
644 $scoringOptionAnyKeyword->
addSubItem( $anyKeyword );
651 $allKeyword->setValues( self::buildAnswerTextOnlyArray( $this->object->getAnswers() ) );
652 $scoringOptionAllKeyword->
addSubItem( $allKeyword );
653 $allKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points" ),
"all_keyword_points");
655 $allKeywordPoints->setValue( $this->object->getPoints() );
656 $allKeywordPoints->setRequired( TRUE );
657 $allKeywordPoints->setSize( 3 );
658 $allKeywordPoints->setMinValue( 0.0 );
659 $allKeywordPoints->setMinvalueShouldBeGreater(
true );
660 $scoringOptionAllKeyword->
addSubItem( $allKeywordPoints );
667 $oneKeyword->setValues( self::buildAnswerTextOnlyArray( $this->object->getAnswers() ) );
668 $scoringOptionOneKeyword->
addSubItem( $oneKeyword );
669 $oneKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points" ),
"one_keyword_points");
671 $oneKeywordPoints->setValue( $this->object->getPoints() );
672 $oneKeywordPoints->setRequired( TRUE );
673 $oneKeywordPoints->setSize( 3 );
674 $oneKeywordPoints->setMinValue( 0.0 );
675 $oneKeywordPoints->setMinvalueShouldBeGreater(
true );
676 $scoringOptionOneKeyword->
addSubItem( $oneKeywordPoints );
678 $form->
addItem( $scoringMode );