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"]);
89 $this->
object->setCompletionBySubmission(
$_POST[
'completion_by_submission'] == 1 ?
true :
false);
108 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
110 $form->setFormAction($this->ctrl->getFormAction($this));
112 $form->setMultipart(
false);
113 $form->setTableWidth(
"100%");
114 $form->setId(
"assfileupload");
120 $maxsize->
setValue($this->object->getMaxSize());
121 $maxsize->setInfo($this->lng->txt(
"maxsize_info"));
122 $maxsize->setSize(10);
123 $maxsize->setMinValue(0);
126 $umf = get_cfg_var(
"upload_max_filesize");
128 $pms = get_cfg_var(
"post_max_size");
131 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
133 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
134 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
136 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
137 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
140 $max_filesize = min($umf, $pms);
142 if (!$max_filesize) $max_filesize=max($umf, $pms);
144 $maxsize->setMaxValue($max_filesize);
147 $maxsize->setRequired(FALSE);
148 $form->addItem($maxsize);
150 $allowedextensions =
new ilTextInputGUI($this->lng->txt(
"allowedextensions"),
"allowedextensions");
151 $allowedextensions->
setInfo($this->lng->txt(
"allowedextensions_info"));
152 $allowedextensions->setValue($this->object->getAllowedExtensions());
153 $allowedextensions->setRequired(FALSE);
154 $form->addItem($allowedextensions);
157 $points->
setValue(is_numeric($this->object->getPoints()) && $this->object->getPoints() >= 0 ? $this->
object->getPoints() :
'');
158 $points->setRequired(TRUE);
160 $points->setMinValue(0.0);
161 $points->setMinvalueShouldBeGreater(
false);
162 $form->addItem($points);
164 $subcompl =
new ilCheckboxInputGUI($this->lng->txt(
'ass_completion_by_submission'),
'completion_by_submission');
165 $subcompl->
setInfo($this->lng->txt(
'ass_completion_by_submission_info'));
166 $subcompl->setValue(1);
167 $subcompl->setChecked($this->object->isCompletionBySubmissionEnabled());
168 $form->addItem($subcompl);
176 $form->setValuesByPost();
177 $errors = !$form->checkInput();
178 $form->setValuesByPost();
179 if (
$errors) $checkonly =
false;
182 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
186 function outQuestionForTest($formaction, $active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
188 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions, $show_feedback);
189 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
190 $this->tpl->setVariable(
"FORMACTION", $formaction);
191 $this->tpl->setVariable(
"ENCTYPE",
'enctype="multipart/form-data"');
210 $graphicalOutput = FALSE,
211 $result_output = FALSE,
212 $show_question_only = TRUE,
213 $show_feedback = FALSE,
214 $show_correct_solution = FALSE,
215 $show_manual_scoring = FALSE
219 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
222 if (($active_id > 0) && (!$show_correct_solution))
224 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
225 include_once
"./Modules/Test/classes/class.ilObjTest.php";
230 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
232 $files = ($show_manual_scoring) ? $this->object->getUploadedFilesForWeb($active_id,
$pass) : $this->
object->getUploadedFiles($active_id,
$pass);
235 include_once
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
237 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'),
'icon_file.gif', $this->lng->txt(
'already_delivered_files'));
238 $table_gui->setData(
$files);
239 $table_gui->setRowTemplate(
"tpl.il_as_qpl_fileupload_file_view_row.html",
"Modules/TestQuestionPool");
240 $table_gui->setSelectAllCheckbox(
"");
241 $table_gui->clearCommandButtons();
242 $table_gui->disable(
'select_all');
243 $table_gui->disable(
'numinfo');
244 $template->setCurrentBlock(
"files");
245 $template->setVariable(
'FILES', $table_gui->getHTML());
246 $template->parseCurrentBlock();
250 if (($active_id > 0) && (!$show_correct_solution))
252 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
253 if ($graphicalOutput)
256 if ($reached_points == $this->object->getMaximumPoints())
258 $template->setCurrentBlock(
"icon_ok");
260 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
261 $template->parseCurrentBlock();
265 $template->setCurrentBlock(
"icon_ok");
266 if ($reached_points > 0)
269 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
274 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
276 $template->parseCurrentBlock();
282 $reached_points = $this->
object->getPoints();
287 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
288 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
290 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
292 $questionoutput = $template->get();
293 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
295 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
296 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
297 $solutionoutput = $solutiontemplate->get();
298 if (!$show_question_only)
303 return $solutionoutput;
308 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
309 if (strlen($this->object->getAllowedExtensions()))
311 $template->setCurrentBlock(
"allowed_extensions");
312 $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") .
": " . $this->
object->getAllowedExtensions()));
313 $template->parseCurrentBlock();
315 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE));
316 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
317 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
318 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') .
": " . $this->
object->getMaxFilesizeAsString()));
320 $questionoutput = $template->get();
321 if (!$show_question_only)
326 return $questionoutput;
329 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
332 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
337 include_once
"./Modules/Test/classes/class.ilObjTest.php";
342 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
344 $files = $this->
object->getUploadedFiles($active_id,
$pass);
347 include_once
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
349 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'),
'icon_file.gif', $this->lng->txt(
'already_delivered_files'));
350 $table_gui->setData(
$files);
351 $template->setCurrentBlock(
"files");
352 $template->setVariable(
'FILES', $table_gui->getHTML());
353 $template->parseCurrentBlock();
357 if (strlen($this->object->getAllowedExtensions()))
359 $template->setCurrentBlock(
"allowed_extensions");
360 $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") .
": " . $this->
object->getAllowedExtensions()));
361 $template->parseCurrentBlock();
363 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE));
364 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
365 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
366 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') .
": " . $this->
object->getMaxFilesizeAsString()));
368 $questionoutput = $template->get();
369 if (!$show_question_only)
374 $questionoutput = $template->get();
375 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
386 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
388 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
389 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
390 $this->
object->cleanupMediaObjectUsage();
401 global $rbacsystem, $ilTabs;
403 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
404 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
405 $q_type = $this->
object->getQuestionType();
409 $classname = $q_type .
"GUI";
410 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
411 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
416 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
419 $ilTabs->addTarget(
"edit_content",
420 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
421 array(
"edit",
"insert",
"exec_pg"),
422 "",
"", $force_active);
426 $ilTabs->addTarget(
"preview",
427 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
429 "ilPageObjectGUI",
"", $force_active);
432 $force_active =
false;
433 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
436 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
438 $ilTabs->addTarget(
"edit_properties",
440 array(
"editQuestion",
"save",
"cancel",
"saveEdit"),
446 $ilTabs->addTarget(
"feedback",
447 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
448 array(
"feedback",
"saveFeedback"),
454 $ilTabs->addTarget(
"solution_hint",
455 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
456 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
457 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
467 $ilTabs->addTarget(
"statistics",
468 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
473 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
478 global $___test_express_mode;
480 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
481 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
485 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
490 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));