ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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)
 
 toNormalized (Transformations $transformations, array $context=[])
 
 fromNormalized (array $normalized, Transformations $transformations)
 
- 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)
 
 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)
 
 updateOriginalId (?int $original_id=null)
 
 duplicate (bool $set_original_id=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)
 
 toNormalized (Transformations $transformations, array $context=[])
 
 fromNormalized (array $normalized, Transformations $transformations)
 
 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)
 
 toNormalized (Transformations $transformations, array $context=[])
 Convert the internal state of the implementing object into a language-neutral array structure. More...
 
 fromNormalized (array $normalized, Transformations $transformations)
 Restore the object from its normalized representation. More...
 

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 41 of file class.assFileUpload.php.

Member Function Documentation

◆ buildTestPresentationConfig()

assFileUpload::buildTestPresentationConfig ( )

Reimplemented from assQuestion.

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

873 {
874 return parent::buildTestPresentationConfig()
876 }
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 188 of file class.assFileUpload.php.

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

◆ calculateReachedPointsForSolution()

assFileUpload::calculateReachedPointsForSolution ( ?array  $user_solution)
protected

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

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

◆ checkUpload()

assFileUpload::checkUpload ( )

Check file upload.

Returns
boolean Input ok, true/false

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

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

References ILIAS\UI\examples\Prompt\Standard\file_upload(), and 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 777 of file class.assFileUpload.php.

777 : void
778 {
779 }

◆ deletePreviewFileUploads()

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

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

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

References $files.

◆ deliverFileUploadZIPFile()

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

Implements ilObjFileHandlingQuestionType.

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

846 : void
847 {
849 $this->db,
850 $this->lng,
851 $ref_id,
853 );
854
855 $exporter->setTestTitle($test_title);
856 $exporter->setQuestion($this);
857
858 $exporter->buildAndDownload();
859 }

References ILIAS\TestQuestionPool\ExportImport\Foundation\Export\$exporter, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ determineMaxFilesize()

assFileUpload::determineMaxFilesize ( )

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

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

◆ fromNormalized()

assFileUpload::fromNormalized ( array  $normalized,
Transformations  $transformations 
)
Parameters
array<array-key,mixed>$normalized

Reimplemented from assQuestion.

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

975 : static
976 {
977 $clone = parent::fromNormalized($normalized, $transformations);
978 $clone->maxsize = $transformations->nullableInt($normalized['maxsize']);
979 $clone->allowedextensions = $transformations->string($normalized['allowedextensions']);
980 $clone->completion_by_submission = $transformations->bool($normalized['completion_by_submission']);
981
982 return $clone;
983 }

References ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\bool(), ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\nullableInt(), and ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\string().

+ Here is the call graph for this function:

◆ getAdditionalTableName()

assFileUpload::getAdditionalTableName ( )

Reimplemented from assQuestion.

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

764 : string
765 {
766 return 'qpl_qst_fileupload';
767 }

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAllowedExtensions()

assFileUpload::getAllowedExtensions ( )

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

815 : string
816 {
818 }

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAllowedExtensionsArray()

assFileUpload::getAllowedExtensionsArray ( )

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

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

◆ getAnswerTableName()

assFileUpload::getAnswerTableName ( )

Reimplemented from assQuestion.

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

769 : string
770 {
771 return '';
772 }

◆ getBestSolution()

assFileUpload::getBestSolution (   $active_id,
  $pass 
)

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

790 : array
791 {
792 $user_solution = [];
793 return $user_solution;
794 }

◆ getCorrectSolutionForTextOutput()

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

Reimplemented from assQuestion.

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

952 : string
953 {
954 return '';
955 }

◆ getFileUploadPath()

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

Returns the filesystem path for file uploads.

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

272 : string
273 {
274 if (is_null($question_id)) {
275 $question_id = $this->getId();
276 }
277 return CLIENT_WEB_DIR . "/assessment/tst_{$test_id}/{$active_id}/{$question_id}/files/";
278 }
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 293 of file class.assFileUpload.php.

294 {
295 if (is_null($question_id)) {
296 $question_id = $this->getId();
297 }
299 . "/assessment/tst_{$test_id}/{$active_id}/{$question_id}/files/";
300 return str_replace(
303 $webdir
304 );
305 }
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 468 of file class.assFileUpload.php.

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

◆ getMaxFilesizeInBytes()

assFileUpload::getMaxFilesizeInBytes ( )
protected

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

482 : int
483 {
484 if ($this->getMaxSize() > 0) {
485 return $this->getMaxSize();
486 }
487
488 return $this->determineMaxFilesize();
489 }

◆ getMaximumPoints()

assFileUpload::getMaximumPoints ( )

Reimplemented from assQuestion.

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

183 : float
184 {
185 return $this->getPoints();
186 }

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 796 of file class.assFileUpload.php.

796 : ?int
797 {
798 return $this->maxsize;
799 }

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 283 of file class.assFileUpload.php.

283 : string
284 {
285 return CLIENT_WEB_DIR . "/assessment/qst_preview/{$userId}/{$this->getId()}/fileuploads/";
286 }

References CLIENT_WEB_DIR.

◆ getPreviewFileUploadPathWeb()

assFileUpload::getPreviewFileUploadPathWeb ( int  $user_id)
protected

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

307 : string
308 {
310 . "/assessment/qst_preview/{$user_id}/{$this->getId()}/fileuploads/";
311 return str_replace(
314 $webdir
315 );
316 }

References CLIENT_WEB_DIR, and ilFileUtils\removeTrailingPathSeparators().

+ Here is the call graph for this function:

◆ getPreviewFileUploads()

assFileUpload::getPreviewFileUploads ( ilAssQuestionPreviewSession  $previewSession)

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

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

References ilAssQuestionPreviewSession\getParticipantsSolution().

+ Here is the call graph for this function:

◆ getQuestionType()

assFileUpload::getQuestionType ( )

Reimplemented from assQuestion.

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

759 : string
760 {
761 return 'assFileUpload';
762 }

◆ 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 785 of file class.assFileUpload.php.

785 : string
786 {
787 return parent::getRTETextWithMediaObjects();
788 }

◆ getUploadedFiles()

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

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

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

◆ 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 358 of file class.assFileUpload.php.

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

References $data.

◆ getUserSolutionPreferingIntermediate()

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

Reimplemented from assQuestion.

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

669 : array {
670 $solution = $this->getSolutionValues($active_id, $pass, false);
671
672 if (!count($solution)) {
673 $solution = $this->getSolutionValues($active_id, $pass, true);
674 } else {
675 $cleaned = [];
676 foreach ($solution as $row) {
677 if (!empty($row['value1'])) {
678 $cleaned[] = $row;
679 }
680 }
681 $solution = $cleaned;
682 }
683
684 return $solution;
685 }
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 825 of file class.assFileUpload.php.

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

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 98 of file class.assFileUpload.php.

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

References getMaximumPoints().

+ Here is the call graph for this function:

◆ isCompletionBySubmissionEnabled()

assFileUpload::isCompletionBySubmissionEnabled ( )

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

861 : bool
862 {
864 }

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ isFileDeletionAction()

assFileUpload::isFileDeletionAction ( )
protected

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

878 : bool
879 {
881 }

References assFileUploadGUI\DELETE_FILES_ACTION.

◆ isFileDeletionSubmitAvailable()

assFileUpload::isFileDeletionSubmitAvailable ( )
protected

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

883 : bool
884 {
885 return $this->isNonEmptyItemListPostSubmission(self::DELETE_FILES_TBL_POSTVAR);
886 }
isNonEmptyItemListPostSubmission(string $post_submission_field_name)

◆ isFileReuseHandlingRequired()

assFileUpload::isFileReuseHandlingRequired ( )
protected

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

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

◆ isFileReuseSubmitAvailable()

assFileUpload::isFileReuseSubmitAvailable ( )
protected

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

888 : bool
889 {
890 return $this->isNonEmptyItemListPostSubmission(self::REUSE_FILES_TBL_POSTVAR);
891 }

◆ isFileUploadAvailable()

assFileUpload::isFileUploadAvailable ( )
protected
Exceptions
IllegalStateException

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

909 : bool
910 {
911 if (!$this->file_upload->hasBeenProcessed()) {
912 $this->file_upload->process();
913 }
914 return $this->file_upload->hasUploads();
915 }

References ILIAS\UI\examples\Prompt\Standard\file_upload().

+ Here is the call graph for this function:

◆ loadFromDb()

assFileUpload::loadFromDb ( int  $question_id)

Reimplemented from assQuestion.

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

141 : void
142 {
143
144 $result = $this->db->queryF(
145 'SELECT qpl_questions.*, ' . $this->getAdditionalTableName()
146 . '.* FROM qpl_questions LEFT JOIN ' . $this->getAdditionalTableName()
147 . ' ON ' . $this->getAdditionalTableName()
148 . '.question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s',
149 ['integer'],
150 [$question_id]
151 );
152 if ($result->numRows() == 1) {
153 $data = $this->db->fetchAssoc($result);
154 $this->setId($question_id);
155 $this->setTitle((string) $data['title']);
156 $this->setComment((string) $data['description']);
157 $this->setNrOfTries($data['nr_of_tries']);
158 $this->setOriginalId($data['original_id']);
159 $this->setObjId($data['obj_fi']);
160 $this->setAuthor($data['author']);
161 $this->setOwner($data['owner']);
162 $this->setPoints($data['points']);
163
164 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data['question_text'], 1));
165 $this->setMaxSize(($data['maxsize'] ?? null) ? (int) $data['maxsize'] : null);
166 $this->setAllowedExtensions($data['allowedextensions'] ?? '');
167 $this->setCompletionBySubmission($data['compl_by_submission'] == 1 ? true : false);
168
169 try {
170 $this->setLifecycle(new ilAssQuestionLifecycle($data['lifecycle']));
173 }
174
175 try {
176 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
178 }
179 }
180 parent::loadFromDb($question_id);
181 }
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(), 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 687 of file class.assFileUpload.php.

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

◆ removeSolutionRecordById()

assFileUpload::removeSolutionRecordById ( int  $solution_id)
protected

Reimplemented from assQuestion.

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

661 : int
662 {
663 return parent::removeSolutionRecordById($solution_id);
664 }

◆ resolveRIDStoDelete()

assFileUpload::resolveRIDStoDelete ( )
protected

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

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

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 121 of file class.assFileUpload.php.

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

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 699 of file class.assFileUpload.php.

699 : void
700 {
701 $userSolution = $previewSession->getParticipantsSolution();
702
703 if (!is_array($userSolution)) {
704 $userSolution = [];
705 }
706
707 // hey: prevPassSolutions - readability spree - get a chance to understand the code
708 if ($this->isFileDeletionAction()) {
709 // hey.
710 // hey: prevPassSolutions - readability spree - get a chance to understand the code
711 if ($this->isFileDeletionSubmitAvailable()) {
712 // hey.
713 $delete_files = $this->questionpool_request->strArray(self::DELETE_FILES_TBL_POSTVAR);
714
715 $userSolution = $this->deletePreviewFileUploads($previewSession->getUserId(), $userSolution, $delete_files);
716 } else {
717 $this->tpl->setOnScreenMessage('info', $this->lng->txt('no_checkbox'), true);
718 }
719 } else {
720 // hey: prevPassSolutions - readability spree - get a chance to understand the code
721 try {
722 $fileUploadAvailable = $this->current_cmd !== 'instantResponse'
723 && $this->isFileUploadAvailable();
724 } catch (IllegalStateException $e) {
725 $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
726 return;
727 }
728 if ($fileUploadAvailable) {
729 // hey.
730 if ($this->checkUpload()) {
731 if (!@file_exists($this->getPreviewFileUploadPath($previewSession->getUserId()))) {
733 }
734
735 $version = time();
736 $filename_arr = pathinfo($_FILES['upload']['name']);
737 $extension = $filename_arr['extension'];
738 $newfile = 'file_' . md5($_FILES['upload']['name']) . '_' . $version . '.' . $extension;
740 $_FILES['upload']['tmp_name'],
741 $_FILES['upload']['name'],
742 $this->getPreviewFileUploadPath($previewSession->getUserId()) . $newfile
743 );
744
745 $userSolution[$newfile] = [
746 'solution_id' => $newfile,
747 'value1' => $newfile,
748 'value2' => $_FILES['upload']['name'],
749 'tstamp' => $version,
750 'webpath' => $this->getPreviewFileUploadPathWeb($previewSession->getUserId())
751 ];
752 }
753 }
754 }
755
756 $previewSession->setParticipantsSolution($userSolution);
757 }
$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 114 of file class.assFileUpload.php.

114 : void
115 {
118 parent::saveToDb();
119 }
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 531 of file class.assFileUpload.php.

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

820 : void
821 {
822 $this->allowedextensions = strtolower(trim($a_value));
823 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setCompletionBySubmission()

assFileUpload::setCompletionBySubmission ( bool  $bool)

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

867 {
868 $this->completion_by_submission = (bool) $bool;
869 return $this;
870 }
Class for file upload questions.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setMaxSize()

assFileUpload::setMaxSize ( ?int  $value)

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

801 : void
802 {
803 $this->maxsize = $value;
804 }

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 934 of file class.assFileUpload.php.

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

◆ 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 944 of file class.assFileUpload.php.

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

◆ 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 917 of file class.assFileUpload.php.

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

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

+ Here is the call graph for this function:

◆ toNormalized()

assFileUpload::toNormalized ( Transformations  $transformations,
array  $context = [] 
)
Parameters
array<string,mixed>$context
Returns
array<array-key, mixed>|float|bool|int|string|null

Reimplemented from assQuestion.

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

961 : array|float|bool|int|string|null
962 {
963 return [
964 ...$transformations->normalize(parent::toNormalized($transformations, $context)),
965 'maxsize' => $this->maxsize,
966 'allowedextensions' => $this->allowedextensions,
967 'completion_by_submission' => $this->completion_by_submission,
968 ];
969 }

Field Documentation

◆ $allowedextensions

string assFileUpload::$allowedextensions = ''
protected

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

◆ $completion_by_submission

assFileUpload::$completion_by_submission = false
protected

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

◆ $current_cmd

string assFileUpload::$current_cmd
private

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

◆ $file_delivery

ILIAS FileDelivery Services assFileUpload::$file_delivery
private

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

◆ $file_upload

ILIAS FileUpload FileUpload assFileUpload::$file_upload
private

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

◆ $irss

ILIAS ResourceStorage Services assFileUpload::$irss
private

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

◆ $maxsize

int assFileUpload::$maxsize = null
protected

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

◆ $participant_repository

ParticipantRepository assFileUpload::$participant_repository
private

Definition at line 48 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 46 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: