24 include_once 
"./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
 
   25 include_once 
"./Modules/Test/classes/inc.AssessmentConstants.php";
 
   49                 include_once 
"./Modules/TestQuestionPool/classes/class.assFileUpload.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"]);
 
   77                         include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
   78                         $questiontext = 
$_POST[
"question"];
 
   79                         $this->
object->setQuestion($questiontext);
 
   80                         $this->
object->setPoints(
$_POST[
"points"]);
 
   82                         $this->
object->setEstimatedWorkingTime(
 
   87                         $this->
object->setMaxSize(
$_POST[
"maxsize"]);
 
   88                         $this->
object->setAllowedExtensions(
$_POST[
"allowedextensions"]);
 
  104                 $save = ((strcmp($this->ctrl->getCmd(), 
"save") == 0) || (strcmp($this->ctrl->getCmd(), 
"saveEdit") == 0)) ? TRUE : FALSE;
 
  107                 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
 
  109                 $form->setFormAction($this->ctrl->getFormAction($this));
 
  111                 $form->setMultipart(
false);
 
  112                 $form->setTableWidth(
"100%");
 
  113                 $form->setId(
"assfileupload");
 
  119                 $maxsize->
setValue($this->object->getMaxSize());
 
  120                 $maxsize->setInfo($this->lng->txt(
"maxsize_info"));
 
  121                 $maxsize->setSize(10);
 
  122                 $maxsize->setMinValue(0);
 
  125                         $umf = get_cfg_var(
"upload_max_filesize");
 
  127                         $pms = get_cfg_var(
"post_max_size");
 
  130                         $multiplier_a=array(
"K"=>1024, 
"M"=>1024*1024, 
"G"=>1024*1024*1024);
 
  132                         $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
 
  133                         $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
 
  135                         if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
 
  136                         if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
 
  139                         $max_filesize = min($umf, $pms);
 
  141                         if (!$max_filesize) $max_filesize=max($umf, $pms);
 
  143                 $maxsize->setMaxValue($max_filesize);
 
  146                 $maxsize->setRequired(FALSE);
 
  147                 $form->addItem($maxsize);
 
  149                 $allowedextensions = 
new ilTextInputGUI($this->lng->txt(
"allowedextensions"), 
"allowedextensions");
 
  150                 $allowedextensions->
setInfo($this->lng->txt(
"allowedextensions_info"));
 
  151                 $allowedextensions->setValue($this->object->getAllowedExtensions());
 
  152                 $allowedextensions->setRequired(FALSE);
 
  153                 $form->addItem($allowedextensions);
 
  156                 $points->
setValue($this->object->getPoints() > 0 ? $this->
object->getPoints() : 
'');
 
  157                 $points->setRequired(TRUE);
 
  159                 $points->setMinValue(0.0);
 
  160                 $points->setMinvalueShouldBeGreater(
true);
 
  161                 $form->addItem($points);
 
  169                         $form->setValuesByPost();
 
  170                         $errors = !$form->checkInput();
 
  171                         $form->setValuesByPost(); 
 
  172                         if (
$errors) $checkonly = 
false;
 
  175                 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
 
  179         function outQuestionForTest($formaction, $active_id, 
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
 
  181                 $test_output = $this->
getTestOutput($active_id, 
$pass, $is_postponed, $use_post_solutions, $show_feedback); 
 
  182                 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
 
  183                 $this->tpl->setVariable(
"FORMACTION", $formaction);
 
  184                 $this->tpl->setVariable(
"ENCTYPE", 
'enctype="multipart/form-data"');
 
  203                 $graphicalOutput = FALSE,
 
  204                 $result_output = FALSE,
 
  205                 $show_question_only = TRUE,
 
  206                 $show_feedback = FALSE,
 
  207                 $show_correct_solution = FALSE,
 
  208                 $show_manual_scoring = FALSE
 
  212                 $template = 
new ilTemplate(
"tpl.il_as_qpl_fileupload_output_solution.html", TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  215                 if (($active_id > 0) && (!$show_correct_solution))
 
  217                         $solutions =& $this->
object->getSolutionValues($active_id, 
$pass);
 
  218                         include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  223                         $solutions =& $this->
object->getSolutionValues($active_id, 
$pass);
 
  225                         $files = ($show_manual_scoring) ? $this->object->getUploadedFilesForWeb($active_id, 
$pass) : $this->
object->getUploadedFiles($active_id, 
$pass);
 
  228                                 include_once 
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
 
  230                                 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'), 
'icon_file.gif', $this->lng->txt(
'already_delivered_files'));
 
  231                                 $table_gui->setData(
$files);
 
  232                                 $table_gui->setRowTemplate(
"tpl.il_as_qpl_fileupload_file_view_row.html", 
"Modules/TestQuestionPool");
 
  233                                 $table_gui->setSelectAllCheckbox(
"");
 
  234                                 $table_gui->clearCommandButtons();
 
  235                                 $table_gui->disable(
'select_all');
 
  236                                 $table_gui->disable(
'numinfo');
 
  237                                 $template->setCurrentBlock(
"files");
 
  238                                 $template->setVariable(
'FILES', $table_gui->getHTML()); 
 
  239                                 $template->parseCurrentBlock();
 
  243                 if (($active_id > 0) && (!$show_correct_solution))
 
  245                         $reached_points = $this->
object->getReachedPoints($active_id, 
$pass);
 
  246                         if ($graphicalOutput)
 
  249                                 if ($reached_points == $this->object->getMaximumPoints())
 
  251                                         $template->setCurrentBlock(
"icon_ok");
 
  253                                         $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
 
  254                                         $template->parseCurrentBlock();
 
  258                                         $template->setCurrentBlock(
"icon_ok");
 
  259                                         if ($reached_points > 0)
 
  262                                                 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
 
  267                                                 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
 
  269                                         $template->parseCurrentBlock();
 
  275                         $reached_points = $this->
object->getPoints();
 
  280                         $resulttext = ($reached_points == 1) ? 
"(%s " . $this->lng->txt(
"point") . 
")" : 
"(%s " . $this->lng->txt(
"points") . 
")"; 
 
  281                         $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
 
  283                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
 
  285                 $questionoutput = $template->get();
 
  286                 $solutiontemplate = 
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  288                 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
 
  289                 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
 
  290                 $solutionoutput = $solutiontemplate->get(); 
 
  291                 if (!$show_question_only)
 
  296                 return $solutionoutput;
 
  301                 $template = 
new ilTemplate(
"tpl.il_as_qpl_fileupload_output.html",TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  302                 if (strlen($this->object->getAllowedExtensions()))
 
  304                         $template->setCurrentBlock(
"allowed_extensions");
 
  305                         $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") . 
": " . $this->
object->getAllowedExtensions()));
 
  306                         $template->parseCurrentBlock();
 
  308                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE));
 
  309                 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
 
  310                 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
 
  311                 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') . 
": " . $this->
object->getMaxFilesizeAsString()));
 
  313                 $questionoutput = $template->get();
 
  314                 if (!$show_question_only)
 
  319                 return $questionoutput;
 
  322         function getTestOutput($active_id, 
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
 
  325                 $template = 
new ilTemplate(
"tpl.il_as_qpl_fileupload_output.html",TRUE, TRUE, 
"Modules/TestQuestionPool");
 
  330                         include_once 
"./Modules/Test/classes/class.ilObjTest.php";
 
  335                         $solutions =& $this->
object->getSolutionValues($active_id, 
$pass);
 
  337                         $files = $this->
object->getUploadedFiles($active_id, 
$pass);
 
  340                                 include_once 
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
 
  342                                 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'), 
'icon_file.gif', $this->lng->txt(
'already_delivered_files'));
 
  343                                 $table_gui->setData(
$files);
 
  344                                 $template->setCurrentBlock(
"files");
 
  345                                 $template->setVariable(
'FILES', $table_gui->getHTML()); 
 
  346                                 $template->parseCurrentBlock();
 
  350                 if (strlen($this->object->getAllowedExtensions()))
 
  352                         $template->setCurrentBlock(
"allowed_extensions");
 
  353                         $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") . 
": " . $this->
object->getAllowedExtensions()));
 
  354                         $template->parseCurrentBlock();
 
  356                 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE));
 
  357                 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
 
  358                 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
 
  359                 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') . 
": " . $this->
object->getMaxFilesizeAsString()));
 
  361                 $questionoutput = $template->get();
 
  362                 if (!$show_question_only)
 
  367                 $questionoutput = $template->get();
 
  368                 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
 
  379                 include_once 
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
 
  381                 $this->
object->saveFeedbackGeneric(0, 
$_POST[
"feedback_incomplete"]);
 
  382                 $this->
object->saveFeedbackGeneric(1, 
$_POST[
"feedback_complete"]);
 
  383                 $this->
object->cleanupMediaObjectUsage();
 
  394                 global $rbacsystem, $ilTabs;
 
  396                 $this->ctrl->setParameterByClass(
"ilpageobjectgui", 
"q_id", 
$_GET[
"q_id"]);
 
  397                 include_once 
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
 
  398                 $q_type = $this->
object->getQuestionType();
 
  402                         $classname = $q_type . 
"GUI";
 
  403                         $this->ctrl->setParameterByClass(strtolower($classname), 
"sel_question_types", $q_type);
 
  404                         $this->ctrl->setParameterByClass(strtolower($classname), 
"q_id", 
$_GET[
"q_id"]);
 
  409                         if ($rbacsystem->checkAccess(
'write', 
$_GET[
"ref_id"]))
 
  412                                 $ilTabs->addTarget(
"edit_content",
 
  413                                         $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI", 
"edit"),
 
  414                                         array(
"edit", 
"insert", 
"exec_pg"),
 
  415                                         "", 
"", $force_active);
 
  419                         $ilTabs->addTarget(
"preview",
 
  420                                 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI", 
"preview"),
 
  422                                 "ilPageObjectGUI", 
"", $force_active);
 
  425                 $force_active = 
false;
 
  426                 if ($rbacsystem->checkAccess(
'write', 
$_GET[
"ref_id"]))
 
  429                         if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname, 
"editQuestion");
 
  431                         $ilTabs->addTarget(
"edit_properties",
 
  433                                 array(
"editQuestion", 
"save", 
"cancel", 
"saveEdit"),
 
  439                         $ilTabs->addTarget(
"feedback",
 
  440                                 $this->ctrl->getLinkTargetByClass($classname, 
"feedback"),
 
  441                                 array(
"feedback", 
"saveFeedback"),
 
  447                         $ilTabs->addTarget(
"solution_hint",
 
  448                                 $this->ctrl->getLinkTargetByClass($classname, 
"suggestedsolution"),
 
  449                                 array(
"suggestedsolution", 
"saveSuggestedSolution", 
"outSolutionExplorer", 
"cancel", 
 
  450                                 "addSuggestedSolution",
"cancelExplorer", 
"linkChilds", 
"removeSuggestedSolution" 
  460                         $ilTabs->addTarget(
"statistics",
 
  461                                 $this->ctrl->getLinkTargetByClass($classname, 
"assessment"),
 
  466                 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
 
  470                         $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), 
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
 
  474                         $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui", 
"questions"));