ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 
 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, $returndetails=FALSE)
 Returns the points, a learner has reached answering the question. More...
 
 checkUpload ()
 Check file upload. 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)
 Returns the uploaded files for an active user in a given pass. More...
 
 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)
 Saves the learners input of the question to the database. 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, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question. 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...
 
 isCompletionBySubmissionEnabled ()
 Checks whether completion by submission is enabled or not. More...
 
 setCompletionBySubmission ($bool)
 Enabled/Disable completion by submission. More...
 
 isAnswered ($active_id, $pass)
 returns boolean wether the question is answered during test pass or not More...
 
 isAutosaveable ()
 
- Public Member Functions inherited from assQuestion
 __construct ( $title="", $comment="", $author="", $owner=-1, $question="")
 assQuestion constructor More...
 
 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. 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...
 
 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 ()
 
 _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question. More...
 
_getQuestionInfo ($question_id)
 Returns question information from the database. More...
 
 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, $question_id, $pass=NULL)
 Returns the points, a learner has reached answering the question. 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)
 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)
 persists the working state for current testactive and testpass More...
 
 saveWorkingData ($active_id, $pass=NULL)
 Saves the learners input of the question to the database. More...
 
 _updateTestResultCache ($active_id, ilAssQuestionProcessLocker $processLocker=null)
 Move this to a proper place. More...
 
 logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. More...
 
 _logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log. 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...
 
 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...
 
getSolutionValues ($active_id, $pass=NULL)
 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...
 
 getQuestionTypeFromDb ($question_id)
 get question type for question id 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...
 
 _getTotalRightAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method More...
 
 _getTitle ($a_q_id)
 Returns the title of a question. More...
 
 _getQuestionText ($a_q_id)
 Returns question text. More...
 
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 
 syncXHTMLMediaObjectsOfQuestion ()
 
 createPageObject ()
 create page object of question More...
 
 copyPageOfQuestion ($a_q_id)
 
 getPageOfQuestion ()
 
 _getQuestionType ($question_id)
 Returns the question type of a question with a given id. More...
 
 _getQuestionTitle ($question_id)
 Returns the question title of a question with a given id. More...
 
 setOriginalId ($original_id)
 
 getOriginalId ()
 
 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)
 
 _getInternalLinkHref ($target="")
 
 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...
 
 _getSolutionMaxPass ($question_id, $active_id)
 Returns the maximum pass a users question solution. More...
 
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user. More...
 
 _isUsedInRandomTest ($question_id="")
 Checks whether the question is used in a random test or not. More...
 
 calculateReachedPoints ($active_id, $pass=NULL, $returndetails=FALSE)
 Returns the points, a learner has reached answering the question. More...
 
 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)
 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...
 
 createNewImageFileName ($image_filename)
 
 _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...
 
 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...
 
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor. More...
 
 cleanupMediaObjectUsage ()
 synchronises appearances of media objects in the question with media object usage table More...
 
getInstances ()
 Gets all instances of the question. More...
 
 _needsManualScoring ($question_id)
 
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id. More...
 
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 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)
 
 _questionExistsInTest ($question_id, $test_id)
 
 formatSAQuestion ($a_q)
 Format self assessment question. More...
 
 setPreventRteUsage ($a_val)
 Set prevent rte usage. More...
 
 getPreventRteUsage ()
 Get prevent rte usage. More...
 
 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...
 
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not More...
 
 setObligationsToBeConsidered ($obligationsToBeConsidered=true)
 sets the flag wether obligations are to be considered or not More...
 
 areObligationsToBeConsidered ()
 gets the flag wether obligations are to be considered 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 ()
 
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 
- Public Member Functions inherited from ilObjFileHandlingQuestionType
 getFileUploadZIPFile ($test_id)
 Generates a ZIP file containing all file uploads for a given test and the original id of the 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 _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 _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 _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 _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 lookupParentObjId ($questionId)
 ilDB $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...
 

Protected Member Functions

 getFileUploadPath ($test_id, $active_id, $question_id=null)
 Returns the filesystem path for file uploads. More...
 
 deleteUploadedFiles ($files, $test_id, $active_id)
 Delete uploaded files. More...
 
 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary. More...
 
 handleSubmission ($active_id, $pass, $obligationsAnswered)
 This method is called after an user submitted one or more files. More...
 
- Protected Member Functions inherited from assQuestion
 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary. More...
 
 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...
 
 onSyncWithOriginal ($originalQuestionId, $duplicateQuestionId)
 
 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)
 
 duplicateQuestionHints ($originalQuestionId, $duplicateQuestionId)
 

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
 
 $outputType
 
 $suggested_solutions
 
 $original_id
 
 $page
 
 $external_id = ''
 
 $questionChangeListeners = array()
 
 $processLocker
 

Additional Inherited Members

- Data Fields inherited from assQuestion
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 = false
 
- Static Protected Member Functions inherited from assQuestion
static doesSolutionRecordsExist ($activeId, $pass, $questionId)
 checks wether there are existing solution records for the given test active / pass and given question id More...
 

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

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

895  {
896  switch ($value)
897  {
898  case "maxsize":
899  return $this->getMaxSize();
900  break;
901  case "allowedextensions":
902  return $this->getAllowedExtensions();
903  break;
904  case 'completion_by_submission':
905  return $this->isCompletionBySubmissionEnabled();
906  break;
907  default:
908  return parent::__get($value);
909  break;
910  }
911  }
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 916 of file class.assFileUpload.php.

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

917  {
918  switch ($key)
919  {
920  case "maxsize":
921  $this->setMaxSize($value);
922  break;
923  case "allowedextensions":
924  $this->setAllowedExtensions($value);
925  break;
926  case 'completion_by_submission':
927  $this->setCompletionBySubmission($value);
928  break;
929  default:
930  parent::__set($key, $value);
931  break;
932  }
933  }
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:

◆ calculateReachedPoints()

assFileUpload::calculateReachedPoints (   $active_id,
  $pass = NULL,
  $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 290 of file class.assFileUpload.php.

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

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

◆ checkUpload()

assFileUpload::checkUpload ( )

Check file upload.

Returns
boolean Input ok, true/false

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

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

Referenced by saveWorkingData().

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

◆ copyObject()

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

Copies an assFileUpload object.

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

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

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

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

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

750  {
751  }

◆ deleteUploadedFiles()

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

Delete uploaded files.

Parameters
arrayArray with ID's of the file datasets

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

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

Referenced by saveWorkingData().

479  {
480  global $ilDB;
481 
482  $pass = null;
483  $active_id = null;
484  foreach ($files as $solution_id)
485  {
486  $result = $ilDB->queryF("SELECT * FROM tst_solutions WHERE solution_id = %s",
487  array("integer"),
488  array($solution_id)
489  );
490  if ($result->numRows() == 1)
491  {
492  $data = $ilDB->fetchAssoc($result);
493  $pass = $data['pass'];
494  $active_id = $data['active_fi'];
495  @unlink($this->getFileUploadPath($test_id, $active_id) . $data['value1']);
496  }
497  }
498  foreach ($files as $solution_id)
499  {
500  $affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s",
501  array("integer"),
502  array($solution_id)
503  );
504  }
505  }
$result
fetchAssoc($a_set)
Fetch row as associative array from result set.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
getFileUploadPath($test_id, $active_id, $question_id=null)
Returns the filesystem path for file uploads.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ duplicate()

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

Duplicates an assFileUpload.

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

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

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

807  {
808  include_once "./Modules/TestQuestionPool/classes/import/qti12/class.assFileUploadImport.php";
809  $import = new assFileUploadImport($this);
810  $import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
811  }
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 729 of file class.assFileUpload.php.

Referenced by loadFromDb(), and saveAdditionalQuestionDataToDb().

730  {
731  return "qpl_qst_fileupload";
732  }
+ Here is the caller graph for this function:

◆ getAllowedExtensions()

assFileUpload::getAllowedExtensions ( )

Get allowed file extensions.

Returns
string Allowed file extensions

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

References $allowedextensions.

Referenced by __get(), and saveAdditionalQuestionDataToDb().

877  {
879  }
+ Here is the caller graph for this function:

◆ getAllowedExtensionsArray()

assFileUpload::getAllowedExtensionsArray ( )

Get allowed file extensions.

Returns
array Allowed file extensions

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

Referenced by checkUpload().

863  {
864  if (strlen($this->allowedextensions))
865  {
866  return array_filter(array_map('trim', explode(",", $this->allowedextensions)));
867  }
868  return array();
869  }
+ 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 739 of file class.assFileUpload.php.

740  {
741  return "";
742  }

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

832  {
833  $user_solution = array();
834  return $user_solution;
835  }

◆ getFileUploadPath()

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

Returns the filesystem path for file uploads.

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

References assQuestion\getId().

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

404  {
405  if (is_null($question_id)) $question_id = $this->getId();
406  return CLIENT_WEB_DIR . "/assessment/tst_$test_id/$active_id/$question_id/files/";
407  }
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 414 of file class.assFileUpload.php.

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

Referenced by getUploadedFilesForWeb().

415  {
416  if (is_null($question_id)) $question_id = $this->getId();
417  include_once "./Services/Utilities/classes/class.ilUtil.php";
418  $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/tst_$test_id/$active_id/$question_id/files/";
420  }
getId()
Gets the id of the assQuestion object.
const ILIAS_ABSOLUTE_PATH
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 512 of file class.assFileUpload.php.

References $size, and getMaxFilesizeInBytes().

513  {
514  $size = $this->getMaxFilesizeInBytes();
515  if ($size < 1024)
516  {
517  $max_filesize = sprintf("%d Bytes",$size);
518  }
519  else if ($size < 1024*1024)
520  {
521  $max_filesize = sprintf("%.1f KB",$size/1024);
522  }
523  else
524  {
525  $max_filesize = sprintf("%.1f MB",$size/1024/1024);
526  }
527 
528  return $max_filesize;
529  }
$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 536 of file class.assFileUpload.php.

References getMaxSize().

Referenced by checkUpload(), and getMaxFilesizeAsString().

537  {
538  if (strlen($this->getMaxSize()))
539  {
540  return $this->getMaxSize();
541  }
542  else
543  {
544  // get the value for the maximal uploadable filesize from the php.ini (if available)
545  $umf = get_cfg_var("upload_max_filesize");
546  // get the value for the maximal post data from the php.ini (if available)
547  $pms = get_cfg_var("post_max_size");
548 
549  //convert from short-string representation to "real" bytes
550  $multiplier_a=array("K"=>1024, "M"=>1024*1024, "G"=>1024*1024*1024);
551 
552  $umf_parts=preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
553  $pms_parts=preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
554 
555  if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
556  if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
557 
558  // use the smaller one as limit
559  $max_filesize = min($umf, $pms);
560 
561  if (!$max_filesize) $max_filesize=max($umf, $pms);
562  return $max_filesize;
563  }
564  }
getMaxSize()
Get max file size.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMaximumPoints()

assFileUpload::getMaximumPoints ( )

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

See also
$points

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

References assQuestion\getPoints().

Referenced by isComplete().

276  {
277  return $this->getPoints();
278  }
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 842 of file class.assFileUpload.php.

References $maxsize.

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

843  {
844  return $this->maxsize;
845  }
+ Here is the caller 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 719 of file class.assFileUpload.php.

720  {
721  return "assFileUpload";
722  }

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

758  {
759  $text = parent::getRTETextWithMediaObjects();
760  return $text;
761  }

◆ getUploadedFiles()

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

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

Returns
array Results

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

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

Referenced by getUploadedFilesForWeb(), and handleSubmission().

428  {
429  global $ilDB;
430  if (is_null($pass))
431  {
432  $pass = $this->getSolutionMaxPass($active_id);
433  }
434  $result = $ilDB->queryF("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s ORDER BY tstamp",
435  array("integer", "integer", "integer"),
436  array($active_id, $this->getId(), $pass)
437  );
438  $found = array();
439  while ($data = $ilDB->fetchAssoc($result))
440  {
441  array_push($found, $data);
442  }
443  return $found;
444  }
getId()
Gets the id of the assQuestion object.
$result
getSolutionMaxPass($active_id)
Returns the maximum pass a users question solution.
fetchAssoc($a_set)
Fetch row as associative array from result set.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ 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 451 of file class.assFileUpload.php.

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

452  {
453  global $ilDB;
454 
455  $found = $this->getUploadedFiles($active_id, $pass);
456  $result = $ilDB->queryF("SELECT test_fi FROM tst_active WHERE active_id = %s",
457  array('integer'),
458  array($active_id)
459  );
460  if ($result->numRows() == 1)
461  {
462  $row = $ilDB->fetchAssoc($result);
463  $test_id = $row["test_fi"];
464  $path = $this->getFileUploadPathWeb($test_id, $active_id);
465  foreach ($found as $idx => $data)
466  {
467  $found[$idx]['webpath'] = $path;
468  }
469  }
470  return $found;
471  }
$result
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)
Returns the uploaded files for an active user in a given pass.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
$path
Definition: index.php:22
+ Here is the call graph for this function:

◆ handleSubmission()

assFileUpload::handleSubmission (   $active_id,
  $pass,
  $obligationsAnswered 
)
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 685 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().

686  {
687  global $ilObjDataCache;
688 
690  {
691  $maxpoints = assQuestion::_getMaximumPoints($this->getId());
692 
693  if($this->getUploadedFiles($active_id, $pass))
694  {
695  $points = $maxpoints;
696  }
697  else
698  {
699  $points = 0;
700  }
701 
702  assQuestion::_setReachedPoints($active_id, $this->getId(), $points, $maxpoints, $pass, 1, $obligationsAnswered);
703 
704  // update learning progress
705  include_once 'Modules/Test/classes/class.ilObjTestAccess.php';
706  include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
708  ilObjTest::_getObjectIDFromActiveID((int)$active_id),
709  ilObjTestAccess::_getParticipantId((int) $active_id)
710  );
711  }
712  }
getId()
Gets the id of the assQuestion object.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_no_raise=false, $a_force_raise=false)
Update status.
getUploadedFiles($active_id, $pass=null)
Returns the uploaded files for an active user in a given pass.
_getObjectIDFromActiveID($active_id)
Returns the ILIAS test object id for a given active id.
_getParticipantId($active_id)
Get user id for active id.
_getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
_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 942 of file class.assFileUpload.php.

References $data, $query, $result, $row, assQuestion\$test_id, ilObjTestAccess\_getParticipantData(), ilUtil\delDir(), ilUtil\deliverFile(), ilFormat\fmtDateTime(), ilUtil\getASCIIFilename(), getFileUploadPath(), ilObjFileHandlingQuestionType\getFileUploadZIPFile(), assQuestion\getId(), assQuestion\getTitle(), ilUtil\ilTempnam(), ilUtil\makeDirParents(), ilFormat\unixtimestamp2datetime(), and ilUtil\zip().

943  {
944  global $ilDB;
945  $query = "
946  SELECT tst_solutions.solution_id
947  FROM tst_solutions, tst_active, qpl_questions
948  WHERE tst_solutions.active_fi = tst_active.active_id
949  AND tst_solutions.question_fi = qpl_questions.question_id
950  AND tst_solutions.question_fi = %s AND tst_active.test_fi = %s";
951  $result = $ilDB->queryF( $query,
952  array("integer", "integer"),
953  array($this->getId(), $test_id)
954  );
955  if ($result->numRows() > 0)
956  {
957  return true;
958  }
959  else
960  {
961  return false;
962  }
963  }
getId()
Gets the id of the assQuestion object.
$result
+ Here is the call graph for this function:

◆ isAnswered()

assFileUpload::isAnswered (   $active_id,
  $pass 
)

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

(overwrites method in class assQuestion)

ilDB $ilDB

Parameters
integer$active_id
integer$pass
Returns
boolean $answered

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

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

1072  {
1073  $answered = assQuestion::doesSolutionRecordsExist($active_id, $pass, $this->getId());
1074 
1075  return $answered;
1076  }
getId()
Gets the id of the assQuestion object.
static doesSolutionRecordsExist($activeId, $pass, $questionId)
checks wether there are existing solution records for the given test active / pass and given question...
+ Here is the call graph for this function:

◆ isAutosaveable()

assFileUpload::isAutosaveable ( )

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

1094  {
1095  return FALSE;
1096  }

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

References getMaximumPoints().

59  {
60  if (
61  strlen($this->title)
62  && ($this->author)
63  && ($this->question)
64  && ($this->getMaximumPoints() >= 0)
65  && is_numeric($this->getMaximumPoints()))
66  {
67  return true;
68  }
69  return false;
70  }
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 1040 of file class.assFileUpload.php.

References $completion_by_submission.

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

1041  {
1043  }
+ 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 1088 of file class.assFileUpload.php.

1089  {
1090  return true;
1091  }

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

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

107  {
108  global $ilDB;
109  $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",
110  array("integer"),
111  array($question_id)
112  );
113  if ($result->numRows() == 1)
114  {
115  $data = $ilDB->fetchAssoc($result);
116  $this->setId($question_id);
117  $this->setTitle($data["title"]);
118  $this->setComment($data["description"]);
119  $this->setNrOfTries($data['nr_of_tries']);
120  $this->setSuggestedSolution($data["solution_hint"]);
121  $this->setOriginalId($data["original_id"]);
122  $this->setObjId($data["obj_fi"]);
123  $this->setAuthor($data["author"]);
124  $this->setOwner($data["owner"]);
125  $this->setPoints($data["points"]);
126 
127  include_once("./Services/RTE/classes/class.ilRTE.php");
128  $this->setQuestion(ilRTE::_replaceMediaObjectImageSrc($data["question_text"], 1));
129  $this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
130  $this->setMaxSize($data["maxsize"]);
131  $this->setAllowedExtensions($data["allowedextensions"]);
132  $this->setCompletionBySubmission($data['compl_by_submission'] == 1 ? true : false);
133 
134  try
135  {
136  $this->setAdditionalContentEditingMode($data['add_cont_edit_mode']);
137  }
139  {
140  }
141  }
142  parent::loadFromDb($question_id);
143  }
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.
setNrOfTries($a_nr_of_tries)
setAdditionalContentEditingMode($additinalContentEditingMode)
setter for additional content editing mode for this question
fetchAssoc($a_set)
Fetch row as associative array from result set.
setAuthor($author="")
Sets the authors name of the assQuestion object.
setMaxSize($a_value)
Set max file size.
setPoints($a_points)
Sets the maximum available points for the question.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
setQuestion($question="")
Sets the question string of the question object.
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:

◆ reworkWorkingData()

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

Reworks the allready saved working data if neccessary.

protected

Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered

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

References $pass, and handleSubmission().

672  {
673  $this->handleSubmission($active_id, $pass, $obligationsAnswered);
674  }
handleSubmission($active_id, $pass, $obligationsAnswered)
This method is called after an user submitted one or more files.
+ Here is the call graph for this function:

◆ saveAdditionalQuestionDataToDb()

assFileUpload::saveAdditionalQuestionDataToDb ( )

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

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

Referenced by saveToDb().

83  {
84  global $ilDB;
85  $ilDB->manipulateF( "DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
86  array( "integer" ),
87  array( $this->getId() )
88  );
89  $ilDB->manipulateF( "INSERT INTO " . $this->getAdditionalTableName(
90  ) . " (question_fi, maxsize, allowedextensions, compl_by_submission) VALUES (%s, %s, %s, %s)",
91  array( "integer", "float", "text", "integer" ),
92  array(
93  $this->getId(),
94  (strlen( $this->getMaxSize() )) ? $this->getMaxSize() : NULL,
95  (strlen( $this->getAllowedExtensions() )) ? $this->getAllowedExtensions() : NULL,
97  )
98  );
99  }
getId()
Gets the id of the assQuestion object.
getAllowedExtensions()
Get allowed file extensions.
getMaxSize()
Get max file size.
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:

◆ saveToDb()

assFileUpload::saveToDb (   $original_id = "")

Saves a assFileUpload object to a database.

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

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

76  {
79  parent::saveToDb();
80  }
saveQuestionDataToDb($original_id="")
+ Here is the call graph for this function:

◆ saveWorkingData()

assFileUpload::saveWorkingData (   $active_id,
  $pass = NULL 
)

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

References $_POST, $ilUser, $pass, $result, $row, assQuestion\$test_id, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), checkUpload(), deleteUploadedFiles(), getFileUploadPath(), assQuestion\getId(), assQuestion\getProcessLocker(), assQuestion\logAction(), ilUtil\makeDirParents(), ilUtil\moveUploadedFile(), and ilUtil\sendInfo().

575  {
576  global $ilDB;
577  global $ilUser;
578 
579  if (is_null($pass))
580  {
581  include_once "./Modules/Test/classes/class.ilObjTest.php";
582  $pass = ilObjTest::_getPass($active_id);
583  }
584 
585  if( $_POST['cmd']['handleQuestionAction'] != $this->lng->txt('delete')
586  && strlen($_FILES["upload"]["tmp_name"]) )
587  {
588  $checkUploadResult = $this->checkUpload();
589  }
590  else
591  {
592  $checkUploadResult = false;
593  }
594 
595  $result = $ilDB->queryF("SELECT test_fi FROM tst_active WHERE active_id = %s",
596  array('integer'),
597  array($active_id)
598  );
599  $test_id = 0;
600  if ($result->numRows() == 1)
601  {
602  $row = $ilDB->fetchAssoc($result);
603  $test_id = $row["test_fi"];
604  }
605 
606  $this->getProcessLocker()->requestUserSolutionUpdateLock();
607 
608  $entered_values = false;
609  if( $_POST['cmd']['handleQuestionAction'] == $this->lng->txt('delete') )
610  {
611  if (is_array($_POST['deletefiles']) && count($_POST['deletefiles']) > 0)
612  {
613  $this->deleteUploadedFiles($_POST['deletefiles'], $test_id, $active_id);
614  }
615  else
616  {
617  ilUtil::sendInfo($this->lng->txt('no_checkbox'), true);
618  }
619  }
620  elseif( $checkUploadResult )
621  {
622  if (!@file_exists($this->getFileUploadPath($test_id, $active_id))) ilUtil::makeDirParents($this->getFileUploadPath($test_id, $active_id));
623  $version = time();
624  $filename_arr = pathinfo($_FILES["upload"]["name"]);
625  $extension = $filename_arr["extension"];
626  $newfile = "file_" . $active_id . "_" . $pass . "_" . $version . "." . $extension;
627  ilUtil::moveUploadedFile($_FILES["upload"]["tmp_name"], $_FILES["upload"]["name"], $this->getFileUploadPath($test_id, $active_id) . $newfile);
628  $next_id = $ilDB->nextId('tst_solutions');
629  $affectedRows = $ilDB->insert("tst_solutions", array(
630  "solution_id" => array("integer", $next_id),
631  "active_fi" => array("integer", $active_id),
632  "question_fi" => array("integer", $this->getId()),
633  "value1" => array("clob", $newfile),
634  "value2" => array("clob", $_FILES['upload']['name']),
635  "pass" => array("integer", $pass),
636  "tstamp" => array("integer", time())
637  ));
638  $entered_values = true;
639  }
640 
641  $this->getProcessLocker()->releaseUserSolutionUpdateLock();
642 
643  if ($entered_values)
644  {
645  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
647  {
648  $this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
649  }
650  }
651  else
652  {
653  include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
655  {
656  $this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
657  }
658  }
659 
660  return true;
661  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getId()
Gets the id of the assQuestion object.
$_POST['username']
Definition: cron.php:12
$result
_getPass($active_id)
Retrieves the actual pass of a given user for a given test.
_enabledAssessmentLogging()
check wether assessment logging is enabled or not
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.
_getLogLanguage()
retrieve the log language for assessment logging
global $ilUser
Definition: imgupload.php:15
getFileUploadPath($test_id, $active_id, $question_id=null)
Returns the filesystem path for file uploads.
logAction($logtext="", $active_id="", $question_id="")
Logs an action into the Test&Assessment log.
deleteUploadedFiles($files, $test_id, $active_id)
Delete uploaded files.
+ 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 886 of file class.assFileUpload.php.

Referenced by __set(), and loadFromDb().

887  {
888  $this->allowedextensions = strtolower(trim($a_value));
889  }
+ 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 1054 of file class.assFileUpload.php.

Referenced by __set(), and loadFromDb().

1055  {
1056  $this->completion_by_submission = (bool)$bool;
1057  return $this;
1058  }
+ Here is the caller graph for this function:

◆ setExportDetailsXLS()

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

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
object$format_titleExcel title format
object$format_boldExcel bold format
array$eval_dataCumulated evaluation data

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

References $pass, ilExcelUtils\_convert_text(), assQuestion\getSolutionValues(), and assQuestion\getTitle().

775  {
776  include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
777  $worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
778  $worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
779  $i = 1;
780  $solutions = $this->getSolutionValues($active_id, $pass);
781  foreach ($solutions as $solution)
782  {
783  $worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($this->lng->txt("result")), $format_bold);
784  if (strlen($solution["value1"]))
785  {
786  $worksheet->write($startrow + $i, 1, ilExcelUtils::_convert_text($solution["value1"]));
787  $worksheet->write($startrow + $i, 2, ilExcelUtils::_convert_text($solution["value2"]));
788  }
789  $i++;
790  }
791  return $startrow + $i + 1;
792  }
& getSolutionValues($active_id, $pass=NULL)
Loads solutions of a given user from the database an returns it.
_convert_text($a_text, $a_target="has been removed")
getTitle()
Gets the title string of the assQuestion object.
+ 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 852 of file class.assFileUpload.php.

Referenced by __set(), and loadFromDb().

853  {
854  $this->maxsize = $a_value;
855  }
+ 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 819 of file class.assFileUpload.php.

820  {
821  include_once "./Modules/TestQuestionPool/classes/export/qti12/class.assFileUploadExport.php";
822  $export = new assFileUploadExport($this);
823  return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
824  }
Class for file upload question exports.

Field Documentation

◆ $allowedextensions

assFileUpload::$allowedextensions
protected

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

Referenced by getAllowedExtensions().

◆ $completion_by_submission

assFileUpload::$completion_by_submission = false
protected

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

Referenced by isCompletionBySubmissionEnabled().

◆ $maxsize

assFileUpload::$maxsize
protected

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

Referenced by getMaxSize().


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