4 require_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
5 require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
6 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
7 require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjFileHandlingQuestionType.php';
87 array( $this->
getId() )
90 ) .
" (question_fi, maxsize, allowedextensions, compl_by_submission) VALUES (%s, %s, %s, %s)",
91 array(
"integer",
"float",
"text",
"integer" ),
116 $this->
setId($question_id);
127 include_once(
"./Services/RTE/classes/class.ilRTE.php");
142 parent::loadFromDb($question_id);
156 $this_id = $this->
getId();
160 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
164 if( (
int)$testObjId > 0 )
166 $clone->setObjId($testObjId);
193 $clone->copyPageOfQuestion($this_id);
195 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
197 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
214 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
217 $source_questionpool_id = $this->
getObjId();
218 $clone->setObjId($target_questionpool_id);
230 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
243 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
246 $sourceParentId = $this->
getObjId();
252 $clone->setObjId($targetParentId);
254 if ($targetQuestionTitle)
256 $clone->setTitle($targetQuestionTitle);
261 $clone->copyPageOfQuestion($sourceQuestionId);
263 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
265 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
294 throw new ilTestException(
'return details not implemented for '.__METHOD__);
320 $this->lng->loadLanguageModule(
"form");
322 while (substr($_FILES[
"upload"][
"name"],-1) ==
'/')
324 $_FILES[
"upload"][
"name"] = substr($_FILES[
"upload"][
"name"],0,-1);
328 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
329 $suffix = $filename_arr[
"extension"];
330 $mimetype = $_FILES[
"upload"][
"type"];
331 $size_bytes = $_FILES[
"upload"][
"size"];
332 $temp_name = $_FILES[
"upload"][
"tmp_name"];
333 $error = $_FILES[
"upload"][
"error"];
346 case UPLOAD_ERR_INI_SIZE:
351 case UPLOAD_ERR_FORM_SIZE:
356 case UPLOAD_ERR_PARTIAL:
361 case UPLOAD_ERR_NO_FILE:
366 case UPLOAD_ERR_NO_TMP_DIR:
371 case UPLOAD_ERR_CANT_WRITE:
376 case UPLOAD_ERR_EXTENSION:
394 if (strlen($temp_name))
397 if ($vir[0] ==
false)
411 if (is_null($question_id)) $question_id = $this->
getId();
412 return CLIENT_WEB_DIR .
"/assessment/tst_$test_id/$active_id/$question_id/files/";
420 return CLIENT_WEB_DIR .
"/assessment/qst_preview/$userId/{$this->getId()}/fileuploads/";
430 if (is_null($question_id)) $question_id = $this->
getId();
431 include_once
"./Services/Utilities/classes/class.ilUtil.php";
441 include_once
"./Services/Utilities/classes/class.ilUtil.php";
460 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND authorized = %s ORDER BY tstamp",
461 array(
"integer",
"integer",
"integer",
'integer'),
462 array($active_id, $this->
getId(),
$pass, (
int)$authorized)
469 array_push($found,
$data);
490 $result = $ilDB->queryF(
"SELECT test_fi FROM tst_active WHERE active_id = %s",
499 foreach ($found as $idx =>
$data)
501 $found[$idx][
'webpath'] =
$path;
518 foreach ($files as $solution_id)
520 $result = $ilDB->queryF(
"SELECT * FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
521 array(
"integer",
'integer'),
522 array($solution_id, (
int)$authorized)
528 $active_id =
$data[
'active_fi'];
532 foreach ($files as $solution_id)
534 $affectedRows = $ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
535 array(
"integer",
'integer'),
536 array($solution_id, $authorized)
543 foreach($files as $name)
545 if( isset($userSolution[$name]) )
547 unset($userSolution[$name]);
552 return $userSolution;
565 $max_filesize = sprintf(
"%d Bytes",
$size);
567 else if (
$size < 1024*1024)
569 $max_filesize = sprintf(
"%.1f KB",
$size/1024);
573 $max_filesize = sprintf(
"%.1f MB",
$size/1024/1024);
576 return $max_filesize;
593 $umf = get_cfg_var(
"upload_max_filesize");
595 $pms = get_cfg_var(
"post_max_size");
598 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
600 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
601 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
603 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
604 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
607 $max_filesize = min($umf, $pms);
609 if (!$max_filesize) $max_filesize=max($umf, $pms);
610 return $max_filesize;
629 include_once
"./Modules/Test/classes/class.ilObjTest.php";
633 if(
$_POST[
'cmd'][$this->questionActionCmd] != $this->lng->txt(
'delete')
634 && strlen($_FILES[
"upload"][
"tmp_name"]) )
640 $checkUploadResult =
false;
643 $result = $ilDB->queryF(
"SELECT test_fi FROM tst_active WHERE active_id = %s",
658 $entered_values =
false;
659 if(
$_POST[
'cmd'][$this->questionActionCmd] == $this->lng->txt(
'delete') )
661 if (is_array(
$_POST[
'deletefiles']) && count(
$_POST[
'deletefiles']) > 0)
670 elseif( $checkUploadResult )
678 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
679 $extension = $filename_arr[
"extension"];
680 $newfile =
"file_" . $active_id .
"_" .
$pass .
"_" . $version .
"." . $extension;
686 $entered_values =
true;
693 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
701 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
715 if( !is_array($userSolution) )
717 $userSolution = array();
720 if (strcmp(
$_POST[
'cmd'][$this->questionActionCmd], $this->lng->txt(
'delete')) == 0)
722 if (is_array(
$_POST[
'deletefiles']) && count(
$_POST[
'deletefiles']) > 0)
733 if (strlen($_FILES[
"upload"][
"tmp_name"]))
743 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
744 $extension = $filename_arr[
"extension"];
745 $newfile =
"file_".md5($_FILES[
"upload"][
"name"]).
"_" . $version .
"." . $extension;
748 $userSolution[$newfile] = array(
749 'solution_id' => $newfile,
750 'value1' => $newfile,
751 'value2' => $_FILES[
'upload'][
'name'],
752 'tstamp' => $version,
807 include_once
'Modules/Test/classes/class.ilObjTestAccess.php';
808 include_once
'Services/Tracking/classes/class.ilLPStatusWrapper.php';
823 return "assFileUpload";
833 return "qpl_qst_fileupload";
861 $text = parent::getRTETextWithMediaObjects();
878 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
883 foreach ($solutions as $solution)
886 if (strlen($solution[
"value1"]))
893 return $startrow + $i + 1;
908 public function fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
910 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class.assFileUploadImport.php";
912 $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
921 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
923 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assFileUploadExport.php";
925 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
935 $user_solution = array();
936 return $user_solution;
956 $this->maxsize = $a_value;
966 if (strlen($this->allowedextensions))
968 return array_filter(array_map(
'trim', explode(
",", $this->allowedextensions)));
990 $this->allowedextensions = strtolower(trim($a_value));
1003 case "allowedextensions":
1006 case 'completion_by_submission':
1010 return parent::__get($value);
1025 case "allowedextensions":
1028 case 'completion_by_submission':
1032 parent::__set($key, $value);
1048 SELECT tst_solutions.solution_id 1049 FROM tst_solutions, tst_active, qpl_questions 1050 WHERE tst_solutions.active_fi = tst_active.active_id 1051 AND tst_solutions.question_fi = qpl_questions.question_id 1052 AND tst_solutions.question_fi = %s AND tst_active.test_fi = %s";
1054 array(
"integer",
"integer"),
1076 require_once
'Modules/TestQuestionPool/classes/class.ilAssFileUploadUploadsExporter.php';
1080 $exporter->setTestTitle($test_title);
1081 $exporter->setQuestion($this);
1086 $exporter->getFinalZipFilePath(), $exporter->getDispoZipFileName(),
1087 $exporter->getZipFileMimeType(),
false, true
1115 $this->completion_by_submission = (bool)$bool;
1134 return $numExistingSolutionRecords > 0;
getPreviewFileUploadPathWeb($userId)
Returns the filesystem path for file uploads.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
calculateReachedPoints($active_id, $pass=NULL, $authorizedSolution=true, $returndetails=FALSE)
Returns the points, a learner has reached answering the question.
getId()
Gets the id of the assQuestion object.
getAllowedExtensions()
Get allowed file extensions.
savePreviewData(ilAssQuestionPreviewSession $previewSession)
static _getOriginalId($question_id)
Returns the original id of a question.
setSuggestedSolution($solution_id="", $subquestion_index=0, $is_import=false)
Sets a suggested solution for the question.
Class for file upload question exports.
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
setAllowedExtensions($a_value)
Set allowed file extensions.
deleteUploadedFiles($files, $test_id, $active_id, $authorized)
Delete uploaded files.
static getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...
__set($key, $value)
Object setter.
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
hasFileUploads($test_id)
Checks if file uploads exist for a given test and the original id of the question.
getPoints()
Returns the maximum available points for the question.
reworkWorkingData($active_id, $pass, $obligationsAnswered, $authorized)
Reworks the allready saved working data if neccessary.
getBestSolution($active_id, $pass)
Returns the best solution for a given pass of a participant.
$completion_by_submission
Abstract basic class which is to be extended by the concrete assessment question type classes...
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
_convert_text($a_text, $a_target="has been removed")
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static isObligationPossible($questionId)
returns boolean wether it is possible to set this question type as obligatory or not considering the ...
setId($id=-1)
Sets the id of the assQuestion object.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Interface ilObjFileHandlingQuestionType.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second. ...
isComplete()
Returns true, if the question is complete for use.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true)
getParticipantsSolution()
deletePreviewFileUploads($userId, $userSolution, $files)
fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
Creates a question from a QTI file.
setNrOfTries($a_nr_of_tries)
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
copyObject($target_questionpool_id, $title="")
Copies an assFileUpload object.
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
getFileUploadPathWeb($test_id, $active_id, $question_id=null)
Returns the file upload path for web accessible files of a question.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
Class for file upload questions.
getMaxSize()
Get max file size.
handleSubmission($active_id, $pass, $obligationsAnswered, $authorized)
This method is called after an user submitted one or more files.
getObjId()
Get the object id of the container object.
getAllowedExtensionsArray()
Get allowed file extensions.
Class for file upload question imports.
Base Exception for all Exceptions relating to Modules/Test.
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assFileUpload.
saveToDb($original_id="")
Saves a assFileUpload object to a database.
setParticipantsSolution($participantSolution)
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
updateCurrentSolutionsAuthorization($activeId, $pass, $authorized)
_getObjectIDFromActiveID($active_id)
Returns the ILIAS test object id for a given active id.
setAuthor($author="")
Sets the authors name of the assQuestion object.
deliverFileUploadZIPFile($test_id, $test_title)
Generates a ZIP file containing all file uploads for a given test and the original id of the question...
const ILIAS_ABSOLUTE_PATH
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
getMaxFilesizeAsString()
Return the maximum allowed file size as string.
checkUpload()
Check file upload.
calculateReachedPointsForSolution($userSolution)
getPreviewFileUploads(ilAssQuestionPreviewSession $previewSession)
getQuestionType()
Returns the question type of the question.
setMaxSize($a_value)
Set max file size.
_getParticipantId($active_id)
Get user id for active id.
_getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static removeTrailingPathSeparators($path)
getUploadedFilesForWeb($active_id, $pass)
Returns the web accessible uploaded files for an active user in a given pass.
_getLogLanguage()
retrieve the log language for assessment logging
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
setPoints($a_points)
Sets the maximum available points for the question.
saveQuestionDataToDb($original_id="")
toXML($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM X...
setExportDetailsXLS(&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
Creates an Excel worksheet for the detailed cumulated results of this question.
getPreviewFileUploadPath($userId)
Returns the filesystem path for file uploads.
getFileUploadPath($test_id, $active_id, $question_id=null)
Returns the filesystem path for file uploads.
getAnswerTableName()
Returns the name of the answer table in the database.
setQuestion($question="")
Sets the question string of the question object.
Interface ilObjQuestionScoringAdjustable.
setOriginalId($original_id)
_setReachedPoints($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled)
Sets the points, a learner has reached answering the question Additionally objective results are upda...
getAdditionalTableName()
Returns the name of the additional question data table in the database.
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
loadFromDb($question_id)
Loads a assFileUpload object from a database.
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getTitle()
Gets the title string of the assQuestion object.
getUploadedFiles($active_id, $pass=null, $authorized=true)
Returns the uploaded files for an active user in a given pass.
saveWorkingData($active_id, $pass=NULL, $authorized=true)
Saves the learners input of the question to the database.
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assFileUpload constructor
getMaxFilesizeInBytes()
Return the maximum allowed file size in bytes.
setCompletionBySubmission($bool)
Enabled/Disable completion by submission.
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
setComment($comment="")
Sets the comment string of the assQuestion object.
__get($value)
Object getter.
deleteAnswers($question_id)
Deletes datasets from answers tables.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
isAnswered($active_id, $pass=null)
returns boolean wether the question is answered during test pass or not