ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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)
 {Creates an Excel worksheet for the detailed cumulated results of this question.
Parameters
object$worksheetReference to the parent excel worksheet
object$startrowStartrow of the output in the excel worksheet
object$active_idActive id of the participant
object$passTest pass
Returns
object
} 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...
 
 saveAdditionalQuestionDataToDb ()
 Saves a record to the question types additional data table. More...
 
 hasFileUploads ($test_id)
 Checks if file uploads exist for a given test and the original id of the question. More...
 
 deliverFileUploadZIPFile ($test_id, $test_title)
 Generates a ZIP file containing all file uploads for a given test and the original id of the question. More...
 
 getFileUploadPath ($test_id, $active_id, $question_id=null)
 Returns the path for uploaded files from given active in given test on current or given question. More...
 

Static Public Member Functions

static isObligationPossible ($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)
 @TODO 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)
 @global 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)
 
 reworkWorkingData ($active_id, $pass, $obligationsAnswered, $authorized)
 {Reworks the allready saved working data if neccessary.
Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered
boolean$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()

Reimplemented from assQuestion.

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.

Reimplemented from assQuestion.

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

1059 {
1060 switch ($value) {
1061 case "maxsize":
1062 return $this->getMaxSize();
1063 break;
1064 case "allowedextensions":
1065 return $this->getAllowedExtensions();
1066 break;
1067 case 'completion_by_submission':
1068 return $this->isCompletionBySubmissionEnabled();
1069 break;
1070 default:
1071 return parent::__get($value);
1072 break;
1073 }
1074 }
isCompletionBySubmissionEnabled()
Checks whether completion by submission is enabled or not.
getAllowedExtensions()
Get allowed file extensions.
getMaxSize()
Get max file size.

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

+ Here is the call graph for this function:

◆ __set()

assFileUpload::__set (   $key,
  $value 
)

Object setter.

Reimplemented from assQuestion.

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

1080 {
1081 switch ($key) {
1082 case "maxsize":
1083 $this->setMaxSize($value);
1084 break;
1085 case "allowedextensions":
1086 $this->setAllowedExtensions($value);
1087 break;
1088 case 'completion_by_submission':
1089 $this->setCompletionBySubmission($value);
1090 break;
1091 default:
1092 parent::__set($key, $value);
1093 break;
1094 }
1095 }
setMaxSize($a_value)
Set max file size.
setAllowedExtensions($a_value)
Set allowed file extensions.
setCompletionBySubmission($bool)
Enabled/Disable completion by submission.
$key
Definition: croninfo.php:18

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

+ 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

Reimplemented from assQuestion.

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

1228 {
1229 // hey: refactored identifiers
1230 return parent::buildTestPresentationConfig()
1231 // hey.
1232 ->setFormChangeDetectionEnabled(false);
1233 }

◆ calculateReachedPoints()

assFileUpload::calculateReachedPoints (   $active_id,
  $pass = null,
  $authorizedSolution = true,
  $returndetails = false 
)

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

The points are calculated from the given answers.

@access public

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

Reimplemented from assQuestion.

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

281 {
282 if ($returndetails) {
283 throw new ilTestException('return details not implemented for ' . __METHOD__);
284 }
285
286 global $ilDB;
287
288 if (is_null($pass)) {
289 $pass = $this->getSolutionMaxPass($active_id);
290 }
291 $points = 0;
292 return $points;
293 }
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
Base Exception for all Exceptions relating to Modules/Test.
global $ilDB

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

+ Here is the call graph for this function:

◆ calculateReachedPointsForSolution()

assFileUpload::calculateReachedPointsForSolution (   $userSolution)
protected

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

296 {
297 if ($this->isCompletionBySubmissionEnabled() && count($userSolution)) {
298 return $this->getPoints();
299 }
300
301 return 0;
302 }
getPoints()
Returns the maximum available points for the question.

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

+ Here is the call graph for this function:

◆ checkUpload()

assFileUpload::checkUpload ( )

Check file upload.

Returns
boolean Input ok, true/false

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

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

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

Referenced by savePreviewData(), and saveWorkingData().

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

◆ copyObject()

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

Copies an assFileUpload object.

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

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

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

+ Here is the call graph for this function:

◆ createNewOriginalFromThisDuplicate()

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

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

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

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

+ 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

Reimplemented from assQuestion.

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

924 {
925 }

◆ deletePreviewFileUploads()

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

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

568 {
569 foreach ($files as $name) {
570 if (isset($userSolution[$name])) {
571 unset($userSolution[$name]);
572 @unlink($this->getPreviewFileUploadPath($userId) . $name);
573 }
574 }
575
576 return $userSolution;
577 }
$files
Definition: add-vimline.php:18
getPreviewFileUploadPath($userId)
Returns the filesystem path for file uploads.
if($format !==null) $name
Definition: metadata.php:146

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

Referenced by savePreviewData().

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

◆ deleteUploadedFiles()

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

Delete uploaded files.

Parameters
arrayArray with ID's of the file datasets

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

501 {
502 global $ilDB;
503
504 $pass = null;
505 $active_id = null;
506 foreach ($files as $solution_id) {
507 $result = $ilDB->queryF(
508 "SELECT * FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
509 array("integer", 'integer'),
510 array($solution_id, (int) $authorized)
511 );
512 if ($result->numRows() == 1) {
513 $data = $ilDB->fetchAssoc($result);
514 $pass = $data['pass'];
515 $active_id = $data['active_fi'];
516 @unlink($this->getFileUploadPath($test_id, $active_id) . $data['value1']);
517 }
518 }
519 foreach ($files as $solution_id) {
520 $affectedRows = $ilDB->manipulateF(
521 "DELETE FROM tst_solutions WHERE solution_id = %s AND authorized = %s",
522 array("integer", 'integer'),
523 array($solution_id, $authorized)
524 );
525 }
526 }
$result
getFileUploadPath($test_id, $active_id, $question_id=null)
Returns the filesystem path for file uploads.

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

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

1131 {
1132 global $ilDB, $lng;
1133
1134 require_once 'Modules/TestQuestionPool/classes/class.ilAssFileUploadUploadsExporter.php';
1135 $exporter = new ilAssFileUploadUploadsExporter($ilDB, $lng);
1136
1137 $exporter->setTestId($test_id);
1138 $exporter->setTestTitle($test_title);
1139 $exporter->setQuestion($this);
1140
1141 $exporter->build();
1142
1144 $exporter->getFinalZipFilePath(),
1145 $exporter->getDispoZipFileName(),
1146 $exporter->getZipFileMimeType(),
1147 false,
1148 true
1149 );
1150 }
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.

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

+ Here is the call graph for this function:

◆ duplicate()

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

Duplicates an assFileUpload.

Reimplemented from assQuestion.

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

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

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

+ Here is the call graph for this function:

◆ fromXML()

assFileUpload::fromXML ( $item,
$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

Reimplemented from assQuestion.

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

972 {
973 include_once "./Modules/TestQuestionPool/classes/import/qti12/class.assFileUploadImport.php";
974 $import = new assFileUploadImport($this);
975 $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
976 }
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

Reimplemented from assQuestion.

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

904 {
905 return "qpl_qst_fileupload";
906 }

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAllowedExtensions()

assFileUpload::getAllowedExtensions ( )

Get allowed file extensions.

Returns
string Allowed file extensions

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

1041 {
1043 }

References $allowedextensions.

Referenced by __get(), and saveAdditionalQuestionDataToDb().

+ Here is the caller graph for this function:

◆ getAllowedExtensionsArray()

assFileUpload::getAllowedExtensionsArray ( )

Get allowed file extensions.

Returns
array Allowed file extensions

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

1028 {
1029 if (strlen($this->allowedextensions)) {
1030 return array_filter(array_map('trim', explode(",", $this->allowedextensions)));
1031 }
1032 return array();
1033 }

Referenced by checkUpload().

+ 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

Reimplemented from assQuestion.

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

914 {
915 return "";
916 }

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

997 {
998 $user_solution = array();
999 return $user_solution;
1000 }

◆ getFileUploadPath()

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

Returns the filesystem path for file uploads.

Implements ilObjFileHandlingQuestionType.

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

396 {
397 if (is_null($question_id)) {
398 $question_id = $this->getId();
399 }
400 return CLIENT_WEB_DIR . "/assessment/tst_$test_id/$active_id/$question_id/files/";
401 }

References assQuestion\getId().

Referenced by deleteUploadedFiles(), and saveWorkingData().

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

◆ getFileUploadPathWeb()

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

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

@access public

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

417 {
418 if (is_null($question_id)) {
419 $question_id = $this->getId();
420 }
421 include_once "./Services/Utilities/classes/class.ilUtil.php";
422 $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/tst_$test_id/$active_id/$question_id/files/";
423 return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir);
424 }
static removeTrailingPathSeparators($path)

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

Referenced by getUploadedFilesForWeb().

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

◆ getMaxFilesizeAsString()

assFileUpload::getMaxFilesizeAsString ( )

Return the maximum allowed file size as string.

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

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

585 {
586 $size = $this->getMaxFilesizeInBytes();
587 if ($size < 1024) {
588 $max_filesize = sprintf("%d Bytes", $size);
589 } elseif ($size < 1024*1024) {
590 $max_filesize = sprintf("%.1f KB", $size/1024);
591 } else {
592 $max_filesize = sprintf("%.1f MB", $size/1024/1024);
593 }
594
595 return $max_filesize;
596 }
sprintf('%.4f', $callTime)
$size
Definition: RandomTest.php:84

References $size, getMaxFilesizeInBytes(), and sprintf.

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

604 {
605 if (strlen($this->getMaxSize())) {
606 return $this->getMaxSize();
607 } else {
608 // get the value for the maximal uploadable filesize from the php.ini (if available)
609 $umf = get_cfg_var("upload_max_filesize");
610 // get the value for the maximal post data from the php.ini (if available)
611 $pms = get_cfg_var("post_max_size");
612
613 //convert from short-string representation to "real" bytes
614 $multiplier_a=array("K"=>1024, "M"=>1024*1024, "G"=>1024*1024*1024);
615
616 $umf_parts=preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
617 $pms_parts=preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
618
619 if (count($umf_parts) == 2) {
620 $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]];
621 }
622 if (count($pms_parts) == 2) {
623 $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]];
624 }
625
626 // use the smaller one as limit
627 $max_filesize = min($umf, $pms);
628
629 if (!$max_filesize) {
630 $max_filesize=max($umf, $pms);
631 }
632 return $max_filesize;
633 }
634 }
echo;exit;}function LogoutNotification($SessionID){ global $ilDB;$q="SELECT session_id, data FROM usr_session WHERE expires > (\w+)\|/" PREG_SPLIT_NO_EMPTY PREG_SPLIT_DELIM_CAPTURE

References getMaxSize(), and PREG_SPLIT_DELIM_CAPTURE.

Referenced by checkUpload(), and getMaxFilesizeAsString().

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

◆ getMaximumPoints()

assFileUpload::getMaximumPoints ( )

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

See also
$points

Reimplemented from assQuestion.

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

266 {
267 return $this->getPoints();
268 }

References assQuestion\getPoints().

Referenced by isComplete().

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

◆ getMaxSize()

assFileUpload::getMaxSize ( )

Get max file size.

Returns
double Max file size

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

1008 {
1009 return $this->maxsize;
1010 }

References $maxsize.

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

+ Here is the caller graph for this function:

◆ getPreviewFileUploadPath()

assFileUpload::getPreviewFileUploadPath (   $userId)
protected

Returns the filesystem path for file uploads.

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

407 {
408 return CLIENT_WEB_DIR . "/assessment/qst_preview/$userId/{$this->getId()}/fileuploads/";
409 }

Referenced by deletePreviewFileUploads(), and savePreviewData().

+ Here is the caller graph for this function:

◆ getPreviewFileUploadPathWeb()

assFileUpload::getPreviewFileUploadPathWeb (   $userId)
protected

Returns the filesystem path for file uploads.

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

430 {
431 include_once "./Services/Utilities/classes/class.ilUtil.php";
432 $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/qst_preview/$userId/{$this->getId()}/fileuploads/";
433 return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir);
434 }

References ilUtil\removeTrailingPathSeparators().

Referenced by savePreviewData().

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

◆ getPreviewFileUploads()

assFileUpload::getPreviewFileUploads ( ilAssQuestionPreviewSession  $previewSession)

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

465 {
466 return (array) $previewSession->getParticipantsSolution();
467 }

References ilAssQuestionPreviewSession\getParticipantsSolution().

+ 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

Reimplemented from assQuestion.

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

894 {
895 return "assFileUpload";
896 }

◆ getRTETextWithMediaObjects()

assFileUpload::getRTETextWithMediaObjects ( )

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

Reimplemented from assQuestion.

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

932 {
933 $text = parent::getRTETextWithMediaObjects();
934 return $text;
935 }
$text
Definition: errorreport.php:18

References $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 441 of file class.assFileUpload.php.

442 {
443 global $ilDB;
444
445 if (is_null($pass)) {
446 $pass = $this->getSolutionMaxPass($active_id);
447 }
448 // fau: testNav - check existing value1 because the intermediate solution will have a dummy entry
449 $result = $ilDB->queryF(
450 "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",
451 array("integer", "integer", "integer", 'integer'),
452 array($active_id, $this->getId(), $pass, (int) $authorized)
453 );
454 // fau.
455 $found = array();
456
457 while ($data = $ilDB->fetchAssoc($result)) {
458 array_push($found, $data);
459 }
460
461 return $found;
462 }

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

Referenced by getUploadedFilesForWeb(), and handleSubmission().

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

◆ getUploadedFilesForWeb()

assFileUpload::getUploadedFilesForWeb (   $active_id,
  $pass 
)

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

Returns
array Results

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

475 {
476 global $ilDB;
477
478 $found = $this->getUploadedFiles($active_id, $pass);
479 $result = $ilDB->queryF(
480 "SELECT test_fi FROM tst_active WHERE active_id = %s",
481 array('integer'),
482 array($active_id)
483 );
484 if ($result->numRows() == 1) {
485 $row = $ilDB->fetchAssoc($result);
486 $test_id = $row["test_fi"];
487 $path = $this->getFileUploadPathWeb($test_id, $active_id);
488 foreach ($found as $idx => $data) {
489 $found[$idx]['webpath'] = $path;
490 }
491 }
492 return $found;
493 }
getFileUploadPathWeb($test_id, $active_id, $question_id=null)
Returns the file upload path for web accessible files of a question.
getUploadedFiles($active_id, $pass=null, $authorized=true)
Returns the uploaded files for an active user in a given pass.

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

+ 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

Reimplemented from assQuestion.

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

750 {
751 $solution = $this->getSolutionValues($active_id, $pass, false);
752
753 if (!count($solution)) {
754 $solution = $this->getSolutionValues($active_id, $pass, true);
755 } else {
756 $cleaned = array();
757 foreach ($solution as $row) {
758 if (!empty($row['value1'])) {
759 $cleaned[] = $row;
760 }
761 }
762 $solution = $cleaned;
763 }
764
765 return $solution;
766 }
getSolutionValues($active_id, $pass=null, $authorized=true)
Loads solutions of a given user from the database an returns it.

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

+ Here is the call graph for this function:

◆ handleSubmission()

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

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

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

Parameters
integer
integer@access protected

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

860 {
861 if (!$authorized) {
862 return;
863 }
864
865 if ($this->isCompletionBySubmissionEnabled()) {
866 $maxpoints = assQuestion::_getMaximumPoints($this->getId());
867
868 if ($this->getUploadedFiles($active_id, $pass, $authorized)) {
869 $points = $maxpoints;
870 } else {
871 // fau: testNav - don't set reached points if no file is available
872 return;
873 // fau.
874 }
875
876 assQuestion::_setReachedPoints($active_id, $this->getId(), $points, $maxpoints, $pass, 1, $obligationsAnswered);
877
878 // update learning progress
879 include_once 'Modules/Test/classes/class.ilObjTestAccess.php';
880 include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
882 ilObjTest::_getObjectIDFromActiveID((int) $active_id),
883 ilObjTestAccess::_getParticipantId((int) $active_id)
884 );
885 }
886 }
static _getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
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...
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _getParticipantId($active_id)
Get user id for active id.
static _getObjectIDFromActiveID($active_id)
Returns the ILIAS test object id for a given active id.

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

Referenced by reworkWorkingData().

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

1105 {
1106 global $ilDB;
1107 $query = "
1108 SELECT tst_solutions.solution_id
1109 FROM tst_solutions, tst_active, qpl_questions
1110 WHERE tst_solutions.active_fi = tst_active.active_id
1111 AND tst_solutions.question_fi = qpl_questions.question_id
1112 AND tst_solutions.question_fi = %s AND tst_active.test_fi = %s";
1113 $result = $ilDB->queryF(
1114 $query,
1115 array("integer", "integer"),
1116 array($this->getId(), $test_id)
1117 );
1118 if ($result->numRows() > 0) {
1119 return true;
1120 } else {
1121 return false;
1122 }
1123 }
$query

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

+ 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)

@global ilDBInterface $ilDB

Parameters
integer$active_id
integer$pass
Returns
boolean $answered

Reimplemented from assQuestion.

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

1192 {
1193 $numExistingSolutionRecords = assQuestion::getNumExistingSolutionRecords($active_id, $pass, $this->getId());
1194
1195 return $numExistingSolutionRecords > 0;
1196 }
static getNumExistingSolutionRecords($activeId, $pass, $questionId)
returns the number of existing solution records for the given test active / pass and given question i...

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

+ Here is the call graph for this function:

◆ isAutosaveable()

assFileUpload::isAutosaveable ( )

Reimplemented from assQuestion.

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

1214 {
1215 return false;
1216 }

◆ isComplete()

assFileUpload::isComplete ( )

Returns true, if the question is complete for use.

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

Reimplemented from assQuestion.

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

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.

References getMaximumPoints().

+ Here is the call graph for this function:

◆ isCompletionBySubmissionEnabled()

assFileUpload::isCompletionBySubmissionEnabled ( )

Checks whether completion by submission is enabled or not.

Returns
boolean @access public

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

1161 {
1163 }

References $completion_by_submission.

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

+ Here is the caller graph for this function:

◆ isFileDeletionAction()

assFileUpload::isFileDeletionAction ( )
protected
Returns
bool

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

1241 {
1242 require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssFileUploadFileTableDeleteButton.php';
1244 }

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

Referenced by savePreviewData(), and saveWorkingData().

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

◆ isFileDeletionSubmitAvailable()

assFileUpload::isFileDeletionSubmitAvailable ( )
protected
Returns
bool

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

1250 {
1251 return $this->isNonEmptyItemListPostSubmission(self::DELETE_FILES_TBL_POSTVAR);
1252 }
isNonEmptyItemListPostSubmission($postSubmissionFieldname)

References assQuestion\isNonEmptyItemListPostSubmission().

Referenced by savePreviewData(), and saveWorkingData().

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

◆ isFileReuseHandlingRequired()

assFileUpload::isFileReuseHandlingRequired ( )
protected
Returns
bool

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

1266 {
1267 if (!$this->getTestPresentationConfig()->isPreviousPassSolutionReuseAllowed()) {
1268 return false;
1269 }
1270
1271 if (!$this->isFileReuseSubmitAvailable()) {
1272 return false;
1273 }
1274
1275 return true;
1276 }
getTestPresentationConfig()
Get the test question configuration (initialised once)

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

Referenced by saveWorkingData().

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

◆ isFileReuseSubmitAvailable()

assFileUpload::isFileReuseSubmitAvailable ( )
protected
Returns
bool

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

1258 {
1259 return $this->isNonEmptyItemListPostSubmission(self::REUSE_FILES_TBL_POSTVAR);
1260 }

References assQuestion\isNonEmptyItemListPostSubmission().

Referenced by isFileReuseHandlingRequired().

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

◆ isFileUploadAvailable()

assFileUpload::isFileUploadAvailable ( )
protected
Returns
bool

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

1282 {
1283 if (!isset($_FILES['upload'])) {
1284 return false;
1285 }
1286
1287 if (!isset($_FILES['upload']['tmp_name'])) {
1288 return false;
1289 }
1290
1291 return strlen($_FILES['upload']['tmp_name']) > 0;
1292 }

Referenced by savePreviewData(), and saveWorkingData().

+ 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

Reimplemented from assQuestion.

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

1209 {
1210 return true;
1211 }

◆ 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

Reimplemented from assQuestion.

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

112 {
113 global $ilDB;
114 $result = $ilDB->queryF(
115 "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",
116 array("integer"),
117 array($question_id)
118 );
119 if ($result->numRows() == 1) {
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 $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
141 } catch (ilTestQuestionPoolException $e) {
142 }
143 }
144 parent::loadFromDb($question_id);
145 }
getAdditionalTableName()
Returns the name of the additional question data table in the database.
setId($id=-1)
Sets the id of the assQuestion object.
setOriginalId($original_id)
setObjId($obj_id=0)
Set the object id of the container object.
setSuggestedSolution($solution_id="", $subquestion_index=0, $is_import=false)
Sets a suggested solution for the question.
setTitle($title="")
Sets the title string of the assQuestion object.
setOwner($owner="")
Sets the creator/owner 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.
setAuthor($author="")
Sets the authors name of the assQuestion object.
setPoints($a_points)
Sets the maximum available points for the question.
setComment($comment="")
Sets the comment string of the assQuestion object.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
setQuestion($question="")
Sets the question string of the question object.
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...

References $data, $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().

+ 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

Reimplemented from assQuestion.

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

778 {
779 global $ilDB;
780
781 $result = parent::removeIntermediateSolution($active_id, $pass);
782
783 // get the current test id
784 // hey: prevPassSolutions - exract until you drop :-D
785 $test_id = $this->lookupTestId($active_id);
786 // hey.
787
788 $this->deleteUnusedFiles($test_id, $active_id, $pass);
789
790 return $result;
791 }
lookupTestId($active_id)

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

+ Here is the call graph for this function:

◆ reworkWorkingData()

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

{Reworks the allready saved working data if neccessary.

Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered
boolean$authorized
}

Reimplemented from assQuestion.

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

846 {
847 $this->handleSubmission($active_id, $pass, $obligationsAnswered, $authorized);
848 }
handleSubmission($active_id, $pass, $obligationsAnswered, $authorized)
This method is called after an user submitted one or more files.

References $pass, and handleSubmission().

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

86 {
87 global $ilDB;
88 $ilDB->manipulateF(
89 "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
90 array( "integer" ),
91 array( $this->getId() )
92 );
93 $ilDB->manipulateF(
94 "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,
102 )
103 );
104 }

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

Referenced by saveToDb().

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

◆ savePreviewData()

assFileUpload::savePreviewData ( ilAssQuestionPreviewSession  $previewSession)
protected

Reimplemented from assQuestion.

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

796 {
797 $userSolution = $previewSession->getParticipantsSolution();
798
799 if (!is_array($userSolution)) {
800 $userSolution = array();
801 }
802
803 // hey: prevPassSolutions - readability spree - get a chance to understand the code
804 if ($this->isFileDeletionAction()) {
805 // hey.
806 // hey: prevPassSolutions - readability spree - get a chance to understand the code
807 if ($this->isFileDeletionSubmitAvailable()) {
808 // hey.
809 $userSolution = $this->deletePreviewFileUploads($previewSession->getUserId(), $userSolution, $_POST['deletefiles']);
810 } else {
811 ilUtil::sendInfo($this->lng->txt('no_checkbox'), true);
812 }
813 } else {
814 // hey: prevPassSolutions - readability spree - get a chance to understand the code
815 if ($this->isFileUploadAvailable()) {
816 // hey.
817 if ($this->checkUpload()) {
818 if (!@file_exists($this->getPreviewFileUploadPath($previewSession->getUserId()))) {
820 }
821
822 $version = time();
823 $filename_arr = pathinfo($_FILES["upload"]["name"]);
824 $extension = $filename_arr["extension"];
825 $newfile = "file_" . md5($_FILES["upload"]["name"]) . "_" . $version . "." . $extension;
826 ilUtil::moveUploadedFile($_FILES["upload"]["tmp_name"], $_FILES["upload"]["name"], $this->getPreviewFileUploadPath($previewSession->getUserId()) . $newfile);
827
828 $userSolution[$newfile] = array(
829 'solution_id' => $newfile,
830 'value1' => $newfile,
831 'value2' => $_FILES['upload']['name'],
832 'tstamp' => $version,
833 'webpath' => $this->getPreviewFileUploadPathWeb($previewSession->getUserId())
834 );
835 }
836 }
837 }
838
839 $previewSession->setParticipantsSolution($userSolution);
840 }
$_POST["username"]
getPreviewFileUploadPathWeb($userId)
Returns the filesystem path for file uploads.
deletePreviewFileUploads($userId, $userSolution, $files)
checkUpload()
Check file upload.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

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

+ Here is the call graph for this function:

◆ saveToDb()

assFileUpload::saveToDb (   $original_id = "")

Saves a assFileUpload object to a database.

Reimplemented from assQuestion.

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

79 {
82 parent::saveToDb();
83 }
saveAdditionalQuestionDataToDb()
Saves a record to the question types additional data table.
saveQuestionDataToDb($original_id="")

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

+ Here is the call graph for this function:

◆ saveWorkingData()

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

Saves the learners input of the question to the database.

@access public

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

Reimplemented from assQuestion.

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

648 {
649 $pass = $this->ensureCurrentTestPass($active_id, $pass);
650 $test_id = $this->lookupTestId($active_id);
651
652 $uploadHandlingRequired = $this->isFileUploadAvailable() && $this->checkUpload();
653
654 $entered_values = false;
655
656 $this->getProcessLocker()->executeUserSolutionUpdateLockOperation(function () use (&$entered_values, $uploadHandlingRequired, $test_id, $active_id, $pass, $authorized) {
657 if ($authorized == false) {
658 $this->forceExistingIntermediateSolution($active_id, $pass, true);
659 }
660
661 if ($this->isFileDeletionAction()) {
662 if ($this->isFileDeletionSubmitAvailable()) {
663 foreach ($_POST[self::DELETE_FILES_TBL_POSTVAR] as $solution_id) {
664 $this->removeSolutionRecordById($solution_id);
665 }
666 } else {
667 ilUtil::sendInfo($this->lng->txt('no_checkbox'), true);
668 }
669 } else {
670 if ($this->isFileReuseHandlingRequired()) {
671 foreach ($_POST[self::REUSE_FILES_TBL_POSTVAR] as $solutionId) {
672 $solution = $this->getSolutionRecordById($solutionId);
673
674 $this->saveCurrentSolution(
675 $active_id,
676 $pass,
677 $solution['value1'],
678 $solution['value2'],
679 false,
680 $solution['tstamp']
681 );
682 }
683 }
684
685 if ($uploadHandlingRequired) {
686 if (!@file_exists($this->getFileUploadPath($test_id, $active_id))) {
688 }
689
690 $solutionFileVersioningUploadTS = time();
691 $filename_arr = pathinfo($_FILES["upload"]["name"]);
692 $extension = $filename_arr["extension"];
693 $newfile = "file_" . $active_id . "_" . $pass . "_" . $solutionFileVersioningUploadTS . "." . $extension;
694
695 include_once 'Services/Utilities/classes/class.ilFileUtils.php';
696 $dispoFilename = ilFileUtils::getValidFilename($_FILES['upload']['name']);
697 $newfile = ilFileUtils::getValidFilename($newfile);
698
699 ilUtil::moveUploadedFile($_FILES["upload"]["tmp_name"], $_FILES["upload"]["name"], $this->getFileUploadPath($test_id, $active_id) . $newfile);
700
701 $this->saveCurrentSolution(
702 $active_id,
703 $pass,
704 $newfile,
705 $dispoFilename,
706 false,
707 $solutionFileVersioningUploadTS
708 );
709
710 $entered_values = true;
711 }
712 }
713
714 if ($authorized == true && $this->intermediateSolutionExists($active_id, $pass)) {
715 // remove the dummy record of the intermediate solution
716 $this->deleteDummySolutionRecord($active_id, $pass);
717
718 // delete the authorized solution and make the intermediate solution authorized (keeping timestamps)
719 $this->removeCurrentSolution($active_id, $pass, true);
720 $this->updateCurrentSolutionsAuthorization($active_id, $pass, true, true);
721 }
722
723 $this->deleteUnusedFiles($test_id, $active_id, $pass);
724 });
725
726 if ($entered_values) {
727 include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
729 assQuestion::logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
730 }
731 } else {
732 include_once("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
734 assQuestion::logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
735 }
736 }
737
738 return true;
739 }
deleteDummySolutionRecord($activeId, $passIndex)
saveCurrentSolution($active_id, $pass, $value1, $value2, $authorized=true, $tstamp=null)
getSolutionRecordById($solutionId)
static logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
removeCurrentSolution($active_id, $pass, $authorized=true)
removeSolutionRecordById($solutionId)
ensureCurrentTestPass($active_id, $pass)
intermediateSolutionExists($active_id, $pass)
forceExistingIntermediateSolution($activeId, $passIndex, $considerDummyRecordCreation)
updateCurrentSolutionsAuthorization($activeId, $pass, $authorized, $keepTime=false)
static getValidFilename($a_filename)
Get valid filename.
static _getLogLanguage()
retrieve the log language for assessment logging
static _enabledAssessmentLogging()
check wether assessment logging is enabled or not

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

+ Here is the call graph for this function:

◆ setAllowedExtensions()

assFileUpload::setAllowedExtensions (   $a_value)

Set allowed file extensions.

Parameters
string$a_valueAllowed file extensions

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

1051 {
1052 $this->allowedextensions = strtolower(trim($a_value));
1053 }

Referenced by __set(), and loadFromDb().

+ Here is the caller graph for this function:

◆ setCompletionBySubmission()

assFileUpload::setCompletionBySubmission (   $bool)

Enabled/Disable completion by submission.

Parameters
boolean
Returns
assFileUpload @access public

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

1175 {
1176 $this->completion_by_submission = (bool) $bool;
1177 return $this;
1178 }

Referenced by __set(), and loadFromDb().

+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

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

{Creates an Excel worksheet for the detailed cumulated results of this question.

Parameters
object$worksheetReference to the parent excel worksheet
object$startrowStartrow of the output in the excel worksheet
object$active_idActive id of the participant
object$passTest pass
Returns
object
}

Reimplemented from assQuestion.

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

941 {
942 parent::setExportDetailsXLS($worksheet, $startrow, $active_id, $pass);
943
944 $i = 1;
945 $solutions = $this->getSolutionValues($active_id, $pass);
946 foreach ($solutions as $solution) {
947 $worksheet->setCell($startrow + $i, 0, $this->lng->txt("result"));
948 $worksheet->setBold($worksheet->getColumnCoord(0) . ($startrow + $i));
949 if (strlen($solution["value1"])) {
950 $worksheet->setCell($startrow + $i, 1, $solution["value1"]);
951 $worksheet->setCell($startrow + $i, 2, $solution["value2"]);
952 }
953 $i++;
954 }
955
956 return $startrow + $i + 1;
957 }
$worksheet
$i
Definition: disco.tpl.php:19

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

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

1018 {
1019 $this->maxsize = $a_value;
1020 }

Referenced by __set(), and loadFromDb().

+ Here is the caller graph for this function:

◆ toXML()

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

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

Reimplemented from assQuestion.

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

985 {
986 include_once "./Modules/TestQuestionPool/classes/export/qti12/class.assFileUploadExport.php";
987 $export = new assFileUploadExport($this);
988 return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
989 }
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: