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;
56 require_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
67 $this->
object->setPoints(
$_POST[
"points"] );
68 $this->
object->setMaxSize(
$_POST[
"maxsize"] );
69 $this->
object->setAllowedExtensions(
$_POST[
"allowedextensions"] );
70 $this->
object->setCompletionBySubmission(
$_POST[
'completion_by_submission'] == 1 ?
true :
false );
83 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
85 $form->setFormAction($this->ctrl->getFormAction($this));
87 $form->setMultipart(
false);
88 $form->setTableWidth(
"100%");
89 $form->setId(
"assfileupload");
101 $form->setValuesByPost();
102 $errors = !$form->checkInput();
103 $form->setValuesByPost();
105 if (
$errors) $checkonly =
false;
108 if (!$checkonly) $this->tpl->setVariable(
"QUESTION_DATA", $form->getHTML());
116 $maxsize->
setValue( $this->object->getMaxSize() );
117 $maxsize->setInfo( $this->lng->txt(
"maxsize_info" ) );
118 $maxsize->setSize( 10 );
119 $maxsize->setMinValue( 0 );
121 $maxsize->setRequired( FALSE );
125 $allowedextensions =
new ilTextInputGUI($this->lng->txt(
"allowedextensions" ),
"allowedextensions");
126 $allowedextensions->
setInfo( $this->lng->txt(
"allowedextensions_info" ) );
127 $allowedextensions->setValue( $this->object->getAllowedExtensions() );
128 $allowedextensions->setRequired( FALSE );
129 $form->
addItem( $allowedextensions );
134 $points->setValue( is_numeric( $this->object->getPoints() ) && $this->object->getPoints(
135 ) >= 0 ? $this->
object->getPoints() :
''
137 $points->setRequired( TRUE );
138 $points->setSize( 3 );
139 $points->setMinValue( 0.0 );
140 $points->setMinvalueShouldBeGreater(
false );
144 ),
'completion_by_submission');
145 $subcompl->
setInfo( $this->lng->txt(
'ass_completion_by_submission_info' ) );
146 $subcompl->setValue( 1 );
147 $subcompl->setChecked( $this->object->isCompletionBySubmissionEnabled() );
158 $upload_max_filesize = get_cfg_var(
"upload_max_filesize" );
160 $post_max_size = get_cfg_var(
"post_max_size" );
163 $multiplier_a = array(
"K" => 1024,
"M" => 1024 * 1024,
"G" => 1024 * 1024 * 1024 );
164 $umf_parts = preg_split(
"/(\d+)([K|G|M])/",
165 $upload_max_filesize,
167 PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
169 $pms_parts = preg_split(
"/(\d+)([K|G|M])/",
172 PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
175 if (count( $umf_parts ) == 2)
177 $upload_max_filesize = $umf_parts[0] * $multiplier_a[$umf_parts[1]];
180 if (count( $pms_parts ) == 2)
182 $post_max_size = $pms_parts[0] * $multiplier_a[$pms_parts[1]];
186 $max_filesize = min( $upload_max_filesize, $post_max_size );
190 $max_filesize = max( $upload_max_filesize, $post_max_size );
191 return $max_filesize;
193 return $max_filesize;
212 $graphicalOutput = FALSE,
213 $result_output = FALSE,
214 $show_question_only = TRUE,
215 $show_feedback = FALSE,
216 $show_correct_solution = FALSE,
217 $show_manual_scoring = FALSE,
218 $show_question_text = TRUE
222 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output_solution.html", TRUE, TRUE,
"Modules/TestQuestionPool");
225 if (($active_id > 0) && (!$show_correct_solution))
227 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
228 include_once
"./Modules/Test/classes/class.ilObjTest.php";
233 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
235 $files = ($show_manual_scoring) ? $this->object->getUploadedFilesForWeb($active_id,
$pass) : $this->
object->getUploadedFiles($active_id,
$pass);
238 include_once
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
240 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'),
'icon_file.svg', $this->lng->txt(
'already_delivered_files'));
241 $table_gui->setData($files);
242 $table_gui->setRowTemplate(
"tpl.il_as_qpl_fileupload_file_view_row.html",
"Modules/TestQuestionPool");
243 $table_gui->setSelectAllCheckbox(
"");
244 $table_gui->clearCommandButtons();
245 $table_gui->disable(
'select_all');
246 $table_gui->disable(
'numinfo');
247 $template->setCurrentBlock(
"files");
248 $template->setVariable(
'FILES', $table_gui->getHTML());
249 $template->parseCurrentBlock();
253 if (($active_id > 0) && (!$show_correct_solution))
255 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
256 if ($graphicalOutput)
259 if ($reached_points == $this->object->getMaximumPoints())
261 $template->setCurrentBlock(
"icon_ok");
263 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
264 $template->parseCurrentBlock();
268 $template->setCurrentBlock(
"icon_ok");
269 if ($reached_points > 0)
272 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
277 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
279 $template->parseCurrentBlock();
285 $reached_points = $this->
object->getPoints();
290 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
291 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
293 if ($show_question_text==
true)
295 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
297 $questionoutput = $template->get();
298 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
300 if (strlen($feedback)) $solutiontemplate->setVariable(
"FEEDBACK", $feedback);
301 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
302 $solutionoutput = $solutiontemplate->get();
303 if (!$show_question_only)
308 return $solutionoutput;
311 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
313 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
320 include_once
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
322 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'),
'icon_file.svg', $this->lng->txt(
'already_delivered_files'));
323 $table_gui->setData($files);
324 $template->setCurrentBlock(
"files");
325 $template->setVariable(
'FILES', $table_gui->getHTML());
326 $template->parseCurrentBlock();
330 if (strlen($this->object->getAllowedExtensions()))
332 $template->setCurrentBlock(
"allowed_extensions");
333 $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") .
": " . $this->
object->getAllowedExtensions()));
334 $template->parseCurrentBlock();
336 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE));
338 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
339 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
340 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') .
" " . $this->
object->getMaxFilesizeAsString()));
342 $questionoutput = $template->get();
343 if (!$show_question_only)
348 return $questionoutput;
351 function getTestOutput($active_id,
$pass = NULL, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
354 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
359 include_once
"./Modules/Test/classes/class.ilObjTest.php";
364 $solutions =& $this->
object->getSolutionValues($active_id,
$pass);
366 $files = $this->
object->getUploadedFiles($active_id,
$pass);
369 include_once
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
371 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'),
'icon_file.svg', $this->lng->txt(
'already_delivered_files'));
372 $table_gui->setData($files);
373 $template->setCurrentBlock(
"files");
374 $template->setVariable(
'FILES', $table_gui->getHTML());
375 $template->parseCurrentBlock();
379 if (strlen($this->object->getAllowedExtensions()))
381 $template->setCurrentBlock(
"allowed_extensions");
382 $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") .
": " . $this->
object->getAllowedExtensions()));
383 $template->parseCurrentBlock();
385 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE));
387 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
388 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
389 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') .
" " . $this->
object->getMaxFilesizeAsString()));
391 $questionoutput = $template->get();
392 if (!$show_question_only)
397 $questionoutput = $template->get();
398 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
411 global $rbacsystem, $ilTabs;
413 $ilTabs->clearTargets();
415 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
416 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
417 $q_type = $this->
object->getQuestionType();
421 $classname = $q_type .
"GUI";
422 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
423 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
428 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
431 $ilTabs->addTarget(
"edit_page",
432 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
433 array(
"edit",
"insert",
"exec_pg"),
434 "",
"", $force_active);
440 $force_active =
false;
441 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
444 if ($classname) $url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
446 $ilTabs->addTarget(
"edit_question",
448 array(
"editQuestion",
"save",
"cancel",
"saveEdit"),
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);