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.assFileUpload.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"]);
78 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
79 $questiontext =
$_POST[
"question"];
80 $this->
object->setQuestion($questiontext);
81 $this->
object->setPoints(
$_POST[
"points"]);
83 $this->
object->setEstimatedWorkingTime(
88 $this->
object->setMaxSize(
$_POST[
"maxsize"]);
89 $this->
object->setAllowedExtensions(
$_POST[
"allowedextensions"]);
90 $this->
object->setCompletionBySubmission(
$_POST[
'completion_by_submission'] == 1 ?
true :
false);
109 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
111 $form->setFormAction($this->ctrl->getFormAction($this));
113 $form->setMultipart(
false);
114 $form->setTableWidth(
"100%");
115 $form->setId(
"assfileupload");
121 $maxsize->
setValue($this->object->getMaxSize());
122 $maxsize->setInfo($this->lng->txt(
"maxsize_info"));
123 $maxsize->setSize(10);
124 $maxsize->setMinValue(0);
127 $umf = get_cfg_var(
"upload_max_filesize");
129 $pms = get_cfg_var(
"post_max_size");
132 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
134 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
135 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
137 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
138 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
141 $max_filesize = min($umf, $pms);
143 if (!$max_filesize) $max_filesize=max($umf, $pms);
145 $maxsize->setMaxValue($max_filesize);
148 $maxsize->setRequired(FALSE);
149 $form->addItem($maxsize);
151 $allowedextensions =
new ilTextInputGUI($this->lng->txt(
"allowedextensions"),
"allowedextensions");
152 $allowedextensions->
setInfo($this->lng->txt(
"allowedextensions_info"));
153 $allowedextensions->setValue($this->object->getAllowedExtensions());
154 $allowedextensions->setRequired(FALSE);
155 $form->addItem($allowedextensions);
158 $points->
setValue(is_numeric($this->object->getPoints()) && $this->object->getPoints() >= 0 ? $this->
object->getPoints() :
'');
159 $points->setRequired(TRUE);
161 $points->setMinValue(0.0);
162 $points->setMinvalueShouldBeGreater(
false);
163 $form->addItem($points);
165 $subcompl =
new ilCheckboxInputGUI($this->lng->txt(
'ass_completion_by_submission'),
'completion_by_submission');
166 $subcompl->
setInfo($this->lng->txt(
'ass_completion_by_submission_info'));
167 $subcompl->setValue(1);
168 $subcompl->setChecked($this->object->isCompletionBySubmissionEnabled());
169 $form->addItem($subcompl);
177 $form->setValuesByPost();
178 $errors = !$form->checkInput();
179 $form->setValuesByPost();
180 if (
$errors) $checkonly =
false;
183 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
187 function outQuestionForTest($formaction, $active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
189 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions, $show_feedback);
190 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
191 $this->tpl->setVariable(
"FORMACTION", $formaction);
192 $this->tpl->setVariable(
"ENCTYPE",
'enctype="multipart/form-data"');
211 $graphicalOutput = FALSE,
212 $result_output = FALSE,
213 $show_question_only = TRUE,
214 $show_feedback = FALSE,
215 $show_correct_solution = FALSE,
216 $show_manual_scoring = FALSE,
217 $show_question_text = TRUE
221 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
224 if (($active_id > 0) && (!$show_correct_solution))
226 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
227 include_once
"./Modules/Test/classes/class.ilObjTest.php";
232 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
234 $files = ($show_manual_scoring) ? $this->object->getUploadedFilesForWeb($active_id,
$pass) : $this->
object->getUploadedFiles($active_id,
$pass);
237 include_once
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
239 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'),
'icon_file.png', $this->lng->txt(
'already_delivered_files'));
240 $table_gui->setData($files);
241 $table_gui->setRowTemplate(
"tpl.il_as_qpl_fileupload_file_view_row.html",
"Modules/TestQuestionPool");
242 $table_gui->setSelectAllCheckbox(
"");
243 $table_gui->clearCommandButtons();
244 $table_gui->disable(
'select_all');
245 $table_gui->disable(
'numinfo');
246 $template->setCurrentBlock(
"files");
247 $template->setVariable(
'FILES', $table_gui->getHTML());
248 $template->parseCurrentBlock();
252 if (($active_id > 0) && (!$show_correct_solution))
254 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
255 if ($graphicalOutput)
258 if ($reached_points == $this->object->getMaximumPoints())
260 $template->setCurrentBlock(
"icon_ok");
262 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
263 $template->parseCurrentBlock();
267 $template->setCurrentBlock(
"icon_ok");
268 if ($reached_points > 0)
271 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
276 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
278 $template->parseCurrentBlock();
284 $reached_points = $this->
object->getPoints();
289 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
290 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
292 if ($show_question_text==
true)
294 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
296 $questionoutput = $template->get();
297 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
299 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput($feedback,
true));
300 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
301 $solutionoutput = $solutiontemplate->get();
302 if (!$show_question_only)
305 $solutionoutput =
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
307 return $solutionoutput;
312 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
313 if (strlen($this->object->getAllowedExtensions()))
315 $template->setCurrentBlock(
"allowed_extensions");
316 $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") .
": " . $this->
object->getAllowedExtensions()));
317 $template->parseCurrentBlock();
319 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE));
320 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
321 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
322 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') .
": " . $this->
object->getMaxFilesizeAsString()));
324 $questionoutput = $template->get();
325 if (!$show_question_only)
330 return $questionoutput;
333 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
336 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
341 include_once
"./Modules/Test/classes/class.ilObjTest.php";
346 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
348 $files = $this->
object->getUploadedFiles($active_id,
$pass);
351 include_once
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
353 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'),
'icon_file.png', $this->lng->txt(
'already_delivered_files'));
354 $table_gui->setData($files);
355 $template->setCurrentBlock(
"files");
356 $template->setVariable(
'FILES', $table_gui->getHTML());
357 $template->parseCurrentBlock();
361 if (strlen($this->object->getAllowedExtensions()))
363 $template->setCurrentBlock(
"allowed_extensions");
364 $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") .
": " . $this->
object->getAllowedExtensions()));
365 $template->parseCurrentBlock();
367 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE));
368 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
369 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
370 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') .
": " . $this->
object->getMaxFilesizeAsString()));
372 $questionoutput = $template->get();
373 if (!$show_question_only)
378 $questionoutput = $template->get();
379 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
390 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
392 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
393 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
394 $this->
object->cleanupMediaObjectUsage();
407 global $rbacsystem, $ilTabs;
409 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
410 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
411 $q_type = $this->
object->getQuestionType();
415 $classname = $q_type .
"GUI";
416 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
417 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
422 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
425 $ilTabs->addTarget(
"edit_page",
426 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
427 array(
"edit",
"insert",
"exec_pg"),
428 "",
"", $force_active);
432 $ilTabs->addTarget(
"preview",
433 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
435 "ilPageObjectGUI",
"", $force_active);
438 $force_active =
false;
439 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
442 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
444 $ilTabs->addTarget(
"edit_question",
446 array(
"editQuestion",
"save",
"cancel",
"saveEdit"),
452 $ilTabs->addTarget(
"feedback",
453 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
454 array(
"feedback",
"saveFeedback"),
463 $ilTabs->addTarget(
"solution_hint",
464 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
465 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
466 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
476 $ilTabs->addTarget(
"statistics",
477 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
482 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
487 global $___test_express_mode;
489 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
490 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
494 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
499 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
506 return $this->
object->prepareTextareaOutput($output, TRUE);