4require_once
'./Modules/TestQuestionPool/classes/class.assQuestion.php';
5require_once
'./Modules/Test/classes/inc.AssessmentConstants.php';
6require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjQuestionScoringAdjustable.php';
7require_once
'./Modules/TestQuestionPool/interfaces/interface.ilObjFileHandlingQuestionType.php';
92 array( $this->
getId() )
95 ) .
" (question_fi, maxsize, allowedextensions, compl_by_submission) VALUES (%s, %s, %s, %s)",
96 array(
"integer",
"float",
"text",
"integer" ),
121 $this->
setId($question_id);
132 include_once(
"./Services/RTE/classes/class.ilRTE.php");
147 parent::loadFromDb($question_id);
161 $this_id = $this->
getId();
165 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
169 if( (
int)$testObjId > 0 )
171 $clone->setObjId($testObjId);
198 $clone->copyPageOfQuestion($this_id);
200 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
202 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
219 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
222 $source_questionpool_id = $this->
getObjId();
223 $clone->setObjId($target_questionpool_id);
235 $clone->onCopy($source_questionpool_id,
$original_id, $clone->getObjId(), $clone->getId());
248 include_once (
"./Modules/TestQuestionPool/classes/class.assQuestion.php");
251 $sourceParentId = $this->
getObjId();
257 $clone->setObjId($targetParentId);
259 if ($targetQuestionTitle)
261 $clone->setTitle($targetQuestionTitle);
266 $clone->copyPageOfQuestion($sourceQuestionId);
268 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
270 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
299 throw new ilTestException(
'return details not implemented for '.__METHOD__);
329 $this->lng->loadLanguageModule(
"form");
331 $_FILES[
"upload"][
"name"] = rtrim($_FILES[
"upload"][
"name"],
'/');
334 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
335 $suffix = $filename_arr[
"extension"];
336 $mimetype = $_FILES[
"upload"][
"type"];
337 $size_bytes = $_FILES[
"upload"][
"size"];
338 $temp_name = $_FILES[
"upload"][
"tmp_name"];
339 $error = $_FILES[
"upload"][
"error"];
352 case UPLOAD_ERR_INI_SIZE:
357 case UPLOAD_ERR_FORM_SIZE:
362 case UPLOAD_ERR_PARTIAL:
367 case UPLOAD_ERR_NO_FILE:
372 case UPLOAD_ERR_NO_TMP_DIR:
377 case UPLOAD_ERR_CANT_WRITE:
382 case UPLOAD_ERR_EXTENSION:
392 if( !strlen($suffix) )
406 if (strlen($temp_name))
409 if ($vir[0] ==
false)
423 if (is_null($question_id)) $question_id = $this->
getId();
424 return CLIENT_WEB_DIR .
"/assessment/tst_$test_id/$active_id/$question_id/files/";
432 return CLIENT_WEB_DIR .
"/assessment/qst_preview/$userId/{$this->getId()}/fileuploads/";
442 if (is_null($question_id)) $question_id = $this->
getId();
443 include_once
"./Services/Utilities/classes/class.ilUtil.php";
453 include_once
"./Services/Utilities/classes/class.ilUtil.php";
472 $result =
$ilDB->queryF(
"SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND authorized = %s AND value1 IS NOT NULL ORDER BY tstamp",
473 array(
"integer",
"integer",
"integer",
'integer'),
474 array($active_id, $this->
getId(),
$pass, (
int)$authorized)
481 array_push($found,
$data);
502 $result =
$ilDB->queryF(
"SELECT test_fi FROM tst_active WHERE active_id = %s",
511 foreach ($found as $idx =>
$data)
513 $found[$idx][
'webpath'] =
$path;
530 foreach (
$files as $solution_id)
532 $result =
$ilDB->queryF(
"SELECT * FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
533 array(
"integer",
'integer'),
534 array($solution_id, (
int)$authorized)
540 $active_id =
$data[
'active_fi'];
544 foreach (
$files as $solution_id)
546 $affectedRows =
$ilDB->manipulateF(
"DELETE FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
547 array(
"integer",
'integer'),
548 array($solution_id, $authorized)
565 $solutions = array_merge(
572 $used_files = array();
573 foreach ($solutions as $solution)
575 $used_files[] = $solution[
'value1'];
582 $existing_files = glob(
"file_" . $active_id .
"_" .
$pass .
"_*");
583 foreach($existing_files as
$file)
585 if (!in_array(
$file, $used_files))
598 if( isset($userSolution[$name]) )
600 unset($userSolution[$name]);
605 return $userSolution;
620 else if (
$size < 1024*1024)
629 return $max_filesize;
646 $umf = get_cfg_var(
"upload_max_filesize");
648 $pms = get_cfg_var(
"post_max_size");
651 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
656 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
657 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
660 $max_filesize = min($umf, $pms);
662 if (!$max_filesize) $max_filesize=max($umf, $pms);
663 return $max_filesize;
685 $entered_values =
false;
687 $this->
getProcessLocker()->executeUserSolutionUpdateLockOperation(
function() use (&$entered_values, $uploadHandlingRequired,
$test_id, $active_id,
$pass, $authorized) {
689 if ($authorized ==
false)
698 foreach (
$_POST[self::DELETE_FILES_TBL_POSTVAR] as $solution_id)
712 foreach (
$_POST[self::REUSE_FILES_TBL_POSTVAR] as $solutionId)
717 $solution[
'value1'], $solution[
'value2'],
718 false, $solution[
'tstamp']
723 if( $uploadHandlingRequired )
730 $solutionFileVersioningUploadTS = time();
731 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
732 $extension = $filename_arr[
"extension"];
733 $newfile =
"file_" . $active_id .
"_" .
$pass .
"_" . $solutionFileVersioningUploadTS .
"." . $extension;
735 include_once
'Services/Utilities/classes/class.ilFileUtils.php';
742 $solutionFileVersioningUploadTS
745 $entered_values =
true;
764 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
772 include_once (
"./Modules/Test/classes/class.ilObjAssessmentFolder.php");
794 if( !count($solution) )
801 foreach ($solution as
$row)
803 if (!empty(
$row[
'value1']))
808 $solution = $cleaned;
827 $result = parent::removeIntermediateSolution($active_id,
$pass);
845 if( !is_array($userSolution) )
847 $userSolution = array();
879 $filename_arr = pathinfo($_FILES[
"upload"][
"name"]);
880 $extension = $filename_arr[
"extension"];
881 $newfile =
"file_".md5($_FILES[
"upload"][
"name"]).
"_" .
$version .
"." . $extension;
884 $userSolution[$newfile] = array(
885 'solution_id' => $newfile,
886 'value1' => $newfile,
887 'value2' => $_FILES[
'upload'][
'name'],
940 include_once
'Modules/Test/classes/class.ilObjTestAccess.php';
941 include_once
'Services/Tracking/classes/class.ilLPStatusWrapper.php';
956 return "assFileUpload";
966 return "qpl_qst_fileupload";
994 $text = parent::getRTETextWithMediaObjects();
1003 parent::setExportDetailsXLS(
$worksheet, $startrow, $active_id,
$pass);
1007 foreach ($solutions as $solution)
1009 $worksheet->setCell($startrow + $i, 0, $this->lng->txt(
"result"));
1011 if (strlen($solution[
"value1"]))
1013 $worksheet->setCell($startrow + $i, 1, $solution[
"value1"]);
1014 $worksheet->setCell($startrow + $i, 2, $solution[
"value2"]);
1019 return $startrow + $i + 1;
1034 public function fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
1036 include_once
"./Modules/TestQuestionPool/classes/import/qti12/class.assFileUploadImport.php";
1038 $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
1047 public function toXML($a_include_header =
true, $a_include_binary =
true, $a_shuffle =
false, $test_output =
false, $force_image_references =
false)
1049 include_once
"./Modules/TestQuestionPool/classes/export/qti12/class.assFileUploadExport.php";
1051 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
1061 $user_solution = array();
1062 return $user_solution;
1082 $this->maxsize = $a_value;
1092 if (strlen($this->allowedextensions))
1094 return array_filter(array_map(
'trim', explode(
",", $this->allowedextensions)));
1116 $this->allowedextensions = strtolower(trim($a_value));
1129 case "allowedextensions":
1132 case 'completion_by_submission':
1136 return parent::__get($value);
1151 case "allowedextensions":
1154 case 'completion_by_submission':
1158 parent::__set($key, $value);
1174 SELECT tst_solutions.solution_id
1175 FROM tst_solutions, tst_active, qpl_questions
1176 WHERE tst_solutions.active_fi = tst_active.active_id
1177 AND tst_solutions.question_fi = qpl_questions.question_id
1178 AND tst_solutions.question_fi = %s AND tst_active.test_fi = %s";
1180 array(
"integer",
"integer"),
1202 require_once
'Modules/TestQuestionPool/classes/class.ilAssFileUploadUploadsExporter.php';
1206 $exporter->setTestTitle($test_title);
1207 $exporter->setQuestion($this);
1212 $exporter->getFinalZipFilePath(), $exporter->getDispoZipFileName(),
1213 $exporter->getZipFileMimeType(),
false,
true
1241 $this->completion_by_submission = (bool)$bool;
1260 return $numExistingSolutionRecords > 0;
1295 return parent::buildTestPresentationConfig()
1297 ->setFormChangeDetectionEnabled(
false);
1307 require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssFileUploadFileTableDeleteButton.php';
1350 if( !isset($_FILES[
'upload']) )
1355 if( !isset($_FILES[
'upload'][
'tmp_name']) )
1360 return strlen($_FILES[
'upload'][
'tmp_name']) > 0;
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
Class for file upload question exports.
Class for file upload question imports.
Class for file upload questions.
fromXML(&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
Creates a question from a QTI file.
__set($key, $value)
Object setter.
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
deleteAnswers($question_id)
Deletes datasets from answers tables.
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
setMaxSize($a_value)
Set max file size.
deleteUnusedFiles($test_id, $active_id, $pass)
Delete all files that are neither used in an authorized or intermediate solution.
hasFileUploads($test_id)
Checks if file uploads exist for a given test and the original id of the question.
calculateReachedPoints($active_id, $pass=NULL, $authorizedSolution=true, $returndetails=FALSE)
Returns the points, a learner has reached answering the question.
deleteUploadedFiles($files, $test_id, $active_id, $authorized)
$completion_by_submission
createNewOriginalFromThisDuplicate($targetParentId, $targetQuestionTitle="")
getPreviewFileUploadPathWeb($userId)
Returns the filesystem path for file uploads.
getFileUploadPathWeb($test_id, $active_id, $question_id=null)
Returns the file upload path for web accessible files of a question.
deletePreviewFileUploads($userId, $userSolution, $files)
duplicate($for_test=true, $title="", $author="", $owner="", $testObjId=null)
Duplicates an assFileUpload.
saveToDb($original_id="")
Saves a assFileUpload object to a database.
getUploadedFiles($active_id, $pass=null, $authorized=true)
Returns the uploaded files for an active user in a given pass.
copyObject($target_questionpool_id, $title="")
Copies an assFileUpload object.
getRTETextWithMediaObjects()
Collects all text in the question which could contain media objects which were created with the Rich ...
removeIntermediateSolution($active_id, $pass)
Remove an intermediate soluton (overridden to remove unused fies)
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveWorkingData($active_id, $pass=NULL, $authorized=true)
Saves the learners input of the question to the database.
calculateReachedPointsForSolution($userSolution)
setExportDetailsXLS($worksheet, $startrow, $active_id, $pass)
{Creates an Excel worksheet for the detailed cumulated results of this question.object}
reworkWorkingData($active_id, $pass, $obligationsAnswered, $authorized)
{Reworks the allready saved working data if neccessary.}
const REUSE_FILES_TBL_POSTVAR
isFileDeletionSubmitAvailable()
handleSubmission($active_id, $pass, $obligationsAnswered, $authorized)
This method is called after an user submitted one or more files.
getBestSolution($active_id, $pass)
Returns the best solution for a given pass of a participant.
getPreviewFileUploadPath($userId)
Returns the filesystem path for file uploads.
isComplete()
Returns true, if the question is complete for use.
getAllowedExtensions()
Get allowed file extensions.
getMaxSize()
Get max file size.
setAllowedExtensions($a_value)
Set allowed file extensions.
getAnswerTableName()
Returns the name of the answer table in the database.
isAnswered($active_id, $pass=null)
returns boolean wether the question is answered during test pass or not
setCompletionBySubmission($bool)
Enabled/Disable completion by submission.
__construct( $title="", $comment="", $author="", $owner=-1, $question="")
assFileUpload constructor
getUserSolutionPreferingIntermediate($active_id, $pass=NULL)
Get the user solution preferring the intermediate solution.
isFileReuseSubmitAvailable()
getFileUploadPath($test_id, $active_id, $question_id=null)
Returns the filesystem path for file uploads.
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...
isFileReuseHandlingRequired()
savePreviewData(ilAssQuestionPreviewSession $previewSession)
loadFromDb($question_id)
Loads a assFileUpload object from a database.
deliverFileUploadZIPFile($test_id, $test_title)
Generates a ZIP file containing all file uploads for a given test and the original id of the question...
getPreviewFileUploads(ilAssQuestionPreviewSession $previewSession)
__get($value)
Object getter.
getAllowedExtensionsArray()
Get allowed file extensions.
getQuestionType()
Returns the question type of the question.
getUploadedFilesForWeb($active_id, $pass)
Returns the web accessible uploaded files for an active user in a given pass.
checkUpload()
Check file upload.
const DELETE_FILES_TBL_POSTVAR
static isObligationPossible($questionId)
returns boolean wether it is possible to set this question type as obligatory or not considering the ...
buildTestPresentationConfig()
Get the test question configuration Overridden from parent to disable the form change detection Other...
getAdditionalTableName()
Returns the name of the additional question data table in the database.
Abstract basic class which is to be extended by the concrete assessment question type classes.
isNonEmptyItemListPostSubmission($postSubmissionFieldname)
static _getOriginalId($question_id)
Returns the original id of a question.
setId($id=-1)
Sets the id of the assQuestion object.
setOriginalId($original_id)
setObjId($obj_id=0)
Set the object id of the container object.
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
setSuggestedSolution($solution_id="", $subquestion_index=0, $is_import=false)
Sets a suggested solution for the question.
static _getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
saveQuestionDataToDb($original_id="")
deleteDummySolutionRecord($activeId, $passIndex)
getId()
Gets the id of the assQuestion object.
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
getObjId()
Get the object id of the container object.
setTitle($title="")
Sets the title string of the assQuestion object.
getSolutionRecordById($solutionId)
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second.
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
removeCurrentSolution($active_id, $pass, $authorized=true)
removeSolutionRecordById($solutionId)
static getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...
setAuthor($author="")
Sets the authors name of the assQuestion object.
getPoints()
Returns the maximum available points for the question.
ensureCurrentTestPass($active_id, $pass)
intermediateSolutionExists($active_id, $pass)
getTestPresentationConfig()
Get the test question configuration (initialised once)
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
forceExistingIntermediateSolution($activeId, $passIndex, $considerDummyRecordCreation)
static _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...
updateCurrentSolutionsAuthorization($activeId, $pass, $authorized, $keepTime=false)
setPoints($a_points)
Sets the maximum available points for the question.
setComment($comment="")
Sets the comment string of the assQuestion object.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
setQuestion($question="")
Sets the question string of the question object.
getParticipantsSolution()
setParticipantsSolution($participantSolution)
static getValidFilename($a_filename)
Get valid filename.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
static _getParticipantId($active_id)
Get user id for active id.
static _getObjectIDFromActiveID($active_id)
Returns the ILIAS test object id for a given active id.
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...
Base Exception for all Exceptions relating to Modules/Test.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static removeTrailingPathSeparators($path)
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
Interface ilObjFileHandlingQuestionType.
Interface ilObjQuestionScoringAdjustable.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
echo;exit;}function LogoutNotification($SessionID) { global $ilDB; $q="SELECT session_id, data FROM usr_session WHERE expires > (\w+)\|/" PREG_SPLIT_NO_EMPTY PREG_SPLIT_DELIM_CAPTURE