4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
5 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilGuiQuestionScoringAdjustable.php';
35 include_once
"./Modules/TestQuestionPool/classes/class.assFileUpload.php";
40 $this->
object->loadFromDb($id);
53 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
66 $this->
object->setPoints(
$_POST[
"points"] );
67 $this->
object->setMaxSize(
$_POST[
"maxsize"] );
68 $this->
object->setAllowedExtensions(
$_POST[
"allowedextensions"] );
69 $this->
object->setCompletionBySubmission(
$_POST[
'completion_by_submission'] == 1 ?
true :
false );
82 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
84 $form->setFormAction($this->ctrl->getFormAction($this));
86 $form->setMultipart(
false);
87 $form->setTableWidth(
"100%");
88 $form->setId(
"assfileupload");
100 $form->setValuesByPost();
101 $errors = !$form->checkInput();
102 $form->setValuesByPost();
104 if (
$errors) $checkonly =
false;
107 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
115 $maxsize->
setValue( $this->object->getMaxSize() );
116 $maxsize->setInfo( $this->lng->txt(
"maxsize_info" ) );
117 $maxsize->setSize( 10 );
118 $maxsize->setMinValue( 0 );
120 $maxsize->setRequired( FALSE );
124 $allowedextensions =
new ilTextInputGUI($this->lng->txt(
"allowedextensions" ),
"allowedextensions");
125 $allowedextensions->
setInfo( $this->lng->txt(
"allowedextensions_info" ) );
126 $allowedextensions->setValue( $this->object->getAllowedExtensions() );
127 $allowedextensions->setRequired( FALSE );
128 $form->
addItem( $allowedextensions );
132 $points->
setValue( is_numeric( $this->object->getPoints() ) && $this->object->getPoints(
133 ) >= 0 ? $this->
object->getPoints() :
''
135 $points->setRequired( TRUE );
136 $points->setSize( 3 );
137 $points->setMinValue( 0.0 );
138 $points->setMinvalueShouldBeGreater(
false );
142 ),
'completion_by_submission');
143 $subcompl->
setInfo( $this->lng->txt(
'ass_completion_by_submission_info' ) );
144 $subcompl->setValue( 1 );
145 $subcompl->setChecked( $this->object->isCompletionBySubmissionEnabled() );
156 $upload_max_filesize = get_cfg_var(
"upload_max_filesize" );
158 $post_max_size = get_cfg_var(
"post_max_size" );
161 $multiplier_a = array(
"K" => 1024,
"M" => 1024 * 1024,
"G" => 1024 * 1024 * 1024 );
162 $umf_parts = preg_split(
"/(\d+)([K|G|M])/",
163 $upload_max_filesize,
165 PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
167 $pms_parts = preg_split(
"/(\d+)([K|G|M])/",
170 PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
173 if (count( $umf_parts ) == 2)
175 $upload_max_filesize = $umf_parts[0] * $multiplier_a[$umf_parts[1]];
178 if (count( $pms_parts ) == 2)
180 $post_max_size = $pms_parts[0] * $multiplier_a[$pms_parts[1]];
184 $max_filesize = min( $upload_max_filesize, $post_max_size );
188 $max_filesize = max( $upload_max_filesize, $post_max_size );
189 return $max_filesize;
191 return $max_filesize;
194 function outQuestionForTest($formaction, $active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
196 $test_output = $this->
getTestOutput($active_id,
$pass, $is_postponed, $use_post_solutions, $show_feedback);
197 $this->tpl->setVariable(
"QUESTION_OUTPUT", $test_output);
198 $this->tpl->setVariable(
"FORMACTION", $formaction);
199 $this->tpl->setVariable(
"ENCTYPE",
'enctype="multipart/form-data"');
218 $graphicalOutput = FALSE,
219 $result_output = FALSE,
220 $show_question_only = TRUE,
221 $show_feedback = FALSE,
222 $show_correct_solution = FALSE,
223 $show_manual_scoring = FALSE,
224 $show_question_text = TRUE
228 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
231 if (($active_id > 0) && (!$show_correct_solution))
233 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
234 include_once
"./Modules/Test/classes/class.ilObjTest.php";
239 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
241 $files = ($show_manual_scoring) ? $this->object->getUploadedFilesForWeb($active_id,
$pass) : $this->
object->getUploadedFiles($active_id,
$pass);
244 include_once
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
246 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'),
'icon_file.png', $this->lng->txt(
'already_delivered_files'));
247 $table_gui->setData($files);
248 $table_gui->setRowTemplate(
"tpl.il_as_qpl_fileupload_file_view_row.html",
"Modules/TestQuestionPool");
249 $table_gui->setSelectAllCheckbox(
"");
250 $table_gui->clearCommandButtons();
251 $table_gui->disable(
'select_all');
252 $table_gui->disable(
'numinfo');
253 $template->setCurrentBlock(
"files");
254 $template->setVariable(
'FILES', $table_gui->getHTML());
255 $template->parseCurrentBlock();
259 if (($active_id > 0) && (!$show_correct_solution))
261 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
262 if ($graphicalOutput)
265 if ($reached_points == $this->object->getMaximumPoints())
267 $template->setCurrentBlock(
"icon_ok");
269 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
270 $template->parseCurrentBlock();
274 $template->setCurrentBlock(
"icon_ok");
275 if ($reached_points > 0)
278 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
283 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
285 $template->parseCurrentBlock();
291 $reached_points = $this->
object->getPoints();
296 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
297 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
299 if ($show_question_text==
true)
301 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
303 $questionoutput = $template->get();
304 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
306 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
307 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
308 $solutionoutput = $solutiontemplate->get();
309 if (!$show_question_only)
312 $solutionoutput =
'<div class="ilc_question_Standard">'.$solutionoutput.
"</div>";
314 return $solutionoutput;
319 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
320 if (strlen($this->object->getAllowedExtensions()))
322 $template->setCurrentBlock(
"allowed_extensions");
323 $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") .
": " . $this->
object->getAllowedExtensions()));
324 $template->parseCurrentBlock();
326 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE));
327 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
328 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
329 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') .
" " . $this->
object->getMaxFilesizeAsString()));
331 $questionoutput = $template->get();
332 if (!$show_question_only)
337 return $questionoutput;
340 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
343 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
348 include_once
"./Modules/Test/classes/class.ilObjTest.php";
353 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
355 $files = $this->
object->getUploadedFiles($active_id,
$pass);
358 include_once
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
360 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'),
'icon_file.png', $this->lng->txt(
'already_delivered_files'));
361 $table_gui->setData($files);
362 $template->setCurrentBlock(
"files");
363 $template->setVariable(
'FILES', $table_gui->getHTML());
364 $template->parseCurrentBlock();
368 if (strlen($this->object->getAllowedExtensions()))
370 $template->setCurrentBlock(
"allowed_extensions");
371 $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") .
": " . $this->
object->getAllowedExtensions()));
372 $template->parseCurrentBlock();
374 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE));
375 $template->setVariable(
"CMD_UPLOAD",
'handleQuestionAction');
376 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
377 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
378 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') .
" " . $this->
object->getMaxFilesizeAsString()));
380 $questionoutput = $template->get();
381 if (!$show_question_only)
386 $questionoutput = $template->get();
387 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
400 global $rbacsystem, $ilTabs;
402 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
403 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
404 $q_type = $this->
object->getQuestionType();
408 $classname = $q_type .
"GUI";
409 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
410 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
415 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
418 $ilTabs->addTarget(
"edit_page",
419 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
420 array(
"edit",
"insert",
"exec_pg"),
421 "",
"", $force_active);
425 $ilTabs->addTarget(
"preview",
426 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"preview"),
428 "ilAssQuestionPageGUI",
"", $force_active);
431 $force_active =
false;
432 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
435 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
437 $ilTabs->addTarget(
"edit_question",
439 array(
"editQuestion",
"save",
"cancel",
"saveEdit"),
451 $ilTabs->addTarget(
"solution_hint",
452 $this->ctrl->getLinkTargetByClass($classname,
"suggestedsolution"),
453 array(
"suggestedsolution",
"saveSuggestedSolution",
"outSolutionExplorer",
"cancel",
454 "addSuggestedSolution",
"cancelExplorer",
"linkChilds",
"removeSuggestedSolution"
464 $ilTabs->addTarget(
"statistics",
465 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
470 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
475 global $___test_express_mode;
477 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
478 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
482 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
487 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
494 return $this->
object->prepareTextareaOutput($output, TRUE);