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';
34 parent::__construct();
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);
236 include_once
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
238 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'),
'icon_file.svg', $this->lng->txt(
'already_delivered_files'));
239 $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();
251 if (strlen($this->object->getAllowedExtensions()))
253 $template->setCurrentBlock(
"allowed_extensions");
254 $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") .
": " . $this->
object->getAllowedExtensions()));
255 $template->parseCurrentBlock();
258 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
259 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
260 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') .
" " . $this->
object->getMaxFilesizeAsString()));
262 if (($active_id > 0) && (!$show_correct_solution))
264 $reached_points = $this->
object->getReachedPoints($active_id,
$pass);
265 if ($graphicalOutput)
268 if ($reached_points == $this->object->getMaximumPoints())
270 $template->setCurrentBlock(
"icon_ok");
272 $template->setVariable(
"TEXT_OK", $this->lng->txt(
"answer_is_right"));
273 $template->parseCurrentBlock();
277 $template->setCurrentBlock(
"icon_ok");
278 if ($reached_points > 0)
281 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_not_correct_but_positive"));
286 $template->setVariable(
"TEXT_NOT_OK", $this->lng->txt(
"answer_is_wrong"));
288 $template->parseCurrentBlock();
294 $reached_points = $this->
object->getPoints();
299 $resulttext = ($reached_points == 1) ?
"(%s " . $this->lng->txt(
"point") .
")" :
"(%s " . $this->lng->txt(
"points") .
")";
300 $template->setVariable(
"RESULT_OUTPUT", sprintf($resulttext, $reached_points));
302 if ($show_question_text==
true)
304 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->getQuestion(), TRUE));
306 $questionoutput = $template->get();
307 $solutiontemplate =
new ilTemplate(
"tpl.il_as_tst_solution_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
309 if (strlen($feedback))
315 $solutiontemplate->setVariable(
"ILC_FB_CSS_CLASS", $cssClass);
316 $solutiontemplate->setVariable(
"FEEDBACK", $this->object->prepareTextareaOutput( $feedback,
true ));
318 $solutiontemplate->setVariable(
"SOLUTION_OUTPUT", $questionoutput);
319 $solutionoutput = $solutiontemplate->get();
320 if (!$show_question_only)
325 return $solutionoutput;
328 function getPreview($show_question_only = FALSE, $showInlineFeedback =
false)
330 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
335 include_once
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
337 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'),
'icon_file.svg', $this->lng->txt(
'already_delivered_files'));
338 $table_gui->setData($files);
340 $template->setCurrentBlock(
"files");
341 $template->setVariable(
'FILES', $table_gui->getHTML());
342 $template->parseCurrentBlock();
345 if (strlen($this->object->getAllowedExtensions()))
347 $template->setCurrentBlock(
"allowed_extensions");
348 $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") .
": " . $this->
object->getAllowedExtensions()));
349 $template->parseCurrentBlock();
351 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE));
353 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
354 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
355 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') .
" " . $this->
object->getMaxFilesizeAsString()));
357 $questionoutput = $template->get();
358 if (!$show_question_only)
363 return $questionoutput;
367 function getTestOutput($active_id,
$pass, $is_postponed = FALSE, $use_post_solutions = FALSE, $show_feedback = FALSE)
371 $template =
new ilTemplate(
"tpl.il_as_qpl_fileupload_output.html",TRUE, TRUE,
"Modules/TestQuestionPool");
377 #include_once "./Modules/Test/classes/class.ilObjTest.php"; 378 #if (!ilObjTest::_getUsePreviousAnswers($active_id, true)) 380 # if (is_null($pass)) $pass = ilObjTest::_getPass($active_id); 384 include_once
"./Modules/TestQuestionPool/classes/tables/class.assFileUploadFileTableGUI.php";
386 $table_gui->setTitle($this->lng->txt(
'already_delivered_files'),
'icon_file.svg', $this->lng->txt(
'already_delivered_files'));
387 $table_gui->setData($files);
389 $template->setCurrentBlock(
"files");
390 $template->setVariable(
'FILES', $table_gui->getHTML());
391 $template->parseCurrentBlock();
394 if (strlen($this->object->getAllowedExtensions()))
396 $template->setCurrentBlock(
"allowed_extensions");
397 $template->setVariable(
"TXT_ALLOWED_EXTENSIONS", $this->object->prepareTextareaOutput($this->lng->txt(
"allowedextensions") .
": " . $this->
object->getAllowedExtensions()));
398 $template->parseCurrentBlock();
400 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($this->object->question, TRUE));
402 $template->setVariable(
"TEXT_UPLOAD", $this->object->prepareTextareaOutput($this->lng->txt(
'upload')));
403 $template->setVariable(
"TXT_UPLOAD_FILE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_add')));
404 $template->setVariable(
"TXT_MAX_SIZE", $this->object->prepareTextareaOutput($this->lng->txt(
'file_notice') .
" " . $this->
object->getMaxFilesizeAsString()));
406 $questionoutput = $template->get();
407 if (!$show_question_only)
412 $questionoutput = $template->get();
413 $pageoutput = $this->
outQuestionPage(
"", $is_postponed, $active_id, $questionoutput);
426 global $rbacsystem, $ilTabs;
428 $ilTabs->clearTargets();
430 $this->ctrl->setParameterByClass(
"ilAssQuestionPageGUI",
"q_id",
$_GET[
"q_id"]);
431 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
432 $q_type = $this->
object->getQuestionType();
436 $classname = $q_type .
"GUI";
437 $this->ctrl->setParameterByClass(strtolower($classname),
"sel_question_types", $q_type);
438 $this->ctrl->setParameterByClass(strtolower($classname),
"q_id",
$_GET[
"q_id"]);
443 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
446 $ilTabs->addTarget(
"edit_page",
447 $this->ctrl->getLinkTargetByClass(
"ilAssQuestionPageGUI",
"edit"),
448 array(
"edit",
"insert",
"exec_pg"),
449 "",
"", $force_active);
455 $force_active =
false;
456 if ($rbacsystem->checkAccess(
'write',
$_GET[
"ref_id"]))
459 if ($classname)
$url = $this->ctrl->getLinkTargetByClass($classname,
"editQuestion");
461 $ilTabs->addTarget(
"edit_question",
463 array(
"editQuestion",
"save",
"cancel",
"saveEdit"),
479 $ilTabs->addTarget(
"statistics",
480 $this->ctrl->getLinkTargetByClass($classname,
"assessment"),
485 if ((
$_GET[
"calling_test"] > 0) || (
$_GET[
"test_ref_id"] > 0))
490 global $___test_express_mode;
492 if (!
$_GET[
'test_express_mode'] && !$___test_express_mode) {
493 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"),
"ilias.php?baseClass=ilObjTestGUI&cmd=questions&ref_id=$ref_id");
497 $ilTabs->setBackTarget($this->lng->txt(
"backtocallingtest"), $link);
502 $ilTabs->setBackTarget($this->lng->txt(
"qpl"), $this->ctrl->getLinkTargetByClass(
"ilobjquestionpoolgui",
"questions"));
509 return $this->
object->prepareTextareaOutput($output, TRUE);
542 return self::FORM_ENCODING_MULTIPART;
isTestPresentationContext()
hasCorrectSolution($activeId, $passIndex)
addTab_QuestionPreview(ilTabsGUI $tabsGUI)
addBasicQuestionFormProperties($form)
Add basic question form properties: assessment: title, author, description, question, working time.
addTab_QuestionHints(ilTabsGUI $tabs)
adds the hints tab to ilTabsGUI
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
getPreview($show_question_only=FALSE, $showInlineFeedback=false)
getTestOutputSolutions($activeId, $pass)
getQuestionTemplate()
get question template
const CSS_CLASS_FEEDBACK_CORRECT
writeQuestionSpecificPostData(ilPropertyFormGUI $form)
Extracts the question specific values from $_POST and applies them to the data object.
Class for file upload questions.
populateTaxonomyFormSection(ilPropertyFormGUI $form)
getAggregatedAnswersView($relevant_answers)
Returns an html string containing a question specific representation of the answers so far given in t...
writePostData($always=false)
Evaluates a posted edit form and writes the form data in the question object.
writeQuestionGenericPostData()
static getReturnToPageLink($q_id=null)
setQuestionTabs()
Sets the ILIAS tabs for this question type.
getILIASPage($html="")
Returns the ILIAS Page around a question.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
addTab_QuestionFeedback(ilTabsGUI $tabs)
adds the feedback tab to ilTabsGUI
const CSS_CLASS_FEEDBACK_WRONG
Basic GUI class for assessment questions.
populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
Adds the question specific forms parts to a question property form gui.
setErrorMessage($errormessage)
_getUsePreviousAnswers($active_id, $user_active_user_setting=false)
Returns if the previous results should be hidden for a learner.
The assFileUploadGUI class encapsulates the GUI representation for file upload questions.
getAnswerFeedbackOutput($active_id, $pass)
Returns the answer generic feedback depending on the results of the question.
getSpecificFeedbackOutput($active_id, $pass)
editQuestion($checkonly=FALSE)
Creates an output of the edit form for the question.
saveTaxonomyAssignments()
getTestOutput($active_id, $pass, $is_postponed=FALSE, $use_post_solutions=FALSE, $show_feedback=FALSE)
__construct($id=-1)
assFileUploadGUI constructor
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="")
output question page
Interface ilGuiQuestionScoringAdjustable.
getAfterParticipationSuppressionQuestionPostVars()
Returns a list of postvars which will be suppressed in the form output when used in scoring adjustmen...
getSolutionOutput( $active_id, $pass=NULL, $graphicalOutput=FALSE, $result_output=FALSE, $show_question_only=TRUE, $show_feedback=FALSE, $show_correct_solution=FALSE, $show_manual_scoring=FALSE, $show_question_text=TRUE)
Get the question solution output.
addTab_SuggestedSolution(ilTabsGUI $tabs, $classname)
addQuestionFormCommandButtons($form)
Add the command buttons of a question properties form.