ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
assFileUpload Class Reference

Class for file upload questions. More...

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

Public Member Functions

 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assFileUpload constructor More...
 
 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 ($for_test=true, $title="", $author="", $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 ()
 Return the maximum allowed file size in bytes. More...
 
 saveWorkingData ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 getUserSolutionPreferingIntermediate ($active_id, $pass=null)
 Get the user solution preferring the intermediate solution. More...
 
 removeIntermediateSolution ($active_id, $pass)
 Remove an intermediate soluton (overridden to remove unused fies) More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 deleteAnswers ($question_id)
 Deletes datasets from answers tables. More...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 setExportDetailsXLS ($worksheet, $startrow, $active_id, $pass)
 {} More...
 
 fromXML (&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 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)
 Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM XML representation of the QTI xml representation. More...
 
 getBestSolution ($active_id, $pass)
 Returns the best solution for a given pass of a participant. More...
 
 getMaxSize ()
 Get max file size. More...
 
 setMaxSize ($a_value)
 Set max file size. More...
 
 getAllowedExtensionsArray ()
 Get allowed file extensions. More...
 
 getAllowedExtensions ()
 Get allowed file extensions. More...
 
 setAllowedExtensions ($a_value)
 Set allowed file extensions. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. 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 ()
 Checks whether completion by submission is enabled or not. More...
 
 setCompletionBySubmission ($bool)
 Enabled/Disable completion by submission. More...
 
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not More...
 
 isAutosaveable ()
 
 buildTestPresentationConfig ()
 Get the test question configuration Overridden from parent to disable the form change detection Otherwise just checking a file would delete it at navigation. More...
 
- Public Member Functions inherited from assQuestion
 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assQuestion constructor More...
 
 getShuffler ()
 
 setShuffler (ilArrayElementShuffler $shuffler)
 
 setProcessLocker ($processLocker)
 
 getProcessLocker ()
 
 fromXML (&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Receives parameters from a QTI parser and creates a valid ILIAS question object. More...
 
 toXML ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
 Returns a QTI xml representation of the question. More...
 
 isComplete ()
 Returns true, if a question is complete for use. More...
 
 questionTitleExists ($questionpool_id, $title)
 Returns TRUE if the question title exists in the database. More...
 
 setTitle ($title="")
 Sets the title string of the assQuestion object. More...
 
 setId ($id=-1)
 Sets the id of the assQuestion object. More...
 
 setTestId ($id=-1)
 Sets the test id of the assQuestion object. More...
 
 setComment ($comment="")
 Sets the comment string of the assQuestion object. More...
 
 setOutputType ($outputType=OUTPUT_HTML)
 Sets the output type. More...
 
 setShuffle ($shuffle=true)
 Sets the shuffle flag. More...
 
 setEstimatedWorkingTime ($hour=0, $min=0, $sec=0)
 Sets the estimated working time of a question from given hour, minute and second. More...
 
 setEstimatedWorkingTimeFromDurationString ($durationString)
 Sets the estimated working time of a question from a given datetime string. More...
 
 keyInArray ($searchkey, $array)
 returns TRUE if the key occurs in an array More...
 
 setAuthor ($author="")
 Sets the authors name of the assQuestion object. More...
 
 setOwner ($owner="")
 Sets the creator/owner ID of the assQuestion object. More...
 
 getTitle ()
 Gets the title string of the assQuestion object. More...
 
 getTitleFilenameCompliant ()
 returns the object title prepared to be used as a filename More...
 
 getId ()
 Gets the id of the assQuestion object. More...
 
 getShuffle ()
 Gets the shuffle flag. More...
 
 getTestId ()
 Gets the test id of the assQuestion object. More...
 
 getComment ()
 Gets the comment string of the assQuestion object. More...
 
 getOutputType ()
 Gets the output type. More...
 
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output. More...
 
 supportsNonJsOutput ()
 
 requiresJsSwitch ()
 
 getEstimatedWorkingTime ()
 Gets the estimated working time of a question. More...
 
 getAuthor ()
 Gets the authors name of the assQuestion object. More...
 
 getOwner ()
 Gets the creator/owner ID of the assQuestion object. More...
 
 getObjId ()
 Get the object id of the container object. More...
 
 setObjId ($obj_id=0)
 Set the object id of the container object. More...
 
 setExternalId ($external_id)
 
 getExternalId ()
 
 getSuggestedSolutionOutput ()
 
_getSuggestedSolution ($question_id, $subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutions ()
 Return the suggested solutions. More...
 
 getReachedPoints ($active_id, $pass=null)
 Returns the points, a learner has reached answering the question This is the fast way to get the points directly from the database. More...
 
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question. More...
 
 getAdjustedReachedPoints ($active_id, $pass=null, $authorizedSolution=true)
 returns the reached points ... More...
 
 calculateResultsFromSolution ($active_id, $pass=null, $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution. More...
 
 persistWorkingState ($active_id, $pass=null, $obligationsEnabled=false, $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 ($active_id, $pass=null, $authorized=true)
 Saves the learners input of the question to the database. More...
 
 moveUploadedMediaFile ($file, $name)
 Move an uploaded media file to an public accessible temp dir to present it. More...
 
 getSuggestedSolutionPath ()
 Returns the path for a suggested solution. More...
 
 getJavaPath ()
 Returns the image path for web accessable images of a question. More...
 
 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...
 
 getJavaPathWeb ()
 Returns the web image path for web accessable java applets of a question. More...
 
 getSuggestedSolutionPathWeb ()
 Returns the web path for a suggested solution. More...
 
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question. More...
 
 getFlashPathWeb ()
 Returns the web image path for web accessable flash applications of a question. More...
 
 getTestOutputSolutions ($activeId, $pass)
 
 getUserSolutionPreferingIntermediate ($active_id, $pass=null)
 
 getSolutionValues ($active_id, $pass=null, $authorized=true)
 Loads solutions of a given user from the database an returns it. More...
 
 isInUse ($question_id="")
 Checks whether the question is in use or not. More...
 
 isClone ($question_id="")
 Checks whether the question is a clone of another question or not. More...
 
 pcArrayShuffle ($array)
 Shuffles the values of a given array. More...
 
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database. More...
 
 getAnswerTableName ()
 Returns the name of the answer table in the database. More...
 
 deleteAnswers ($question_id)
 Deletes datasets from answers tables. More...
 
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database. More...
 
 delete ($question_id)
 Deletes a question and all materials from the database. More...
 
 getTotalAnswers ()
 get total number of answers More...
 
 _getTotalAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 create page object of question More...
 
 copyPageOfQuestion ($a_q_id)
 
 getPageOfQuestion ()
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 fixSvgToPng ($imageFilenameContainingString)
 
 fixUnavailableSkinImageSources ($html)
 
 loadFromDb ($question_id)
 Loads the question from the database. More...
 
 createNewQuestion ($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 ($original_id="")
 
 saveToDb ($original_id="")
 Saves the question to the database. More...
 
 setNewOriginalId ($newId)
 
 deleteSuggestedSolutions ()
 Deletes all suggestes solutions in the database. More...
 
 getSuggestedSolution ($subquestion_index=0)
 Returns a suggested solution for a given subquestion index. More...
 
 getSuggestedSolutionTitle ($subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index. More...
 
 setSuggestedSolution ($solution_id="", $subquestion_index=0, $is_import=false)
 Sets a suggested solution for the question. More...
 
 _resolveInternalLink ($internal_link)
 
 _resolveIntLinks ($question_id)
 
 syncWithOriginal ()
 
 createRandomSolution ($test_id, $user_id)
 
 _questionExists ($question_id)
 Returns true if the question already exists in the database. More...
 
 _questionExistsInPool ($question_id)
 Returns true if the question already exists in the database and is assigned to a question pool. More...
 
 getPoints ()
 Returns the maximum available points for the question. More...
 
 setPoints ($a_points)
 Sets the maximum available points for the question. More...
 
 getSolutionMaxPass ($active_id)
 Returns the maximum pass a users question solution. More...
 
 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 ($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
 Prepares a string for a text area output in tests. More...
 
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string. More...
 
 addQTIMaterial (&$a_xml_writer, $a_material, $close_material_tag=true, $add_mobs=true)
 Creates a QTI material tag from a plain text or xhtml text. More...
 
 buildHashedImageFilename ($plain_image_filename, $unique=false)
 
 getQuestion ()
 Gets the question string of the question object. More...
 
 setQuestion ($question="")
 Sets the question string of the question object. More...
 
 getQuestionType ()
 Returns the question type of the question. More...
 
 getQuestionTypeID ()
 Returns the question type of the question. More...
 
 cleanupMediaObjectUsage ()
 synchronises appearances of media objects in the question with media object usage table More...
 
getInstances ()
 Gets all instances of the question. More...
 
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id. More...
 
 setExportDetailsXLS ($worksheet, $startrow, $active_id, $pass)
 Creates an Excel worksheet for the detailed cumulated results of this question. More...
 
 __get ($value)
 Object getter. More...
 
 __set ($key, $value)
 Object setter. More...
 
 getNrOfTries ()
 
 setNrOfTries ($a_nr_of_tries)
 
 setExportImagePath ($a_path)
 
 formatSAQuestion ($a_q)
 Format self assessment question. More...
 
 setPreventRteUsage ($a_val)
 Set prevent rte usage. More...
 
 getPreventRteUsage ()
 Get prevent rte usage. More...
 
 migrateContentForLearningModule (ilAssSelfAssessmentMigrator $migrator)
 
 setSelfAssessmentEditingMode ($a_selfassessmenteditingmode)
 Set Self-Assessment Editing Mode. More...
 
 getSelfAssessmentEditingMode ()
 Get Self-Assessment Editing Mode. More...
 
 setDefaultNrOfTries ($a_defaultnroftries)
 Set Default Nr of Tries. More...
 
 getDefaultNrOfTries ()
 Get Default Nr of Tries. More...
 
 syncSkillAssignments ($srcParentId, $srcQuestionId, $trgParentId, $trgQuestionId)
 
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not More...
 
 isAutosaveable ()
 
 getAdditionalContentEditingMode ()
 getter for additional content editing mode for this question More...
 
 setAdditionalContentEditingMode ($additinalContentEditingMode)
 setter for additional content editing mode for this question More...
 
 isAdditionalContentEditingModePageObject ()
 isser for additional "pageobject" content editing mode More...
 
 isValidAdditionalContentEditingMode ($additionalContentEditingMode)
 returns the fact wether the passed additional content mode is valid or not More...
 
 getValidAdditionalContentEditingModes ()
 getter for valid additional content editing modes More...
 
 addQuestionChangeListener (ilQuestionChangeListener $listener)
 
 getQuestionChangeListeners ()
 
 getHtmlUserSolutionPurifier ()
 
 getHtmlQuestionContentPurifier ()
 
 setLastChange ($lastChange)
 
 getLastChange ()
 
 removeIntermediateSolution ($active_id, $pass)
 
 removeCurrentSolution ($active_id, $pass, $authorized=true)
 
 saveCurrentSolution ($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
 
 updateCurrentSolution ($solutionId, $value1, $value2, $authorized=true)
 
 updateCurrentSolutionsAuthorization ($activeId, $pass, $authorized, $keepTime=false)
 
 setStep ($step)
 
 getStep ()
 
 toJSON ()
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 
 intermediateSolutionExists ($active_id, $pass)
 
 authorizedSolutionExists ($active_id, $pass)
 
 authorizedOrIntermediateSolutionExists ($active_id, $pass)
 
 isAddableAnswerOptionValue ($qIndex, $answerOptionValue)
 
 addAnswerOptionValue ($qIndex, $answerOptionValue, $points)
 
 removeAllExistingSolutions ()
 
 removeExistingSolutions ($activeId, $pass)
 
 resetUsersAnswer ($activeId, $pass)
 
 removeResultRecord ($activeId, $pass)
 
 fetchValuePairsFromIndexedValues (array $indexedValues)
 
 fetchIndexedValuesFromValuePairs (array $valuePairs)
 
 areObligationsToBeConsidered ()
 
 setObligationsToBeConsidered ($obligationsToBeConsidered)
 
 updateTimestamp ()
 
 getTestPresentationConfig ()
 Get the test question configuration (initialised once) More...
 
 savePartial ()
 

Static Public Member Functions

static isObligationPossible ($questionId)
 returns boolean wether it is possible to set this question type as obligatory or not considering the current question configuration More...
 
- Static Public Member Functions inherited from assQuestion
static setForcePassResultUpdateEnabled ($forcePassResultsUpdateEnabled)
 
static isForcePassResultUpdateEnabled ()
 
static isAllowedImageMimeType ($mimeType)
 
static fetchMimeTypeIdentifier ($contentTypeString)
 
static getAllowedFileExtensionsForMimeType ($mimeType)
 
static isAllowedImageFileExtension ($mimeType, $fileExtension)
 
static getAllowedImageMaterialFileExtensions ()
 
static _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
static _getQuestionInfo ($question_id)
 Returns question information from the database. More...
 
static _getSuggestedSolutionCount ($question_id)
 Returns the number of suggested solutions associated with a question. More...
 
static _getSuggestedSolutionOutput ($question_id)
 Returns the output of the suggested solution. More...
 
static _getReachedPoints ($active_id, $question_id, $pass=null)
 Returns the points, a learner has reached answering the question. More...
 
static _updateTestResultCache ($active_id, ilAssQuestionProcessLocker $processLocker=null)
 Move this to a proper place. More...
 
static logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. More...
 
static getQuestionTypeFromDb ($question_id)
 get question type for question id More...
 
static _getTotalRightAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
static _getTitle ($a_q_id)
 Returns the title of a question. More...
 
static _getQuestionText ($a_q_id)
 Returns question text. More...
 
static isFileAvailable ($file)
 
static _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
static _getQuestionTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
static saveOriginalId ($questionId, $originalId)
 
static resetOriginalId ($questionId)
 
static _getInternalLinkHref ($target="")
 
static _getOriginalId ($question_id)
 Returns the original id of a question. More...
 
static originalQuestionExists ($questionId)
 
static _instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id. More...
 
static _instantiateQuestion ($question_id)
 
static _getSolutionMaxPass ($question_id, $active_id)
 Returns the maximum pass a users question solution. More...
 
static _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
static _isUsedInRandomTest ($question_id="")
 Checks whether the question is used in a random test or not. More...
 
static _isWorkedThrough ($active_id, $question_id, $pass=null)
 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 ($a_user_id, $a_question_ids)
 Checks if an array of question ids is answered by an user or not. More...
 
static _setReachedPoints ($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled)
 Sets the points, a learner has reached answering the question Additionally objective results are updated. More...
 
static _needsManualScoring ($question_id)
 
static _includeClass ($question_type, $gui=0)
 Include the php class file for a given question type. More...
 
static getGuiClassNameByQuestionType ($questionType)
 
static getObjectClassNameByQuestionType ($questionType)
 
static getFeedbackClassNameByQuestionType ($questionType)
 
static isCoreQuestionType ($questionType)
 
static includeCoreClass ($questionType, $withGuiClass)
 
static includePluginClass ($questionType, $withGuiClass)
 
static _getQuestionTypeName ($type_tag)
 Return the translation for a given question type tag. More...
 
static & _instanciateQuestionGUI ($question_id)
 Creates an instance of a question gui with a given question id. More...
 
static instantiateQuestionGUI ($a_question_id)
 Creates an instance of a question gui with a given question id. More...
 
static _questionExistsInTest ($question_id, $test_id)
 
static lookupParentObjId ($questionId)
 ilDBInterface $ilDB More...
 
static lookupOriginalParentObjId ($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 ($questionId)
 returns boolean wether it is possible to set this question type as obligatory or not considering the current question configuration More...
 
static implodeKeyValues ($keyValues)
 
static explodeKeyValues ($keyValues)
 
static setResultGateway ($resultGateway)
 
static getResultGateway ()
 
static sumTimesInISO8601FormatH_i_s_Extended ($time1, $time2)
 
static convertISO8601FormatH_i_s_ExtendedToSeconds ($time)
 
static missingResultRecordExists ($activeId, $pass, $questionIds)
 
static getQuestionsMissingResultRecord ($activeId, $pass, $questionIds)
 
static lookupResultRecordExist ($activeId, $questionId, $pass)
 

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 ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT = 'default'
 constant for additional content editing mode "default" More...
 
const ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT = 'pageobject'
 constant for additional content editing mode "pageobject" More...
 
 $feedbackOBJ = null
 
 $prevent_rte_usage = false
 
 $selfassessmenteditingmode = false
 
 $defaultnroftries = 0
 
 $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 ($postSubmissionFieldname)
 
 ensureCurrentTestPass ($active_id, $pass)
 
 lookupCurrentTestPass ($active_id, $pass)
 
 lookupTestId ($active_id)
 
 log ($active_id, $langVar)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 deletePageOfQuestion ($question_id)
 Deletes the page object of a question with a given ID. More...
 
 onDuplicate ($originalParentId, $originalQuestionId, $duplicateParentId, $duplicateQuestionId)
 Will be called when a question is duplicated (inside a question pool or for insertion in a test) More...
 
 beforeSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 afterSyncWithOriginal ($origQuestionId, $dupQuestionId, $origParentObjId, $dupParentObjId)
 
 onCopy ($sourceParentId, $sourceQuestionId, $targetParentId, $targetQuestionId)
 Will be called when a question is copied (into another question pool) More...
 
 duplicateSuggestedSolutionFiles ($parent_id, $question_id)
 Duplicates the files of a suggested solution if the question is duplicated. More...
 
 syncSuggestedSolutionFiles ($original_id)
 Syncs the files of a suggested solution if the question is synced. More...
 
 copySuggestedSolutionFiles ($source_questionpool_id, $source_question_id)
 
 ensureNonNegativePoints ($points)
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 getSelfAssessmentFormatter ()
 
 lmMigrateQuestionTypeGenericContent (ilAssSelfAssessmentMigrator $migrator)
 
 lmMigrateQuestionTypeSpecificContent (ilAssSelfAssessmentMigrator $migrator)
 
 duplicateQuestionHints ($originalQuestionId, $duplicateQuestionId)
 
 duplicateSkillAssignments ($srcParentId, $srcQuestionId, $trgParentId, $trgQuestionId)
 
 buildQuestionDataQuery ()
 
 getCurrentSolutionResultSet ($active_id, $pass, $authorized=true)
 Get a restulset for the current user solution for a this question by active_id and pass. More...
 
 removeSolutionRecordById ($solutionId)
 
 getSolutionRecordById ($solutionId)
 
 deleteDummySolutionRecord ($activeId, $passIndex)
 
 isDummySolutionRecord ($solutionRecord)
 
 deleteSolutionRecordByValues ($activeId, $passIndex, $authorized, $matchValues)
 
 duplicateIntermediateSolutionAuthorized ($activeId, $passIndex)
 
 forceExistingIntermediateSolution ($activeId, $passIndex, $considerDummyRecordCreation)
 
 buildTestPresentationConfig ()
 build basic test question configuration instance More...
 

Protected Attributes

 $maxsize
 
 $allowedextensions
 
 $completion_by_submission = false
 
- Protected Attributes inherited from assQuestion
 $id
 
 $title
 
 $comment
 
 $owner
 
 $author
 
 $question
 
 $points
 
 $est_working_time
 
 $shuffle
 
 $test_id
 
 $obj_id
 
 $ilias
 
 $tpl
 
 $lng
 
 $db
 
 $outputType = OUTPUT_JAVASCRIPT
 
 $suggested_solutions
 
 $original_id
 
 $page
 
 $external_id = ''
 
 $questionChangeListeners = array()
 
 $processLocker
 
 $step = null
 
 $lastChange
 
 $shuffler
 
 $testQuestionConfig
 

Additional Inherited Members

- Static Protected Member Functions inherited from assQuestion
static getNumExistingSolutionRecords ($activeId, $pass, $questionId)
 returns the number of existing solution records for the given test active / pass and given question id More...
 
static getKeyValuesImplosionSeparator ()
 
- 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 20 of file class.assFileUpload.php.

Constructor & Destructor Documentation

◆ __construct()

assFileUpload::__construct (   $title = "",
  $comment = "",
  $author = "",
  $owner = -1,
  $question = "" 
)

assFileUpload constructor

The constructor takes possible arguments an creates an instance of the assFileUpload object.

Parameters
string$titleA title string to describe the question
string$commentA comment string to describe the question
string$authorA string containing the name of the questions author
integer$ownerA numerical ID to identify the owner/creator
string$questionThe question string of the single choice question
See also
assQuestion:__construct()

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

References assQuestion\$author, assQuestion\$comment, assQuestion\$owner, assQuestion\$question, and assQuestion\$title.

Member Function Documentation

◆ __get()

assFileUpload::__get (   $value)

Object getter.

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

References getAllowedExtensions(), getMaxSize(), and isCompletionBySubmissionEnabled().

1069  {
1070  switch ($value) {
1071  case "maxsize":
1072  return $this->getMaxSize();
1073  break;
1074  case "allowedextensions":
1075  return $this->getAllowedExtensions();
1076  break;
1077  case 'completion_by_submission':
1078  return $this->isCompletionBySubmissionEnabled();
1079  break;
1080  default:
1081  return parent::__get($value);
1082  break;
1083  }
1084  }
getAllowedExtensions()
Get allowed file extensions.
getMaxSize()
Get max file size.
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
+ Here is the call graph for this function:

◆ __set()

assFileUpload::__set (   $key,
  $value 
)

Object setter.

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

References $key, setAllowedExtensions(), setCompletionBySubmission(), and setMaxSize().

1090  {
1091  switch ($key) {
1092  case "maxsize":
1093  $this->setMaxSize($value);
1094  break;
1095  case "allowedextensions":
1096  $this->setAllowedExtensions($value);
1097  break;
1098  case 'completion_by_submission':
1099  $this->setCompletionBySubmission($value);
1100  break;
1101  default:
1102  parent::__set($key, $value);
1103  break;
1104  }
1105  }
setAllowedExtensions($a_value)
Set allowed file extensions.
setMaxSize($a_value)
Set max file size.
setCompletionBySubmission($bool)
Enabled/Disable completion by submission.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ buildTestPresentationConfig()

assFileUpload::buildTestPresentationConfig ( )

Get the test question configuration Overridden from parent to disable the form change detection Otherwise just checking a file would delete it at navigation.

Returns
ilTestQuestionConfig

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

1242  {
1243  // hey: refactored identifiers
1244  return parent::buildTestPresentationConfig()
1245  // hey.
1246  ->setFormChangeDetectionEnabled(false);
1247  }

◆ 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.

public

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

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

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

283  {
284  if ($returndetails) {
285  throw new ilTestException('return details not implemented for ' . __METHOD__);
286  }
287 
288  if ($this->isCompletionBySubmissionEnabled()) {
289  if (is_null($pass)) {
290  $pass = $this->getSolutionMaxPass($active_id);
291  }
292 
293  global $DIC;
294 
295  $result = $this->getCurrentSolutionResultSet($active_id, $pass, $authorizedSolution);
296 
297  while ($data = $DIC->database()->fetchAssoc($result)) {
298  if ($this->isDummySolutionRecord($data)) {
299  continue;
300  }
301 
302  return $this->getPoints();
303  }
304  }
305 
306  return 0;
307  }
$result
getPoints()
Returns the maximum available points for the question.
global $DIC
Definition: saml.php:7
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
isDummySolutionRecord($solutionRecord)
getCurrentSolutionResultSet($active_id, $pass, $authorized=true)
Get a restulset for the current user solution for a this question by active_id and pass...
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

assFileUpload::calculateReachedPointsForSolution (   $userSolution)
protected

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

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

310  {
311  if ($this->isCompletionBySubmissionEnabled() && count($userSolution)) {
312  return $this->getPoints();
313  }
314 
315  return 0;
316  }
getPoints()
Returns the maximum available points for the question.
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
+ Here is the call graph for this function:

◆ checkUpload()

assFileUpload::checkUpload ( )

Check file upload.

Returns
boolean Input ok, true/false

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

References $filename, getAllowedExtensionsArray(), getMaxFilesizeInBytes(), ilUtil\sendFailure(), and ilUtil\virusHandling().

Referenced by savePreviewData(), and saveWorkingData().

324  {
325  $this->lng->loadLanguageModule("form");
326  // remove trailing '/'
327  $_FILES["upload"]["name"] = rtrim($_FILES["upload"]["name"], '/');
328 
329  $filename = $_FILES["upload"]["name"];
330  $filename_arr = pathinfo($_FILES["upload"]["name"]);
331  $suffix = $filename_arr["extension"];
332  $mimetype = $_FILES["upload"]["type"];
333  $size_bytes = $_FILES["upload"]["size"];
334  $temp_name = $_FILES["upload"]["tmp_name"];
335  $error = $_FILES["upload"]["error"];
336 
337  if ($size_bytes > $this->getMaxFilesizeInBytes()) {
338  ilUtil::sendFailure($this->lng->txt("form_msg_file_size_exceeds"), true);
339  return false;
340  }
341 
342  // error handling
343  if ($error > 0) {
344  switch ($error) {
345  case UPLOAD_ERR_INI_SIZE:
346  ilUtil::sendFailure($this->lng->txt("form_msg_file_size_exceeds"), true);
347  return false;
348  break;
349 
350  case UPLOAD_ERR_FORM_SIZE:
351  ilUtil::sendFailure($this->lng->txt("form_msg_file_size_exceeds"), true);
352  return false;
353  break;
354 
355  case UPLOAD_ERR_PARTIAL:
356  ilUtil::sendFailure($this->lng->txt("form_msg_file_partially_uploaded"), true);
357  return false;
358  break;
359 
360  case UPLOAD_ERR_NO_FILE:
361  ilUtil::sendFailure($this->lng->txt("form_msg_file_no_upload"), true);
362  return false;
363  break;
364 
365  case UPLOAD_ERR_NO_TMP_DIR:
366  ilUtil::sendFailure($this->lng->txt("form_msg_file_missing_tmp_dir"), true);
367  return false;
368  break;
369 
370  case UPLOAD_ERR_CANT_WRITE:
371  ilUtil::sendFailure($this->lng->txt("form_msg_file_cannot_write_to_disk"), true);
372  return false;
373  break;
374 
375  case UPLOAD_ERR_EXTENSION:
376  ilUtil::sendFailure($this->lng->txt("form_msg_file_upload_stopped_ext"), true);
377  return false;
378  break;
379  }
380  }
381 
382  // check suffixes
383  if (count($this->getAllowedExtensionsArray())) {
384  if (!strlen($suffix)) {
385  ilUtil::sendFailure($this->lng->txt("form_msg_file_missing_file_ext"), true);
386  return false;
387  }
388 
389  if (!in_array(strtolower($suffix), $this->getAllowedExtensionsArray())) {
390  ilUtil::sendFailure($this->lng->txt("form_msg_file_wrong_file_type"), true);
391  return false;
392  }
393  }
394 
395  // virus handling
396  if (strlen($temp_name)) {
397  $vir = ilUtil::virusHandling($temp_name, $filename);
398  if ($vir[0] == false) {
399  ilUtil::sendFailure($this->lng->txt("form_msg_file_virus_found") . "<br />" . $vir[1], true);
400  return false;
401  }
402  }
403  return true;
404  }
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
getAllowedExtensionsArray()
Get allowed file extensions.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$filename
Definition: buildRTE.php:89
getMaxFilesizeInBytes()
Return the maximum allowed file size in bytes.
+ 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 201 of file class.assFileUpload.php.

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

202  {
203  if ($this->id <= 0) {
204  // The question has not been saved. It cannot be duplicated
205  return;
206  }
207  // duplicate the question in database
208  $clone = $this;
209  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
211  $clone->id = -1;
212  $source_questionpool_id = $this->getObjId();
213  $clone->setObjId($target_questionpool_id);
214  if ($title) {
215  $clone->setTitle($title);
216  }
217  $clone->saveToDb();
218 
219  // copy question page content
220  $clone->copyPageOfQuestion($original_id);
221  // copy XHTML media objects
222  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
223 
224  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
225 
226  return $clone->id;
227  }
static _getOriginalId($question_id)
Returns the original id of a question.
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

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

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

230  {
231  if ($this->id <= 0) {
232  // The question has not been saved. It cannot be duplicated
233  return;
234  }
235 
236  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
237 
238  $sourceQuestionId = $this->id;
239  $sourceParentId = $this->getObjId();
240 
241  // duplicate the question in database
242  $clone = $this;
243  $clone->id = -1;
244 
245  $clone->setObjId($targetParentId);
246 
247  if ($targetQuestionTitle) {
248  $clone->setTitle($targetQuestionTitle);
249  }
250 
251  $clone->saveToDb();
252  // copy question page content
253  $clone->copyPageOfQuestion($sourceQuestionId);
254  // copy XHTML media objects
255  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
256 
257  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
258 
259  return $clone->id;
260  }
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ deleteAnswers()

assFileUpload::deleteAnswers (   $question_id)

Deletes datasets from answers tables.

Parameters
integer$question_idThe question id which should be deleted in the answers table

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

934  {
935  }

◆ deletePreviewFileUploads()

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

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

References $files, $name, and getPreviewFileUploadPath().

Referenced by savePreviewData().

585  {
586  foreach ($files as $name) {
587  if (isset($userSolution[$name])) {
588  unset($userSolution[$name]);
589  @unlink($this->getPreviewFileUploadPath($userId) . $name);
590  }
591  }
592 
593  return $userSolution;
594  }
$files
Definition: metarefresh.php:49
getPreviewFileUploadPath($userId)
Returns the filesystem path for file uploads.
+ 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 516 of file class.assFileUpload.php.

References $data, $DIC, $files, $ilDB, $pass, $result, assQuestion\$step, assQuestion\$test_id, getFileUploadPath(), assQuestion\getSolutionValues(), assQuestion\getStep(), and assQuestion\setStep().

517  {
518  global $DIC;
519  $ilDB = $DIC['ilDB'];
520 
521  $pass = null;
522  $active_id = null;
523  foreach ($files as $solution_id) {
524  $result = $ilDB->queryF(
525  "SELECT * FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
526  array("integer", 'integer'),
527  array($solution_id, (int) $authorized)
528  );
529  if ($result->numRows() == 1) {
530  $data = $ilDB->fetchAssoc($result);
531  $pass = $data['pass'];
532  $active_id = $data['active_fi'];
533  @unlink($this->getFileUploadPath($test_id, $active_id) . $data['value1']);
534  }
535  }
536  foreach ($files as $solution_id) {
537  $affectedRows = $ilDB->manipulateF(
538  "DELETE FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
539  array("integer", 'integer'),
540  array($solution_id, $authorized)
541  );
542  }
543  }
$files
Definition: metarefresh.php:49
$result
global $DIC
Definition: saml.php:7
getFileUploadPath($test_id, $active_id, $question_id=null)
Returns the filesystem path for file uploads.
global $ilDB
$data
Definition: bench.php:6
+ 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$test_id

Implements ilObjFileHandlingQuestionType.

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

References $DIC, $ilDB, assQuestion\$lng, assQuestion\$test_id, and ilUtil\deliverFile().

1142  {
1143  global $DIC;
1144  $ilDB = $DIC['ilDB'];
1145  $lng = $DIC['lng'];
1146 
1147  require_once 'Modules/TestQuestionPool/classes/class.ilAssFileUploadUploadsExporter.php';
1148  $exporter = new ilAssFileUploadUploadsExporter($ilDB, $lng);
1149 
1150  $exporter->setRefId($ref_id);
1151  $exporter->setTestId($test_id);
1152  $exporter->setTestTitle($test_title);
1153  $exporter->setQuestion($this);
1154 
1155  $exporter->build();
1156 
1158  $exporter->getFinalZipFilePath(),
1159  $exporter->getDispoZipFileName(),
1160  $exporter->getZipFileMimeType(),
1161  false,
1162  true
1163  );
1164  }
global $DIC
Definition: saml.php:7
global $ilDB
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
+ Here is the call graph for this function:

◆ duplicate()

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

Duplicates an assFileUpload.

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

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

153  {
154  if ($this->id <= 0) {
155  // The question has not been saved. It cannot be duplicated
156  return;
157  }
158  // duplicate the question in database
159  $this_id = $this->getId();
160  $thisObjId = $this->getObjId();
161 
162  $clone = $this;
163  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
165  $clone->id = -1;
166 
167  if ((int) $testObjId > 0) {
168  $clone->setObjId($testObjId);
169  }
170 
171  if ($title) {
172  $clone->setTitle($title);
173  }
174 
175  if ($author) {
176  $clone->setAuthor($author);
177  }
178  if ($owner) {
179  $clone->setOwner($owner);
180  }
181 
182  if ($for_test) {
183  $clone->saveToDb($original_id);
184  } else {
185  $clone->saveToDb();
186  }
187 
188  // copy question page content
189  $clone->copyPageOfQuestion($this_id);
190  // copy XHTML media objects
191  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
192 
193  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
194 
195  return $clone->id;
196  }
getId()
Gets the id of the assQuestion object.
static _getOriginalId($question_id)
Returns the original id of a question.
getObjId()
Get the object id of the container object.
+ Here is the call graph for this function:

◆ fromXML()

assFileUpload::fromXML ( $item,
$questionpool_id,
$tst_id,
$tst_object,
$question_counter,
$import_mapping 
)

Creates a question from a QTI file.

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

Parameters
object$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

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

982  {
983  include_once "./Modules/TestQuestionPool/classes/import/qti12/class.assFileUploadImport.php";
984  $import = new assFileUploadImport($this);
985  $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
986  }
Class for file upload question imports.

◆ getAdditionalTableName()

assFileUpload::getAdditionalTableName ( )

Returns the name of the additional question data table in the database.

Returns
string The additional table name

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

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

914  {
915  return "qpl_qst_fileupload";
916  }
+ Here is the caller graph for this function:

◆ getAllowedExtensions()

assFileUpload::getAllowedExtensions ( )

Get allowed file extensions.

Returns
string Allowed file extensions

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

References $allowedextensions.

Referenced by __get(), and saveAdditionalQuestionDataToDb().

1051  {
1052  return $this->allowedextensions;
1053  }
+ Here is the caller graph for this function:

◆ getAllowedExtensionsArray()

assFileUpload::getAllowedExtensionsArray ( )

Get allowed file extensions.

Returns
array Allowed file extensions

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

Referenced by checkUpload().

1038  {
1039  if (strlen($this->allowedextensions)) {
1040  return array_filter(array_map('trim', explode(",", $this->allowedextensions)));
1041  }
1042  return array();
1043  }
+ Here is the caller graph for this function:

◆ getAnswerTableName()

assFileUpload::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name

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

924  {
925  return "";
926  }

◆ getBestSolution()

assFileUpload::getBestSolution (   $active_id,
  $pass 
)

Returns the best solution for a given pass of a participant.

Returns
array An associated array containing the best solution

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

1007  {
1008  $user_solution = array();
1009  return $user_solution;
1010  }

◆ getFileUploadPath()

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

Returns the filesystem path for file uploads.

Implements ilObjFileHandlingQuestionType.

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

References assQuestion\getId().

Referenced by deleteUploadedFiles(), and saveWorkingData().

410  {
411  if (is_null($question_id)) {
412  $question_id = $this->getId();
413  }
414  return CLIENT_WEB_DIR . "/assessment/tst_$test_id/$active_id/$question_id/files/";
415  }
getId()
Gets the id of the assQuestion object.
+ 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.

public

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

References assQuestion\getId(), and ilUtil\removeTrailingPathSeparators().

Referenced by getUploadedFilesForWeb().

431  {
432  if (is_null($question_id)) {
433  $question_id = $this->getId();
434  }
435  include_once "./Services/Utilities/classes/class.ilUtil.php";
436  $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/tst_$test_id/$active_id/$question_id/files/";
437  return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir);
438  }
getId()
Gets the id of the assQuestion object.
static removeTrailingPathSeparators($path)
+ 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 601 of file class.assFileUpload.php.

References $size, and getMaxFilesizeInBytes().

602  {
603  $size = $this->getMaxFilesizeInBytes();
604  if ($size < 1024) {
605  $max_filesize = sprintf("%d Bytes", $size);
606  } elseif ($size < 1024 * 1024) {
607  $max_filesize = sprintf("%.1f KB", $size / 1024);
608  } else {
609  $max_filesize = sprintf("%.1f MB", $size / 1024 / 1024);
610  }
611 
612  return $max_filesize;
613  }
$size
Definition: RandomTest.php:84
getMaxFilesizeInBytes()
Return the maximum allowed file size in bytes.
+ Here is the call graph for this function:

◆ getMaxFilesizeInBytes()

assFileUpload::getMaxFilesizeInBytes ( )

Return the maximum allowed file size in bytes.

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

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

References getMaxSize().

Referenced by checkUpload(), and getMaxFilesizeAsString().

621  {
622  if (strlen($this->getMaxSize())) {
623  return $this->getMaxSize();
624  } else {
625  // get the value for the maximal uploadable filesize from the php.ini (if available)
626  $umf = get_cfg_var("upload_max_filesize");
627  // get the value for the maximal post data from the php.ini (if available)
628  $pms = get_cfg_var("post_max_size");
629 
630  //convert from short-string representation to "real" bytes
631  $multiplier_a = array("K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024);
632 
633  $umf_parts = preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
634  $pms_parts = preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
635 
636  if (count($umf_parts) == 2) {
637  $umf = $umf_parts[0] * $multiplier_a[$umf_parts[1]];
638  }
639  if (count($pms_parts) == 2) {
640  $pms = $pms_parts[0] * $multiplier_a[$pms_parts[1]];
641  }
642 
643  // use the smaller one as limit
644  $max_filesize = min($umf, $pms);
645 
646  if (!$max_filesize) {
647  $max_filesize = max($umf, $pms);
648  }
649  return $max_filesize;
650  }
651  }
getMaxSize()
Get max file size.
+ 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

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

References assQuestion\getPoints().

Referenced by isComplete().

268  {
269  return $this->getPoints();
270  }
getPoints()
Returns the maximum available points for the question.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMaxSize()

assFileUpload::getMaxSize ( )

Get max file size.

Returns
double Max file size

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

References $maxsize.

Referenced by __get(), getMaxFilesizeInBytes(), and saveAdditionalQuestionDataToDb().

1018  {
1019  return $this->maxsize;
1020  }
+ Here is the caller graph for this function:

◆ getPreviewFileUploadPath()

assFileUpload::getPreviewFileUploadPath (   $userId)
protected

Returns the filesystem path for file uploads.

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

Referenced by deletePreviewFileUploads(), and savePreviewData().

421  {
422  return CLIENT_WEB_DIR . "/assessment/qst_preview/$userId/{$this->getId()}/fileuploads/";
423  }
+ Here is the caller graph for this function:

◆ getPreviewFileUploadPathWeb()

assFileUpload::getPreviewFileUploadPathWeb (   $userId)
protected

Returns the filesystem path for file uploads.

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

References ilUtil\removeTrailingPathSeparators().

Referenced by savePreviewData().

444  {
445  include_once "./Services/Utilities/classes/class.ilUtil.php";
446  $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/qst_preview/$userId/{$this->getId()}/fileuploads/";
447  return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir);
448  }
static removeTrailingPathSeparators($path)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPreviewFileUploads()

assFileUpload::getPreviewFileUploads ( ilAssQuestionPreviewSession  $previewSession)

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

References ilAssQuestionPreviewSession\getParticipantsSolution().

480  {
481  return (array) $previewSession->getParticipantsSolution();
482  }
+ Here is the call graph for this function:

◆ getQuestionType()

assFileUpload::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question

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

904  {
905  return "assFileUpload";
906  }

◆ getRTETextWithMediaObjects()

assFileUpload::getRTETextWithMediaObjects ( )

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

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

References $text.

942  {
943  $text = parent::getRTETextWithMediaObjects();
944  return $text;
945  }
$text
Definition: errorreport.php:18

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

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

Referenced by getUploadedFilesForWeb(), and handleSubmission().

456  {
457  global $DIC;
458  $ilDB = $DIC['ilDB'];
459 
460  if (is_null($pass)) {
461  $pass = $this->getSolutionMaxPass($active_id);
462  }
463  // fau: testNav - check existing value1 because the intermediate solution will have a dummy entry
464  $result = $ilDB->queryF(
465  "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",
466  array("integer", "integer", "integer", 'integer'),
467  array($active_id, $this->getId(), $pass, (int) $authorized)
468  );
469  // fau.
470  $found = array();
471 
472  while ($data = $ilDB->fetchAssoc($result)) {
473  array_push($found, $data);
474  }
475 
476  return $found;
477  }
getId()
Gets the id of the assQuestion object.
$result
global $DIC
Definition: saml.php:7
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
global $ilDB
$data
Definition: bench.php:6
+ 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 489 of file class.assFileUpload.php.

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

490  {
491  global $DIC;
492  $ilDB = $DIC['ilDB'];
493 
494  $found = $this->getUploadedFiles($active_id, $pass);
495  $result = $ilDB->queryF(
496  "SELECT test_fi FROM tst_active WHERE active_id = %s",
497  array('integer'),
498  array($active_id)
499  );
500  if ($result->numRows() == 1) {
501  $row = $ilDB->fetchAssoc($result);
502  $test_id = $row["test_fi"];
503  $path = $this->getFileUploadPathWeb($test_id, $active_id);
504  foreach ($found as $idx => $data) {
505  $found[$idx]['webpath'] = $path;
506  }
507  }
508  return $found;
509  }
$path
Definition: aliased.php:25
$result
global $DIC
Definition: saml.php:7
getFileUploadPathWeb($test_id, $active_id, $question_id=null)
Returns the file upload path for web accessible files of a question.
$row
global $ilDB
getUploadedFiles($active_id, $pass=null, $authorized=true)
Returns the uploaded files for an active user in a given pass.
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ getUserSolutionPreferingIntermediate()

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

Get the user solution preferring the intermediate solution.

Parameters
int$active_id
int | null$pass
Returns
array

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

References $pass, $row, and assQuestion\getSolutionValues().

767  {
768  $solution = $this->getSolutionValues($active_id, $pass, false);
769 
770  if (!count($solution)) {
771  $solution = $this->getSolutionValues($active_id, $pass, true);
772  } else {
773  $cleaned = array();
774  foreach ($solution as $row) {
775  if (!empty($row['value1'])) {
776  $cleaned[] = $row;
777  }
778  }
779  $solution = $cleaned;
780  }
781 
782  return $solution;
783  }
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
$row
+ 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
integerprotected

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

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

870  {
871  if (!$authorized) {
872  return;
873  }
874 
875  if ($this->isCompletionBySubmissionEnabled()) {
876  $maxpoints = assQuestion::_getMaximumPoints($this->getId());
877 
878  if ($this->getUploadedFiles($active_id, $pass, $authorized)) {
879  $points = $maxpoints;
880  } else {
881  // fau: testNav - don't set reached points if no file is available
882  return;
883  // fau.
884  }
885 
886  assQuestion::_setReachedPoints($active_id, $this->getId(), $points, $maxpoints, $pass, 1, $obligationsAnswered);
887 
888  // update learning progress
889  include_once 'Modules/Test/classes/class.ilObjTestAccess.php';
890  include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
892  ilObjTest::_getObjectIDFromActiveID((int) $active_id),
893  ilObjTestAccess::_getParticipantId((int) $active_id)
894  );
895  }
896  }
getId()
Gets the id of the assQuestion object.
static _getParticipantId($active_id)
Get user id for active id.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _getObjectIDFromActiveID($active_id)
Returns the ILIAS test object id for a given active id.
static _getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
getUploadedFiles($active_id, $pass=null, $authorized=true)
Returns the uploaded files for an active user in a given pass.
static _setReachedPoints($active_id, $question_id, $points, $maxpoints, $pass, $manualscoring, $obligationsEnabled)
Sets the points, a learner has reached answering the question Additionally objective results are upda...
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
+ 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
Returns
boolean TRUE if file uploads exist, FALSE otherwise

Implements ilObjFileHandlingQuestionType.

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

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

1115  {
1116  global $DIC;
1117  $ilDB = $DIC['ilDB'];
1118  $query = "
1119  SELECT tst_solutions.solution_id
1120  FROM tst_solutions, tst_active, qpl_questions
1121  WHERE tst_solutions.active_fi = tst_active.active_id
1122  AND tst_solutions.question_fi = qpl_questions.question_id
1123  AND tst_solutions.question_fi = %s AND tst_active.test_fi = %s";
1124  $result = $ilDB->queryF(
1125  $query,
1126  array("integer", "integer"),
1127  array($this->getId(), $test_id)
1128  );
1129  if ($result->numRows() > 0) {
1130  return true;
1131  } else {
1132  return false;
1133  }
1134  }
getId()
Gets the id of the assQuestion object.
$result
global $DIC
Definition: saml.php:7
$query
global $ilDB
+ Here is the call graph for this function:

◆ isAnswered()

assFileUpload::isAnswered (   $active_id,
  $pass = null 
)

returns boolean wether the question is answered during test pass or not

(overwrites method in class assQuestion)

ilDBInterface $ilDB

Parameters
integer$active_id
integer$pass
Returns
boolean $answered

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

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

1206  {
1207  $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
1208 
1209  return $numExistingSolutionRecords > 0;
1210  }
getId()
Gets the id of the assQuestion object.
static getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...
+ Here is the call graph for this function:

◆ isAutosaveable()

assFileUpload::isAutosaveable ( )

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

1228  {
1229  return false;
1230  }

◆ isComplete()

assFileUpload::isComplete ( )

Returns true, if the question is complete for use.

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

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

References getMaximumPoints().

63  {
64  if (
65  strlen($this->title)
66  && ($this->author)
67  && ($this->question)
68  && ($this->getMaximumPoints() >= 0)
69  && is_numeric($this->getMaximumPoints())) {
70  return true;
71  }
72  return false;
73  }
getMaximumPoints()
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ isCompletionBySubmissionEnabled()

assFileUpload::isCompletionBySubmissionEnabled ( )

Checks whether completion by submission is enabled or not.

Returns
boolean public

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

References $completion_by_submission.

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

1175  {
1177  }
+ Here is the caller graph for this function:

◆ isFileDeletionAction()

assFileUpload::isFileDeletionAction ( )
protected
Returns
bool

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

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

Referenced by savePreviewData(), and saveWorkingData().

1255  {
1256  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssFileUploadFileTableDeleteButton.php';
1258  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFileDeletionSubmitAvailable()

assFileUpload::isFileDeletionSubmitAvailable ( )
protected
Returns
bool

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

References assQuestion\isNonEmptyItemListPostSubmission().

Referenced by savePreviewData(), and saveWorkingData().

1264  {
1265  return $this->isNonEmptyItemListPostSubmission(self::DELETE_FILES_TBL_POSTVAR);
1266  }
isNonEmptyItemListPostSubmission($postSubmissionFieldname)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFileReuseHandlingRequired()

assFileUpload::isFileReuseHandlingRequired ( )
protected
Returns
bool

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

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

Referenced by saveWorkingData().

1280  {
1281  if (!$this->getTestPresentationConfig()->isPreviousPassSolutionReuseAllowed()) {
1282  return false;
1283  }
1284 
1285  if (!$this->isFileReuseSubmitAvailable()) {
1286  return false;
1287  }
1288 
1289  return true;
1290  }
getTestPresentationConfig()
Get the test question configuration (initialised once)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFileReuseSubmitAvailable()

assFileUpload::isFileReuseSubmitAvailable ( )
protected
Returns
bool

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

References assQuestion\isNonEmptyItemListPostSubmission().

Referenced by isFileReuseHandlingRequired().

1272  {
1273  return $this->isNonEmptyItemListPostSubmission(self::REUSE_FILES_TBL_POSTVAR);
1274  }
isNonEmptyItemListPostSubmission($postSubmissionFieldname)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFileUploadAvailable()

assFileUpload::isFileUploadAvailable ( )
protected
Returns
bool

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

Referenced by savePreviewData(), and saveWorkingData().

1296  {
1297  if (!isset($_FILES['upload'])) {
1298  return false;
1299  }
1300 
1301  if (!isset($_FILES['upload']['tmp_name'])) {
1302  return false;
1303  }
1304 
1305  return strlen($_FILES['upload']['tmp_name']) > 0;
1306  }
+ Here is the caller graph for this function:

◆ isObligationPossible()

static assFileUpload::isObligationPossible (   $questionId)
static

returns boolean wether it is possible to set this question type as obligatory or not considering the current question configuration

(overwrites method in class assQuestion)

Parameters
integer$questionId
Returns
boolean $obligationPossible

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

1223  {
1224  return true;
1225  }

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

References $data, $DIC, $ilDB, $result, ilRTE\_replaceMediaObjectImageSrc(), getAdditionalTableName(), assQuestion\setAdditionalContentEditingMode(), setAllowedExtensions(), assQuestion\setAuthor(), assQuestion\setComment(), setCompletionBySubmission(), assQuestion\setEstimatedWorkingTime(), assQuestion\setId(), setMaxSize(), assQuestion\setNrOfTries(), assQuestion\setObjId(), assQuestion\setOriginalId(), assQuestion\setOwner(), assQuestion\setPoints(), assQuestion\setQuestion(), assQuestion\setSuggestedSolution(), and assQuestion\setTitle().

113  {
114  global $DIC;
115  $ilDB = $DIC['ilDB'];
116  $result = $ilDB->queryF(
117  "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",
118  array("integer"),
119  array($question_id)
120  );
121  if ($result->numRows() == 1) {
122  $data = $ilDB->fetchAssoc($result);
123  $this->setId($question_id);
124  $this->setTitle($data["title"]);
125  $this->setComment($data["description"]);
126  $this->setNrOfTries($data['nr_of_tries']);
127  $this->setSuggestedSolution($data["solution_hint"]);
128  $this->setOriginalId($data["original_id"]);
129  $this->setObjId($data["obj_fi"]);
130  $this->setAuthor($data["author"]);
131  $this->setOwner($data["owner"]);
132  $this->setPoints($data["points"]);
133 
134  include_once("./Services/RTE/classes/class.ilRTE.php");
135  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
136  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
137  $this->setMaxSize($data["maxsize"]);
138  $this->setAllowedExtensions($data["allowedextensions"]);
139  $this->setCompletionBySubmission($data['compl_by_submission'] == 1 ? true : false);
140 
141  try {
142  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
143  } catch (ilTestQuestionPoolException $e) {
144  }
145  }
146  parent::loadFromDb($question_id);
147  }
setSuggestedSolution($solution_id="", $subquestion_index=0, $is_import=false)
Sets a suggested solution for the question.
setAllowedExtensions($a_value)
Set allowed file extensions.
$result
global $DIC
Definition: saml.php:7
setId($id=-1)
Sets the id of the assQuestion object.
setEstimatedWorkingTime($hour=0, $min=0, $sec=0)
Sets the estimated working time of a question from given hour, minute and second. ...
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
setAuthor($author="")
Sets the authors name of the assQuestion object.
setMaxSize($a_value)
Set max file size.
setPoints($a_points)
Sets the maximum available points for the question.
setQuestion($question="")
Sets the question string of the question object.
global $ilDB
setOriginalId($original_id)
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setCompletionBySubmission($bool)
Enabled/Disable completion by submission.
setTitle($title="")
Sets the title string of the assQuestion object.
setObjId($obj_id=0)
Set the object id of the container object.
setComment($comment="")
Sets the comment string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner ID of the assQuestion object.
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ removeIntermediateSolution()

assFileUpload::removeIntermediateSolution (   $active_id,
  $pass 
)

Remove an intermediate soluton (overridden to remove unused fies)

Parameters
int$active_id
int$pass
Returns
int|object

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

References $DIC, $ilDB, $pass, $result, assQuestion\$test_id, and assQuestion\lookupTestId().

795  {
796  global $DIC;
797  $ilDB = $DIC['ilDB'];
798 
799  $result = parent::removeIntermediateSolution($active_id, $pass);
800 
801  // get the current test id
802  // hey: prevPassSolutions - exract until you drop :-D
803  $test_id = $this->lookupTestId($active_id);
804  // hey.
805 
806  $this->deleteUnusedFiles($test_id, $active_id, $pass);
807 
808  return $result;
809  }
$result
global $DIC
Definition: saml.php:7
lookupTestId($active_id)
global $ilDB
+ 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 85 of file class.assFileUpload.php.

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

Referenced by saveToDb().

86  {
87  global $DIC;
88  $ilDB = $DIC['ilDB'];
89  $ilDB->manipulateF(
90  "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
91  array( "integer" ),
92  array( $this->getId() )
93  );
94  $ilDB->manipulateF(
95  "INSERT INTO " . $this->getAdditionalTableName(
96  ) . " (question_fi, maxsize, allowedextensions, compl_by_submission) VALUES (%s, %s, %s, %s)",
97  array( "integer", "float", "text", "integer" ),
98  array(
99  $this->getId(),
100  (strlen($this->getMaxSize())) ? $this->getMaxSize() : null,
101  (strlen($this->getAllowedExtensions())) ? $this->getAllowedExtensions() : null,
102  (int) $this->isCompletionBySubmissionEnabled()
103  )
104  );
105  }
getId()
Gets the id of the assQuestion object.
getAllowedExtensions()
Get allowed file extensions.
global $DIC
Definition: saml.php:7
getMaxSize()
Get max file size.
global $ilDB
getAdditionalTableName()
Returns the name of the additional question data table in the database.
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ savePreviewData()

assFileUpload::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

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

References $_POST, $version, checkUpload(), deletePreviewFileUploads(), ilAssQuestionPreviewSession\getParticipantsSolution(), getPreviewFileUploadPath(), getPreviewFileUploadPathWeb(), ilAssQuestionPreviewSession\getUserId(), isFileDeletionAction(), isFileDeletionSubmitAvailable(), isFileUploadAvailable(), ilUtil\makeDirParents(), ilUtil\sendInfo(), and ilAssQuestionPreviewSession\setParticipantsSolution().

814  {
815  $userSolution = $previewSession->getParticipantsSolution();
816 
817  if (!is_array($userSolution)) {
818  $userSolution = array();
819  }
820 
821  // hey: prevPassSolutions - readability spree - get a chance to understand the code
822  if ($this->isFileDeletionAction()) {
823  // hey.
824  // hey: prevPassSolutions - readability spree - get a chance to understand the code
825  if ($this->isFileDeletionSubmitAvailable()) {
826  // hey.
827  $userSolution = $this->deletePreviewFileUploads($previewSession->getUserId(), $userSolution, $_POST['deletefiles']);
828  } else {
829  ilUtil::sendInfo($this->lng->txt('no_checkbox'), true);
830  }
831  } else {
832  // hey: prevPassSolutions - readability spree - get a chance to understand the code
833  if ($this->isFileUploadAvailable()) {
834  // hey.
835  if ($this->checkUpload()) {
836  if (!@file_exists($this->getPreviewFileUploadPath($previewSession->getUserId()))) {
837  ilUtil::makeDirParents($this->getPreviewFileUploadPath($previewSession->getUserId()));
838  }
839 
840  $version = time();
841  $filename_arr = pathinfo($_FILES["upload"]["name"]);
842  $extension = $filename_arr["extension"];
843  $newfile = "file_" . md5($_FILES["upload"]["name"]) . "_" . $version . "." . $extension;
844  ilUtil::moveUploadedFile($_FILES["upload"]["tmp_name"], $_FILES["upload"]["name"], $this->getPreviewFileUploadPath($previewSession->getUserId()) . $newfile);
845 
846  $userSolution[$newfile] = array(
847  'solution_id' => $newfile,
848  'value1' => $newfile,
849  'value2' => $_FILES['upload']['name'],
850  'tstamp' => $version,
851  'webpath' => $this->getPreviewFileUploadPathWeb($previewSession->getUserId())
852  );
853  }
854  }
855  }
856 
857  $previewSession->setParticipantsSolution($userSolution);
858  }
getPreviewFileUploadPathWeb($userId)
Returns the filesystem path for file uploads.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
deletePreviewFileUploads($userId, $userSolution, $files)
$version
Definition: build.php:27
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
checkUpload()
Check file upload.
getPreviewFileUploadPath($userId)
Returns the filesystem path for file uploads.
$_POST["username"]
+ Here is the call graph for this function:

◆ saveToDb()

assFileUpload::saveToDb (   $original_id = "")

Saves a assFileUpload object to a database.

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

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

79  {
82  parent::saveToDb();
83  }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveQuestionDataToDb($original_id="")
+ Here is the call graph for this function:

◆ saveWorkingData()

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

Saves the learners input of the question to the database.

public

Parameters
integer$active_idActive id of the user
integer$passTest pass
Returns
boolean $status

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

References $_POST, $pass, assQuestion\$test_id, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), checkUpload(), assQuestion\deleteDummySolutionRecord(), assQuestion\ensureCurrentTestPass(), assQuestion\forceExistingIntermediateSolution(), getFileUploadPath(), assQuestion\getId(), assQuestion\getProcessLocker(), assQuestion\getSolutionRecordById(), ilFileUtils\getValidFilename(), assQuestion\intermediateSolutionExists(), isFileDeletionAction(), isFileDeletionSubmitAvailable(), isFileReuseHandlingRequired(), isFileUploadAvailable(), assQuestion\logAction(), assQuestion\lookupTestId(), ilUtil\makeDirParents(), assQuestion\removeCurrentSolution(), assQuestion\removeSolutionRecordById(), assQuestion\saveCurrentSolution(), ilUtil\sendInfo(), and assQuestion\updateCurrentSolutionsAuthorization().

665  {
666  $pass = $this->ensureCurrentTestPass($active_id, $pass);
667  $test_id = $this->lookupTestId($active_id);
668 
669  $uploadHandlingRequired = $this->isFileUploadAvailable() && $this->checkUpload();
670 
671  $entered_values = false;
672 
673  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $uploadHandlingRequired, $test_id, $active_id, $pass, $authorized) {
674  if ($authorized == false) {
675  $this->forceExistingIntermediateSolution($active_id, $pass, true);
676  }
677 
678  if ($this->isFileDeletionAction()) {
679  if ($this->isFileDeletionSubmitAvailable()) {
680  foreach ($_POST[self::DELETE_FILES_TBL_POSTVAR] as $solution_id) {
681  $this->removeSolutionRecordById($solution_id);
682  }
683  } else {
684  ilUtil::sendInfo($this->lng->txt('no_checkbox'), true);
685  }
686  } else {
687  if ($this->isFileReuseHandlingRequired()) {
688  foreach ($_POST[self::REUSE_FILES_TBL_POSTVAR] as $solutionId) {
689  $solution = $this->getSolutionRecordById($solutionId);
690 
691  $this->saveCurrentSolution(
692  $active_id,
693  $pass,
694  $solution['value1'],
695  $solution['value2'],
696  false,
697  $solution['tstamp']
698  );
699  }
700  }
701 
702  if ($uploadHandlingRequired) {
703  if (!@file_exists($this->getFileUploadPath($test_id, $active_id))) {
705  }
706 
707  $solutionFileVersioningUploadTS = time();
708  $filename_arr = pathinfo($_FILES["upload"]["name"]);
709  $extension = $filename_arr["extension"];
710  $newfile = "file_" . $active_id . "_" . $pass . "_" . $solutionFileVersioningUploadTS . "." . $extension;
711 
712  include_once 'Services/Utilities/classes/class.ilFileUtils.php';
713  $dispoFilename = ilFileUtils::getValidFilename($_FILES['upload']['name']);
714  $newfile = ilFileUtils::getValidFilename($newfile);
715 
716  ilUtil::moveUploadedFile($_FILES["upload"]["tmp_name"], $_FILES["upload"]["name"], $this->getFileUploadPath($test_id, $active_id) . $newfile);
717 
718  $this->saveCurrentSolution(
719  $active_id,
720  $pass,
721  $newfile,
722  $dispoFilename,
723  false,
724  $solutionFileVersioningUploadTS
725  );
726 
727  $entered_values = true;
728  }
729  }
730 
731  if ($authorized == true && $this->intermediateSolutionExists($active_id, $pass)) {
732  // remove the dummy record of the intermediate solution
733  $this->deleteDummySolutionRecord($active_id, $pass);
734 
735  // delete the authorized solution and make the intermediate solution authorized (keeping timestamps)
736  $this->removeCurrentSolution($active_id, $pass, true);
737  $this->updateCurrentSolutionsAuthorization($active_id, $pass, true, true);
738  }
739 
740  $this->deleteUnusedFiles($test_id, $active_id, $pass);
741  });
742 
743  if ($entered_values) {
744  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
746  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
747  }
748  } else {
749  include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
751  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
752  }
753  }
754 
755  return true;
756  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
getId()
Gets the id of the assQuestion object.
forceExistingIntermediateSolution($activeId, $passIndex, $considerDummyRecordCreation)
intermediateSolutionExists($active_id, $pass)
deleteDummySolutionRecord($activeId, $passIndex)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
removeSolutionRecordById($solutionId)
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not
updateCurrentSolutionsAuthorization($activeId, $pass, $authorized, $keepTime=false)
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
checkUpload()
Check file upload.
getFileUploadPath($test_id, $active_id, $question_id=null)
Returns the filesystem path for file uploads.
lookupTestId($active_id)
removeCurrentSolution($active_id, $pass, $authorized=true)
ensureCurrentTestPass($active_id, $pass)
$_POST["username"]
static getValidFilename($a_filename)
Get valid filename.
getSolutionRecordById($solutionId)
+ 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 1060 of file class.assFileUpload.php.

Referenced by __set(), and loadFromDb().

1061  {
1062  $this->allowedextensions = strtolower(trim($a_value));
1063  }
+ Here is the caller graph for this function:

◆ setCompletionBySubmission()

assFileUpload::setCompletionBySubmission (   $bool)

Enabled/Disable completion by submission.

Parameters
boolean
Returns
assFileUpload public

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

Referenced by __set(), and loadFromDb().

1189  {
1190  $this->completion_by_submission = (bool) $bool;
1191  return $this;
1192  }
+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

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

{}

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

References $i, $pass, and assQuestion\getSolutionValues().

951  {
952  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
953 
954  $i = 1;
955  $solutions = $this->getSolutionValues($active_id, $pass);
956  foreach ($solutions as $solution) {
957  $worksheet->setCell($startrow + $i, 0, $this->lng->txt("result"));
958  $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
959  if (strlen($solution["value1"])) {
960  $worksheet->setCell($startrow + $i, 1, $solution["value1"]);
961  $worksheet->setCell($startrow + $i, 2, $solution["value2"]);
962  }
963  $i++;
964  }
965 
966  return $startrow + $i + 1;
967  }
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:

◆ setMaxSize()

assFileUpload::setMaxSize (   $a_value)

Set max file size.

Parameters
double$a_valueMax file size

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

Referenced by __set(), and loadFromDb().

1028  {
1029  $this->maxsize = $a_value;
1030  }
+ 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 
)

Returns a QTI xml representation of the question and sets the internal domxml variable with the DOM XML representation of the QTI xml representation.

Returns
string The QTI xml representation of the question

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

995  {
996  include_once "./Modules/TestQuestionPool/classes/export/qti12/class.assFileUploadExport.php";
997  $export = new assFileUploadExport($this);
998  return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
999  }
Class for file upload question exports.

Field Documentation

◆ $allowedextensions

assFileUpload::$allowedextensions
protected

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

Referenced by getAllowedExtensions().

◆ $completion_by_submission

assFileUpload::$completion_by_submission = false
protected

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

Referenced by isCompletionBySubmissionEnabled().

◆ $maxsize

assFileUpload::$maxsize
protected

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

Referenced by getMaxSize().

◆ DELETE_FILES_TBL_POSTVAR

const assFileUpload::DELETE_FILES_TBL_POSTVAR = 'deletefiles'

◆ REUSE_FILES_TBL_POSTVAR

const assFileUpload::REUSE_FILES_TBL_POSTVAR = 'reusefiles'

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