24 include_once 
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
 
   25 include_once 
"./Modules/Test/classes/inc.AssessmentConstants.php";
 
   50                 include_once 
"./Modules/TestQuestionPool/classes/class.assTextSubset.php";
 
   54                         $this->
object->loadFromDb($id);
 
   71                 $hasErrors = (!$always) ? $this->
editQuestion(
true) : 
false;
 
   74                         $this->
object->setTitle(
$_POST[
"title"]);
 
   75                         $this->
object->setAuthor(
$_POST[
"author"]);
 
   76                         $this->
object->setComment(
$_POST[
"comment"]);
 
   79                         $this->
object->setEstimatedWorkingTime(
 
   85                         include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
   86                         $questiontext = 
$_POST[
"question"];
 
   87                         $this->
object->setQuestion($questiontext);
 
   88                         $this->
object->setCorrectAnswers(
$_POST[
"correctanswers"]);
 
   89                         $this->
object->setTextRating(
$_POST[
"text_rating"]);
 
   91                         $this->
object->flushAnswers();
 
   92                         foreach (
$_POST[
'answers'][
'answer'] as $index => $answer)
 
   94                                 $answertext = $answer;
 
   95                                 $this->
object->addAnswer($answertext, 
$_POST[
'answers'][
'points'][$index], $index);
 
  112                 $save = ((strcmp($this->ctrl->getCmd(), 
"save") == 0) || (strcmp($this->ctrl->getCmd(), 
"saveEdit") == 0)) ? TRUE : FALSE;
 
  115                 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
 
  117                 $form->setFormAction($this->ctrl->getFormAction($this));
 
  119                 $form->setMultipart(FALSE);
 
  120                 $form->setTableWidth(
"100%");
 
  121                 $form->setId(
"asstextsubset");
 
  126                 $correctanswers = 
new ilNumberInputGUI($this->lng->txt(
"nr_of_correct_answers"), 
"correctanswers");
 
  128                 $correctanswers->setDecimals(0);
 
  129                 $correctanswers->setSize(3);
 
  130                 $correctanswers->setValue($this->object->getCorrectAnswers());
 
  131                 $correctanswers->setRequired(
true);
 
  132                 $form->addItem($correctanswers);
 
  135                 $points = 
new ilNumberInputGUI($this->lng->txt(
"maximum_points"), 
"points");
 
  138                 $points->setDisabled(
true);
 
  139                 $points->setValue($this->object->getMaximumPoints());
 
  140                 $points->setRequired(
false);
 
  141                 $form->addItem($points);
 
  144                 $textrating = 
new ilSelectInputGUI($this->lng->txt(
"text_rating"), 
"text_rating");
 
  145                 $text_options = array(
 
  146                         "ci" => $this->lng->txt(
"cloze_textgap_case_insensitive"),
 
  147                         "cs" => $this->lng->txt(
"cloze_textgap_case_sensitive"),
 
  148                         "l1" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"1"),
 
  149                         "l2" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"2"),
 
  150                         "l3" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"3"),
 
  151                         "l4" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"4"),
 
  152                         "l5" => sprintf($this->lng->txt(
"cloze_textgap_levenshtein_of"), 
"5")
 
  154                 $textrating->setOptions($text_options);
 
  155                 $textrating->setValue($this->object->getTextRating());
 
  156                 $form->addItem($textrating);
 
  159                 include_once 
"./Modules/TestQuestionPool/classes/class.ilAnswerWizardInputGUI.php";
 
  162                 $choices->setQuestionObject($this->
object);
 
  163                 $choices->setSingleline(
true);
 
  164                 $choices->setAllowMove(
false);
 
  165                 if ($this->object->getAnswerCount() == 0) $this->object->addAnswer(
"", 0, 0);
 
  166                 $choices->setValues($this->object->getAnswers());
 
  167                 $form->addItem($choices);
 
  175                         $form->setValuesByPost();
 
  176                         $points->setValue($this->object->getMaximumPoints());
 
  177                         $errors = !$form->checkInput();
 
  178                         $form->setValuesByPost(); 
 
  179                         if (
$errors) $checkonly = 
false;
 
  182                 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
 
  192                 $position = key(
$_POST[
'cmd'][
'addanswers']);
 
  193                 $this->
object->addAnswer(
"", 0, $position+1);
 
  203                 $position = key(
$_POST[
'cmd'][
'removeanswers']);
 
  204                 $this->
object->deleteAnswer($position);
 
  210                 $test_output = $this->
getTestOutput($active_id, 
$pass, $is_postponed, $use_post_solutions); 
 
  211                 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
 
  212                 $this->tpl->setVariable(
"FORMACTION", $formaction);
 
  231                 $graphicalOutput = FALSE,
 
  232                 $result_output = FALSE,
 
  233                 $show_question_only = TRUE,
 
  234                 $show_feedback = FALSE,
 
  235                 $show_correct_solution = FALSE,
 
  236                 $show_manual_scoring = FALSE
 
  240                 $solutions = array();
 
  241                 if (($active_id > 0) && (!$show_correct_solution))
 
  243                         $solutions =& $this->
object->getSolutionValues($active_id, 
$pass);
 
  248                         foreach ($this->object->answers as $answer)
 
  250                                 if ($answer->getPoints() > 0)
 
  252                                         if (!is_array($rank[$answer->getPoints()]))
 
  254                                                 $rank[$answer->getPoints()] = array();
 
  256                                         array_push($rank[$answer->getPoints()], $answer->getAnswertext());
 
  259                         krsort($rank, SORT_NUMERIC);
 
  260                         foreach ($rank as $index => $bestsolutions)
 
  262                                 array_push($solutions, array(
"value1" => join(
",", $bestsolutions), 
"points" => $index));
 
  267                 include_once 
"./classes/class.ilTemplate.php";
 
  268                 $template = 
new ilTemplate(
"tpl.il_as_qpl_textsubset_output_solution.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  269                 $solutiontemplate = 
new ilTemplate(
"tpl.il_as_tst_solution_output.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  270                 $available_answers =& $this->
object->getAvailableAnswers();
 
  271                 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
 
  273                         if ((!$test_id) && (strcmp($solutions[$i][
"value1"], 
"") == 0))
 
  278                                 if (($active_id > 0) && (!$show_correct_solution))
 
  280                                         if ($graphicalOutput)
 
  283                                                 $index = $this->
object->isAnswerCorrect($available_answers, $solutions[$i][
"value1"]);
 
  285                                                 if ($index !== FALSE)
 
  287                                                         unset($available_answers[$index]);
 
  292                                                         $template->setCurrentBlock(
"icon_ok");
 
  294                                                         $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
 
  295                                                         $template->parseCurrentBlock();
 
  299                                                         $template->setCurrentBlock(
"icon_ok");
 
  301                                                         $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
 
  302                                                         $template->parseCurrentBlock();
 
  306                                 $template->setCurrentBlock(
"textsubset_row");
 
  307                                 $template->setVariable(
"SOLUTION", $solutions[$i][
"value1"]);
 
  308                                 $template->setVariable(
"COUNTER", $i+1);
 
  311                                         $points = $solutions[$i][
"points"];
 
  312                                         $resulttext = ($points == 1) ? 
"(%s " . $this->lng->txt(
"point") . 
")" : 
"(%s " . $this->lng->txt(
"points") . 
")"; 
 
  313                                         $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $points));
 
  315                                 $template->parseCurrentBlock();
 
  318                 $questiontext = $this->
object->getQuestion();
 
  319                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
  320                 $questionoutput = $template->get();
 
  322                 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
 
  323                 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
 
  325                 $solutionoutput = $solutiontemplate->get(); 
 
  326                 if (!$show_question_only)
 
  331                 return $solutionoutput;
 
  337                 include_once 
"./classes/class.ilTemplate.php";
 
  338                 $template = 
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  339                 $width = $this->
object->getMaxTextboxWidth();
 
  340                 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
 
  342                         $template->setCurrentBlock(
"textsubset_row");
 
  343                         $template->setVariable(
"COUNTER", $i+1);
 
  344                         $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
 
  345                         $template->setVariable(
"TEXTFIELD_SIZE", $width);
 
  346                         $template->parseCurrentBlock();
 
  348                 $questiontext = $this->
object->getQuestion();
 
  349                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
  350                 $questionoutput = $template->get();
 
  351                 if (!$show_question_only)
 
  356                 return $questionoutput;
 
  366                         include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  371                         $solutions =& $this->
object->getSolutionValues($active_id, 
$pass);
 
  375                 include_once 
"./classes/class.ilTemplate.php";
 
  376                 $template = 
new ilTemplate(
"tpl.il_as_qpl_textsubset_output.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  377                 $width = $this->
object->getMaxTextboxWidth();
 
  378                 for ($i = 0; $i < $this->
object->getCorrectAnswers(); $i++)
 
  380                         $template->setCurrentBlock(
"textsubset_row");
 
  381                         foreach ($solutions as $idx => $solution_value)
 
  385                                         $template->setVariable(
"TEXTFIELD_VALUE", 
" value=\"" . $solution_value[
"value1"].
"\"");
 
  388                         $template->setVariable(
"COUNTER", $i+1);
 
  389                         $template->setVariable(
"TEXTFIELD_ID", sprintf(
"%02d", $i+1));
 
  390                         $template->setVariable(
"TEXTFIELD_SIZE", $width);
 
  391                         $template->parseCurrentBlock();
 
  393                 $questiontext = $this->
object->getQuestion();
 
  394                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
 
  395                 $questionoutput = $template->get();
 
  396                 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
 
  407                 include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
  409                 $this->
object->saveFeedbackGeneric(0, 
$_POST[
"feedback_incomplete"]);
 
  410                 $this->
object->saveFeedbackGeneric(1, 
$_POST[
"feedback_complete"]);
 
  411                 $this->
object->cleanupMediaObjectUsage();
 
  422                 global $rbacsystem, $ilTabs;
 
  424                 $this->ctrl->setParameterByClass(
"ilpageobjectgui", 
"q_id", 
$_GET[
"q_id"]);
 
  425                 include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  426                 $q_type = $this->
object->getQuestionType();
 
  430                         $classname = $q_type . 
"GUI";
 
  431                         $this->ctrl->setParameterByClass(strtolower($classname), 
"sel_question_types", $q_type);
 
  432                         $this->ctrl->setParameterByClass(strtolower($classname), 
"q_id", 
$_GET[
"q_id"]);
 
  437                         if ($rbacsystem->checkAccess(
'write', 
$_GET[
"ref_id"]))
 
  440                                 $ilTabs->addTarget(
"edit_content",
 
  441                                         $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI", 
"edit"),
 
  442                                         array(
"edit", 
"insert", 
"exec_pg"),
 
  443                                         "", 
"", $force_active);
 
  447                         $ilTabs->addTarget(
"preview",
 
  448                                 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI", 
"preview"),
 
  450                                 "ilPageObjectGUI", 
"", $force_active);
 
  453                 $force_active = 
false;
 
  454                 if ($rbacsystem->checkAccess(
'write', 
$_GET[
"ref_id"]))
 
  457                         if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, 
"editQuestion");
 
  459                         $ilTabs->addTarget(
"edit_properties",
 
  461                                 array(
"editQuestion", 
"save", 
"saveEdit", 
"addanswers", 
"removeanswers", 
"originalSyncForm"),
 
  462                                 $classname, 
"", $force_active);
 
  467                         $ilTabs->addTarget(
"feedback",
 
  468                                 $this->ctrl->getLinkTargetByClass($classname, 
"feedback"),
 
  469                                 array(
"feedback", 
"saveFeedback"),
 
  475                         $ilTabs->addTarget(
"solution_hint",
 
  476                                 $this->ctrl->getLinkTargetByClass($classname, 
"suggestedsolution"),
 
  477                                 array(
"suggestedsolution", 
"saveSuggestedSolution", 
"outSolutionExplorer", 
"cancel", 
 
  478                                 "addSuggestedSolution",
"cancelExplorer", 
"linkChilds", 
"removeSuggestedSolution" 
  488                         $ilTabs->addTarget(
"statistics",
 
  489                                 $this->ctrl->getLinkTargetByClass($classname, 
"assessment"),
 
  494                 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
 
  498                         $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), 
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
 
  502                         $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui", 
"questions"));