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);
123 $maxsize->setMaxValue($this->object->getMaxFilesizeInBytes());
124 $maxsize->setRequired(FALSE);
125 $form->addItem($maxsize);
127 $allowedextensions =
new ilTextInputGUI($this->lng->txt(
"allowedextensions"),
"allowedextensions");
128 $allowedextensions->
setInfo($this->lng->txt(
"allowedextensions_info"));
129 $allowedextensions->setValue($this->object->getAllowedExtensions());
130 $allowedextensions->setRequired(FALSE);
131 $form->addItem($allowedextensions);
134 $points->setValue($this->object->getPoints());
146 $form->setValuesByPost();
147 $errors = !$form->checkInput();
148 $form->setValuesByPost();
149 if (
$errors) $checkonly =
false;
152 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
156 function outQuestionForTest($formaction, $active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
158 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions, $show_feedback);
159 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
160 $this->tpl->setVariable(
"FORMACTION", $formaction);
161 $this->tpl->setVariable(
"ENCTYPE",
'enctype="multipart/form-data"');
180 $graphicalOutput = FALSE,
181 $result_output = FALSE,
182 $show_question_only = TRUE,
183 $show_feedback = FALSE,
184 $show_correct_solution = FALSE,
185 $show_manual_scoring = FALSE
189 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
192 if (($active_id > 0) && (!$show_correct_solution))
194 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
195 include_once
"./Modules/Test/classes/class.ilObjTest.php";
200 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
202 $files = ($show_manual_scoring) ? $this->object->getUploadedFilesForWeb($active_id,
$pass) : $this->
object->getUploadedFiles($active_id,
$pass);
205 include_once
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
207 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'),
'icon_file.gif', $this->lng->txt(
'already_delivered_files'));
208 $table_gui->setData(
$files);
209 $table_gui->setRowTemplate(
"tpl.il_as_qpl_fileupload_file_view_row.html",
"Modules/TestQuestionPool");
210 $table_gui->setSelectAllCheckbox(
"");
211 $table_gui->clearCommandButtons();
212 $table_gui->disable(
'select_all');
213 $table_gui->disable(
'numinfo');
214 $template->setCurrentBlock(
"files");
215 $template->setVariable(
'FILES', $table_gui->getHTML());
216 $template->parseCurrentBlock();
220 if (($active_id > 0) && (!$show_correct_solution))
222 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
223 if ($graphicalOutput)
226 if ($reached_points == $this->object->getMaximumPoints())
228 $template->setCurrentBlock(
"icon_ok");
230 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
231 $template->parseCurrentBlock();
235 $template->setCurrentBlock(
"icon_ok");
236 if ($reached_points > 0)
239 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
244 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
246 $template->parseCurrentBlock();
252 $reached_points = $this->
object->getPoints();
257 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
258 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
260 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
262 $questionoutput = $template->get();
263 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
265 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
266 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
267 $solutionoutput = $solutiontemplate->get();
268 if (!$show_question_only)
273 return $solutionoutput;
278 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
279 if (strlen($this->object->getAllowedExtensions()))
281 $template->setCurrentBlock(
"allowed_extensions");
282 $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") .
": " . $this->
object->getAllowedExtensions()));
283 $template->parseCurrentBlock();
285 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE));
286 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
287 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
288 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') .
": " . $this->
object->getMaxFilesizeAsString()));
290 $questionoutput = $template->get();
291 if (!$show_question_only)
296 return $questionoutput;
299 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
302 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
307 include_once
"./Modules/Test/classes/class.ilObjTest.php";
312 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
314 $files = $this->
object->getUploadedFiles($active_id,
$pass);
317 include_once
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
319 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'),
'icon_file.gif', $this->lng->txt(
'already_delivered_files'));
320 $table_gui->setData(
$files);
321 $template->setCurrentBlock(
"files");
322 $template->setVariable(
'FILES', $table_gui->getHTML());
323 $template->parseCurrentBlock();
327 if (strlen($this->object->getAllowedExtensions()))
329 $template->setCurrentBlock(
"allowed_extensions");
330 $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") .
": " . $this->
object->getAllowedExtensions()));
331 $template->parseCurrentBlock();
333 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE));
334 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
335 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
336 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') .
": " . $this->
object->getMaxFilesizeAsString()));
338 $questionoutput = $template->get();
339 if (!$show_question_only)
344 $questionoutput = $template->get();
345 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
356 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
358 $this->
object->saveFeedbackGeneric(0,
$_POST[
"feedback_incomplete"]);
359 $this->
object->saveFeedbackGeneric(1,
$_POST[
"feedback_complete"]);
360 $this->
object->cleanupMediaObjectUsage();
371 global $rbacsystem, $ilTabs;
373 $this->ctrl->setParameterByClass(
"ilpageobjectgui",
"q_id",
$_GET[
"q_id"]);
374 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
375 $q_type = $this->
object->getQuestionType();
379 $classname = $q_type .
"GUI";
380 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
381 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
386 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
389 $ilTabs->addTarget(
"edit_content",
390 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"edit"),
391 array(
"edit",
"insert",
"exec_pg"),
392 "",
"", $force_active);
396 $ilTabs->addTarget(
"preview",
397 $this->ctrl->getLinkTargetByClass(
"ilPageObjectGUI",
"preview"),
399 "ilPageObjectGUI",
"", $force_active);
402 $force_active =
false;
403 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
406 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
408 $ilTabs->addTarget(
"edit_properties",
410 array(
"editQuestion",
"save",
"cancel",
"saveEdit"),
416 $ilTabs->addTarget(
"feedback",
417 $this->ctrl->getLinkTargetByClass($classname,
"feedback"),
418 array(
"feedback",
"saveFeedback"),
424 $ilTabs->addTarget(
"solution_hint",
425 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
426 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
427 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
437 $ilTabs->addTarget(
"statistics",
438 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
443 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
447 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
451 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));