ILIAS  release_8 Revision v8.24
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 ($original_id="")
 Saves a assFileUpload object to a database. More...
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 loadFromDb ($question_id)
 Loads a assFileUpload object from a database. More...
 
 duplicate (bool $for_test=true, string $title="", string $author="", string $owner="", $testObjId=null)
 Duplicates an assFileUpload. More...
 
 copyObject ($target_questionpool_id, $title="")
 Copies an assFileUpload object. More...
 
 createNewOriginalFromThisDuplicate ($targetParentId, $targetQuestionTitle="")
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 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 ($active_id, $pass=null, $authorized=true)
 Returns the uploaded files for an active user in a given pass. More...
 
 getPreviewFileUploads (ilAssQuestionPreviewSession $previewSession)
 
 getUploadedFilesForWeb ($active_id, $pass)
 Returns the web accessible uploaded files for an active user in a given pass. More...
 
 getMaxFilesizeAsString ()
 Return the maximum allowed file size as string. More...
 
 getMaxFilesizeInBytes ()
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 @access public More...
 
 getUserSolutionPreferingIntermediate ($active_id, $pass=null)
 
 removeIntermediateSolution (int $active_id, int $pass)
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 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...
 
 setExportDetailsXLS (ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
 {} More...
 
 fromXML ($item, int $questionpool_id, ?int $tst_id, &$tst_object, int &$question_counter, array $import_mapping, array &$solutionhints=[])
 Creates a question from a QTI file. More...
 
 toXML ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
 
 getBestSolution ($active_id, $pass)
 
 getMaxSize ()
 
 setMaxSize (?int $a_value)
 
 getAllowedExtensionsArray ()
 
 getAllowedExtensions ()
 
 setAllowedExtensions ($a_value)
 Set allowed file extensions. More...
 
 hasFileUploads ($test_id)
 Checks if file uploads exist for a given test and the original id of the question. More...
 
 deliverFileUploadZIPFile ($ref_id, $test_id, $test_title)
 Generates a ZIP file containing all file uploads for a given test and the original id of the question. More...
 
 isCompletionBySubmissionEnabled ()
 
 setCompletionBySubmission ($bool)
 Enabled/Disable completion by submission. More...
 
 isAnswered (int $active_id, int $pass)
 
 isAutosaveable ()
 
 buildTestPresentationConfig ()
 build basic test question configuration instance More...
 
- Public Member Functions inherited from assQuestion
 __construct (string $title="", string $comment="", string $author="", int $owner=-1, string $question="")
 assQuestion constructor More...
 
 getShuffler ()
 
 setShuffler (Transformation $shuffler)
 
 setProcessLocker (ilAssQuestionProcessLocker $processLocker)
 
 getProcessLocker ()
 
 fromXML ($item, int $questionpool_id, ?int $tst_id, &$tst_object, int &$question_counter, array $import_mapping, array &$solutionhints=[])
 Receives parameters from a QTI parser and creates a valid ILIAS question object. More...
 
 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...
 
 isComplete ()
 Returns true, if a question is complete for use. More...
 
 questionTitleExists (int $questionpool_id, string $title)
 Returns TRUE if the question title exists in a question pool in the database. More...
 
 setTitle (string $title="")
 
 setId (int $id=-1)
 
 setTestId (int $id=-1)
 
 setComment (string $comment="")
 
 setOutputType (int $outputType=OUTPUT_HTML)
 
 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 ()
 
 getOutputType ()
 
 supportsJavascriptOutput ()
 
 supportsNonJsOutput ()
 
 requiresJsSwitch ()
 
 getAuthor ()
 
 getAuthorForHTMLOutput ()
 
 getOwner ()
 
 getObjId ()
 
 setObjId (int $obj_id=0)
 
 getLifecycle ()
 
 setLifecycle (ilAssQuestionLifecycle $lifecycle)
 
 setExternalId (?string $external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
 _getSuggestedSolution (int $question_id, int $subquestion_index=0)
 
 loadSuggestedSolution (int $question_id, int $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutions ()
 
 getReachedPoints (int $active_id, int $pass)
 
 getMaximumPoints ()
 
 getAdjustedReachedPoints (int $active_id, int $pass, bool $authorizedSolution=true)
 returns the reached points ... More...
 
 calculateResultsFromSolution (int $active_id, int $pass, bool $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState (int $active_id, $pass, bool $obligationsEnabled=false, bool $authorized=true)
 persists the working state for current testactive and testpass More...
 
 persistPreviewState (ilAssQuestionPreviewSession $previewSession)
 persists the preview state for current user and question More...
 
 validateSolutionSubmit ()
 
 saveWorkingData (int $active_id, int $pass, bool $authorized=true)
 Saves the learners input of the question to the database. More...
 
 moveUploadedMediaFile (string $file, string $name)
 Move an uploaded media file to an public accessible temp dir to present it. More...
 
 getSuggestedSolutionPath ()
 
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question. More...
 
 buildImagePath ($questionId, $parentObjectId)
 
 getFlashPath ()
 Returns the image path for web accessable flash files 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, $pass=null)
 
 getSolutionValues ($active_id, $pass=null, bool $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 isInUse (int $question_id=0)
 Checks whether the question is in use or not in pools or tests. More...
 
 usageNumber (int $question_id=0)
 Returns the number of place the question is in use in pools or tests. More...
 
 isClone (int $question_id=0)
 Checks whether the question is a clone of another question or not. More...
 
 getAdditionalTableName ()
 
 getAnswerTableName ()
 
 deleteAnswers (int $question_id)
 
 deleteAdditionalTableData (int $question_id)
 
 delete (int $question_id)
 
 getTotalAnswers ()
 
 copyXHTMLMediaObjectsOfQuestion (int $a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 
 copyPageOfQuestion (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=-1)
 
 saveToDb ()
 
 setNewOriginalId (int $newId)
 
 deleteSuggestedSolutions ()
 
 getSuggestedSolution (int $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutionTitle (int $subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index. More...
 
 setSuggestedSolution (string $solution_id="", int $subquestion_index=0, bool $is_import=false)
 Sets a suggested solution for the question. More...
 
 updateSuggestedSolutions (int $original_id=-1, int $original_obj_id=-1)
 
 _resolveInternalLink (string $internal_link)
 
 _resolveIntLinks (int $question_id)
 
 syncWithOriginal ()
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 _questionExistsInPool (int $question_id)
 
 getPoints ()
 
 setPoints (float $points)
 
 getSolutionMaxPass (int $active_id)
 
 calculateReachedPoints ($active_id, $pass=null, $authorizedSolution=true, $returndetails=false)
 Returns the points, a learner has reached answering the question. More...
 
 deductHintPointsFromReachedPoints (ilAssQuestionPreviewSession $previewSession, $reachedPoints)
 
 calculateReachedPointsFromPreviewSession (ilAssQuestionPreviewSession $previewSession)
 
 isPreviewSolutionCorrect (ilAssQuestionPreviewSession $previewSession)
 
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=null)
 Adjust the given reached points by checks for all special scoring options in the test container. More...
 
 isHTML ($a_text)
 Checks if a given string contains HTML or not. More...
 
 prepareTextareaOutput (string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
 
 QTIMaterialToString (ilQTIMaterial $a_material)
 Reads an QTI material tag and creates a text or XHTML string. More...
 
 addQTIMaterial (ilXmlWriter $a_xml_writer, string $a_material, bool $close_material_tag=true, bool $add_mobs=true)
 
 buildHashedImageFilename (string $plain_image_filename, bool $unique=false)
 
 getQuestion ()
 
 getQuestionForHTMLOutput ()
 
 setQuestion (string $question="")
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 
 syncHints ()
 
 cleanupMediaObjectUsage ()
 
 getInstances ()
 
 getActiveUserData (int $active_id)
 Returns the user id and the test id for a given active id. More...
 
 hasSpecificFeedback ()
 
 setExportDetailsXLS (ilAssExcelFormatHelper $worksheet, int $startrow, int $active_id, int $pass)
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 __isset ($key)
 Object issetter. More...
 
 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)
 
 ensureHintPageObjectExists ($pageObjectId)
 
 isAnswered (int $active_id, int $pass)
 
 isAutosaveable ()
 
 getAdditionalContentEditingMode ()
 
 setAdditionalContentEditingMode (?string $additionalContentEditingMode)
 
 isAdditionalContentEditingModePageObject ()
 
 isValidAdditionalContentEditingMode (string $additionalContentEditingMode)
 
 getValidAdditionalContentEditingModes ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange ($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 ()
 
 duplicate (bool $for_test=true, string $title="", string $author="", string $owner="", $testObjId=null)
 
 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 $valuePairs)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered (bool $obligationsToBeConsidered)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 
 savePartial ()
 
 isInActiveTest ()
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 hasFileUploads ($test_id)
 Checks if file uploads exist for a given test and the original id of the question. More...
 
 deliverFileUploadZIPFile ($ref_id, $test_id, $test_title)
 Generates a ZIP file containing all file uploads for a given test and the original id of the question. More...
 
 getFileUploadPath ($test_id, $active_id, $question_id=null)
 Returns the path for uploaded files from given active in given test on current or given question. More...
 

Static Public Member Functions

static isObligationPossible (int $questionId)
 
- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled (bool $forcePassResultsUpdateEnabled)
 
static isForcePassResultUpdateEnabled ()
 
static isAllowedImageMimeType ($mimeType)
 
static fetchMimeTypeIdentifier (string $contentType)
 
static getAllowedFileExtensionsForMimeType (string $mimeType)
 
static isAllowedImageFileExtension (string $mimeType, string $fileExtension)
 
static getAllowedImageMaterialFileExtensions ()
 
static _getMaximumPoints (int $question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
static _getQuestionInfo (int $question_id)
 
static _getSuggestedSolutionCount (int $question_id)
 
static _getSuggestedSolutionOutput (int $question_id)
 
static _getReachedPoints (int $active_id, int $question_id, int $pass)
 
static _updateTestResultCache (int $active_id, ilAssQuestionProcessLocker $processLocker=null)
 @TODO Move this to a proper place. More...
 
static logAction (string $logtext, int $active_id, int $question_id)
 
static getQuestionTypeFromDb (int $question_id)
 
static _getTotalRightAnswers (int $a_q_id)
 
static _getTitle (int $a_q_id)
 
static _getQuestionText (int $a_q_id)
 
static isFileAvailable (string $file)
 
static _getQuestionType (int $question_id)
 
static _getQuestionTitle (int $question_id)
 
static saveOriginalId (int $questionId, int $originalId)
 
static resetOriginalId (int $questionId)
 
static _getInternalLinkHref (string $target="")
 
static _getOriginalId (int $question_id)
 
static originalQuestionExists (int $questionId)
 
static _instanciateQuestion (int $question_id)
 
static _instantiateQuestion (int $question_id)
 
static instantiateQuestion (int $question_id)
 
static _getSolutionMaxPass (int $question_id, int $active_id)
 Returns the maximum pass a users question solution. More...
 
static _isWriteable (int $question_id, int $user_id)
 
static _isUsedInRandomTest (int $question_id)
 
static _isWorkedThrough (int $active_id, int $question_id, int $pass)
 Returns true if the question was worked through in the given pass Worked through means that the user entered at least one value. More...
 
static _areAnswered (int $a_user_id, array $a_question_ids)
 Checks if an array of question ids is answered by a user or not. More...
 
static _setReachedPoints (int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring, bool $obligationsEnabled)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
static _needsManualScoring (int $question_id)
 
static _includeClass (string $question_type, int $gui=0)
 
static getFeedbackClassNameByQuestionType (string $questionType)
 
static isCoreQuestionType (string $questionType)
 
static includeCoreClass ($questionType, $withGuiClass)
 
static _getQuestionTypeName ($type_tag)
 
static _instanciateQuestionGUI (int $question_id)
 
static instantiateQuestionGUI (int $a_question_id)
 
static _questionExistsInTest (int $question_id, int $test_id)
 
static lookupParentObjId (int $questionId)
 
static lookupOriginalParentObjId (int $originalQuestionId)
 returns the parent object id for given original question id (should be a qpl id, but theoretically it can be a tst id, too) More...
 
static isObligationPossible (int $questionId)
 
static implodeKeyValues (array $keyValues)
 
static explodeKeyValues (string $keyValues)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds (string $time)
 
static missingResultRecordExists (int $activeId, int $pass, array $questionIds)
 
static getQuestionsMissingResultRecord (int $activeId, int $pass, array $questionIds)
 
static lookupResultRecordExist (int $activeId, int $questionId, int $pass)
 
static extendedTrim (string $value)
 Trim non-printable characters from the beginning and end of a string. More...
 

Data Fields

const REUSE_FILES_TBL_POSTVAR = 'reusefiles'
 
const DELETE_FILES_TBL_POSTVAR = 'deletefiles'
 
- Data Fields inherited from assQuestion
const IMG_MIME_TYPE_JPG = 'image/jpeg'
 
const IMG_MIME_TYPE_PNG = 'image/png'
 
const IMG_MIME_TYPE_GIF = 'image/gif'
 
const TRIM_PATTERN = '/^[\p{C}\p{Z}]+|[\p{C}\p{Z}]+$/u'
 
const ADDITIONAL_CONTENT_EDITING_MODE_RTE = 'default'
 
const ADDITIONAL_CONTENT_EDITING_MODE_IPE = 'pageobject'
 
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 ($userSolution)
 
 getPreviewFileUploadPath ($userId)
 Returns the filesystem path for file uploads. More...
 
 getPreviewFileUploadPathWeb ($userId)
 Returns the filesystem path for file uploads. More...
 
 deleteUploadedFiles ($files, $test_id, $active_id, $authorized)
 Delete uploaded files. More...
 
 deletePreviewFileUploads ($userId, $userSolution, $files)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 handleSubmission ($active_id, $pass, $obligationsAnswered, $authorized)
 This method is called after an user submitted one or more files. More...
 
 isFileDeletionAction ()
 
 isFileDeletionSubmitAvailable ()
 
 isFileReuseSubmitAvailable ()
 
 isFileReuseHandlingRequired ()
 
 isFileUploadAvailable ()
 
- Protected Member Functions inherited from assQuestion
 getQuestionAction ()
 
 isNonEmptyItemListPostSubmission (string $postSubmissionFieldname)
 
 ensureCurrentTestPass (int $active_id, int $pass)
 
 lookupCurrentTestPass (int $active_id, int $pass)
 
 lookupTestId (int $active_id)
 @refactor Move to ilObjTest or similar More...
 
 log (int $active_id, string $langVar)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 deletePageOfQuestion (int $question_id)
 
 onDuplicate (int $originalParentId, int $originalQuestionId, int $duplicateParentId, int $duplicateQuestionId)
 
 beforeSyncWithOriginal (int $origQuestionId, int $dupQuestionId, int $origParentObjId, int $dupParentObjId)
 
 afterSyncWithOriginal (int $origQuestionId, int $dupQuestionId, int $origParentObjId, int $dupParentObjId)
 
 onCopy (int $sourceParentId, int $sourceQuestionId, int $targetParentId, int $targetQuestionId)
 
 duplicateSuggestedSolutionFiles (int $parent_id, int $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles (int $target_question_id, int $target_obj_id)
 
 copySuggestedSolutionFiles (int $source_questionpool_id, int $source_question_id)
 
 ensureNonNegativePoints ($points)
 
 purifyAndPrepareTextAreaOutput (string $content)
 
 getRTETextWithMediaObjects ()
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateQuestionHints (int $originalQuestionId, int $duplicateQuestionId)
 
 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 ()
 build basic test question configuration instance More...
 

Protected Attributes

const HAS_SPECIFIC_FEEDBACK = false
 
int $maxsize = null
 
 $allowedextensions
 
 $completion_by_submission = false
 
- Protected Attributes inherited from assQuestion
const HAS_SPECIFIC_FEEDBACK = true
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
ILIAS DI LoggingServices $ilLog
 
int $id
 
string $title
 
string $comment
 
string $owner
 
string $author
 
int $thumb_size
 
string $question
 The question text. More...
 
float $points
 The maximum available points for the question. More...
 
bool $shuffle
 Indicates whether the answers will be shuffled or not. More...
 
int $test_id
 The database id of a test in which the question is contained. More...
 
int $obj_id = 0
 Object id of the container object. More...
 
 $ilias
 
ilGlobalPageTemplate $tpl
 
ilLanguage $lng
 
ilDBInterface $db
 
Container $dic
 
int $outputType = OUTPUT_JAVASCRIPT
 Contains the output type of a question. More...
 
array $suggested_solutions
 
int $original_id = null
 
 $page
 
string $external_id = null
 
ilAssQuestionProcessLocker $processLocker
 
 $step
 
 $lastChange
 
Transformation $shuffler
 
ilTestQuestionConfig $testQuestionConfig
 
ilAssQuestionLifecycle $lifecycle
 
ilObjUser $current_user
 

Private Attributes

string $current_cmd
 
ILIAS FileUpload FileUpload $file_upload
 

Additional Inherited Members

- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords (int $activeId, int $pass, int $questionId)
 
- Static Protected Attributes inherited from assQuestion
static $allowedFileExtensionsByMimeType
 
static $allowedCharsetsByMimeType
 
static $allowedImageMaterialFileExtensionsByMimeType
 
static $forcePassResultsUpdateEnabled = 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 34 of file class.assFileUpload.php.

Member Function Documentation

◆ buildTestPresentationConfig()

assFileUpload::buildTestPresentationConfig ( )

build basic test question configuration instance

method can be overwritten to configure an instance use parent call for building when possible

Reimplemented from assQuestion.

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

1151 {
1152 return parent::buildTestPresentationConfig()
1154 }
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 (   $active_id,
  $pass = null,
  $authorizedSolution = true,
  $returndetails = false 
)

Returns the points, a learner has reached answering the question.

The points are calculated from the given answers.

@access public

Parameters
integer$active_id
integer$pass
boolean$returndetails(deprecated !!)
Returns
integer/array $points/$details (array $details is deprecated !!)

Reimplemented from assQuestion.

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

309 {
310 if ($returndetails) {
311 throw new ilTestException('return details not implemented for ' . __METHOD__);
312 }
313
314 if ($this->isCompletionBySubmissionEnabled()) {
315 if (is_null($pass)) {
316 $pass = $this->getSolutionMaxPass($active_id);
317 }
318
319 global $DIC;
320
321 $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
322
323 while ($data = $DIC->database()->fetchAssoc($result)) {
324 if ($this->isDummySolutionRecord($data)) {
325 continue;
326 }
327
328 return $this->getPoints();
329 }
330 }
331
332 return 0;
333 }
getCurrentSolutionResultSet(int $active_id, int $pass, bool $authorized=true)
getSolutionMaxPass(int $active_id)
isDummySolutionRecord(array $solutionRecord)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28

References $data, $DIC, assQuestion\getCurrentSolutionResultSet(), assQuestion\getPoints(), assQuestion\getSolutionMaxPass(), isCompletionBySubmissionEnabled(), and assQuestion\isDummySolutionRecord().

+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

assFileUpload::calculateReachedPointsForSolution (   $userSolution)
protected

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

336 {
337 if ($this->isCompletionBySubmissionEnabled() &&
338 is_array($userSolution) &&
339 count($userSolution)) {
340 return $this->getPoints();
341 }
342
343 return 0;
344 }

References assQuestion\getPoints(), and isCompletionBySubmissionEnabled().

+ Here is the call graph for this function:

◆ checkUpload()

assFileUpload::checkUpload ( )

Check file upload.

Returns
boolean Input ok, true/false

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

351 : bool
352 {
353 $this->lng->loadLanguageModule("form");
354 // remove trailing '/'
355 $_FILES["upload"]["name"] = rtrim($_FILES["upload"]["name"], '/');
356
357 $filename = $_FILES["upload"]["name"];
358 $filename_arr = pathinfo($_FILES["upload"]["name"]);
359 $suffix = $filename_arr["extension"] ?? '';
360 $mimetype = $_FILES["upload"]["type"];
361 $size_bytes = $_FILES["upload"]["size"];
362 $temp_name = $_FILES["upload"]["tmp_name"];
363 $error = $_FILES["upload"]["error"];
364
365 if ($size_bytes > $this->getMaxFilesizeInBytes()) {
366 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_msg_file_size_exceeds"), true);
367 return false;
368 }
369
370 // error handling
371 if ($error > 0) {
372 switch ($error) {
373 case UPLOAD_ERR_FORM_SIZE:
374 case UPLOAD_ERR_INI_SIZE:
375 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_msg_file_size_exceeds"), true);
376 return false;
377 break;
378
379 case UPLOAD_ERR_PARTIAL:
380 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_msg_file_partially_uploaded"), true);
381 return false;
382 break;
383
384 case UPLOAD_ERR_NO_FILE:
385 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_msg_file_no_upload"), true);
386 return false;
387 break;
388
389 case UPLOAD_ERR_NO_TMP_DIR:
390 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_msg_file_missing_tmp_dir"), true);
391 return false;
392 break;
393
394 case UPLOAD_ERR_CANT_WRITE:
395 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_msg_file_cannot_write_to_disk"), true);
396 return false;
397 break;
398
399 case UPLOAD_ERR_EXTENSION:
400 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_msg_file_upload_stopped_ext"), true);
401 return false;
402 break;
403 }
404 }
405
406 // check suffixes
407 if (count($this->getAllowedExtensionsArray())) {
408 if (!strlen($suffix)) {
409 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_msg_file_missing_file_ext"), true);
410 return false;
411 }
412
413 if (!in_array(strtolower($suffix), $this->getAllowedExtensionsArray())) {
414 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_msg_file_wrong_file_type"), true);
415 return false;
416 }
417 }
418
419 // virus handling
420 if (strlen($temp_name)) {
421 $vir = ilVirusScanner::virusHandling($temp_name, $filename);
422 if ($vir[0] == false) {
423 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_msg_file_virus_found") . "<br />" . $vir[1], true);
424 return false;
425 }
426 }
427 return true;
428 }
$filename
Definition: buildRTE.php:78
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)

References $filename, getAllowedExtensionsArray(), getMaxFilesizeInBytes(), ILIAS\Repository\lng(), and ilVirusScanner\virusHandling().

Referenced by savePreviewData(), and saveWorkingData().

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

◆ copyObject()

assFileUpload::copyObject (   $target_questionpool_id,
  $title = "" 
)

Copies an assFileUpload object.

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

232 : int
233 {
234 if ($this->getId() <= 0) {
235 throw new RuntimeException('The question has not been saved. It cannot be duplicated');
236 }
237 // duplicate the question in database
238 $clone = $this;
240 $clone->id = -1;
241 $source_questionpool_id = $this->getObjId();
242 $clone->setObjId($target_questionpool_id);
243 if ($title) {
244 $clone->setTitle($title);
245 }
246 $clone->saveToDb();
247
248 // copy question page content
249 $clone->copyPageOfQuestion($original_id);
250 // copy XHTML media objects
251 $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
252
253 $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
254
255 return $clone->id;
256 }
static _getOriginalId(int $question_id)

References assQuestion\$original_id, assQuestion\$title, assQuestion\_getOriginalId(), assQuestion\getId(), and assQuestion\getObjId().

+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

assFileUpload::createNewOriginalFromThisDuplicate (   $targetParentId,
  $targetQuestionTitle = "" 
)

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

258 : int
259 {
260 if ($this->getId() <= 0) {
261 throw new RuntimeException('The question has not been saved. It cannot be duplicated');
262 }
263
264 $sourceQuestionId = $this->id;
265 $sourceParentId = $this->getObjId();
266
267 // duplicate the question in database
268 $clone = $this;
269 $clone->id = -1;
270
271 $clone->setObjId($targetParentId);
272
273 if ($targetQuestionTitle) {
274 $clone->setTitle($targetQuestionTitle);
275 }
276
277 $clone->saveToDb();
278 // copy question page content
279 $clone->copyPageOfQuestion($sourceQuestionId);
280 // copy XHTML media objects
281 $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
282
283 $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
284
285 return $clone->id;
286 }

References assQuestion\$id, assQuestion\getId(), and assQuestion\getObjId().

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

959 : void
960 {
961 }

◆ deletePreviewFileUploads()

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

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

619 {
620 foreach ($files as $name) {
621 if (isset($userSolution[$name])) {
622 unset($userSolution[$name]);
623 @unlink($this->getPreviewFileUploadPath($userId) . $name);
624 }
625 }
626
627 return $userSolution;
628 }
getPreviewFileUploadPath($userId)
Returns the filesystem path for file uploads.
if($format !==null) $name
Definition: metadata.php:247

References $name, and getPreviewFileUploadPath().

Referenced by savePreviewData().

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

◆ deleteUploadedFiles()

assFileUpload::deleteUploadedFiles (   $files,
  $test_id,
  $active_id,
  $authorized 
)
protected

Delete uploaded files.

Parameters
arrayArray with ID's of the file datasets

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

550 : void
551 {
552 global $DIC;
553 $ilDB = $DIC['ilDB'];
554
555 $pass = null;
556 $active_id = null;
557 foreach ($files as $solution_id) {
558 $result = $ilDB->queryF(
559 "SELECT * FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
560 array("integer", 'integer'),
561 array($solution_id, (int) $authorized)
562 );
563 if ($result->numRows() == 1) {
564 $data = $ilDB->fetchAssoc($result);
565 $pass = $data['pass'];
566 $active_id = $data['active_fi'];
567 @unlink($this->getFileUploadPath($test_id, $active_id) . $data['value1']);
568 }
569 }
570 foreach ($files as $solution_id) {
571 $affectedRows = $ilDB->manipulateF(
572 "DELETE FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
573 array("integer", 'integer'),
574 array($solution_id, $authorized)
575 );
576 }
577 }
getFileUploadPath($test_id, $active_id, $question_id=null)
Returns the filesystem path for file uploads.
int $test_id
The database id of a test in which the question is contained.

References $data, $DIC, $ilDB, assQuestion\$test_id, and getFileUploadPath().

+ Here is the call graph for this function:

◆ deliverFileUploadZIPFile()

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

Generates a ZIP file containing all file uploads for a given test and the original id of the question.

Parameters
int$ref_id
int$test_id
string$test_title

Implements ilObjFileHandlingQuestionType.

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

1093 : void
1094 {
1095 global $DIC;
1096 $ilDB = $DIC['ilDB'];
1097 $lng = $DIC['lng'];
1098
1099 $exporter = new ilAssFileUploadUploadsExporter($ilDB, $lng);
1100
1101 $exporter->setRefId($ref_id);
1102 $exporter->setTestId($test_id);
1103 $exporter->setTestTitle($test_title);
1104 $exporter->setQuestion($this);
1105
1106 $exporter->build();
1107
1109 $exporter->getFinalZipFilePath(),
1110 $exporter->getDispoZipFileName(),
1111 $exporter->getZipFileMimeType(),
1112 false,
1113 true
1114 );
1115 }
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
$ref_id
Definition: ltiauth.php:67

References $DIC, $ilDB, assQuestion\$lng, $ref_id, assQuestion\$test_id, and ilFileDelivery\deliverFileLegacy().

+ Here is the call graph for this function:

◆ duplicate()

assFileUpload::duplicate ( bool  $for_test = true,
string  $title = "",
string  $author = "",
string  $owner = "",
  $testObjId = null 
)

Duplicates an assFileUpload.

Reimplemented from assQuestion.

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

184 : int
185 {
186 if ($this->id <= 0) {
187 // The question has not been saved. It cannot be duplicated
188 return -1;
189 }
190 // duplicate the question in database
191 $this_id = $this->getId();
192 $thisObjId = $this->getObjId();
193
194 $clone = $this;
196 $clone->id = -1;
197
198 if ((int) $testObjId > 0) {
199 $clone->setObjId($testObjId);
200 }
201
202 if ($title) {
203 $clone->setTitle($title);
204 }
205
206 if ($author) {
207 $clone->setAuthor($author);
208 }
209 if ($owner) {
210 $clone->setOwner($owner);
211 }
212
213 if ($for_test) {
214 $clone->saveToDb($original_id);
215 } else {
216 $clone->saveToDb();
217 }
218
219 // copy question page content
220 $clone->copyPageOfQuestion($this_id);
221 // copy XHTML media objects
222 $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
223
224 $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
225
226 return $clone->id;
227 }

References assQuestion\$author, assQuestion\$original_id, assQuestion\$owner, assQuestion\$title, assQuestion\_getOriginalId(), assQuestion\getId(), and assQuestion\getObjId().

+ Here is the call graph for this function:

◆ fromXML()

assFileUpload::fromXML (   $item,
int  $questionpool_id,
?int  $tst_id,
$tst_object,
int &  $question_counter,
array  $import_mapping,
array &  $solutionhints = [] 
)

Creates a question from a QTI file.

Receives parameters from a QTI parser and creates a valid ILIAS question object

Parameters
ilQTIItem$itemThe QTI item object
integer$questionpool_idThe id of the parent questionpool
integer$tst_idThe id of the parent test if the question is part of a test
object$tst_objectA reference to the parent test object
integer$question_counterA reference to a question counter to count the questions of an imported question pool
array$import_mappingAn array containing references to included ILIAS objects

Reimplemented from assQuestion.

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

1007 : array
1008 {
1009 $import = new assFileUploadImport($this);
1010 return $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
1011 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getAdditionalTableName()

assFileUpload::getAdditionalTableName ( )
Returns
string|array Or Array?
See also
Deletion methods here

Reimplemented from assQuestion.

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

946 : string
947 {
948 return "qpl_qst_fileupload";
949 }

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAllowedExtensions()

assFileUpload::getAllowedExtensions ( )

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

1043 : string
1044 {
1046 }

References $allowedextensions.

Referenced by saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAllowedExtensionsArray()

assFileUpload::getAllowedExtensionsArray ( )

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

1035 : array
1036 {
1037 if (strlen($this->allowedextensions)) {
1038 return array_filter(array_map('trim', explode(",", $this->allowedextensions)));
1039 }
1040 return array();
1041 }

Referenced by checkUpload().

+ Here is the caller graph for this function:

◆ getAnswerTableName()

assFileUpload::getAnswerTableName ( )
Returns
string|array Or Array?
See also
Deletion methods here

Reimplemented from assQuestion.

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

951 : string
952 {
953 return "";
954 }

◆ getBestSolution()

assFileUpload::getBestSolution (   $active_id,
  $pass 
)

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

1019 : array
1020 {
1021 $user_solution = array();
1022 return $user_solution;
1023 }

◆ getFileUploadPath()

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

Returns the filesystem path for file uploads.

Implements ilObjFileHandlingQuestionType.

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

433 : string
434 {
435 if (is_null($question_id)) {
436 $question_id = $this->getId();
437 }
438 return CLIENT_WEB_DIR . "/assessment/tst_$test_id/$active_id/$question_id/files/";
439 }
const CLIENT_WEB_DIR
Definition: constants.php:47

References CLIENT_WEB_DIR, and assQuestion\getId().

Referenced by deleteUploadedFiles(), and saveWorkingData().

+ Here is the call graph for this function:
+ Here is the caller 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 454 of file class.assFileUpload.php.

455 {
456 if (is_null($question_id)) {
457 $question_id = $this->getId();
458 }
459 $webdir = ilFileUtils::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/tst_$test_id/$active_id/$question_id/files/";
460 return str_replace(
463 $webdir
464 );
465 }
static removeTrailingPathSeparators(string $path)

References CLIENT_WEB_DIR, assQuestion\getId(), and ilFileUtils\removeTrailingPathSeparators().

Referenced by getUploadedFilesForWeb().

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

◆ getMaxFilesizeAsString()

assFileUpload::getMaxFilesizeAsString ( )

Return the maximum allowed file size as string.

Returns
string The number of bytes of the maximum allowed file size

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

635 : string
636 {
637 $size = $this->getMaxFilesizeInBytes();
638 if ($size < 1024) {
639 $max_filesize = sprintf("%d Bytes", $size);
640 } elseif ($size < 1024 * 1024) {
641 $max_filesize = sprintf("%.1f KB", $size / 1024);
642 } else {
643 $max_filesize = sprintf("%.1f MB", $size / 1024 / 1024);
644 }
645
646 return $max_filesize;
647 }

References getMaxFilesizeInBytes().

+ Here is the call graph for this function:

◆ getMaxFilesizeInBytes()

assFileUpload::getMaxFilesizeInBytes ( )

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

649 : int
650 {
651 if ($this->getMaxSize() > 0) {
652 return $this->getMaxSize();
653 }
654
655 // get the value for the maximal uploadable filesize from the php.ini (if available)
656 $umf = get_cfg_var("upload_max_filesize");
657 // get the value for the maximal post data from the php.ini (if available)
658 $pms = get_cfg_var("post_max_size");
659
660 //convert from short-string representation to "real" bytes
661 $multiplier_a = array("K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024);
662
663 $umf_parts = preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
664 $pms_parts = preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
665
666 if (count($umf_parts) === 2) {
667 $umf = $umf_parts[0] * $multiplier_a[$umf_parts[1]];
668 }
669 if (count($pms_parts) === 2) {
670 $pms = $pms_parts[0] * $multiplier_a[$pms_parts[1]];
671 }
672
673 // use the smaller one as limit
674 $max_filesize = min($umf, $pms);
675
676 if (!$max_filesize) {
677 $max_filesize = max($umf, $pms);
678 }
679
680 return (int) $max_filesize;
681 }

References getMaxSize().

Referenced by checkUpload(), and getMaxFilesizeAsString().

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

◆ getMaximumPoints()

assFileUpload::getMaximumPoints ( )

Returns the maximum points, a learner can reach answering the question.

See also
$points

Reimplemented from assQuestion.

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

293 : float
294 {
295 return $this->getPoints();
296 }

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

1025 : ?int
1026 {
1027 return $this->maxsize;
1028 }

References $maxsize.

Referenced by getMaxFilesizeInBytes(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getPreviewFileUploadPath()

assFileUpload::getPreviewFileUploadPath (   $userId)
protected

Returns the filesystem path for file uploads.

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

444 : string
445 {
446 return CLIENT_WEB_DIR . "/assessment/qst_preview/$userId/{$this->getId()}/fileuploads/";
447 }

References CLIENT_WEB_DIR.

Referenced by deletePreviewFileUploads(), and savePreviewData().

+ Here is the caller graph for this function:

◆ getPreviewFileUploadPathWeb()

assFileUpload::getPreviewFileUploadPathWeb (   $userId)
protected

Returns the filesystem path for file uploads.

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

471 {
472 $webdir = ilFileUtils::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/qst_preview/$userId/{$this->getId()}/fileuploads/";
473 return str_replace(
476 $webdir
477 );
478 }

References CLIENT_WEB_DIR, and ilFileUtils\removeTrailingPathSeparators().

Referenced by savePreviewData().

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

◆ getPreviewFileUploads()

assFileUpload::getPreviewFileUploads ( ilAssQuestionPreviewSession  $previewSession)

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

509 : array
510 {
511 if ($previewSession->getParticipantsSolution() === false || $previewSession->getParticipantsSolution() === null) {
512 return [];
513 }
514
515 return $previewSession->getParticipantsSolution();
516 }

References ilAssQuestionPreviewSession\getParticipantsSolution().

+ Here is the call graph for this function:

◆ getQuestionType()

assFileUpload::getQuestionType ( )

Returns the question type of the question.

Returns
string The question type of the question

Reimplemented from assQuestion.

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

941 : string
942 {
943 return "assFileUpload";
944 }

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

967 : string
968 {
969 $text = parent::getRTETextWithMediaObjects();
970 return $text;
971 }

◆ getUploadedFiles()

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

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

Returns
array Results

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

485 : array
486 {
487 global $DIC;
488 $ilDB = $DIC['ilDB'];
489
490 if (is_null($pass)) {
491 $pass = $this->getSolutionMaxPass($active_id);
492 }
493 // fau: testNav - check existing value1 because the intermediate solution will have a dummy entry
494 $result = $ilDB->queryF(
495 "SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND authorized = %s AND value1 IS NOT NULL ORDER BY tstamp",
496 array("integer", "integer", "integer", 'integer'),
497 array($active_id, $this->getId(), $pass, (int) $authorized)
498 );
499 // fau.
500 $found = array();
501
502 while ($data = $ilDB->fetchAssoc($result)) {
503 array_push($found, $data);
504 }
505
506 return $found;
507 }

References $data, $DIC, $ilDB, assQuestion\getId(), and assQuestion\getSolutionMaxPass().

Referenced by getUploadedFilesForWeb(), and handleSubmission().

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

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

523 : array
524 {
525 global $DIC;
526 $ilDB = $DIC['ilDB'];
527
528 $found = $this->getUploadedFiles($active_id, $pass);
529 $result = $ilDB->queryF(
530 "SELECT test_fi FROM tst_active WHERE active_id = %s",
531 array('integer'),
532 array($active_id)
533 );
534 if ($result->numRows() == 1) {
535 $row = $ilDB->fetchAssoc($result);
536 $test_id = $row["test_fi"];
537 $path = $this->getFileUploadPathWeb($test_id, $active_id);
538 foreach ($found as $idx => $data) {
539 $found[$idx]['webpath'] = $path;
540 }
541 }
542 return $found;
543 }
getFileUploadPathWeb($test_id, $active_id, $question_id=null)
Returns the file upload path for web accessible files of a question.
getUploadedFiles($active_id, $pass=null, $authorized=true)
Returns the uploaded files for an active user in a given pass.
$path
Definition: ltiservices.php:32

References $data, $DIC, $ilDB, $path, assQuestion\$test_id, getFileUploadPathWeb(), and getUploadedFiles().

+ Here is the call graph for this function:

◆ getUserSolutionPreferingIntermediate()

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

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

812 : array
813 {
814 $solution = $this->getSolutionValues($active_id, $pass, false);
815
816 if (!count($solution)) {
817 $solution = $this->getSolutionValues($active_id, $pass, true);
818 } else {
819 $cleaned = array();
820 foreach ($solution as $row) {
821 if (!empty($row['value1'])) {
822 $cleaned[] = $row;
823 }
824 }
825 $solution = $cleaned;
826 }
827
828 return $solution;
829 }
getSolutionValues($active_id, $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.

References assQuestion\getSolutionValues().

+ Here is the call graph for this function:

◆ handleSubmission()

assFileUpload::handleSubmission (   $active_id,
  $pass,
  $obligationsAnswered,
  $authorized 
)
protected

This method is called after an user submitted one or more files.

It should handle the setting "Completion by Submission" and, if enabled, set the status of the current user.

Parameters
integer
integer

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

915 : void
916 {
917 if (!$authorized) {
918 return;
919 }
920
921 if ($this->isCompletionBySubmissionEnabled()) {
922 $maxpoints = assQuestion::_getMaximumPoints($this->getId());
923
924 if ($this->getUploadedFiles($active_id, $pass, $authorized)) {
925 $points = $maxpoints;
926 } else {
927 // fau: testNav - don't set reached points if no file is available
928 return;
929 // fau.
930 }
931
932 assQuestion::_setReachedPoints($active_id, $this->getId(), $points, $maxpoints, $pass, true, $obligationsAnswered);
933
935 ilObjTest::_getObjectIDFromActiveID((int) $active_id),
936 ilObjTestAccess::_getParticipantId((int) $active_id)
937 );
938 }
939 }
static _getMaximumPoints(int $question_id)
Returns the maximum points, a learner can reach answering the question.
float $points
The maximum available points for the question.
static _setReachedPoints(int $active_id, int $question_id, float $points, float $maxpoints, int $pass, bool $manualscoring, bool $obligationsEnabled)
Sets the points, a learner has reached answering the question Additionally objective results are upda...
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
static _getParticipantId($active_id)
Get user id for active id.
static _getObjectIDFromActiveID($active_id)
Returns the ILIAS test object id for a given active id.

References assQuestion\$points, assQuestion\_getMaximumPoints(), ilObjTest\_getObjectIDFromActiveID(), ilObjTestAccess\_getParticipantId(), assQuestion\_setReachedPoints(), ilLPStatusWrapper\_updateStatus(), assQuestion\getId(), getUploadedFiles(), and isCompletionBySubmissionEnabled().

+ Here is the call graph for this function:

◆ hasFileUploads()

assFileUpload::hasFileUploads (   $test_id)

Checks if file uploads exist for a given test and the original id of the question.

Parameters
int$test_id

Implements ilObjFileHandlingQuestionType.

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

1063 : bool
1064 {
1065 global $DIC;
1066 $ilDB = $DIC['ilDB'];
1067 $query = "
1068 SELECT tst_solutions.solution_id
1069 FROM tst_solutions, tst_active, qpl_questions
1070 WHERE tst_solutions.active_fi = tst_active.active_id
1071 AND tst_solutions.question_fi = qpl_questions.question_id
1072 AND tst_solutions.question_fi = %s AND tst_active.test_fi = %s
1073 AND tst_solutions.value1 is not null";
1074 $result = $ilDB->queryF(
1075 $query,
1076 array("integer", "integer"),
1077 array($this->getId(), $test_id)
1078 );
1079 if ($result->numRows() > 0) {
1080 return true;
1081 } else {
1082 return false;
1083 }
1084 }
$query

References $DIC, $ilDB, $query, assQuestion\$test_id, and assQuestion\getId().

+ Here is the call graph for this function:

◆ isAnswered()

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

Reimplemented from assQuestion.

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

1133 : bool
1134 {
1135 $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
1136
1137 return $numExistingSolutionRecords > 0;
1138 }
static getNumExistingSolutionRecords(int $activeId, int $pass, int $questionId)

References assQuestion\getId(), and assQuestion\getNumExistingSolutionRecords().

+ Here is the call graph for this function:

◆ isAutosaveable()

assFileUpload::isAutosaveable ( )

Reimplemented from assQuestion.

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

1145 : bool
1146 {
1147 return false;
1148 }

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

86 : bool
87 {
88 if (
89 strlen($this->title)
90 && ($this->author)
91 && ($this->question)
92 && ($this->getMaximumPoints() >= 0)
93 && is_numeric($this->getMaximumPoints())) {
94 return true;
95 }
96 return false;
97 }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.

References getMaximumPoints().

+ Here is the call graph for this function:

◆ isCompletionBySubmissionEnabled()

assFileUpload::isCompletionBySubmissionEnabled ( )

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

1117 : bool
1118 {
1120 }

References $completion_by_submission.

Referenced by calculateReachedPoints(), calculateReachedPointsForSolution(), handleSubmission(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ isFileDeletionAction()

assFileUpload::isFileDeletionAction ( )
protected

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

References ilAssFileUploadFileTableDeleteButton\ACTION, and assQuestion\getQuestionAction().

Referenced by savePreviewData(), and saveWorkingData().

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

◆ isFileDeletionSubmitAvailable()

assFileUpload::isFileDeletionSubmitAvailable ( )
protected

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

1161 : bool
1162 {
1163 return $this->isNonEmptyItemListPostSubmission(self::DELETE_FILES_TBL_POSTVAR);
1164 }
isNonEmptyItemListPostSubmission(string $postSubmissionFieldname)

References assQuestion\isNonEmptyItemListPostSubmission().

Referenced by savePreviewData(), and saveWorkingData().

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

◆ isFileReuseHandlingRequired()

assFileUpload::isFileReuseHandlingRequired ( )
protected

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

1171 : bool
1172 {
1173 if (!$this->getTestPresentationConfig()->isPreviousPassSolutionReuseAllowed()) {
1174 return false;
1175 }
1176
1177 if (!$this->isFileReuseSubmitAvailable()) {
1178 return false;
1179 }
1180
1181 return true;
1182 }

References assQuestion\getTestPresentationConfig(), and isFileReuseSubmitAvailable().

Referenced by saveWorkingData().

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

◆ isFileReuseSubmitAvailable()

assFileUpload::isFileReuseSubmitAvailable ( )
protected

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

1166 : bool
1167 {
1168 return $this->isNonEmptyItemListPostSubmission(self::REUSE_FILES_TBL_POSTVAR);
1169 }

References assQuestion\isNonEmptyItemListPostSubmission().

Referenced by isFileReuseHandlingRequired().

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

◆ isFileUploadAvailable()

assFileUpload::isFileUploadAvailable ( )
protected
Exceptions
IllegalStateException

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

1187 : bool
1188 {
1189 if (!$this->file_upload->hasUploads()) {
1190 return false;
1191 }
1192
1193 if (!$this->file_upload->hasBeenProcessed()) {
1194 $this->file_upload->process();
1195 }
1196
1197 return true;
1198 }

Referenced by savePreviewData(), and saveWorkingData().

+ Here is the caller graph for this function:

◆ isObligationPossible()

static assFileUpload::isObligationPossible ( int  $questionId)
static

Reimplemented from assQuestion.

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

1140 : bool
1141 {
1142 return true;
1143 }

◆ loadFromDb()

assFileUpload::loadFromDb (   $question_id)

Loads a assFileUpload object from a database.

Parameters
integer$question_idA unique key which defines the question in the database

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

141 : void
142 {
143 global $DIC;
144 $ilDB = $DIC['ilDB'];
145 $result = $ilDB->queryF(
146 "SELECT qpl_questions.*, " . $this->getAdditionalTableName() . ".* FROM qpl_questions LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = qpl_questions.question_id WHERE qpl_questions.question_id = %s",
147 array("integer"),
148 array($question_id)
149 );
150 if ($result->numRows() == 1) {
151 $data = $ilDB->fetchAssoc($result);
152 $this->setId($question_id);
153 $this->setTitle((string) $data["title"]);
154 $this->setComment((string) $data["description"]);
155 $this->setNrOfTries($data['nr_of_tries']);
156 $this->setOriginalId($data["original_id"]);
157 $this->setObjId($data["obj_fi"]);
158 $this->setAuthor($data["author"]);
159 $this->setOwner($data["owner"]);
160 $this->setPoints($data["points"]);
161
162 $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc((string) $data["question_text"], 1));
163 $this->setMaxSize(($data["maxsize"] ?? null) ? (int) $data["maxsize"] : null);
164 $this->setAllowedExtensions($data["allowedextensions"]);
165 $this->setCompletionBySubmission($data['compl_by_submission'] == 1 ? true : false);
166
167 try {
171 }
172
173 try {
174 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
176 }
177 }
178 parent::loadFromDb($question_id);
179 }
setMaxSize(?int $a_value)
setAllowedExtensions($a_value)
Set allowed file extensions.
setCompletionBySubmission($bool)
Enabled/Disable completion by submission.
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, $DIC, Vendor\Package\$e, $ilDB, 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 832 of file class.assFileUpload.php.

832 : void
833 {
834 parent::removeIntermediateSolution($active_id, $pass);
835
836 $test_id = $this->lookupTestId($active_id);
837 if ($test_id !== -1) {
838 $this->deleteUnusedFiles($test_id, $active_id, $pass);
839 }
840 }
lookupTestId(int $active_id)
@refactor Move to ilObjTest or similar

References assQuestion\$test_id, and assQuestion\lookupTestId().

+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assFileUpload::saveAdditionalQuestionDataToDb ( )

Saves a record to the question types additional data table.

Returns
mixed

Implements ilObjQuestionScoringAdjustable.

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

115 {
116 global $DIC;
117 $ilDB = $DIC['ilDB'];
118 $ilDB->manipulateF(
119 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
120 array( "integer" ),
121 array( $this->getId() )
122 );
123 $ilDB->manipulateF(
124 "INSERT INTO " . $this->getAdditionalTableName(
125 ) . " (question_fi, maxsize, allowedextensions, compl_by_submission) VALUES (%s, %s, %s, %s)",
126 array( "integer", "float", "text", "integer" ),
127 array(
128 $this->getId(),
129 $this->getMaxSize(),
130 (strlen($this->getAllowedExtensions())) ? $this->getAllowedExtensions() : null,
132 )
133 );
134 }

References $DIC, $ilDB, 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 843 of file class.assFileUpload.php.

843 : void
844 {
845 $userSolution = $previewSession->getParticipantsSolution();
846
847 if (!is_array($userSolution)) {
848 $userSolution = array();
849 }
850
851 // hey: prevPassSolutions - readability spree - get a chance to understand the code
852 if ($this->isFileDeletionAction()) {
853 // hey.
854 // hey: prevPassSolutions - readability spree - get a chance to understand the code
855 if ($this->isFileDeletionSubmitAvailable()) {
856 // hey.
857 $userSolution = $this->deletePreviewFileUploads($previewSession->getUserId(), $userSolution, $_POST['deletefiles']);
858 } else {
859 $this->tpl->setOnScreenMessage('info', $this->lng->txt('no_checkbox'), true);
860 }
861 } else {
862 try {
863 $fileUploadAvailable = $this->current_cmd !== 'instantResponse'
864 && $this->isFileUploadAvailable();
865 } catch (IllegalStateException $e) {
866 $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
867 return;
868 }
869 // hey: prevPassSolutions - readability spree - get a chance to understand the code
870 if ($fileUploadAvailable) {
871 // hey.
872 if ($this->checkUpload()) {
873 if (!@file_exists($this->getPreviewFileUploadPath($previewSession->getUserId()))) {
875 }
876
877 $version = time();
878 $filename_arr = pathinfo($_FILES["upload"]["name"]);
879 $extension = $filename_arr["extension"];
880 $newfile = "file_" . md5($_FILES["upload"]["name"]) . "_" . $version . "." . $extension;
881 try {
883 $_FILES["upload"]["tmp_name"],
884 $_FILES["upload"]["name"],
885 $this->getPreviewFileUploadPath($previewSession->getUserId()) . $newfile
886 );
887 } catch (ilException $e) {
888 $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
889 return;
890 }
891
892
893 $userSolution[$newfile] = array(
894 'solution_id' => $newfile,
895 'value1' => $newfile,
896 'value2' => $_FILES['upload']['name'],
897 'tstamp' => $version,
898 'webpath' => $this->getPreviewFileUploadPathWeb($previewSession->getUserId())
899 );
900 }
901 }
902 }
903
904 $previewSession->setParticipantsSolution($userSolution);
905 }
$version
Definition: plugin.php:24
getPreviewFileUploadPathWeb($userId)
Returns the filesystem path for file uploads.
deletePreviewFileUploads($userId, $userSolution, $files)
checkUpload()
Check file upload.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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, checkUpload(), deletePreviewFileUploads(), ilAssQuestionPreviewSession\getParticipantsSolution(), getPreviewFileUploadPath(), getPreviewFileUploadPathWeb(), ilAssQuestionPreviewSession\getUserId(), isFileDeletionAction(), isFileDeletionSubmitAvailable(), isFileUploadAvailable(), ILIAS\Repository\lng(), ilFileUtils\makeDirParents(), ilFileUtils\moveUploadedFile(), and ilAssQuestionPreviewSession\setParticipantsSolution().

+ Here is the call graph for this function:

◆ saveToDb()

assFileUpload::saveToDb (   $original_id = "")

Saves a assFileUpload object to a database.

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

102 : void
103 {
104 if ($original_id == '') {
105 $this->saveQuestionDataToDb();
106 } else {
108 }
109
111 parent::saveToDb();
112 }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveQuestionDataToDb(int $original_id=-1)

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

+ Here is the call graph for this function:

◆ saveWorkingData()

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

@access public

Parameters
integer$active_idActive id of the user
integer$passTest pass

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

688 : bool
689 {
690 $pass = $this->ensureCurrentTestPass($active_id, $pass);
691 $test_id = $this->lookupTestId($active_id);
692
693 try {
694 $upload_handling_required = $this->current_cmd !== 'submitSolution'
695 && $this->current_cmd !== 'showInstantResponse'
696 && !$this->isFileDeletionAction()
697 && $this->isFileUploadAvailable()
698 && $this->checkUpload();
699 } catch (IllegalStateException $e) {
700 $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
701 return false;
702 }
703 $upload_file_data = [];
704
705 if ($upload_handling_required) {
706 if (!@file_exists($this->getFileUploadPath($test_id, $active_id))) {
708 }
709
710 $upload_file_data ['solution_file_versioning_upload_ts'] = time();
711 $filename_arr = pathinfo($_FILES["upload"]["name"]);
712 $extension = $filename_arr["extension"];
713 $new_file_name = "file_" . $active_id . "_" . $pass . "_" . $upload_file_data ['solution_file_versioning_upload_ts'] . "." . $extension;
714 $upload_file_data['new_file_name'] = ilFileUtils::getValidFilename($new_file_name);
715
716 try {
718 $_FILES["upload"]["tmp_name"],
719 $_FILES["upload"]["name"],
720 $this->getFileUploadPath($test_id, $active_id) . $upload_file_data['new_file_name']
721 );
722 } catch (ilException $e) {
723 $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
724 return false;
725 }
726 }
727
728 $entered_values = false;
729
730 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $upload_handling_required, $upload_file_data, $test_id, $active_id, $pass, $authorized) {
731 if ($authorized == false) {
732 $this->forceExistingIntermediateSolution($active_id, $pass, true);
733 }
734
735 if ($this->isFileDeletionAction()) {
736 if ($this->isFileDeletionSubmitAvailable()) {
737 foreach ($_POST[self::DELETE_FILES_TBL_POSTVAR] as $solution_id) {
738 $this->removeSolutionRecordById($solution_id);
739 }
740 } else {
741 $this->tpl->setOnScreenMessage('info', $this->lng->txt('no_checkbox'), true);
742 }
743 } else {
744 if ($this->isFileReuseHandlingRequired()) {
745 foreach ($_POST[self::REUSE_FILES_TBL_POSTVAR] as $solutionId) {
746 $solution = $this->getSolutionRecordById($solutionId);
747
748 $this->saveCurrentSolution(
749 $active_id,
750 $pass,
751 $solution['value1'],
752 $solution['value2'],
753 false,
754 $solution['tstamp']
755 );
756 }
757 }
758
759 if ($upload_handling_required) {
760 $dispoFilename = ilFileUtils::getValidFilename($_FILES['upload']['name']);
761
762 $this->saveCurrentSolution(
763 $active_id,
764 $pass,
765 $upload_file_data['new_file_name'],
766 $dispoFilename,
767 false,
768 $upload_file_data ['solution_file_versioning_upload_ts']
769 );
770
771 $entered_values = true;
772 }
773 }
774
775 if ($authorized == true && $this->intermediateSolutionExists($active_id, $pass)) {
776 // remove the dummy record of the intermediate solution
777 $this->deleteDummySolutionRecord($active_id, $pass);
778
779 // delete the authorized solution and make the intermediate solution authorized (keeping timestamps)
780 $this->removeCurrentSolution($active_id, $pass, true);
781 $this->updateCurrentSolutionsAuthorization($active_id, $pass, true, true);
782 }
783
784 $this->deleteUnusedFiles($test_id, $active_id, $pass);
785 });
786
787 if ($entered_values) {
789 assQuestion::logAction($this->lng->txtlng(
790 "assessment",
791 "log_user_entered_values",
793 ), $active_id, $this->getId());
794 }
795 } else {
797 assQuestion::logAction($this->lng->txtlng(
798 "assessment",
799 "log_user_not_entered_values",
801 ), $active_id, $this->getId());
802 }
803 }
804
805 return true;
806 }
static logAction(string $logtext, int $active_id, int $question_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)
ensureCurrentTestPass(int $active_id, int $pass)
removeSolutionRecordById(int $solutionId)
forceExistingIntermediateSolution(int $activeId, int $passIndex, bool $considerDummyRecordCreation)
removeCurrentSolution(int $active_id, int $pass, bool $authorized=true)
intermediateSolutionExists(int $active_id, int $pass)
static getValidFilename(string $a_filename)

References Vendor\Package\$e, assQuestion\$test_id, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), checkUpload(), assQuestion\deleteDummySolutionRecord(), assQuestion\ensureCurrentTestPass(), assQuestion\forceExistingIntermediateSolution(), getFileUploadPath(), assQuestion\getProcessLocker(), assQuestion\getSolutionRecordById(), ilFileUtils\getValidFilename(), assQuestion\intermediateSolutionExists(), isFileDeletionAction(), isFileDeletionSubmitAvailable(), isFileReuseHandlingRequired(), isFileUploadAvailable(), ILIAS\Repository\lng(), assQuestion\logAction(), assQuestion\lookupTestId(), ilFileUtils\makeDirParents(), ilFileUtils\moveUploadedFile(), assQuestion\removeCurrentSolution(), assQuestion\removeSolutionRecordById(), assQuestion\saveCurrentSolution(), and assQuestion\updateCurrentSolutionsAuthorization().

+ Here is the call graph for this function:

◆ setAllowedExtensions()

assFileUpload::setAllowedExtensions (   $a_value)

Set allowed file extensions.

Parameters
string$a_valueAllowed file extensions

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

1053 : void
1054 {
1055 $this->allowedextensions = strtolower(trim($a_value));
1056 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setCompletionBySubmission()

assFileUpload::setCompletionBySubmission (   $bool)

Enabled/Disable completion by submission.

Parameters
boolean$bool

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

1128 {
1129 $this->completion_by_submission = (bool) $bool;
1130 return $this;
1131 }
Class for file upload questions.

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

assFileUpload::setExportDetailsXLS ( ilAssExcelFormatHelper  $worksheet,
int  $startrow,
int  $active_id,
int  $pass 
)

{}

Reimplemented from assQuestion.

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

976 : int
977 {
978 parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
979
980 $i = 1;
981 $solutions = $this->getSolutionValues($active_id, $pass);
982 foreach ($solutions as $solution) {
983 $worksheet->setCell($startrow + $i, 0, $this->lng->txt("result"));
984 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
985 if (strlen($solution["value1"])) {
986 $worksheet->setCell($startrow + $i, 2, $solution["value1"]);
987 $worksheet->setCell($startrow + $i, 3, $solution["value2"]);
988 }
989 $i++;
990 }
991
992 return $startrow + $i + 1;
993 }
setCell($a_row, $a_col, $a_value, $datatype=null)
setBold(string $a_coords)
Set cell(s) to bold.
getColumnCoord(int $a_col)
Get column "name" from number.
$i
Definition: metadata.php:41

References $i, ilExcel\getColumnCoord(), assQuestion\getSolutionValues(), ILIAS\Repository\lng(), ilExcel\setBold(), and ilAssExcelFormatHelper\setCell().

+ Here is the call graph for this function:

◆ setMaxSize()

assFileUpload::setMaxSize ( ?int  $a_value)

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

1030 : void
1031 {
1032 $this->maxsize = $a_value;
1033 }

Referenced by loadFromDb().

+ Here is the caller graph for this function:

◆ toXML()

assFileUpload::toXML (   $a_include_header = true,
  $a_include_binary = true,
  $a_shuffle = false,
  $test_output = false,
  $force_image_references = false 
)

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

1013 : string
1014 {
1015 $export = new assFileUploadExport($this);
1016 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
1017 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Field Documentation

◆ $allowedextensions

assFileUpload::$allowedextensions
protected

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

Referenced by getAllowedExtensions().

◆ $completion_by_submission

assFileUpload::$completion_by_submission = false
protected

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

Referenced by isCompletionBySubmissionEnabled().

◆ $current_cmd

string assFileUpload::$current_cmd
private

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

◆ $file_upload

ILIAS FileUpload FileUpload assFileUpload::$file_upload
private

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

◆ $maxsize

int assFileUpload::$maxsize = null
protected

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

Referenced by getMaxSize().

◆ DELETE_FILES_TBL_POSTVAR

const assFileUpload::DELETE_FILES_TBL_POSTVAR = 'deletefiles'

◆ HAS_SPECIFIC_FEEDBACK

const assFileUpload::HAS_SPECIFIC_FEEDBACK = false
protected

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