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;
54 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
74 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
76 $form->setFormAction($this->ctrl->getFormAction($this));
78 $form->setMultipart(TRUE);
79 $form->setTableWidth(
"100%");
80 $form->setId(
"asstextquestion");
95 $form->setValuesByPost();
97 $form->setValuesByPost();
98 if (
$errors) $checkonly =
false;
101 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
107 $answerTexts = array();
109 foreach($answers as $answer)
111 $answerTexts[] = $answer->getAnswertext();
119 if ($this->object->getMaxNumOfChars() > 0)
121 $this->tpl->addBlockFile(
"CONTENT_BLOCK",
"charcounter",
"tpl.charcounter.html",
"Modules/TestQuestionPool");
122 $this->tpl->setCurrentBlock(
"charcounter");
123 $this->tpl->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
124 $this->tpl->parseCurrentBlock();
130 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
131 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
132 $this->tpl->setVariable(
"FORMACTION", $formaction);
136 include_once
"./Services/RTE/classes/class.ilRTE.php";
138 include_once
"./Services/RTE/classes/class.$rtestring.php";
139 $rte =
new $rtestring();
140 include_once
"./Services/Object/classes/class.ilObject.php";
143 $rte->addUserTextEditor(
"textinput");
165 $graphicalOutput = FALSE,
166 $result_output = FALSE,
167 $show_question_only = TRUE,
168 $show_feedback = FALSE,
169 $show_correct_solution = FALSE,
170 $show_manual_scoring = FALSE,
171 $show_question_text = TRUE
178 if (($active_id > 0) && (!$show_correct_solution))
180 $solution = $user_solution;
188 include_once
"./Services/UICore/classes/class.ilTemplate.php";
189 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
190 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
192 $solution = $this->
object->getHtmlUserSolutionPurifier()->purify($solution);
193 $template->setVariable(
"ESSAY", $this->object->prepareTextareaOutput($solution, TRUE));
195 $questiontext = $this->
object->getQuestion();
197 if (!$show_correct_solution)
199 $max_no_of_chars = $this->
object->getMaxNumOfChars();
201 if ($max_no_of_chars == 0)
203 $max_no_of_chars = ucfirst($this->lng->txt(
'unlimited'));
206 $act_no_of_chars = strlen($user_solution);
207 $template->setVariable(
"CHARACTER_INFO",
'<b>' . $max_no_of_chars .
'</b>' .
208 $this->lng->txt(
'answer_characters') .
' <b>' . $act_no_of_chars .
'</b>');
210 if (($active_id > 0) && (!$show_correct_solution))
212 if ($graphicalOutput)
215 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
216 if ($reached_points == $this->object->getMaximumPoints())
218 $template->setCurrentBlock(
"icon_ok");
220 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
221 $template->parseCurrentBlock();
225 $template->setCurrentBlock(
"icon_ok");
226 if ($reached_points > 0)
229 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
234 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
236 $template->parseCurrentBlock();
240 if ($show_question_text==
true)
242 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
244 $questionoutput = $template->get();
250 $feedback .= strlen($fb) ? $fb :
'';
253 $feedback .= strlen($fb) ? $fb :
'';
255 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
257 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
259 $solutionoutput = $solutiontemplate->get();
260 if (!$show_question_only)
265 return $solutionoutput;
270 $answers = $this->
object->getAnswers();
271 if (count( $answers ))
273 $user_solution = $this->lng->txt(
"solution_contain_keywords" ) .
"<ul>";
275 foreach ($answers as $answer)
277 $user_solution .=
'<li>'. $answer->getAnswertext();
281 $user_solution .=
' ' . $this->lng->txt(
'for') .
' ';
282 $user_solution .= $answer->getPoints() .
' ' . $this->lng->txt(
'points') .
'</li>';
285 $user_solution .=
'</ul>';
287 $user_solution .= $this->lng->txt(
'essay_scoring_mode') .
': ';
289 switch( $this->object->getKeywordRelation() )
292 $user_solution .= $this->lng->txt(
'essay_scoring_mode_keyword_relation_any');
295 $user_solution .= $this->lng->txt(
'essay_scoring_mode_keyword_relation_all');
298 $user_solution .= $this->lng->txt(
'essay_scoring_mode_keyword_relation_one');
302 return $user_solution;
308 $solutions = $this->
object->getSolutionValues( $active_id,
$pass );
309 foreach ($solutions as $idx => $solution_value)
311 $user_solution = $solution_value[
"value1"];
313 return $user_solution;
316 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
319 include_once
"./Services/UICore/classes/class.ilTemplate.php";
320 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
321 if ($this->object->getMaxNumOfChars())
323 $template->setCurrentBlock(
"maximum_char_hint");
324 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
325 $template->parseCurrentBlock();
326 #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
327 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
328 $template->parseCurrentBlock();
329 $template->setCurrentBlock(
"maxchars_counter");
330 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
331 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
332 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
333 $template->parseCurrentBlock();
343 $questiontext = $this->
object->getQuestion();
344 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
345 $questionoutput = $template->get();
346 if (!$show_question_only)
351 return $questionoutput;
361 include_once
"./Modules/Test/classes/class.ilObjTest.php";
366 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
367 foreach ($solutions as $idx => $solution_value)
369 $user_solution = $solution_value[
"value1"];
374 include_once
"./Services/UICore/classes/class.ilTemplate.php";
375 $template =
new ilTemplate(
"tpl.il_as_qpl_text_question_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
376 if ($this->object->getMaxNumOfChars())
378 $template->setCurrentBlock(
"maximum_char_hint");
379 $template->setVariable(
"MAXIMUM_CHAR_HINT", sprintf($this->lng->txt(
"text_maximum_chars_allowed"), $this->
object->getMaxNumOfChars()));
380 $template->parseCurrentBlock();
381 #mbecker: No such block. $template->setCurrentBlock("has_maxchars");
382 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
383 $template->parseCurrentBlock();
384 $template->setCurrentBlock(
"maxchars_counter");
385 $template->setVariable(
"MAXCHARS", $this->object->getMaxNumOfChars());
386 $template->setVariable(
"TEXTBOXSIZE", strlen($this->object->getMaxNumOfChars()));
387 $template->setVariable(
"CHARACTERS", $this->lng->txt(
"characters"));
388 $template->parseCurrentBlock();
391 $questiontext = $this->
object->getQuestion();
392 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
393 $questionoutput = $template->get();
394 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
395 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
403 if (
$_POST[
"cmd"][
"addSuggestedSolution"])
411 if (!$this->checkInput())
413 ilUtil::sendInfo($this->lng->txt(
"fill_out_all_required_fields_add_answer"));
418 $this->
object->saveToDb();
419 $this->ctrl->setParameter($this,
"q_id", $this->object->getId());
420 $this->tpl->setVariable(
"HEADER", $this->object->getTitle());
434 global $rbacsystem, $ilTabs;
436 $ilTabs->clearTargets();
438 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
439 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
440 $q_type = $this->
object->getQuestionType();
444 $classname = $q_type .
"GUI";
445 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
446 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
451 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
454 $ilTabs->addTarget(
"edit_page",
455 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
456 array(
"edit",
"insert",
"exec_pg"),
457 "",
"", $force_active);
463 $force_active =
false;
464 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
467 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
469 $ilTabs->addTarget(
"edit_question",
471 array(
"editQuestion",
"save",
"saveEdit",
"originalSyncForm"),
472 $classname,
"", $force_active);
487 $ilTabs->addTarget(
"statistics",
488 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
498 $feedback =
'<table><tbody>';
499 $user_answers = $this->
object->getSolutionValues($active_id);
500 $user_answer =
' '. $user_answers[0][
'value1'];
502 foreach ($this->object->getAnswers() as $idx => $ans)
504 if ($this->object->isKeywordMatching($user_answer, $ans->getAnswertext() ))
506 $fb = $this->
object->feedbackOBJ->getSpecificAnswerFeedbackTestPresentation(
507 $this->object->getId(), $idx
509 $feedback .=
'<tr><td><b><i>' . $ans->getAnswertext() .
'</i></b></td><td>';
510 $feedback .= $fb .
'</td> </tr>';
514 $feedback .=
'</tbody></table>';
515 return $this->
object->prepareTextareaOutput($feedback, TRUE);
520 $this->
object->setMaxNumOfChars(
$_POST[
"maxchars"] );
521 $this->
object->setTextRating(
$_POST[
"text_rating"] );
522 $this->
object->setKeywordRelation(
$_POST[
'scoring_mode'] );
527 switch ($this->object->getKeywordRelation())
530 $this->
object->setAnswers( array() );
531 $this->
object->setPoints(
$_POST[
'non_keyword_points'] );
534 $this->
object->setAnswers(
$_POST[
'any_keyword'] );
535 $this->
object->setPoints( $this->object->getMaximumPoints() );
538 $this->
object->setAnswers(
$_POST[
'all_keyword'] );
539 $this->
object->setPoints(
$_POST[
'all_keyword_points'] );
542 $this->
object->setAnswers(
$_POST[
'one_keyword'] );
543 $this->
object->setPoints(
$_POST[
'one_keyword_points'] );
551 $maxchars =
new ilNumberInputGUI($this->lng->txt(
"maxchars" ),
"maxchars");
553 if ($this->object->getMaxNumOfChars() > 0)
554 $maxchars->setValue( $this->object->getMaxNumOfChars() );
555 $maxchars->setInfo( $this->lng->txt(
"description_maxchars" ) );
559 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating"),
"text_rating");
560 $text_options = array(
561 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
562 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
563 "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"1"),
564 "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"2"),
565 "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"3"),
566 "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"4"),
567 "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"),
"5")
569 $textrating->setOptions($text_options);
570 $textrating->setValue($this->object->getTextRating());
579 $this->lng->txt(
'essay_scoring_mode' ),
'scoring_mode'
582 $scoringOptionNone =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_without_keywords' ),
583 'non', $this->lng->txt(
'essay_scoring_mode_without_keywords_desc'
586 $scoringOptionAnyKeyword =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_keyword_relation_any' ),
587 'any', $this->lng->txt(
'essay_scoring_mode_keyword_relation_any_desc'
590 $scoringOptionAllKeyword =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_keyword_relation_all' ),
591 'all', $this->lng->txt(
'essay_scoring_mode_keyword_relation_all_desc'
594 $scoringOptionOneKeyword =
new ilRadioOption($this->lng->txt(
'essay_scoring_mode_keyword_relation_one' ),
595 'one', $this->lng->txt(
'essay_scoring_mode_keyword_relation_one_desc'
599 $scoringMode->addOption( $scoringOptionNone );
600 $scoringMode->addOption( $scoringOptionAnyKeyword );
601 $scoringMode->addOption( $scoringOptionAllKeyword );
602 $scoringMode->addOption( $scoringOptionOneKeyword );
603 $scoringMode->setRequired(
true );
604 $scoringMode->
setValue( strlen( $this->object->getKeywordRelation() ) ? $this->object->getKeywordRelation(
608 if ($this->object->getAnswerCount() == 0)
610 $this->
object->addAnswer(
"", 1, 0, 0 );
612 require_once
"./Modules/TestQuestionPool/classes/class.ilEssayKeywordWizardInputGUI.php";
615 $nonKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points" ),
"non_keyword_points");
617 $nonKeywordPoints->setValue( $this->object->getPoints() );
618 $nonKeywordPoints->setRequired( TRUE );
619 $nonKeywordPoints->setSize( 3 );
620 $nonKeywordPoints->setMinValue( 0.0 );
621 $nonKeywordPoints->setMinvalueShouldBeGreater(
true );
622 $scoringOptionNone->
addSubItem( $nonKeywordPoints );
627 $anyKeyword->setQuestionObject( $this->
object );
628 $anyKeyword->setSingleline( TRUE );
629 $anyKeyword->setValues( $this->object->getAnswers() );
630 $scoringOptionAnyKeyword->
addSubItem( $anyKeyword );
637 $allKeyword->setValues( self::buildAnswerTextOnlyArray( $this->object->getAnswers() ) );
638 $scoringOptionAllKeyword->
addSubItem( $allKeyword );
639 $allKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points" ),
"all_keyword_points");
641 $allKeywordPoints->setValue( $this->object->getPoints() );
642 $allKeywordPoints->setRequired( TRUE );
643 $allKeywordPoints->setSize( 3 );
644 $allKeywordPoints->setMinValue( 0.0 );
645 $allKeywordPoints->setMinvalueShouldBeGreater(
true );
646 $scoringOptionAllKeyword->
addSubItem( $allKeywordPoints );
653 $oneKeyword->setValues( self::buildAnswerTextOnlyArray( $this->object->getAnswers() ) );
654 $scoringOptionOneKeyword->
addSubItem( $oneKeyword );
655 $oneKeywordPoints =
new ilNumberInputGUI($this->lng->txt(
"points" ),
"one_keyword_points");
657 $oneKeywordPoints->setValue( $this->object->getPoints() );
658 $oneKeywordPoints->setRequired( TRUE );
659 $oneKeywordPoints->setSize( 3 );
660 $oneKeywordPoints->setMinValue( 0.0 );
661 $oneKeywordPoints->setMinvalueShouldBeGreater(
true );
662 $scoringOptionOneKeyword->
addSubItem( $oneKeywordPoints );
664 $form->
addItem( $scoringMode );