24 include_once 
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
 
   25 include_once 
"./Modules/Test/classes/inc.AssessmentConstants.php";
 
   51                 include_once 
"./Modules/TestQuestionPool/classes/class.assTextSubset.php";
 
   55                         $this->
object->loadFromDb($id);
 
   72                 $hasErrors = (!$always) ? $this->
editQuestion(
true) : 
false;
 
   75                         $this->
object->setTitle(
$_POST[
"title"]);
 
   76                         $this->
object->setAuthor(
$_POST[
"author"]);
 
   77                         $this->
object->setComment(
$_POST[
"comment"]);
 
   80                                 $this->
object->setNrOfTries(
$_POST[
'nr_of_tries']);
 
   84                         $this->
object->setEstimatedWorkingTime(
 
   89                         include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
   90                         $questiontext = 
$_POST[
"question"];
 
   91                         $this->
object->setQuestion($questiontext);
 
   92                         $this->
object->setCorrectAnswers(
$_POST[
"correctanswers"]);
 
   93                         $this->
object->setTextRating(
$_POST[
"text_rating"]);
 
   95                         $this->
object->flushAnswers();
 
   96                         foreach (
$_POST[
'answers'][
'answer'] as $index => $answer)
 
   98                                 $answertext = $answer;
 
   99                                 $this->
object->addAnswer($answertext, 
$_POST[
'answers'][
'points'][$index], $index);
 
  119                 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
 
  121                 $form->setFormAction($this->ctrl->getFormAction($this));
 
  123                 $form->setMultipart(FALSE);
 
  124                 $form->setTableWidth(
"100%");
 
  125                 $form->setId(
"asstextsubset");
 
  130                 $correctanswers = 
new ilNumberInputGUI($this->lng->txt(
"nr_of_correct_answers"), 
"correctanswers");
 
  132                 $correctanswers->setDecimals(0);
 
  133                 $correctanswers->setSize(3);
 
  134                 $correctanswers->setValue($this->object->getCorrectAnswers());
 
  135                 $correctanswers->setRequired(
true);
 
  136                 $form->addItem($correctanswers);
 
  139                 $points = 
new ilNumberInputGUI($this->lng->txt(
"maximum_points"), 
"points");
 
  141                 $points->setMinvalueShouldBeGreater(
true);
 
  143                 $points->setDisabled(
true);
 
  144                 $points->setValue($this->object->getMaximumPoints());
 
  145                 $points->setRequired(
false);
 
  146                 $form->addItem($points);
 
  149                 $textrating = 
new ilSelectInputGUI($this->lng->txt(
"text_rating"), 
"text_rating");
 
  150                 $text_options = array(
 
  151                         "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
 
  152                         "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive")
 
  156                         $text_options[
"l1"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"1");
 
  157                         $text_options[
"l2"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"2");
 
  158                         $text_options[
"l3"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"3");
 
  159                         $text_options[
"l4"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"4");
 
  160                         $text_options[
"l5"] = sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"5");
 
  163                 $textrating->setValue($this->object->getTextRating());
 
  164                 $form->addItem($textrating);
 
  167                 include_once 
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
 
  170                 $choices->setQuestionObject($this->
object);
 
  171                 $choices->setSingleline(
true);
 
  172                 $choices->setAllowMove(
false);
 
  173                 $choices->setMinValue(0.0);
 
  174                 if ($this->object->getAnswerCount() == 0) $this->object->addAnswer(
"", 0, 0);
 
  175                 $choices->setValues($this->object->getAnswers());
 
  176                 $form->addItem($choices);
 
  184                         $form->setValuesByPost();
 
  185                         $points->setValue($this->object->getMaximumPoints());
 
  186                         $errors = !$form->checkInput();
 
  187                         $form->setValuesByPost(); 
 
  188                         if (
$errors) $checkonly = 
false;
 
  191                 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
 
  201                 $position = key(
$_POST[
'cmd'][
'addanswers']);
 
  202                 $this->
object->addAnswer(
"", 0, $position+1);
 
  212                 $position = key(
$_POST[
'cmd'][
'removeanswers']);
 
  213                 $this->
object->deleteAnswer($position);
 
  219                 $test_output = $this->
getTestOutput($active_id, 
$pass, $is_postponed, $use_post_solutions); 
 
  220                 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
 
  221                 $this->tpl->setVariable(
"FORMACTION", $formaction);
 
  240                 $graphicalOutput = FALSE,
 
  241                 $result_output = FALSE,
 
  242                 $show_question_only = TRUE,
 
  243                 $show_feedback = FALSE,
 
  244                 $show_correct_solution = FALSE,
 
  245                 $show_manual_scoring = FALSE,
 
  246                 $show_question_text = TRUE
 
  250                 $solutions = array();
 
  251                 if (($active_id > 0) && (!$show_correct_solution))
 
  253                         $solutions =& $this->
object->getSolutionValues($active_id, 
$pass);
 
  258                         foreach ($this->object->answers as $answer)
 
  260                                 if ($answer->getPoints() > 0)
 
  262                                         if (!is_array($rank[$answer->getPoints()]))
 
  264                                                 $rank[$answer->getPoints()] = array();
 
  266                                         array_push($rank[$answer->getPoints()], $answer->getAnswertext());
 
  269                         krsort($rank, SORT_NUMERIC);
 
  270                         foreach ($rank as $index => $bestsolutions)
 
  272                                 array_push($solutions, array(
"value1" => join(
",", $bestsolutions), 
"points" => $index));
 
  277                 include_once 
"./Services/UICore/classes/class.ilTemplate.php";
 
  278                 $template = 
new ilTemplate(
"tpl.il_as_qpl_textsubset_output_solution.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  279                 $solutiontemplate = 
new ilTemplate(
"tpl.il_as_tst_solution_output.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  280                 $available_answers =& $this->
object->getAvailableAnswers();
 
  281                 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
 
  283                         if ((!$test_id) && (strcmp($solutions[$i][
"value1"], 
"") == 0))
 
  288                                 if (($active_id > 0) && (!$show_correct_solution))
 
  290                                         if ($graphicalOutput)
 
  293                                                 $index = $this->
object->isAnswerCorrect($available_answers, $solutions[$i][
"value1"]);
 
  295                                                 if ($index !== FALSE)
 
  297                                                         unset($available_answers[$index]);
 
  302                                                         $template->setCurrentBlock(
"icon_ok");
 
  304                                                         $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
 
  305                                                         $template->parseCurrentBlock();
 
  309                                                         $template->setCurrentBlock(
"icon_ok");
 
  311                                                         $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
 
  312                                                         $template->parseCurrentBlock();
 
  316                                 $template->setCurrentBlock(
"textsubset_row");
 
  317                                 $template->setVariable(
"SOLUTION", $solutions[$i][
"value1"]);
 
  318                                 $template->setVariable(
"COUNTER", $i+1);
 
  321                                         $points = $solutions[$i][
"points"];
 
  322                                         $resulttext = ($points == 1) ? 
"(%s " . $this->lng->txt(
"point") . 
")" : 
"(%s " . $this->lng->txt(
"points") . 
")"; 
 
  323                                         $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
 
  325                                 $template->parseCurrentBlock();
 
  328                 $questiontext = $this->
object->getQuestion();
 
  329                 if ($show_question_text==
true)
 
  331                         $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
  333                 $questionoutput = $template->get();
 
  335                 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback, 
true));
 
  336                 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
 
  338                 $solutionoutput = $solutiontemplate->get(); 
 
  339                 if (!$show_question_only)
 
  342                         $solutionoutput = 
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
 
  344                 return $solutionoutput;
 
  350                 include_once 
"./Services/UICore/classes/class.ilTemplate.php";
 
  351                 $template = 
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  352                 $width = $this->
object->getMaxTextboxWidth();
 
  353                 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
 
  355                         $template->setCurrentBlock(
"textsubset_row");
 
  356                         $template->setVariable(
"COUNTER", $i+1);
 
  357                         $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
 
  358                         $template->setVariable(
"TEXTFIELD_SIZE", $width);
 
  359                         $template->parseCurrentBlock();
 
  361                 $questiontext = $this->
object->getQuestion();
 
  362                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
  363                 $questionoutput = $template->get();
 
  364                 if (!$show_question_only)
 
  369                 return $questionoutput;
 
  379                         include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  384                         $solutions =& $this->
object->getSolutionValues($active_id, 
$pass);
 
  388                 include_once 
"./Services/UICore/classes/class.ilTemplate.php";
 
  389                 $template = 
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  390                 $width = $this->
object->getMaxTextboxWidth();
 
  391                 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
 
  393                         $template->setCurrentBlock(
"textsubset_row");
 
  394                         foreach ($solutions as $idx => $solution_value)
 
  401                         $template->setVariable(
"COUNTER", $i+1);
 
  402                         $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
 
  403                         $template->setVariable(
"TEXTFIELD_SIZE", $width);
 
  404                         $template->parseCurrentBlock();
 
  406                 $questiontext = $this->
object->getQuestion();
 
  407                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
  408                 $questionoutput = $template->get();
 
  409                 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
 
  420                 include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
  422                 $this->
object->saveFeedbackGeneric(0, 
$_POST[
"feedback_incomplete"]);
 
  423                 $this->
object->saveFeedbackGeneric(1, 
$_POST[
"feedback_complete"]);
 
  424                 $this->
object->cleanupMediaObjectUsage();
 
  437                 global $rbacsystem, $ilTabs;
 
  439                 $this->ctrl->setParameterByClass(
"ilpageobjectgui", 
"q_id", 
$_GET[
"q_id"]);
 
  440                 include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  441                 $q_type = $this->
object->getQuestionType();
 
  445                         $classname = $q_type . 
"GUI";
 
  446                         $this->ctrl->setParameterByClass(strtolower($classname), 
"sel_question_types", $q_type);
 
  447                         $this->ctrl->setParameterByClass(strtolower($classname), 
"q_id", 
$_GET[
"q_id"]);
 
  452                         if ($rbacsystem->checkAccess(
'write', 
$_GET[
"ref_id"]))
 
  455                                 $ilTabs->addTarget(
"edit_page",
 
  456                                         $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI", 
"edit"),
 
  457                                         array(
"edit", 
"insert", 
"exec_pg"),
 
  458                                         "", 
"", $force_active);
 
  462                         $ilTabs->addTarget(
"preview",
 
  463                                 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI", 
"preview"),
 
  465                                 "ilPageObjectGUI", 
"", $force_active);
 
  468                 $force_active = 
false;
 
  469                 if ($rbacsystem->checkAccess(
'write', 
$_GET[
"ref_id"]))
 
  472                         if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, 
"editQuestion");
 
  474                         $ilTabs->addTarget(
"edit_question",
 
  476                                 array(
"editQuestion", 
"save", 
"saveEdit", 
"addanswers", 
"removeanswers", 
"originalSyncForm"),
 
  477                                 $classname, 
"", $force_active);
 
  482                         $ilTabs->addTarget(
"feedback",
 
  483                                 $this->ctrl->getLinkTargetByClass($classname, 
"feedback"),
 
  484                                 array(
"feedback", 
"saveFeedback"),
 
  493                         $ilTabs->addTarget(
"solution_hint",
 
  494                                 $this->ctrl->getLinkTargetByClass($classname, 
"suggestedsolution"),
 
  495                                 array(
"suggestedsolution", 
"saveSuggestedSolution", 
"outSolutionExplorer", 
"cancel", 
 
  496                                 "addSuggestedSolution",
"cancelExplorer", 
"linkChilds", 
"removeSuggestedSolution" 
  506                         $ilTabs->addTarget(
"statistics",
 
  507                                 $this->ctrl->getLinkTargetByClass($classname, 
"assessment"),
 
  512                 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
 
  517                         global $___test_express_mode;
 
  519                         if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
 
  520                             $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), 
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
 
  524                             $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
 
  529                         $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui", 
"questions"));
 
  536                 return $this->
object->prepareTextareaOutput($output, TRUE);