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';
35 require_once
'./Modules/TestQuestionPool/classes/class.assTextSubset.php';
39 $this->
object->loadFromDb($id);
52 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
72 require_once
'./Services/Form/classes/class.ilPropertyFormGUI.php';
74 $form->setFormAction($this->ctrl->getFormAction($this));
76 $form->setMultipart(FALSE);
77 $form->setTableWidth(
"100%");
78 $form->setId(
"asstextsubset");
89 $form->setValuesByPost();
90 $points = $form->getItemByPostVar(
'points');
91 $points->setValue($this->object->getMaximumPoints());
93 $form->setValuesByPost();
94 if (
$errors) $checkonly =
false;
97 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
107 $position = key(
$_POST[
'cmd'][
'addanswers']);
108 $this->
object->addAnswer(
"", 0, $position+1);
118 $position = key(
$_POST[
'cmd'][
'removeanswers']);
119 $this->
object->deleteAnswer($position);
125 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions);
126 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
127 $this->tpl->setVariable(
"FORMACTION", $formaction);
146 $graphicalOutput = FALSE,
147 $result_output = FALSE,
148 $show_question_only = TRUE,
149 $show_feedback = FALSE,
150 $show_correct_solution = FALSE,
151 $show_manual_scoring = FALSE,
152 $show_question_text = TRUE
156 $solutions = array();
157 if (($active_id > 0) && (!$show_correct_solution))
159 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
164 foreach ($this->object->answers as $answer)
166 if ($answer->getPoints() > 0)
168 if (!is_array($rank[$answer->getPoints()]))
170 $rank[$answer->getPoints()] = array();
172 array_push($rank[$answer->getPoints()], $answer->getAnswertext());
175 krsort($rank, SORT_NUMERIC);
176 foreach ($rank as $index => $bestsolutions)
178 array_push($solutions, array(
"value1" => join(
",", $bestsolutions),
"points" => $index));
183 include_once
"./Services/UICore/classes/class.ilTemplate.php";
184 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
185 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
186 $available_answers =& $this->
object->getAvailableAnswers();
187 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
189 if ((!$test_id) && (strcmp($solutions[$i][
"value1"],
"") == 0))
194 if (($active_id > 0) && (!$show_correct_solution))
196 if ($graphicalOutput)
199 $index = $this->
object->isAnswerCorrect($available_answers, $solutions[$i][
"value1"]);
201 if ($index !== FALSE)
203 unset($available_answers[$index]);
208 $template->setCurrentBlock(
"icon_ok");
210 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
211 $template->parseCurrentBlock();
215 $template->setCurrentBlock(
"icon_ok");
217 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
218 $template->parseCurrentBlock();
222 $template->setCurrentBlock(
"textsubset_row");
223 $template->setVariable(
"SOLUTION", $solutions[$i][
"value1"]);
224 $template->setVariable(
"COUNTER", $i+1);
227 $points = $solutions[$i][
"points"];
228 $resulttext = ($points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
229 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
231 $template->parseCurrentBlock();
234 $questiontext = $this->
object->getQuestion();
235 if ($show_question_text==
true)
237 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
239 $questionoutput = $template->get();
241 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true));
242 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
244 $solutionoutput = $solutiontemplate->get();
245 if (!$show_question_only)
248 $solutionoutput =
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
250 return $solutionoutput;
256 include_once
"./Services/UICore/classes/class.ilTemplate.php";
257 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
258 $width = $this->
object->getMaxTextboxWidth();
259 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
261 $template->setCurrentBlock(
"textsubset_row");
262 $template->setVariable(
"COUNTER", $i+1);
263 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
264 $template->setVariable(
"TEXTFIELD_SIZE", $width);
265 $template->parseCurrentBlock();
267 $questiontext = $this->
object->getQuestion();
268 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
269 $questionoutput = $template->get();
270 if (!$show_question_only)
275 return $questionoutput;
285 include_once
"./Modules/Test/classes/class.ilObjTest.php";
290 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
294 include_once
"./Services/UICore/classes/class.ilTemplate.php";
295 $template =
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE,
"Modules/TestQuestionPool");
296 $width = $this->
object->getMaxTextboxWidth();
297 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
299 $template->setCurrentBlock(
"textsubset_row");
300 foreach ($solutions as $idx => $solution_value)
307 $template->setVariable(
"COUNTER", $i+1);
308 $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
309 $template->setVariable(
"TEXTFIELD_SIZE", $width);
310 $template->parseCurrentBlock();
312 $questiontext = $this->
object->getQuestion();
313 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
314 $questionoutput = $template->get();
315 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
328 global $rbacsystem, $ilTabs;
330 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
331 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
332 $q_type = $this->
object->getQuestionType();
336 $classname = $q_type .
"GUI";
337 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
338 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
343 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
346 $ilTabs->addTarget(
"edit_page",
347 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
348 array(
"edit",
"insert",
"exec_pg"),
349 "",
"", $force_active);
353 $ilTabs->addTarget(
"preview",
354 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"preview"),
356 "ilAssQuestionPageGUI",
"", $force_active);
359 $force_active =
false;
360 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
363 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
365 $ilTabs->addTarget(
"edit_question",
367 array(
"editQuestion",
"save",
"saveEdit",
"addanswers",
"removeanswers",
"originalSyncForm"),
368 $classname,
"", $force_active);
379 $ilTabs->addTarget(
"solution_hint",
380 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
381 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
382 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
392 $ilTabs->addTarget(
"statistics",
393 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
398 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
403 global $___test_express_mode;
405 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
406 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
410 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
415 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
422 return $this->
object->prepareTextareaOutput($output, TRUE);
427 $this->
object->setCorrectAnswers(
$_POST[
"correctanswers"] );
428 $this->
object->setTextRating(
$_POST[
"text_rating"] );
434 $this->
object->flushAnswers();
435 foreach (
$_POST[
'answers'][
'answer'] as $index => $answer)
437 $answertext = $answer;
438 $this->
object->addAnswer( $answertext,
$_POST[
'answers'][
'points'][$index], $index );
445 $correctanswers =
new ilNumberInputGUI($this->lng->txt(
"nr_of_correct_answers" ),
"correctanswers");
447 $correctanswers->setDecimals( 0 );
448 $correctanswers->setSize( 3 );
449 $correctanswers->setValue( $this->object->getCorrectAnswers() );
450 $correctanswers->setRequired(
true );
451 $form->
addItem( $correctanswers );
454 $points =
new ilNumberInputGUI($this->lng->txt(
"maximum_points" ),
"points");
456 $points->setMinvalueShouldBeGreater(
true);
457 $points->setSize( 6 );
458 $points->setDisabled(
true );
459 $points->setValue( $this->object->getMaximumPoints() );
460 $points->setRequired(
false );
464 $textrating =
new ilSelectInputGUI($this->lng->txt(
"text_rating" ),
"text_rating");
465 $text_options = array(
466 "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive" ),
467 "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive" )
469 if (!$this->object->getSelfAssessmentEditingMode())
471 $text_options[
"l1"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"1" );
472 $text_options[
"l2"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"2" );
473 $text_options[
"l3"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"3" );
474 $text_options[
"l4"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"4" );
475 $text_options[
"l5"] = sprintf( $this->lng->txt(
"cloze_textgap_levenshtein_of" ),
"5" );
478 $textrating->setValue( $this->object->getTextRating() );
486 include_once
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
489 $choices->setQuestionObject( $this->
object );
490 $choices->setSingleline(
true );
491 $choices->setAllowMove(
false );
492 $choices->setMinValue(0.0);
493 if ($this->object->getAnswerCount() == 0)
494 $this->object->addAnswer(
"", 0, 0 );
495 $choices->setValues( $this->object->getAnswers() );
526 return array(
'correctanswers');
531 $element = $form->getItemByPostvar(
'correctanswers');
532 $_POST[
'correctanswers'] = $this->
object->getCorrectAnswers();
533 $element->setValue( $this->object->getCorrectAnswers() );
547 foreach($relevant_answers as
$pass)
549 $passes[$pass[
'active_fi'].
'-'.$pass[
'pass']] =
'-';
551 $passcount = count($passes);
553 foreach($relevant_answers as $pass)
555 $actives[$pass[
'active_fi']] = $pass[
'active_fi'];
557 $usercount = count($actives);
558 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_header.html',
true,
true,
"Modules/TestQuestionPool");
559 $tpl->setVariable(
'HEADERTEXT', $this->lng->txt(
'overview'));
560 $tpl->setVariable(
'NUMBER_OF_USERS_INFO', $this->lng->txt(
'number_of_users'));
561 $tpl->setVariable(
'NUMBER_OF_USERS', $usercount);
562 $tpl->setVariable(
'NUMBER_OF_PASSES_INFO', $this->lng->txt(
'number_of_passes'));
563 $tpl->setVariable(
'NUMBER_OF_PASSES', $passcount);
571 $aggregate = array();
573 foreach ($relevant_answers_chosen as $relevant_answer)
575 if ( array_key_exists($relevant_answer[
'value1'], $aggregate) )
577 $aggregate[$relevant_answer[
'value1']]++;
581 $aggregate[$relevant_answer[
'value1']] = 1;
594 $tpl =
new ilTemplate(
'tpl.il_as_aggregated_answers_table.html',
true,
true,
"Modules/TestQuestionPool");
595 $tpl->setVariable(
'OPTION_HEADER', $this->lng->txt(
'answer') );
596 $tpl->setVariable(
'COUNT_HEADER', $this->lng->txt(
'count') );
597 $tpl->setVariable(
'AGGREGATION_HEADER', $this->lng->txt(
'aggregated_answers_header') );
599 foreach ($aggregate as $key => $value)
601 $tpl->setCurrentBlock(
'aggregaterow' );
602 $tpl->setVariable(
'OPTION', $key );
603 $tpl->setVariable(
'COUNT', $value );
604 $tpl->parseCurrentBlock();