ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
assFileUpload Class Reference

Class for file upload questions. More...

+ Inheritance diagram for assFileUpload:
+ Collaboration diagram for assFileUpload:

Public Member Functions

 isComplete ()
 Returns true, if the question is complete for use. More...
 
 saveToDb (?int $original_id=null)
 Saves a assFileUpload object to a database. More...
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 loadFromDb (int $question_id)
 
 getMaximumPoints ()
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 checkUpload ()
 Check file upload. More...
 
 getFileUploadPath ($test_id, $active_id, $question_id=null)
 Returns the filesystem path for file uploads. More...
 
 getFileUploadPathWeb ($test_id, $active_id, $question_id=null)
 Returns the file upload path for web accessible files of a question. More...
 
 getUploadedFiles (int $active_id, ?int $pass=null, bool $authorized=true)
 
 getPreviewFileUploads (ilAssQuestionPreviewSession $previewSession)
 
 getUploadedFilesForWeb ($active_id, $pass)
 Returns the web accessible uploaded files for an active user in a given pass. More...
 
 getMaxFilesizeAsString ()
 
 determineMaxFilesize ()
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 getUserSolutionPreferingIntermediate (int $active_id, ?int $pass=null)
 
 removeIntermediateSolution (int $active_id, int $pass)
 
 getQuestionType ()
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 deleteAnswers ($question_id)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 getBestSolution ($active_id, $pass)
 
 getMaxSize ()
 
 setMaxSize (?int $value)
 
 getAllowedExtensionsArray ()
 
 getAllowedExtensions ()
 
 setAllowedExtensions (string $a_value)
 
 hasFileUploads (int $test_id)
 
 deliverFileUploadZIPFile (int $ref_id, int $test_id, string $test_title)
 
 isCompletionBySubmissionEnabled ()
 
 setCompletionBySubmission (bool $bool)
 
 buildTestPresentationConfig ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 MUST return an array of the question settings that can be stored in the log. More...
 
 solutionValuesToText (array $solution_values)
 MUST convert the given solution values into text. More...
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
- Public Member Functions inherited from assQuestion
 getQuestionType ()
 
 isComplete ()
 
 saveWorkingData (int $active_id, ?int $pass=null, bool $authorized=true)
 
 calculateReachedPoints (int $active_id, ?int $pass=null, bool $authorized_solution=true)
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 MUST return an array of the question settings that can be stored in the log. More...
 
 getCurrentUser ()
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML (string $importdirectory, int $user_id, ilQTIItem $item, int $questionpool_id, ?int $tst_id, ?ilObject &$tst_object, int &$question_counter, array $import_mapping)
 
 toXML (bool $a_include_header=true, bool $a_include_binary=true, bool $a_shuffle=false, bool $test_output=false, bool $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 
 setTitle (string $title="")
 
 setId (int $id=-1)
 
 setTestId (int $id=-1)
 
 setComment (string $comment="")
 
 setShuffle (?bool $shuffle=true)
 
 setAuthor (string $author="")
 
 setOwner (int $owner=-1)
 
 getTitle ()
 
 getTitleForHTMLOutput ()
 
 getTitleFilenameCompliant ()
 
 getId ()
 
 getShuffle ()
 
 getTestId ()
 
 getComment ()
 
 getDescriptionForHTMLOutput ()
 
 getThumbSize ()
 
 setThumbSize (int $a_size)
 
 getMinimumThumbSize ()
 
 getMaximumThumbSize ()
 
 getAuthor ()
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 
 getObjId ()
 
 setObjId (int $obj_id=0)
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId (?string $external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
 getSuggestedSolutions ()
 
 getReachedPoints (int $active_id, int $pass)
 
 getMaximumPoints ()
 
 getAdjustedReachedPoints (int $active_id, int $pass, bool $authorized_solution=true)
 
 calculateResultsFromSolution (int $active_id, int $pass)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $preview_session)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 getSuggestedSolutionPath ()
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 getSuggestedSolutionPathWeb ()
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getTestOutputSolutions (int $activeId, int $pass)
 
 getUserSolutionPreferingIntermediate (int $active_id, ?int $pass=null)
 
 getSolutionValues (int $active_id, ?int $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 cloneXHTMLMediaObjectsOfQuestion (int $source_question_id)
 
 createPageObject ()
 
 clonePageOfQuestion (int $a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId (?int $original_id)
 
 getOriginalId ()
 
 fixSvgToPng (string $imageFilenameContainingString)
 
 fixUnavailableSkinImageSources (string $html)
 
 loadFromDb (int $question_id)
 
 createNewQuestion (bool $a_create_page=true)
 Creates a new question without an owner when a new question is created This assures that an ID is given to the question if a file upload or something else occurs. More...
 
 saveQuestionDataToDb (?int $original_id=null)
 
 duplicate (bool $for_test=true, string $title='', string $author='', int $owner=-1, $test_obj_id=null)
 
 copyObject (int $target_parent_id, string $title='')
 
 createNewOriginalFromThisDuplicate (int $target_parent_id, string $target_question_title='')
 
 saveToDb (?int $original_id=null)
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 
 resolveInternalLink (string $internal_link)
 
 resolveSuggestedSolutionLinks ()
 
 getInternalLinkHref (string $target)
 
 syncWithOriginal ()
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 isWriteable ()
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $preview_session)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $preview_session)
 
 adjustReachedPointsByScoringOptions (float $points, int $active_id)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 buildHashedImageFilename (string $plain_image_filename, bool $unique=false)
 
 getQuestion ()
 
 getQuestionForHTMLOutput ()
 
 setQuestion (string $question="")
 
 getQuestionTypeID ()
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 getNrOfTries ()
 
 setNrOfTries (int $a_nr_of_tries)
 
 setExportImagePath (string $path)
 
 formatSAQuestion ($a_q)
 
 setPreventRteUsage (bool $prevent_rte_usage)
 
 getPreventRteUsage ()
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode (bool $selfassessmenteditingmode)
 
 getSelfAssessmentEditingMode ()
 
 setDefaultNrOfTries (int $defaultnroftries)
 
 getDefaultNrOfTries ()
 
 syncSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 isAnswered (int $active_id, int $pass)
 
 getAdditionalContentEditingMode ()
 
 setAdditionalContentEditingMode (?string $additionalContentEditingMode)
 
 isAdditionalContentEditingModePageObject ()
 
 isValidAdditionalContentEditingMode (string $additionalContentEditingMode)
 
 getValidAdditionalContentEditingModes ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange (int $lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution (int $active_id, int $pass)
 
 removeCurrentSolution (int $active_id, int $pass, bool $authorized=true)
 
 saveCurrentSolution (int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
 
 updateCurrentSolution (int $solutionId, $value1, $value2, bool $authorized=true)
 
 updateCurrentSolutionsAuthorization (int $activeId, int $pass, bool $authorized, bool $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 intermediateSolutionExists (int $active_id, int $pass)
 
 authorizedSolutionExists (int $active_id, ?int $pass)
 
 authorizedOrIntermediateSolutionExists (int $active_id, int $pass)
 
 lookupForExistingSolutions (int $activeId, int $pass)
 Lookup if an authorized or intermediate solution exists. More...
 
 isAddableAnswerOptionValue (int $qIndex, string $answerOptionValue)
 
 addAnswerOptionValue (int $qIndex, string $answerOptionValue, float $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions (int $activeId, int $pass)
 
 resetUsersAnswer (int $activeId, int $pass)
 
 removeResultRecord (int $activeId, int $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $value_pairs)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
 hasWritableOriginalInQuestionPool ()
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_ref_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 getSolutionForTextOutput (int $active_id, int $pass)
 
 getCorrectSolutionForTextOutput (int $active_id, int $pass)
 
 getVariablesAsTextArray (int $active_id, int $pass)
 
 validateSolutionSubmit ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 
 answerToParticipantInteraction (AdditionalInformationGenerator $additional_info, int $test_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
 
 toQuestionAdministrationInteraction (AdditionalInformationGenerator $additional_info, int $test_id, TestQuestionAdministrationInteractionTypes $interaction_type)
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
- Public Member Functions inherited from ilObjFileHandlingQuestionType
 hasFileUploads (int $test_id)
 
 deliverFileUploadZIPFile (int $ref_id, int $test_id, string $test_title)
 
 getFileUploadPath (int $test_id, int $active_id, ?int $question_id=null)
 

Data Fields

const REUSE_FILES_TBL_POSTVAR = 'reusefiles'
 
const DELETE_FILES_TBL_POSTVAR = 'deletefiles'
 
- Data Fields inherited from assQuestion
const ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 
const TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'
 
ilAssQuestionFeedback $feedbackOBJ
 
bool $prevent_rte_usage = false
 
bool $selfassessmenteditingmode = false
 
int $defaultnroftries = 0
 
string $questionActionCmd = 'handleQuestionAction'
 
const KEY_VALUES_IMPLOSION_SEPARATOR = ':'
 

Protected Member Functions

 calculateReachedPointsForSolution (?array $user_solution)
 
 getPreviewFileUploadPath ($userId)
 Returns the filesystem path for file uploads. More...
 
 getPreviewFileUploadPathWeb (int $user_id)
 
 deletePreviewFileUploads ($userId, $userSolution, $files)
 
 getMaxFilesizeInBytes ()
 
 resolveRIDStoDelete ()
 
 removeSolutionRecordById (int $solution_id)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 isFileDeletionAction ()
 
 isFileDeletionSubmitAvailable ()
 
 isFileReuseSubmitAvailable ()
 
 isFileReuseHandlingRequired ()
 
 isFileUploadAvailable ()
 
 solutionValuesToLog (AdditionalInformationGenerator $additional_info, array $solution_values)
 MUST convert the given solution values into an array or a string that can be stored in the log. More...
 
- Protected Member Functions inherited from assQuestion
 solutionValuesToLog (AdditionalInformationGenerator $additional_info, array $solution_values)
 MUST convert the given solution values into an array or a string that can be stored in the log. More...
 
 solutionValuesToText (array $solution_values)
 MUST convert the given solution values into text. More...
 
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission (string $post_submission_field_name)
 
 savePreviewData (ilAssQuestionPreviewSession $preview_session)
 
 deletePageOfQuestion (int $question_id)
 
 cloneQuestionTypeSpecificProperties (self $target)
 
 removeAllImageFiles (string $image_target_path)
 
 onDuplicate (int $original_parent_id, int $original_question_id, int $duplicate_parent_id, int $duplicate_question_id)
 
 afterSyncWithOriginal (int $original_question_id, int $clone_question_id, int $original_parent_id, int $clone_parent_id)
 
 onCopy (int $sourceParentId, int $sourceQuestionId, int $targetParentId, int $targetQuestionId)
 
 duplicateComments (int $parent_source_id, int $source_id, int $parent_target_id, int $target_id)
 
 deleteComments ()
 
 getNotesManager ()
 
 getNotesDataService ()
 
 getNotesRepo ()
 
 cloneSuggestedSolutions (int $source_question_id, int $target_question_id)
 
 duplicateSuggestedSolutionFiles (int $parent_id, int $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 cloneSuggestedSolutionFiles (int $source_question_id, int $target_question_id)
 
 copySuggestedSolutions (int $target_question_id)
 
 ensureNonNegativePoints (float $points)
 
 purifyAndPrepareTextAreaOutput (string $content)
 
 getRTETextWithMediaObjects ()
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateSkillAssignments (int $srcParentId, int $srcQuestionId, int $trgParentId, int $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet (int $active_id, int $pass, bool $authorized=true)
 
 removeSolutionRecordById (int $solutionId)
 
 getSolutionRecordById (int $solutionId)
 
 deleteDummySolutionRecord (int $activeId, int $passIndex)
 
 isDummySolutionRecord (array $solutionRecord)
 
 deleteSolutionRecordByValues (int $activeId, int $passIndex, bool $authorized, array $matchValues)
 
 duplicateIntermediateSolutionAuthorized (int $activeId, int $passIndex)
 
 forceExistingIntermediateSolution (int $activeId, int $passIndex, bool $considerDummyRecordCreation)
 
 lookupMaxStep (int $active_id, int $pass)
 
 buildTestPresentationConfig ()
 
 getSuggestedSolutionsRepo ()
 
 loadSuggestedSolutions ()
 
 answerToLog (AdditionalInformationGenerator $additional_info, int $active_id, int $pass)
 

Protected Attributes

const HAS_SPECIFIC_FEEDBACK = false
 
int $maxsize = null
 
string $allowedextensions = ''
 
 $completion_by_submission = false
 
- Protected Attributes inherited from assQuestion
const HAS_SPECIFIC_FEEDBACK = true
 
GeneralQuestionPropertiesRepository $questionrepository
 
RequestDataCollector $questionpool_request
 
QuestionFiles $question_files
 
ilAssQuestionProcessLocker $processLocker
 
ilTestQuestionConfig $testQuestionConfig
 
SuggestedSolutionsDatabaseRepository $suggestedsolution_repo
 
ILIAS $ilias
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
ilDBInterface $db
 
ilObjUser $current_user
 
SkillUsageService $skillUsageService
 
HTTPServices $http
 
Refinery $refinery
 
Transformation $shuffler
 
LoggingServices $log
 
Container $dic
 
ilAssQuestionLifecycle $lifecycle
 
ilAssQuestionPage $page
 
TestResultRepository $test_result_repository
 
int $id
 
string $title
 
string $comment
 
int $owner
 
string $author
 
int $thumb_size
 
string $question
 
float $points = 0.0
 
bool $shuffle = true
 
int $test_id
 
int $obj_id = 0
 
int $original_id = null
 
int $lastChange = null
 
string $external_id = null
 
int $step = null
 
array $suggested_solutions
 

Private Attributes

ParticipantRepository $participant_repository
 
ILIAS ResourceStorage Services $irss
 
ILIAS FileDelivery Services $file_delivery
 
ILIAS FileUpload FileUpload $file_upload
 
string $current_cmd
 

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled (bool $force_pass_results_update_enabled)
 
static isForcePassResultUpdateEnabled ()
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static isFileAvailable (string $file)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static instantiateQuestion (int $question_id)
 
static _getSolutionMaxPass (int $question_id, int $active_id)
 Returns the maximum pass a users question solution. More...
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $question_id)
 
static implodeKeyValues (array $keyValues)
 
static explodeKeyValues (string $keyValues)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds (string $time)
 
static extendedTrim (string $value)
 Trim non-printable characters from the beginning and end of a string. More...
 
- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords (int $activeId, int $pass, int $questionId)
 
- Static Protected Attributes inherited from assQuestion
static $force_pass_results_update_enabled = false
 
static $imageSourceFixReplaceMap
 

Detailed Description

Class for file upload questions.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Björn Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 38 of file class.assFileUpload.php.

Member Function Documentation

◆ buildTestPresentationConfig()

assFileUpload::buildTestPresentationConfig ( )

Reimplemented from assQuestion.

Definition at line 869 of file class.assFileUpload.php.

870 {
871 return parent::buildTestPresentationConfig()
873 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFormChangeDetectionEnabled($enableFormChangeDetection)
Set if the detection of form changes is enabled.

References ilTestQuestionConfig\setFormChangeDetectionEnabled().

+ Here is the call graph for this function:

◆ calculateReachedPoints()

assFileUpload::calculateReachedPoints ( int  $active_id,
?int  $pass = null,
bool  $authorized_solution = true 
)

Reimplemented from assQuestion.

Definition at line 185 of file class.assFileUpload.php.

189 : float {
190 if (!$this->isCompletionBySubmissionEnabled()) {
191 return 0.0;
192 }
193
194 if ($pass === null) {
195 $pass = $this->getSolutionMaxPass($active_id);
196 }
197
198 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorized_solution);
199
200 while ($data = $this->db->fetchAssoc($result)) {
201 if ($this->isDummySolutionRecord($data)) {
202 continue;
203 }
204
205 return $this->getPoints();
206 }
207
208 return 0.0;
209 }
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
getSolutionMaxPass(int $active_id)
isDummySolutionRecord(array $solutionRecord)

◆ calculateReachedPointsForSolution()

assFileUpload::calculateReachedPointsForSolution ( ?array  $user_solution)
protected

Definition at line 211 of file class.assFileUpload.php.

211 : float
212 {
214 && is_array($user_solution)
215 && $user_solution !== []) {
216 return $this->getPoints();
217 }
218
219 return 0.0;
220 }

◆ checkUpload()

assFileUpload::checkUpload ( )

Check file upload.

Returns
boolean Input ok, true/false

Definition at line 227 of file class.assFileUpload.php.

227 : bool
228 {
229 $this->lng->loadLanguageModule('form');
230
231 foreach (
232 $this->file_upload->getResults() as $upload_result
233 ) { // only one supported at the moment, but we check all
234 if (!$upload_result->isOK()) {
235 $this->tpl->setOnScreenMessage('failure', $upload_result->getStatus()->getMessage(), true);
236 return false;
237 }
238
239 // check file size
240 $size_bytes = $upload_result->getSize();
241 if ($size_bytes > $this->getMaxFilesizeInBytes()) {
242 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_msg_file_size_exceeds'), true);
243 return false;
244 }
245
246 // check suffixes
247 if (count($this->getAllowedExtensionsArray())) {
248 $filename_arr = pathinfo($upload_result->getName());
249 $suffix = $filename_arr['extension'] ?? '';
250 $mimetype = $upload_result->getMimeType();
251 if ($suffix === '') {
252 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_msg_file_missing_file_ext'), true);
253 return false;
254 }
255
256 if (!in_array(strtolower($suffix), $this->getAllowedExtensionsArray(), true)) {
257 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('form_msg_file_wrong_file_type'), true);
258 return false;
259 }
260 }
261 // virus handling already done in upload-service
262 }
263 return true;
264 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ deleteAnswers()

assFileUpload::deleteAnswers (   $question_id)
Parameters
integer$question_idThe question id which should be deleted in the answers table

Definition at line 774 of file class.assFileUpload.php.

774 : void
775 {
776 }

◆ deletePreviewFileUploads()

assFileUpload::deletePreviewFileUploads (   $userId,
  $userSolution,
  $files 
)
protected

Definition at line 453 of file class.assFileUpload.php.

454 {
455 foreach ($files as $name) {
456 if (isset($userSolution[$name])) {
457 unset($userSolution[$name]);
458 @unlink($this->getPreviewFileUploadPath($userId) . $name);
459 }
460 }
461
462 return $userSolution;
463 }
getPreviewFileUploadPath($userId)
Returns the filesystem path for file uploads.

◆ deliverFileUploadZIPFile()

assFileUpload::deliverFileUploadZIPFile ( int  $ref_id,
int  $test_id,
string  $test_title 
)

Implements ilObjFileHandlingQuestionType.

Definition at line 843 of file class.assFileUpload.php.

843 : void
844 {
845 $exporter = new ilAssFileUploadUploadsExporter(
846 $this->db,
847 $this->lng,
848 $ref_id,
850 );
851
852 $exporter->setTestTitle($test_title);
853 $exporter->setQuestion($this);
854
855 $exporter->buildAndDownload();
856 }
$ref_id
Definition: ltiauth.php:66

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ determineMaxFilesize()

assFileUpload::determineMaxFilesize ( )

Definition at line 489 of file class.assFileUpload.php.

489 : int
490 {
491 $upload_max_filesize = ini_get('upload_max_filesize');
492 $post_max_size = ini_get('post_max_size');
493
494 //convert from short-string representation to "real" bytes
495 $multiplier_a = [ "K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024 ];
496 $umf_parts = preg_split(
497 "/(\d+)([K|G|M])/",
498 $upload_max_filesize,
499 -1,
500 PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
501 );
502 $pms_parts = preg_split(
503 "/(\d+)([K|G|M])/",
504 $post_max_size,
505 -1,
506 PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
507 );
508
509 if (count($umf_parts) === 2) {
510 $upload_max_filesize = $umf_parts[0] * $multiplier_a[$umf_parts[1]];
511 }
512
513 if (count($pms_parts) === 2) {
514 $post_max_size = $pms_parts[0] * $multiplier_a[$pms_parts[1]];
515 }
516
517 // use the smaller one as limit
518 $max_filesize = min($upload_max_filesize, $post_max_size);
519
520 if (!$max_filesize) {
521 $max_filesize = max($upload_max_filesize, $post_max_size);
522 return $max_filesize;
523 }
524
525 return $max_filesize;
526 }
PREG_SPLIT_NO_EMPTY PREG_SPLIT_DELIM_CAPTURE

References PREG_SPLIT_DELIM_CAPTURE.

◆ getAdditionalTableName()

assFileUpload::getAdditionalTableName ( )

Reimplemented from assQuestion.

Definition at line 761 of file class.assFileUpload.php.

761 : string
762 {
763 return 'qpl_qst_fileupload';
764 }

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAllowedExtensions()

assFileUpload::getAllowedExtensions ( )

Definition at line 812 of file class.assFileUpload.php.

812 : string
813 {
815 }

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAllowedExtensionsArray()

assFileUpload::getAllowedExtensionsArray ( )

Definition at line 803 of file class.assFileUpload.php.

803 : array
804 {
805 if ($this->allowedextensions === '') {
806 return [];
807 }
808
809 return array_filter(array_map('trim', explode(',', $this->allowedextensions)));
810 }

◆ getAnswerTableName()

assFileUpload::getAnswerTableName ( )

Reimplemented from assQuestion.

Definition at line 766 of file class.assFileUpload.php.

766 : string
767 {
768 return '';
769 }

◆ getBestSolution()

assFileUpload::getBestSolution (   $active_id,
  $pass 
)

Definition at line 787 of file class.assFileUpload.php.

787 : array
788 {
789 $user_solution = [];
790 return $user_solution;
791 }

◆ getCorrectSolutionForTextOutput()

assFileUpload::getCorrectSolutionForTextOutput ( int  $active_id,
int  $pass 
)

Reimplemented from assQuestion.

Definition at line 949 of file class.assFileUpload.php.

949 : string
950 {
951 return '';
952 }

◆ getFileUploadPath()

assFileUpload::getFileUploadPath (   $test_id,
  $active_id,
  $question_id = null 
)

Returns the filesystem path for file uploads.

Definition at line 269 of file class.assFileUpload.php.

269 : string
270 {
271 if (is_null($question_id)) {
272 $question_id = $this->getId();
273 }
274 return CLIENT_WEB_DIR . "/assessment/tst_{$test_id}/{$active_id}/{$question_id}/files/";
275 }
const CLIENT_WEB_DIR
Definition: constants.php:47

References CLIENT_WEB_DIR, and ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ getFileUploadPathWeb()

assFileUpload::getFileUploadPathWeb (   $test_id,
  $active_id,
  $question_id = null 
)

Returns the file upload path for web accessible files of a question.

@access public

Definition at line 290 of file class.assFileUpload.php.

291 {
292 if (is_null($question_id)) {
293 $question_id = $this->getId();
294 }
296 . "/assessment/tst_{$test_id}/{$active_id}/{$question_id}/files/";
297 return str_replace(
300 $webdir
301 );
302 }
static removeTrailingPathSeparators(string $path)

References CLIENT_WEB_DIR, ILIAS\Survey\Mode\getId(), and ilFileUtils\removeTrailingPathSeparators().

+ Here is the call graph for this function:

◆ getMaxFilesizeAsString()

assFileUpload::getMaxFilesizeAsString ( )

Definition at line 465 of file class.assFileUpload.php.

465 : string
466 {
467 $size = $this->getMaxFilesizeInBytes();
468 if ($size < 1024) {
469 return sprintf('%d Bytes', $size);
470 }
471
472 if ($size < 1024 * 1024) {
473 return sprintf('%.1f KB', $size / 1024);
474 }
475
476 return sprintf('%.1f MB', $size / 1024 / 1024);
477 }

◆ getMaxFilesizeInBytes()

assFileUpload::getMaxFilesizeInBytes ( )
protected

Definition at line 479 of file class.assFileUpload.php.

479 : int
480 {
481 if ($this->getMaxSize() > 0) {
482 return $this->getMaxSize();
483 }
484
485 return $this->determineMaxFilesize();
486 }

◆ getMaximumPoints()

assFileUpload::getMaximumPoints ( )

Reimplemented from assQuestion.

Definition at line 180 of file class.assFileUpload.php.

180 : float
181 {
182 return $this->getPoints();
183 }

References assQuestion\getPoints().

Referenced by isComplete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMaxSize()

assFileUpload::getMaxSize ( )

Definition at line 793 of file class.assFileUpload.php.

793 : ?int
794 {
795 return $this->maxsize;
796 }

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getPreviewFileUploadPath()

assFileUpload::getPreviewFileUploadPath (   $userId)
protected

Returns the filesystem path for file uploads.

Definition at line 280 of file class.assFileUpload.php.

280 : string
281 {
282 return CLIENT_WEB_DIR . "/assessment/qst_preview/{$userId}/{$this->getId()}/fileuploads/";
283 }

References CLIENT_WEB_DIR.

◆ getPreviewFileUploadPathWeb()

assFileUpload::getPreviewFileUploadPathWeb ( int  $user_id)
protected

Definition at line 304 of file class.assFileUpload.php.

304 : string
305 {
307 . "/assessment/qst_preview/{$user_id}/{$this->getId()}/fileuploads/";
308 return str_replace(
311 $webdir
312 );
313 }

References CLIENT_WEB_DIR, and ilFileUtils\removeTrailingPathSeparators().

+ Here is the call graph for this function:

◆ getPreviewFileUploads()

assFileUpload::getPreviewFileUploads ( ilAssQuestionPreviewSession  $previewSession)

Definition at line 341 of file class.assFileUpload.php.

341 : array
342 {
343 if ($previewSession->getParticipantsSolution() === false || $previewSession->getParticipantsSolution() === null) {
344 return [];
345 }
346
347 return $previewSession->getParticipantsSolution();
348 }

References ilAssQuestionPreviewSession\getParticipantsSolution().

+ Here is the call graph for this function:

◆ getQuestionType()

assFileUpload::getQuestionType ( )

Reimplemented from assQuestion.

Definition at line 756 of file class.assFileUpload.php.

756 : string
757 {
758 return 'assFileUpload';
759 }

◆ getRTETextWithMediaObjects()

assFileUpload::getRTETextWithMediaObjects ( )

Collects all text in the question which could contain media objects which were created with the Rich Text Editor.

Reimplemented from assQuestion.

Definition at line 782 of file class.assFileUpload.php.

782 : string
783 {
784 return parent::getRTETextWithMediaObjects();
785 }

◆ getUploadedFiles()

assFileUpload::getUploadedFiles ( int  $active_id,
?int  $pass = null,
bool  $authorized = true 
)

Definition at line 315 of file class.assFileUpload.php.

319 : array {
320 if (is_null($pass)) {
321 $pass = $this->getSolutionMaxPass($active_id);
322 }
323 // fau: testNav - check existing value1 because the intermediate solution will have a dummy entry
324 $result = $this->db->queryF(
325 'SELECT * FROM tst_solutions WHERE active_fi = %s '
326 . 'AND question_fi = %s AND pass = %s AND authorized = %s '
327 . 'AND value1 IS NOT NULL ORDER BY tstamp',
328 ['integer', 'integer', 'integer', 'integer'],
329 [$active_id, $this->getId(), $pass, (int) $authorized]
330 );
331 // fau.
332 $found = [];
333
334 while ($data = $this->db->fetchAssoc($result)) {
335 array_push($found, $data);
336 }
337
338 return $found;
339 }

◆ getUploadedFilesForWeb()

assFileUpload::getUploadedFilesForWeb (   $active_id,
  $pass 
)

Returns the web accessible uploaded files for an active user in a given pass.

Returns
array Results

Definition at line 355 of file class.assFileUpload.php.

355 : array
356 {
357 $found = $this->getUploadedFiles($active_id, $pass);
358 $result = $this->db->queryF(
359 'SELECT test_fi FROM tst_active WHERE active_id = %s',
360 ['integer'],
361 [$active_id]
362 );
363 if ($result->numRows() == 1) {
364 $row = $this->db->fetchAssoc($result);
365 $test_id = $row['test_fi'];
366 $path = $this->getFileUploadPathWeb($test_id, $active_id);
367 foreach ($found as $idx => $data) {
368 // depending on whether the files are already stored in the IRSS or not, the files are compiled differently here.
369 // this can be removed with ILIAs 10 and switched exclusively to the IRSS variant.
370 // We recommend then to revise the whole handling of files
371
372 if ($data['value2'] === 'rid') {
373 $rid = $this->irss->manage()->find($data['value1']);
374 if ($rid === null) {
375 continue;
376 }
377 $revision = $this->irss->manage()->getCurrentRevision($rid);
378 $stream = $this->irss->consume()->stream($rid)->getStream();
379 $url = $this->file_delivery->buildTokenURL(
380 $stream,
381 $revision->getTitle(),
382 Disposition::ATTACHMENT,
383 $this->current_user->getId(),
384 1
385 );
386
387 $path = (string) $url;
388 $found[$idx]['webpath'] = $path;
389 $found[$idx]['value2'] = $revision->getTitle();
390 } else {
391 $found[$idx]['webpath'] = $path;
392 }
393 }
394 }
395 return $found;
396 }
getFileUploadPathWeb($test_id, $active_id, $question_id=null)
Returns the file upload path for web accessible files of a question.
getUploadedFiles(int $active_id, ?int $pass=null, bool $authorized=true)
$path
Definition: ltiservices.php:30
$url
Definition: shib_logout.php:68

References $data, $path, and $url.

◆ getUserSolutionPreferingIntermediate()

assFileUpload::getUserSolutionPreferingIntermediate ( int  $active_id,
?int  $pass = null 
)

Reimplemented from assQuestion.

Definition at line 663 of file class.assFileUpload.php.

666 : array {
667 $solution = $this->getSolutionValues($active_id, $pass, false);
668
669 if (!count($solution)) {
670 $solution = $this->getSolutionValues($active_id, $pass, true);
671 } else {
672 $cleaned = [];
673 foreach ($solution as $row) {
674 if (!empty($row['value1'])) {
675 $cleaned[] = $row;
676 }
677 }
678 $solution = $cleaned;
679 }
680
681 return $solution;
682 }
getSolutionValues(int $active_id, ?int $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.

◆ hasFileUploads()

assFileUpload::hasFileUploads ( int  $test_id)

Implements ilObjFileHandlingQuestionType.

Definition at line 822 of file class.assFileUpload.php.

822 : bool
823 {
824 $query = '
825 SELECT tst_solutions.solution_id
826 FROM tst_solutions, tst_active, qpl_questions
827 WHERE tst_solutions.active_fi = tst_active.active_id
828 AND tst_solutions.question_fi = qpl_questions.question_id
829 AND tst_solutions.question_fi = %s AND tst_active.test_fi = %s
830 AND tst_solutions.value1 is not null';
831 $result = $this->db->queryF(
832 $query,
833 ['integer', 'integer'],
834 [$this->getId(), $test_id]
835 );
836 if ($result->numRows() > 0) {
837 return true;
838 }
839
840 return false;
841 }

References ILIAS\Survey\Mode\getId().

+ Here is the call graph for this function:

◆ isComplete()

assFileUpload::isComplete ( )

Returns true, if the question is complete for use.

Returns
boolean True, if the question is complete for use, otherwise false

Reimplemented from assQuestion.

Definition at line 95 of file class.assFileUpload.php.

95 : bool
96 {
97 if (
98 strlen($this->title)
99 && ($this->author)
100 && ($this->question)
101 && ($this->getMaximumPoints() >= 0)
102 && is_numeric($this->getMaximumPoints())) {
103 return true;
104 }
105 return false;
106 }

References getMaximumPoints().

+ Here is the call graph for this function:

◆ isCompletionBySubmissionEnabled()

assFileUpload::isCompletionBySubmissionEnabled ( )

Definition at line 858 of file class.assFileUpload.php.

858 : bool
859 {
861 }

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ isFileDeletionAction()

assFileUpload::isFileDeletionAction ( )
protected

Definition at line 875 of file class.assFileUpload.php.

875 : bool
876 {
878 }

References assFileUploadGUI\DELETE_FILES_ACTION.

◆ isFileDeletionSubmitAvailable()

assFileUpload::isFileDeletionSubmitAvailable ( )
protected

Definition at line 880 of file class.assFileUpload.php.

880 : bool
881 {
882 return $this->isNonEmptyItemListPostSubmission(self::DELETE_FILES_TBL_POSTVAR);
883 }
isNonEmptyItemListPostSubmission(string $post_submission_field_name)

◆ isFileReuseHandlingRequired()

assFileUpload::isFileReuseHandlingRequired ( )
protected

Definition at line 890 of file class.assFileUpload.php.

890 : bool
891 {
892 if (!$this->getTestPresentationConfig()->isPreviousPassSolutionReuseAllowed()) {
893 return false;
894 }
895
896 if (!$this->isFileReuseSubmitAvailable()) {
897 return false;
898 }
899
900 return true;
901 }

◆ isFileReuseSubmitAvailable()

assFileUpload::isFileReuseSubmitAvailable ( )
protected

Definition at line 885 of file class.assFileUpload.php.

885 : bool
886 {
887 return $this->isNonEmptyItemListPostSubmission(self::REUSE_FILES_TBL_POSTVAR);
888 }

◆ isFileUploadAvailable()

assFileUpload::isFileUploadAvailable ( )
protected
Exceptions
IllegalStateException

Definition at line 906 of file class.assFileUpload.php.

906 : bool
907 {
908 if (!$this->file_upload->hasBeenProcessed()) {
909 $this->file_upload->process();
910 }
911 return $this->file_upload->hasUploads();
912 }

◆ loadFromDb()

assFileUpload::loadFromDb ( int  $question_id)

Reimplemented from assQuestion.

Definition at line 138 of file class.assFileUpload.php.

138 : void
139 {
140
141 $result = $this->db->queryF(
142 'SELECT qpl_questions.*, ' . $this->getAdditionalTableName()
143 . '.* FROM qpl_questions LEFT JOIN ' . $this->getAdditionalTableName()
144 . ' ON ' . $this->getAdditionalTableName()
145 . '.question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s',
146 ['integer'],
147 [$question_id]
148 );
149 if ($result->numRows() == 1) {
150 $data = $this->db->fetchAssoc($result);
151 $this->setId($question_id);
152 $this->setTitle((string) $data['title']);
153 $this->setComment((string) $data['description']);
154 $this->setNrOfTries($data['nr_of_tries']);
155 $this->setOriginalId($data['original_id']);
156 $this->setObjId($data['obj_fi']);
157 $this->setAuthor($data['author']);
158 $this->setOwner($data['owner']);
159 $this->setPoints($data['points']);
160
161 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data['question_text'], 1));
162 $this->setMaxSize(($data['maxsize'] ?? null) ? (int) $data['maxsize'] : null);
163 $this->setAllowedExtensions($data['allowedextensions'] ?? '');
164 $this->setCompletionBySubmission($data['compl_by_submission'] == 1 ? true : false);
165
166 try {
170 }
171
172 try {
173 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
175 }
176 }
177 parent::loadFromDb($question_id);
178 }
setCompletionBySubmission(bool $bool)
setAllowedExtensions(string $a_value)
setMaxSize(?int $value)
setOriginalId(?int $original_id)
setId(int $id=-1)
setAdditionalContentEditingMode(?string $additionalContentEditingMode)
setQuestion(string $question="")
setAuthor(string $author="")
setComment(string $comment="")
setObjId(int $obj_id=0)
setOwner(int $owner=-1)
setNrOfTries(int $a_nr_of_tries)
setLifecycle(ilAssQuestionLifecycle $lifecycle)
setTitle(string $title="")
setPoints(float $points)
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...

References $data, Vendor\Package\$e, ilRTE\_replaceMediaObjectImageSrc(), getAdditionalTableName(), ilAssQuestionLifecycle\getDraftInstance(), ilAssQuestionLifecycle\getInstance(), assQuestion\setAdditionalContentEditingMode(), setAllowedExtensions(), assQuestion\setAuthor(), assQuestion\setComment(), setCompletionBySubmission(), assQuestion\setId(), assQuestion\setLifecycle(), setMaxSize(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), and assQuestion\setTitle().

+ Here is the call graph for this function:

◆ removeIntermediateSolution()

assFileUpload::removeIntermediateSolution ( int  $active_id,
int  $pass 
)

Reimplemented from assQuestion.

Definition at line 684 of file class.assFileUpload.php.

684 : void
685 {
686 parent::removeIntermediateSolution($active_id, $pass);
687
688 $test_id = $this->participant_repository->lookupTestIdByActiveId($active_id);
689 if ($test_id !== -1) {
690 // TODO: This can be removed with ILIAS 10
691 $this->deleteUnusedFiles([], $test_id, $active_id, $pass);
692 }
693 }

◆ removeSolutionRecordById()

assFileUpload::removeSolutionRecordById ( int  $solution_id)
protected

Reimplemented from assQuestion.

Definition at line 658 of file class.assFileUpload.php.

658 : int
659 {
660 return parent::removeSolutionRecordById($solution_id);
661 }

◆ resolveRIDStoDelete()

assFileUpload::resolveRIDStoDelete ( )
protected

Definition at line 637 of file class.assFileUpload.php.

637 : array
638 {
639 $rids_to_delete = [];
640 if ($this->isFileDeletionAction() && $this->isFileDeletionSubmitAvailable()) {
641 $delete_files = $this->questionpool_request->intArray(self::DELETE_FILES_TBL_POSTVAR);
642
643 $res = $this->db->query(
644 "SELECT value1 FROM tst_solutions WHERE value2 = 'rid' AND " . $this->db->in(
645 'solution_id',
646 $delete_files,
647 false,
648 'integer'
649 )
650 );
651 while ($d = $this->db->fetchAssoc($res)) {
652 $rids_to_delete[] = $d['value1'];
653 }
654 }
655 return $rids_to_delete;
656 }
$res
Definition: ltiservices.php:69

References Vendor\Package\$d, and $res.

◆ saveAdditionalQuestionDataToDb()

assFileUpload::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

Definition at line 118 of file class.assFileUpload.php.

119 {
120 $this->db->manipulateF(
121 'DELETE FROM ' . $this->getAdditionalTableName() . ' WHERE question_fi = %s',
122 ['integer'],
123 [$this->getId()]
124 );
125 $this->db->manipulateF(
126 'INSERT INTO ' . $this->getAdditionalTableName(
127 ) . ' (question_fi, maxsize, allowedextensions, compl_by_submission) VALUES (%s, %s, %s, %s)',
128 ['integer', 'float', 'text', 'integer' ],
129 [
130 $this->getId(),
131 $this->getMaxSize(),
132 (strlen($this->getAllowedExtensions())) ? $this->getAllowedExtensions() : null,
134 ]
135 );
136 }

References getAdditionalTableName(), getAllowedExtensions(), assQuestion\getId(), getMaxSize(), and isCompletionBySubmissionEnabled().

Referenced by saveToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePreviewData()

assFileUpload::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

Reimplemented from assQuestion.

Definition at line 696 of file class.assFileUpload.php.

696 : void
697 {
698 $userSolution = $previewSession->getParticipantsSolution();
699
700 if (!is_array($userSolution)) {
701 $userSolution = [];
702 }
703
704 // hey: prevPassSolutions - readability spree - get a chance to understand the code
705 if ($this->isFileDeletionAction()) {
706 // hey.
707 // hey: prevPassSolutions - readability spree - get a chance to understand the code
708 if ($this->isFileDeletionSubmitAvailable()) {
709 // hey.
710 $delete_files = $this->questionpool_request->strArray(self::DELETE_FILES_TBL_POSTVAR);
711
712 $userSolution = $this->deletePreviewFileUploads($previewSession->getUserId(), $userSolution, $delete_files);
713 } else {
714 $this->tpl->setOnScreenMessage('info', $this->lng->txt('no_checkbox'), true);
715 }
716 } else {
717 // hey: prevPassSolutions - readability spree - get a chance to understand the code
718 try {
719 $fileUploadAvailable = $this->current_cmd !== 'instantResponse'
720 && $this->isFileUploadAvailable();
721 } catch (IllegalStateException $e) {
722 $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
723 return;
724 }
725 if ($fileUploadAvailable) {
726 // hey.
727 if ($this->checkUpload()) {
728 if (!@file_exists($this->getPreviewFileUploadPath($previewSession->getUserId()))) {
730 }
731
732 $version = time();
733 $filename_arr = pathinfo($_FILES['upload']['name']);
734 $extension = $filename_arr['extension'];
735 $newfile = 'file_' . md5($_FILES['upload']['name']) . '_' . $version . '.' . $extension;
737 $_FILES['upload']['tmp_name'],
738 $_FILES['upload']['name'],
739 $this->getPreviewFileUploadPath($previewSession->getUserId()) . $newfile
740 );
741
742 $userSolution[$newfile] = [
743 'solution_id' => $newfile,
744 'value1' => $newfile,
745 'value2' => $_FILES['upload']['name'],
746 'tstamp' => $version,
747 'webpath' => $this->getPreviewFileUploadPathWeb($previewSession->getUserId())
748 ];
749 }
750 }
751 }
752
753 $previewSession->setParticipantsSolution($userSolution);
754 }
$version
Definition: plugin.php:24
deletePreviewFileUploads($userId, $userSolution, $files)
getPreviewFileUploadPathWeb(int $user_id)
checkUpload()
Check file upload.
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static moveUploadedFile(string $a_file, string $a_name, string $a_target, bool $a_raise_errors=true, string $a_mode="move_uploaded")
move uploaded file

References Vendor\Package\$e, $version, ilAssQuestionPreviewSession\getParticipantsSolution(), ilAssQuestionPreviewSession\getUserId(), ILIAS\Repository\lng(), ilFileUtils\makeDirParents(), ilFileUtils\moveUploadedFile(), and ilAssQuestionPreviewSession\setParticipantsSolution().

+ Here is the call graph for this function:

◆ saveToDb()

assFileUpload::saveToDb ( ?int  $original_id = null)

Saves a assFileUpload object to a database.

Reimplemented from assQuestion.

Definition at line 111 of file class.assFileUpload.php.

111 : void
112 {
115 parent::saveToDb();
116 }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveQuestionDataToDb(?int $original_id=null)

References assQuestion\$original_id, saveAdditionalQuestionDataToDb(), and assQuestion\saveQuestionDataToDb().

+ Here is the call graph for this function:

◆ saveWorkingData()

assFileUpload::saveWorkingData ( int  $active_id,
?int  $pass = null,
bool  $authorized = true 
)

Reimplemented from assQuestion.

Definition at line 528 of file class.assFileUpload.php.

532 : bool {
533 if ($pass === null || $pass < 0) {
534 $pass = \ilObjTest::_getPass($active_id);
535 }
536
537 $test_id = $this->participant_repository->lookupTestIdByActiveId($active_id);
538
539 try {
540 $upload_handling_required = $this->current_cmd !== 'submitSolution'
541 && $this->current_cmd !== 'showInstantResponse'
542 && !$this->isFileDeletionAction()
543 && $this->isFileUploadAvailable()
544 && $this->checkUpload();
545 } catch (IllegalStateException $e) {
546 $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
547 return false;
548 }
549
550 $rid = null;
551
552 if ($upload_handling_required) {
553 // upload new file to storage
554 $upload_results = $this->file_upload->getResults();
555 $upload_result = end($upload_results); // only one supported at the moment
556 $rid = $this->irss->manage()->upload(
557 $upload_result,
559 );
560 }
561
562 // RIDS to delete
563 // Unfortunately, at the moment it is not possible to delete the files from the IRSS, because the process takes
564 // place within the ProcessLocker and the IRSS tables cannot be used. we have to remove them after the lock.
565 // therefore we store the rids to delete in an array for later deletion.
566 $rids_to_delete = $this->resolveRIDStoDelete();
567
568 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(
569 function () use ($upload_handling_required, $active_id, $pass, $authorized, $rid) {
570 if ($authorized === false) {
571 $this->forceExistingIntermediateSolution($active_id, $pass, true);
572 }
573
574 if ($this->isFileDeletionAction()) {
575 if ($this->isFileDeletionSubmitAvailable()) {
576 $delete_files = $this->questionpool_request->intArray(self::DELETE_FILES_TBL_POSTVAR);
577
578 foreach ($delete_files as $solution_id) {
579 $this->removeSolutionRecordById($solution_id);
580 }
581 } else {
582 $this->tpl->setOnScreenMessage('info', $this->lng->txt('no_checkbox'), true);
583 }
584 } else {
585 if ($this->isFileReuseHandlingRequired()) {
586 $reuse_files = $this->questionpool_request->intArray(self::REUSE_FILES_TBL_POSTVAR);
587
588 foreach ($reuse_files as $solutionId) {
589 $solution = $this->getSolutionRecordById($solutionId);
590
591 $this->saveCurrentSolution(
592 $active_id,
593 $pass,
594 $solution['value1'],
595 $solution['value2'],
596 false,
597 $solution['tstamp']
598 );
599 }
600 }
601
602 if ($upload_handling_required && $rid !== null) {
603 $revision = $this->irss->manage()->getCurrentRevision($rid);
604 $this->saveCurrentSolution(
605 $active_id,
606 $pass,
607 $rid->serialize(),
608 'rid',
609 false,
610 time()
611 );
612 }
613 }
614
615 if ($authorized === true && $this->intermediateSolutionExists($active_id, $pass)) {
616 // remove the dummy record of the intermediate solution
617 $this->deleteDummySolutionRecord($active_id, $pass);
618
619 // delete the authorized solution and make the intermediate solution authorized (keeping timestamps)
620 $this->removeCurrentSolution($active_id, $pass, true);
621 $this->updateCurrentSolutionsAuthorization($active_id, $pass, true, true);
622 }
623
624 }
625 );
626
627 $this->deleteUnusedFiles(
628 $rids_to_delete,
629 $test_id,
630 $active_id,
631 $pass
632 );
633
634 return true;
635 }
removeSolutionRecordById(int $solution_id)
updateCurrentSolutionsAuthorization(int $activeId, int $pass, bool $authorized, bool $keepTime=false)
saveCurrentSolution(int $active_id, int $pass, $value1, $value2, bool $authorized=true, $tstamp=0)
getSolutionRecordById(int $solutionId)
deleteDummySolutionRecord(int $activeId, int $passIndex)
forceExistingIntermediateSolution(int $activeId, int $passIndex, bool $considerDummyRecordCreation)
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
intermediateSolutionExists(int $active_id, int $pass)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.

References ilObjTest\_getPass().

+ Here is the call graph for this function:

◆ setAllowedExtensions()

assFileUpload::setAllowedExtensions ( string  $a_value)

Definition at line 817 of file class.assFileUpload.php.

817 : void
818 {
819 $this->allowedextensions = strtolower(trim($a_value));
820 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setCompletionBySubmission()

assFileUpload::setCompletionBySubmission ( bool  $bool)

Definition at line 863 of file class.assFileUpload.php.

864 {
865 $this->completion_by_submission = (bool) $bool;
866 return $this;
867 }
Class for file upload questions.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setMaxSize()

assFileUpload::setMaxSize ( ?int  $value)

Definition at line 798 of file class.assFileUpload.php.

798 : void
799 {
800 $this->maxsize = $value;
801 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ solutionValuesToLog()

assFileUpload::solutionValuesToLog ( AdditionalInformationGenerator  $additional_info,
array  $solution_values 
)
protected

MUST convert the given solution values into an array or a string that can be stored in the log.

Language variables must be generated through the corresponding functions in the AdditionalInformationGenerator. If an array is returned it will be rendered into a line per array entry in the format "key: value". If the key exists as a language variable, it will be translated.

Reimplemented from assQuestion.

Definition at line 931 of file class.assFileUpload.php.

934 : array {
935 return array_map(
936 static fn(array $v): string => "{$v['value1']} - {$v['value2']}",
937 $solution_values
938 );
939 }

◆ solutionValuesToText()

assFileUpload::solutionValuesToText ( array  $solution_values)

MUST convert the given solution values into text.

If the text has multiple lines each line MUST be placed as an entry in an array.

Reimplemented from assQuestion.

Definition at line 941 of file class.assFileUpload.php.

941 : array
942 {
943 return array_map(
944 static fn(array $v): string => "{$v['value1']} - {$v['value2']}",
945 $solution_values
946 );
947 }

◆ toLog()

assFileUpload::toLog ( AdditionalInformationGenerator  $additional_info)

MUST return an array of the question settings that can be stored in the log.

Language variables must be generated through the corresponding functions in the AdditionalInformationGenerator. If an array is returned it will be rendered into a line per array entry in the format "key: value". If the key exists as a language variable, it will be translated.

Reimplemented from assQuestion.

Definition at line 914 of file class.assFileUpload.php.

914 : array
915 {
916 return [
917 AdditionalInformationGenerator::KEY_QUESTION_TYPE => (string) $this->getQuestionType(),
918 AdditionalInformationGenerator::KEY_QUESTION_TITLE => $this->getTitleForHTMLOutput(),
919 AdditionalInformationGenerator::KEY_QUESTION_TEXT => $this->formatSAQuestion($this->getQuestion()),
920 AdditionalInformationGenerator::KEY_QUESTION_REACHABLE_POINTS => $this->getPoints(),
921 AdditionalInformationGenerator::KEY_QUESTION_UPLOAD_MAXSIZE => $this->getMaxFilesizeAsString(),
922 AdditionalInformationGenerator::KEY_QUESTION_UPLOAD_ALLOWED_EXTENSIONS => $this->getAllowedExtensionsArray(),
923 AdditionalInformationGenerator::KEY_QUESTION_UPLOAD_COMPLETION_BY_SUBMISSION => $additional_info->getEnabledDisabledTagForBool($this->isCompletionBySubmissionEnabled()),
924 AdditionalInformationGenerator::KEY_FEEDBACK => [
925 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_INCOMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), false)),
926 AdditionalInformationGenerator::KEY_QUESTION_FEEDBACK_ON_COMPLETE => $this->formatSAQuestion($this->feedbackOBJ->getGenericFeedbackTestPresentation($this->getId(), true))
927 ]
928 ];
929 }

References ILIAS\Test\Logging\AdditionalInformationGenerator\getEnabledDisabledTagForBool().

+ Here is the call graph for this function:

Field Documentation

◆ $allowedextensions

string assFileUpload::$allowedextensions = ''
protected

Definition at line 52 of file class.assFileUpload.php.

◆ $completion_by_submission

assFileUpload::$completion_by_submission = false
protected

Definition at line 57 of file class.assFileUpload.php.

◆ $current_cmd

string assFileUpload::$current_cmd
private

Definition at line 54 of file class.assFileUpload.php.

◆ $file_delivery

ILIAS FileDelivery Services assFileUpload::$file_delivery
private

Definition at line 47 of file class.assFileUpload.php.

◆ $file_upload

ILIAS FileUpload FileUpload assFileUpload::$file_upload
private

Definition at line 48 of file class.assFileUpload.php.

◆ $irss

ILIAS ResourceStorage Services assFileUpload::$irss
private

Definition at line 46 of file class.assFileUpload.php.

◆ $maxsize

int assFileUpload::$maxsize = null
protected

Definition at line 50 of file class.assFileUpload.php.

◆ $participant_repository

ParticipantRepository assFileUpload::$participant_repository
private

Definition at line 45 of file class.assFileUpload.php.

◆ DELETE_FILES_TBL_POSTVAR

const assFileUpload::DELETE_FILES_TBL_POSTVAR = 'deletefiles'

◆ HAS_SPECIFIC_FEEDBACK

const assFileUpload::HAS_SPECIFIC_FEEDBACK = false
protected

Definition at line 43 of file class.assFileUpload.php.

◆ REUSE_FILES_TBL_POSTVAR

const assFileUpload::REUSE_FILES_TBL_POSTVAR = 'reusefiles'

The documentation for this class was generated from the following file: