ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ($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)
 
 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...
 

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...
 
 deleteUnusedFiles ($test_id, $active_id, $pass)
 Delete all files that are neither used in an authorized or intermediate solution. More...
 
 deletePreviewFileUploads ($userId, $userSolution, $files)
 
 savePreviewData (ilAssQuestionPreviewSession $previewSession)
 
 reworkWorkingData ($active_id, $pass, $obligationsAnswered, $authorized)
 {} More...
 
 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)
 
 reworkWorkingData ($active_id, $pass, $obligationsAnswered, $authorized)
 Reworks the allready saved working data if neccessary. More...
 
 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)
 
 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 1122 of file class.assFileUpload.php.

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

1123  {
1124  switch ($value)
1125  {
1126  case "maxsize":
1127  return $this->getMaxSize();
1128  break;
1129  case "allowedextensions":
1130  return $this->getAllowedExtensions();
1131  break;
1132  case 'completion_by_submission':
1133  return $this->isCompletionBySubmissionEnabled();
1134  break;
1135  default:
1136  return parent::__get($value);
1137  break;
1138  }
1139  }
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 1144 of file class.assFileUpload.php.

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

1145  {
1146  switch ($key)
1147  {
1148  case "maxsize":
1149  $this->setMaxSize($value);
1150  break;
1151  case "allowedextensions":
1152  $this->setAllowedExtensions($value);
1153  break;
1154  case 'completion_by_submission':
1155  $this->setCompletionBySubmission($value);
1156  break;
1157  default:
1158  parent::__set($key, $value);
1159  break;
1160  }
1161  }
setAllowedExtensions($a_value)
Set allowed file extensions.
setMaxSize($a_value)
Set max file size.
setCompletionBySubmission($bool)
Enabled/Disable completion by submission.
+ 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 1291 of file class.assFileUpload.php.

1293  {
1294  // hey: refactored identifiers
1295  return parent::buildTestPresentationConfig()
1296  // hey.
1297  ->setFormChangeDetectionEnabled(false);
1298  }

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

References $ilDB, $pass, assQuestion\$points, and assQuestion\getSolutionMaxPass().

296  {
297  if( $returndetails )
298  {
299  throw new ilTestException('return details not implemented for '.__METHOD__);
300  }
301 
302  global $ilDB;
303 
304  if (is_null($pass))
305  {
306  $pass = $this->getSolutionMaxPass($active_id);
307  }
308  $points = 0;
309  return $points;
310  }
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
global $ilDB
+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

assFileUpload::calculateReachedPointsForSolution (   $userSolution)
protected

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

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

313  {
314  if( $this->isCompletionBySubmissionEnabled() && count($userSolution) )
315  {
316  return $this->getPoints();
317  }
318 
319  return 0;
320  }
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 327 of file class.assFileUpload.php.

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

Referenced by savePreviewData(), and saveWorkingData().

328  {
329  $this->lng->loadLanguageModule("form");
330  // remove trailing '/'
331  $_FILES["upload"]["name"] = rtrim($_FILES["upload"]["name"], '/');
332 
333  $filename = $_FILES["upload"]["name"];
334  $filename_arr = pathinfo($_FILES["upload"]["name"]);
335  $suffix = $filename_arr["extension"];
336  $mimetype = $_FILES["upload"]["type"];
337  $size_bytes = $_FILES["upload"]["size"];
338  $temp_name = $_FILES["upload"]["tmp_name"];
339  $error = $_FILES["upload"]["error"];
340 
341  if ($size_bytes > $this->getMaxFilesizeInBytes())
342  {
343  ilUtil::sendFailure($this->lng->txt("form_msg_file_size_exceeds"), true);
344  return false;
345  }
346 
347  // error handling
348  if ($error > 0)
349  {
350  switch ($error)
351  {
352  case UPLOAD_ERR_INI_SIZE:
353  ilUtil::sendFailure($this->lng->txt("form_msg_file_size_exceeds"), true);
354  return false;
355  break;
356 
357  case UPLOAD_ERR_FORM_SIZE:
358  ilUtil::sendFailure($this->lng->txt("form_msg_file_size_exceeds"), true);
359  return false;
360  break;
361 
362  case UPLOAD_ERR_PARTIAL:
363  ilUtil::sendFailure($this->lng->txt("form_msg_file_partially_uploaded"), true);
364  return false;
365  break;
366 
367  case UPLOAD_ERR_NO_FILE:
368  ilUtil::sendFailure($this->lng->txt("form_msg_file_no_upload"), true);
369  return false;
370  break;
371 
372  case UPLOAD_ERR_NO_TMP_DIR:
373  ilUtil::sendFailure($this->lng->txt("form_msg_file_missing_tmp_dir"), true);
374  return false;
375  break;
376 
377  case UPLOAD_ERR_CANT_WRITE:
378  ilUtil::sendFailure($this->lng->txt("form_msg_file_cannot_write_to_disk"), true);
379  return false;
380  break;
381 
382  case UPLOAD_ERR_EXTENSION:
383  ilUtil::sendFailure($this->lng->txt("form_msg_file_upload_stopped_ext"), true);
384  return false;
385  break;
386  }
387  }
388 
389  // check suffixes
390  if( count($this->getAllowedExtensionsArray()) )
391  {
392  if( !strlen($suffix) )
393  {
394  ilUtil::sendFailure($this->lng->txt("form_msg_file_missing_file_ext"), true);
395  return false;
396  }
397 
398  if( !in_array(strtolower($suffix), $this->getAllowedExtensionsArray()) )
399  {
400  ilUtil::sendFailure($this->lng->txt("form_msg_file_wrong_file_type"), true);
401  return false;
402  }
403  }
404 
405  // virus handling
406  if (strlen($temp_name))
407  {
408  $vir = ilUtil::virusHandling($temp_name, $filename);
409  if ($vir[0] == false)
410  {
411  ilUtil::sendFailure($this->lng->txt("form_msg_file_virus_found")."<br />".$vir[1], true);
412  return false;
413  }
414  }
415  return true;
416  }
$error
Definition: Error.php:17
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.
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 210 of file class.assFileUpload.php.

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

211  {
212  if ($this->id <= 0)
213  {
214  // The question has not been saved. It cannot be duplicated
215  return;
216  }
217  // duplicate the question in database
218  $clone = $this;
219  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
221  $clone->id = -1;
222  $source_questionpool_id = $this->getObjId();
223  $clone->setObjId($target_questionpool_id);
224  if ($title)
225  {
226  $clone->setTitle($title);
227  }
228  $clone->saveToDb();
229 
230  // copy question page content
231  $clone->copyPageOfQuestion($original_id);
232  // copy XHTML media objects
233  $clone->copyXHTMLMediaObjectsOfQuestion($original_id);
234 
235  $clone->onCopy($source_questionpool_id, $original_id, $clone->getObjId(), $clone->getId());
236 
237  return $clone->id;
238  }
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 240 of file class.assFileUpload.php.

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

241  {
242  if ($this->id <= 0)
243  {
244  // The question has not been saved. It cannot be duplicated
245  return;
246  }
247 
248  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
249 
250  $sourceQuestionId = $this->id;
251  $sourceParentId = $this->getObjId();
252 
253  // duplicate the question in database
254  $clone = $this;
255  $clone->id = -1;
256 
257  $clone->setObjId($targetParentId);
258 
259  if ($targetQuestionTitle)
260  {
261  $clone->setTitle($targetQuestionTitle);
262  }
263 
264  $clone->saveToDb();
265  // copy question page content
266  $clone->copyPageOfQuestion($sourceQuestionId);
267  // copy XHTML media objects
268  $clone->copyXHTMLMediaObjectsOfQuestion($sourceQuestionId);
269 
270  $clone->onCopy($sourceParentId, $sourceQuestionId, $clone->getObjId(), $clone->getId());
271 
272  return $clone->id;
273  }
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 984 of file class.assFileUpload.php.

985  {
986  }

◆ deletePreviewFileUploads()

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

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

References $files, and getPreviewFileUploadPath().

Referenced by savePreviewData().

595  {
596  foreach($files as $name)
597  {
598  if( isset($userSolution[$name]) )
599  {
600  unset($userSolution[$name]);
601  @unlink($this->getPreviewFileUploadPath($userId) . $name);
602  }
603  }
604 
605  return $userSolution;
606  }
$files
Definition: add-vimline.php:18
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:

◆ deleteUnusedFiles()

assFileUpload::deleteUnusedFiles (   $test_id,
  $active_id,
  $pass 
)
protected

Delete all files that are neither used in an authorized or intermediate solution.

Parameters
int$test_id
int$active_id
int$pass

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

References $file, $pass, assQuestion\$step, assQuestion\$test_id, array, getFileUploadPath(), assQuestion\getSolutionValues(), assQuestion\getStep(), and assQuestion\setStep().

Referenced by removeIntermediateSolution(), and saveWorkingData().

561  {
562  // read all solutions (authorized and intermediate) from all steps
563  $step = $this->getStep();
564  $this->setStep(null);
565  $solutions = array_merge(
566  $this->getSolutionValues($active_id, $pass, true),
567  $this->getSolutionValues($active_id, $pass, false)
568  );
569  $this->setStep($step);
570 
571  // get the used files from these solutions
572  $used_files = array();
573  foreach ($solutions as $solution)
574  {
575  $used_files[] = $solution['value1'];
576  }
577 
578  // read the existing files for user and pass
579  // delete all files that are not used in the solutions
580  $curdir = getcwd();
581  chdir($this->getFileUploadPath($test_id, $active_id));
582  $existing_files = glob("file_" . $active_id . "_" . $pass . "_*");
583  foreach($existing_files as $file)
584  {
585  if (!in_array($file, $used_files))
586  {
587  @unlink($file);
588  }
589  }
590  chdir($curdir);
591  }
Create styles array
The data for the language used.
getFileUploadPath($test_id, $active_id, $question_id=null)
Returns the filesystem path for file uploads.
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
+ 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 524 of file class.assFileUpload.php.

References $data, $files, $ilDB, $pass, $result, assQuestion\$test_id, array, and getFileUploadPath().

525  {
526  global $ilDB;
527 
528  $pass = null;
529  $active_id = null;
530  foreach ($files as $solution_id)
531  {
532  $result = $ilDB->queryF("SELECT * FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
533  array("integer", 'integer'),
534  array($solution_id, (int)$authorized)
535  );
536  if ($result->numRows() == 1)
537  {
538  $data = $ilDB->fetchAssoc($result);
539  $pass = $data['pass'];
540  $active_id = $data['active_fi'];
541  @unlink($this->getFileUploadPath($test_id, $active_id) . $data['value1']);
542  }
543  }
544  foreach ($files as $solution_id)
545  {
546  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
547  array("integer", 'integer'),
548  array($solution_id, $authorized)
549  );
550  }
551  }
$files
Definition: add-vimline.php:18
$result
Create styles array
The data for the language used.
getFileUploadPath($test_id, $active_id, $question_id=null)
Returns the filesystem path for file uploads.
global $ilDB
+ Here is the call graph for this function:

◆ deliverFileUploadZIPFile()

assFileUpload::deliverFileUploadZIPFile (   $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 1198 of file class.assFileUpload.php.

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

1199  {
1200  global $ilDB, $lng;
1201 
1202  require_once 'Modules/TestQuestionPool/classes/class.ilAssFileUploadUploadsExporter.php';
1203  $exporter = new ilAssFileUploadUploadsExporter($ilDB, $lng);
1204 
1205  $exporter->setTestId($test_id);
1206  $exporter->setTestTitle($test_title);
1207  $exporter->setQuestion($this);
1208 
1209  $exporter->build();
1210 
1212  $exporter->getFinalZipFilePath(), $exporter->getDispoZipFileName(),
1213  $exporter->getZipFileMimeType(), false, true
1214  );
1215  }
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
global $ilDB
+ 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 153 of file class.assFileUpload.php.

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

154  {
155  if ($this->id <= 0)
156  {
157  // The question has not been saved. It cannot be duplicated
158  return;
159  }
160  // duplicate the question in database
161  $this_id = $this->getId();
162  $thisObjId = $this->getObjId();
163 
164  $clone = $this;
165  include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
167  $clone->id = -1;
168 
169  if( (int)$testObjId > 0 )
170  {
171  $clone->setObjId($testObjId);
172  }
173 
174  if ($title)
175  {
176  $clone->setTitle($title);
177  }
178 
179  if ($author)
180  {
181  $clone->setAuthor($author);
182  }
183  if ($owner)
184  {
185  $clone->setOwner($owner);
186  }
187 
188  if ($for_test)
189  {
190  $clone->saveToDb($original_id);
191  }
192  else
193  {
194  $clone->saveToDb();
195  }
196 
197  // copy question page content
198  $clone->copyPageOfQuestion($this_id);
199  // copy XHTML media objects
200  $clone->copyXHTMLMediaObjectsOfQuestion($this_id);
201 
202  $clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
203 
204  return $clone->id;
205  }
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 1034 of file class.assFileUpload.php.

1035  {
1036  include_once "./Modules/TestQuestionPool/classes/import/qti12/class.assFileUploadImport.php";
1037  $import = new assFileUploadImport($this);
1038  $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
1039  }
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 964 of file class.assFileUpload.php.

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

965  {
966  return "qpl_qst_fileupload";
967  }
+ Here is the caller graph for this function:

◆ getAllowedExtensions()

assFileUpload::getAllowedExtensions ( )

Get allowed file extensions.

Returns
string Allowed file extensions

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

References $allowedextensions.

Referenced by __get(), and saveAdditionalQuestionDataToDb().

1105  {
1106  return $this->allowedextensions;
1107  }
+ Here is the caller graph for this function:

◆ getAllowedExtensionsArray()

assFileUpload::getAllowedExtensionsArray ( )

Get allowed file extensions.

Returns
array Allowed file extensions

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

References array.

Referenced by checkUpload().

1091  {
1092  if (strlen($this->allowedextensions))
1093  {
1094  return array_filter(array_map('trim', explode(",", $this->allowedextensions)));
1095  }
1096  return array();
1097  }
Create styles array
The data for the language used.
+ 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 974 of file class.assFileUpload.php.

975  {
976  return "";
977  }

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

References array.

1060  {
1061  $user_solution = array();
1062  return $user_solution;
1063  }
Create styles array
The data for the language used.

◆ getFileUploadPath()

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

Returns the filesystem path for file uploads.

Implements ilObjFileHandlingQuestionType.

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

References assQuestion\getId().

Referenced by deleteUnusedFiles(), deleteUploadedFiles(), and saveWorkingData().

422  {
423  if (is_null($question_id)) $question_id = $this->getId();
424  return CLIENT_WEB_DIR . "/assessment/tst_$test_id/$active_id/$question_id/files/";
425  }
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 440 of file class.assFileUpload.php.

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

Referenced by getUploadedFilesForWeb().

441  {
442  if (is_null($question_id)) $question_id = $this->getId();
443  include_once "./Services/Utilities/classes/class.ilUtil.php";
444  $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/tst_$test_id/$active_id/$question_id/files/";
445  return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir);
446  }
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 613 of file class.assFileUpload.php.

References $size, and getMaxFilesizeInBytes().

614  {
615  $size = $this->getMaxFilesizeInBytes();
616  if ($size < 1024)
617  {
618  $max_filesize = sprintf("%d Bytes",$size);
619  }
620  else if ($size < 1024*1024)
621  {
622  $max_filesize = sprintf("%.1f KB",$size/1024);
623  }
624  else
625  {
626  $max_filesize = sprintf("%.1f MB",$size/1024/1024);
627  }
628 
629  return $max_filesize;
630  }
$size
Definition: RandomTest.php:79
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 637 of file class.assFileUpload.php.

References array, and getMaxSize().

Referenced by checkUpload(), and getMaxFilesizeAsString().

638  {
639  if (strlen($this->getMaxSize()))
640  {
641  return $this->getMaxSize();
642  }
643  else
644  {
645  // get the value for the maximal uploadable filesize from the php.ini (if available)
646  $umf = get_cfg_var("upload_max_filesize");
647  // get the value for the maximal post data from the php.ini (if available)
648  $pms = get_cfg_var("post_max_size");
649 
650  //convert from short-string representation to "real" bytes
651  $multiplier_a=array("K"=>1024, "M"=>1024*1024, "G"=>1024*1024*1024);
652 
653  $umf_parts=preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
654  $pms_parts=preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
655 
656  if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
657  if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
658 
659  // use the smaller one as limit
660  $max_filesize = min($umf, $pms);
661 
662  if (!$max_filesize) $max_filesize=max($umf, $pms);
663  return $max_filesize;
664  }
665  }
getMaxSize()
Get max file size.
Create styles array
The data for the language used.
+ 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 280 of file class.assFileUpload.php.

References assQuestion\getPoints().

Referenced by isComplete().

281  {
282  return $this->getPoints();
283  }
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 1070 of file class.assFileUpload.php.

References $maxsize.

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

1071  {
1072  return $this->maxsize;
1073  }
+ Here is the caller graph for this function:

◆ getPreviewFileUploadPath()

assFileUpload::getPreviewFileUploadPath (   $userId)
protected

Returns the filesystem path for file uploads.

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

Referenced by deletePreviewFileUploads(), and savePreviewData().

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

◆ getPreviewFileUploadPathWeb()

assFileUpload::getPreviewFileUploadPathWeb (   $userId)
protected

Returns the filesystem path for file uploads.

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

References ilUtil\removeTrailingPathSeparators().

Referenced by savePreviewData().

452  {
453  include_once "./Services/Utilities/classes/class.ilUtil.php";
454  $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/qst_preview/$userId/{$this->getId()}/fileuploads/";
455  return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir);
456  }
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 487 of file class.assFileUpload.php.

References array, and ilAssQuestionPreviewSession\getParticipantsSolution().

488  {
489  return (array)$previewSession->getParticipantsSolution();
490  }
Create styles array
The data for the language used.
+ 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 954 of file class.assFileUpload.php.

955  {
956  return "assFileUpload";
957  }

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

References $text.

993  {
994  $text = parent::getRTETextWithMediaObjects();
995  return $text;
996  }
$text

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

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

Referenced by getUploadedFilesForWeb(), and handleSubmission().

464  {
465  global $ilDB;
466 
467  if (is_null($pass))
468  {
469  $pass = $this->getSolutionMaxPass($active_id);
470  }
471 // fau: testNav - check existing value1 because the intermediate solution will have a dummy entry
472  $result = $ilDB->queryF("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s AND authorized = %s AND value1 IS NOT NULL ORDER BY tstamp",
473  array("integer", "integer", "integer", 'integer'),
474  array($active_id, $this->getId(), $pass, (int)$authorized)
475  );
476 // fau.
477  $found = array();
478 
479  while ($data = $ilDB->fetchAssoc($result))
480  {
481  array_push($found, $data);
482  }
483 
484  return $found;
485  }
getId()
Gets the id of the assQuestion object.
$result
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Create styles array
The data for the language used.
global $ilDB
+ 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 497 of file class.assFileUpload.php.

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

498  {
499  global $ilDB;
500 
501  $found = $this->getUploadedFiles($active_id, $pass);
502  $result = $ilDB->queryF("SELECT test_fi FROM tst_active WHERE active_id = %s",
503  array('integer'),
504  array($active_id)
505  );
506  if ($result->numRows() == 1)
507  {
508  $row = $ilDB->fetchAssoc($result);
509  $test_id = $row["test_fi"];
510  $path = $this->getFileUploadPathWeb($test_id, $active_id);
511  foreach ($found as $idx => $data)
512  {
513  $found[$idx]['webpath'] = $path;
514  }
515  }
516  return $found;
517  }
$path
Definition: aliased.php:25
$result
getFileUploadPathWeb($test_id, $active_id, $question_id=null)
Returns the file upload path for web accessible files of a question.
Create styles array
The data for the language used.
global $ilDB
getUploadedFiles($active_id, $pass=null, $authorized=true)
Returns the uploaded files for an active user in a given pass.
+ 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 790 of file class.assFileUpload.php.

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

791  {
792  $solution = $this->getSolutionValues($active_id, $pass, false);
793 
794  if( !count($solution) )
795  {
796  $solution = $this->getSolutionValues($active_id, $pass, true);
797  }
798  else
799  {
800  $cleaned = array();
801  foreach ($solution as $row)
802  {
803  if (!empty($row['value1']))
804  {
805  $cleaned[] = $row;
806  }
807  }
808  $solution = $cleaned;
809  }
810 
811  return $solution;
812  }
Create styles array
The data for the language used.
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
+ 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 915 of file class.assFileUpload.php.

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

Referenced by reworkWorkingData().

916  {
917  if(!$authorized)
918  {
919  return;
920  }
921 
923  {
924  $maxpoints = assQuestion::_getMaximumPoints($this->getId());
925 
926  if($this->getUploadedFiles($active_id, $pass, $authorized))
927  {
928  $points = $maxpoints;
929  }
930  else
931  {
932 // fau: testNav - don't set reached points if no file is available
933  return;
934 // fau.
935  }
936 
937  assQuestion::_setReachedPoints($active_id, $this->getId(), $points, $maxpoints, $pass, 1, $obligationsAnswered);
938 
939  // update learning progress
940  include_once 'Modules/Test/classes/class.ilObjTestAccess.php';
941  include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
943  ilObjTest::_getObjectIDFromActiveID((int)$active_id),
944  ilObjTestAccess::_getParticipantId((int) $active_id)
945  );
946  }
947  }
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:
+ Here is the caller 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 1170 of file class.assFileUpload.php.

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

1171  {
1172  global $ilDB;
1173  $query = "
1174  SELECT tst_solutions.solution_id
1175  FROM tst_solutions, tst_active, qpl_questions
1176  WHERE tst_solutions.active_fi = tst_active.active_id
1177  AND tst_solutions.question_fi = qpl_questions.question_id
1178  AND tst_solutions.question_fi = %s AND tst_active.test_fi = %s";
1179  $result = $ilDB->queryF( $query,
1180  array("integer", "integer"),
1181  array($this->getId(), $test_id)
1182  );
1183  if ($result->numRows() > 0)
1184  {
1185  return true;
1186  }
1187  else
1188  {
1189  return false;
1190  }
1191  }
getId()
Gets the id of the assQuestion object.
$result
Create styles array
The data for the language used.
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 1256 of file class.assFileUpload.php.

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

1257  {
1258  $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
1259 
1260  return $numExistingSolutionRecords > 0;
1261  }
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 1278 of file class.assFileUpload.php.

1279  {
1280  return FALSE;
1281  }

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

References getMaximumPoints().

64  {
65  if (
66  strlen($this->title)
67  && ($this->author)
68  && ($this->question)
69  && ($this->getMaximumPoints() >= 0)
70  && is_numeric($this->getMaximumPoints()))
71  {
72  return true;
73  }
74  return false;
75  }
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 1225 of file class.assFileUpload.php.

References $completion_by_submission.

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

1226  {
1228  }
+ Here is the caller graph for this function:

◆ isFileDeletionAction()

assFileUpload::isFileDeletionAction ( )
protected
Returns
bool

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

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

Referenced by savePreviewData(), and saveWorkingData().

1306  {
1307  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssFileUploadFileTableDeleteButton.php';
1309  }
+ 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 1314 of file class.assFileUpload.php.

References assQuestion\isNonEmptyItemListPostSubmission().

Referenced by savePreviewData(), and saveWorkingData().

1315  {
1316  return $this->isNonEmptyItemListPostSubmission(self::DELETE_FILES_TBL_POSTVAR);
1317  }
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 1330 of file class.assFileUpload.php.

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

Referenced by saveWorkingData().

1331  {
1332  if( !$this->getTestPresentationConfig()->isPreviousPassSolutionReuseAllowed() )
1333  {
1334  return false;
1335  }
1336 
1337  if( !$this->isFileReuseSubmitAvailable() )
1338  {
1339  return false;
1340  }
1341 
1342  return true;
1343  }
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 1322 of file class.assFileUpload.php.

References assQuestion\isNonEmptyItemListPostSubmission().

Referenced by isFileReuseHandlingRequired().

1323  {
1324  return $this->isNonEmptyItemListPostSubmission(self::REUSE_FILES_TBL_POSTVAR);
1325  }
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 1348 of file class.assFileUpload.php.

Referenced by savePreviewData(), and saveWorkingData().

1349  {
1350  if( !isset($_FILES['upload']) )
1351  {
1352  return false;
1353  }
1354 
1355  if( !isset($_FILES['upload']['tmp_name']) )
1356  {
1357  return false;
1358  }
1359 
1360  return strlen($_FILES['upload']['tmp_name']) > 0;
1361  }
+ 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 1273 of file class.assFileUpload.php.

1274  {
1275  return true;
1276  }

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

References $data, $ilDB, $result, ilRTE\_replaceMediaObjectImageSrc(), array, 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().

112  {
113  global $ilDB;
114  $result = $ilDB->queryF("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",
115  array("integer"),
116  array($question_id)
117  );
118  if ($result->numRows() == 1)
119  {
120  $data = $ilDB->fetchAssoc($result);
121  $this->setId($question_id);
122  $this->setTitle($data["title"]);
123  $this->setComment($data["description"]);
124  $this->setNrOfTries($data['nr_of_tries']);
125  $this->setSuggestedSolution($data["solution_hint"]);
126  $this->setOriginalId($data["original_id"]);
127  $this->setObjId($data["obj_fi"]);
128  $this->setAuthor($data["author"]);
129  $this->setOwner($data["owner"]);
130  $this->setPoints($data["points"]);
131 
132  include_once("./Services/RTE/classes/class.ilRTE.php");
133  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
134  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
135  $this->setMaxSize($data["maxsize"]);
136  $this->setAllowedExtensions($data["allowedextensions"]);
137  $this->setCompletionBySubmission($data['compl_by_submission'] == 1 ? true : false);
138 
139  try
140  {
141  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
142  }
144  {
145  }
146  }
147  parent::loadFromDb($question_id);
148  }
setSuggestedSolution($solution_id="", $subquestion_index=0, $is_import=false)
Sets a suggested solution for the question.
setAllowedExtensions($a_value)
Set allowed file extensions.
$result
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.
Create styles array
The data for the language used.
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.
+ 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 823 of file class.assFileUpload.php.

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

824  {
825  global $ilDB;
826 
827  $result = parent::removeIntermediateSolution($active_id, $pass);
828 
829  // get the current test id
830  // hey: prevPassSolutions - exract until you drop :-D
831  $test_id = $this->lookupTestId($active_id);
832  // hey.
833 
834  $this->deleteUnusedFiles($test_id, $active_id, $pass);
835 
836  return $result;
837  }
$result
lookupTestId($active_id)
global $ilDB
deleteUnusedFiles($test_id, $active_id, $pass)
Delete all files that are neither used in an authorized or intermediate solution. ...
+ Here is the call graph for this function:

◆ reworkWorkingData()

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

{}

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

References $pass, and handleSubmission().

902  {
903  $this->handleSubmission($active_id, $pass, $obligationsAnswered, $authorized);
904  }
handleSubmission($active_id, $pass, $obligationsAnswered, $authorized)
This method is called after an user submitted one or more files.
+ 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 87 of file class.assFileUpload.php.

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

Referenced by saveToDb().

88  {
89  global $ilDB;
90  $ilDB->manipulateF( "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
91  array( "integer" ),
92  array( $this->getId() )
93  );
94  $ilDB->manipulateF( "INSERT INTO " . $this->getAdditionalTableName(
95  ) . " (question_fi, maxsize, allowedextensions, compl_by_submission) VALUES (%s, %s, %s, %s)",
96  array( "integer", "float", "text", "integer" ),
97  array(
98  $this->getId(),
99  (strlen( $this->getMaxSize() )) ? $this->getMaxSize() : NULL,
100  (strlen( $this->getAllowedExtensions() )) ? $this->getAllowedExtensions() : NULL,
101  (int)$this->isCompletionBySubmissionEnabled()
102  )
103  );
104  }
getId()
Gets the id of the assQuestion object.
getAllowedExtensions()
Get allowed file extensions.
getMaxSize()
Get max file size.
Create styles array
The data for the language used.
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 841 of file class.assFileUpload.php.

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

842  {
843  $userSolution = $previewSession->getParticipantsSolution();
844 
845  if( !is_array($userSolution) )
846  {
847  $userSolution = array();
848  }
849 
850  // hey: prevPassSolutions - readability spree - get a chance to understand the code
851  if( $this->isFileDeletionAction() )
852  // hey.
853  {
854  // hey: prevPassSolutions - readability spree - get a chance to understand the code
855  if( $this->isFileDeletionSubmitAvailable() )
856  // hey.
857  {
858  $userSolution = $this->deletePreviewFileUploads($previewSession->getUserId(), $userSolution, $_POST['deletefiles']);
859  }
860  else
861  {
862  ilUtil::sendInfo($this->lng->txt('no_checkbox'), true);
863  }
864  }
865  else
866  {
867  // hey: prevPassSolutions - readability spree - get a chance to understand the code
868  if ( $this->isFileUploadAvailable() )
869  // hey.
870  {
871  if ($this->checkUpload())
872  {
873  if( !@file_exists($this->getPreviewFileUploadPath($previewSession->getUserId())) )
874  {
875  ilUtil::makeDirParents($this->getPreviewFileUploadPath($previewSession->getUserId()));
876  }
877 
878  $version = time();
879  $filename_arr = pathinfo($_FILES["upload"]["name"]);
880  $extension = $filename_arr["extension"];
881  $newfile = "file_".md5($_FILES["upload"]["name"])."_" . $version . "." . $extension;
882  ilUtil::moveUploadedFile($_FILES["upload"]["tmp_name"], $_FILES["upload"]["name"], $this->getPreviewFileUploadPath($previewSession->getUserId()) . $newfile);
883 
884  $userSolution[$newfile] = array(
885  'solution_id' => $newfile,
886  'value1' => $newfile,
887  'value2' => $_FILES['upload']['name'],
888  'tstamp' => $version,
889  'webpath' => $this->getPreviewFileUploadPathWeb($previewSession->getUserId())
890  );
891  }
892  }
893  }
894 
895  $previewSession->setParticipantsSolution($userSolution);
896  }
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)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
checkUpload()
Check file upload.
Create styles array
The data for the language used.
getPreviewFileUploadPath($userId)
Returns the filesystem path for file uploads.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
$_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 80 of file class.assFileUpload.php.

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

81  {
84  parent::saveToDb();
85  }
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 678 of file class.assFileUpload.php.

References $_POST, $pass, assQuestion\$test_id, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), checkUpload(), assQuestion\deleteDummySolutionRecord(), deleteUnusedFiles(), 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(), ilUtil\moveUploadedFile(), assQuestion\removeCurrentSolution(), assQuestion\removeSolutionRecordById(), assQuestion\saveCurrentSolution(), ilUtil\sendInfo(), time, and assQuestion\updateCurrentSolutionsAuthorization().

679  {
680  $pass = $this->ensureCurrentTestPass($active_id, $pass);
681  $test_id = $this->lookupTestId($active_id);
682 
683  $uploadHandlingRequired = $this->isFileUploadAvailable() && $this->checkUpload();
684 
685  $entered_values = false;
686 
687  $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function() use (&$entered_values, $uploadHandlingRequired, $test_id, $active_id, $pass, $authorized) {
688 
689  if ($authorized == false)
690  {
691  $this->forceExistingIntermediateSolution($active_id, $pass, true);
692  }
693 
694  if( $this->isFileDeletionAction() )
695  {
696  if( $this->isFileDeletionSubmitAvailable() )
697  {
698  foreach ($_POST[self::DELETE_FILES_TBL_POSTVAR] as $solution_id)
699  {
700  $this->removeSolutionRecordById($solution_id);
701  }
702  }
703  else
704  {
705  ilUtil::sendInfo($this->lng->txt('no_checkbox'), true);
706  }
707  }
708  else
709  {
710  if( $this->isFileReuseHandlingRequired() )
711  {
712  foreach ($_POST[self::REUSE_FILES_TBL_POSTVAR] as $solutionId)
713  {
714  $solution = $this->getSolutionRecordById($solutionId);
715 
716  $this->saveCurrentSolution($active_id, $pass,
717  $solution['value1'], $solution['value2'],
718  false, $solution['tstamp']
719  );
720  }
721  }
722 
723  if( $uploadHandlingRequired )
724  {
725  if(!@file_exists($this->getFileUploadPath($test_id, $active_id)))
726  {
728  }
729 
730  $solutionFileVersioningUploadTS = time();
731  $filename_arr = pathinfo($_FILES["upload"]["name"]);
732  $extension = $filename_arr["extension"];
733  $newfile = "file_" . $active_id . "_" . $pass . "_" . $solutionFileVersioningUploadTS . "." . $extension;
734 
735  include_once 'Services/Utilities/classes/class.ilFileUtils.php';
736  $dispoFilename = ilFileUtils::getValidFilename($_FILES['upload']['name']);
737  $newfile = ilFileUtils::getValidFilename($newfile);
738 
739  ilUtil::moveUploadedFile($_FILES["upload"]["tmp_name"], $_FILES["upload"]["name"], $this->getFileUploadPath($test_id, $active_id) . $newfile);
740 
741  $this->saveCurrentSolution($active_id, $pass, $newfile, $dispoFilename, false,
742  $solutionFileVersioningUploadTS
743  );
744 
745  $entered_values = true;
746  }
747  }
748 
749  if ($authorized == true && $this->intermediateSolutionExists($active_id, $pass))
750  {
751  // remove the dummy record of the intermediate solution
752  $this->deleteDummySolutionRecord($active_id, $pass);
753 
754  // delete the authorized solution and make the intermediate solution authorized (keeping timestamps)
755  $this->removeCurrentSolution($active_id, $pass, true);
756  $this->updateCurrentSolutionsAuthorization($active_id, $pass, true, true);
757  }
758 
759  $this->deleteUnusedFiles($test_id, $active_id, $pass);
760  });
761 
762  if ($entered_values)
763  {
764  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
766  {
767  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
768  }
769  }
770  else
771  {
772  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
774  {
775  assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
776  }
777  }
778 
779  return true;
780  }
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)
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
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)
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
deleteUnusedFiles($test_id, $active_id, $pass)
Delete all files that are neither used in an authorized or intermediate solution. ...
$_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 1114 of file class.assFileUpload.php.

Referenced by __set(), and loadFromDb().

1115  {
1116  $this->allowedextensions = strtolower(trim($a_value));
1117  }
+ 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 1239 of file class.assFileUpload.php.

Referenced by __set(), and loadFromDb().

1240  {
1241  $this->completion_by_submission = (bool)$bool;
1242  return $this;
1243  }
+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

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

{}

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

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

1002  {
1003  parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
1004 
1005  $i = 1;
1006  $solutions = $this->getSolutionValues($active_id, $pass);
1007  foreach ($solutions as $solution)
1008  {
1009  $worksheet->setCell($startrow + $i, 0, $this->lng->txt("result"));
1010  $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
1011  if (strlen($solution["value1"]))
1012  {
1013  $worksheet->setCell($startrow + $i, 1, $solution["value1"]);
1014  $worksheet->setCell($startrow + $i, 2, $solution["value2"]);
1015  }
1016  $i++;
1017  }
1018 
1019  return $startrow + $i + 1;
1020  }
$worksheet
getSolutionValues($active_id, $pass=NULL, $authorized=true)
Loads solutions of a given user from the database an returns it.
+ 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 1080 of file class.assFileUpload.php.

Referenced by __set(), and loadFromDb().

1081  {
1082  $this->maxsize = $a_value;
1083  }
+ 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 1047 of file class.assFileUpload.php.

1048  {
1049  include_once "./Modules/TestQuestionPool/classes/export/qti12/class.assFileUploadExport.php";
1050  $export = new assFileUploadExport($this);
1051  return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
1052  }
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: