ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups 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
 isComplete ()
 Returns true, if a single choice question is complete for use.
 saveToDb ($original_id="")
 Saves a assFileUpload object to a database.
 loadFromDb ($question_id)
 Loads a assFileUpload object from a database.
 duplicate ($for_test=true, $title="", $author="", $owner="", $testObjId=null)
 Duplicates an assFileUpload.
 copyObject ($target_questionpool, $title="")
 Copies an assFileUpload object.
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question.
 calculateReachedPoints ($active_id, $pass=NULL)
 Returns the points, a learner has reached answering the question The points are calculated from the given answers including checks for all special scoring options in the test container.
 checkUpload ()
 Check file upload.
 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.
 getUploadedFilesForWeb ($active_id, $pass)
 Returns the web accessible uploaded files for an active user in a given pass.
 getMaxFilesizeAsString ()
 Return the maximum allowed file size as string.
 getMaxFilesizeInBytes ()
 Return the maximum allowed file size in bytes.
 saveWorkingData ($active_id, $pass=NULL)
 Saves the learners input of the question to the database.
 getQuestionType ()
 Returns the question type of the question.
 getAdditionalTableName ()
 Returns the name of the additional question data table in the database.
 getAnswerTableName ()
 Returns the name of the answer table in the database.
 deleteAnswers ($question_id)
 Deletes datasets from answers tables.
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor.
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question.
 fromXML (&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Creates a question from a QTI file.
 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.
 getBestSolution ($active_id, $pass)
 Returns the best solution for a given pass of a participant.
 getMaxSize ()
 Get max file size.
 setMaxSize ($a_value)
 Set max file size.
 getAllowedExtensionsArray ()
 Get allowed file extensions.
 getAllowedExtensions ()
 Get allowed file extensions.
 setAllowedExtensions ($a_value)
 Set allowed file extensions.
 __get ($value)
 Object getter.
 __set ($key, $value)
 Object setter.
 hasFileUploads ($test_id)
 Checks if file uploads exist for a given test and the original id of the question.
 isCompletionBySubmissionEnabled ()
 Checks whether completion by submission is enabled or not.
 setCompletionBySubmission ($bool)
 Enabled/Disable completion by submission.
- Public Member Functions inherited from assQuestion
 questionTitleExists ($questionpool_id, $title)
 Returns TRUE if the question title exists in the database.
 setTitle ($title="")
 Sets the title string of the assQuestion object.
 setId ($id=-1)
 Sets the id of the assQuestion object.
 setTestId ($id=-1)
 Sets the test id of the assQuestion object.
 setComment ($comment="")
 Sets the comment string of the assQuestion object.
 setOutputType ($outputType=OUTPUT_HTML)
 Sets the output type.
 setShuffle ($shuffle=true)
 Sets the shuffle flag.
 setEstimatedWorkingTime ($hour=0, $min=0, $sec=0)
 Sets the estimated working time of a question.
 keyInArray ($searchkey, $array)
 returns TRUE if the key occurs in an array
 setAuthor ($author="")
 Sets the authors name of the assQuestion object.
 setOwner ($owner="")
 Sets the creator/owner ID of the assQuestion object.
 getTitle ()
 Gets the title string of the assQuestion object.
 getId ()
 Gets the id of the assQuestion object.
 getShuffle ()
 Gets the shuffle flag.
 getTestId ()
 Gets the test id of the assQuestion object.
 getComment ()
 Gets the comment string of the assQuestion object.
 getOutputType ()
 Gets the output type.
 supportsJavascriptOutput ()
 Returns true if the question type supports JavaScript output.
 getEstimatedWorkingTime ()
 Gets the estimated working time of a question.
 getAuthor ()
 Gets the authors name of the assQuestion object.
 getOwner ()
 Gets the creator/owner ID of the assQuestion object.
 getObjId ()
 Get the object id of the container object.
 setObjId ($obj_id=0)
 Set the object id of the container object.
 _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question.
_getQuestionInfo ($question_id)
 Returns question information from the database.
 getSuggestedSolutionOutput ()
_getSuggestedSolution ($question_id, $subquestion_index=0)
 Returns a suggested solution for a given subquestion index.
 getSuggestedSolutions ()
 Return the suggested solutions.
 _getReachedPoints ($active_id, $question_id, $pass=NULL)
 Returns the points, a learner has reached answering the question.
 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.
 calculateResultsFromSolution ($active_id, $pass=NULL)
 Calculates the question results from a previously saved question solution.
 _updateTestResultCache ($active_id)
 _updateTestPassResults ($active_id, $pass)
 logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log.
 _logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log.
 moveUploadedMediaFile ($file, $name)
 Move an uploaded media file to an public accessible temp dir to present it.
 getSuggestedSolutionPath ()
 Returns the path for a suggested solution.
 getJavaPath ()
 Returns the image path for web accessable images of a question.
 getImagePath ($question_id=null, $object_id=null)
 Returns the image path for web accessable images of a question.
 getFlashPath ()
 Returns the image path for web accessable flash files of a question.
 getJavaPathWeb ()
 Returns the web image path for web accessable java applets of a question.
 getSuggestedSolutionPathWeb ()
 Returns the web path for a suggested solution.
 getImagePathWeb ()
 Returns the web image path for web accessable images of a question.
 getFlashPathWeb ()
 Returns the web image path for web accessable flash applications of a question.
getSolutionValues ($active_id, $pass=NULL)
 Loads solutions of a given user from the database an returns it.
 isInUse ($question_id="")
 Checks whether the question is in use or not.
 isClone ($question_id="")
 Checks whether the question is a clone of another question or not.
 pcArrayShuffle ($array)
 Shuffles the values of a given array.
 getQuestionTypeFromDb ($question_id)
 get question type for question id
 deleteAdditionalTableData ($question_id)
 Deletes datasets from the additional question table in the database.
 delete ($question_id)
 Deletes a question and all materials from the database.
 getTotalAnswers ()
 get total number of answers
 _getTotalAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method
 _getTotalRightAnswers ($a_q_id)
 get number of answers for question id (static) note: do not use $this inside this method
 _getTitle ($a_q_id)
 Returns the title of a question.
 _getQuestionText ($a_q_id)
 Returns question text.
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 syncXHTMLMediaObjectsOfQuestion ()
 createPageObject ()
 create page object of question
 copyPageOfQuestion ($a_q_id)
 getPageOfQuestion ()
 _getQuestionType ($question_id)
 Returns the question type of a question with a given id.
 _getQuestionTitle ($question_id)
 Returns the question title of a question with a given id.
 setOriginalId ($original_id)
 getOriginalId ()
 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.
 saveQuestionDataToDb ($original_id="")
 setNewOriginalId ($newId)
 deleteSuggestedSolutions ()
 Deletes all suggestes solutions in the database.
 getSuggestedSolution ($subquestion_index=0)
 Returns a suggested solution for a given subquestion index.
 getSuggestedSolutionTitle ($subquestion_index=0)
 Returns the title of a suggested solution at a given subquestion_index.
 setSuggestedSolution ($solution_id="", $subquestion_index=0, $is_import=false)
 Sets a suggested solution for the question.
 _resolveInternalLink ($internal_link)
 _resolveIntLinks ($question_id)
 _getInternalLinkHref ($target="")
 _getOriginalId ($question_id)
 Returns the original id of a question.
 syncWithOriginal ()
 createRandomSolution ($test_id, $user_id)
 _questionExists ($question_id)
 Returns true if the question already exists in the database.
 _questionExistsInPool ($question_id)
 Returns true if the question already exists in the database and is assigned to a question pool.
_instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id.
 getPoints ()
 Returns the maximum available points for the question.
 setPoints ($a_points)
 Sets the maximum available points for the question.
 getSolutionMaxPass ($active_id)
 Returns the maximum pass a users question solution.
 _getSolutionMaxPass ($question_id, $active_id)
 Returns the maximum pass a users question solution.
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user.
 _isUsedInRandomTest ($question_id="")
 Checks whether the question is used in a random test or not.
 calculateReachedPoints ($active_id, $pass=NULL, $points=0)
 Returns the points, a learner has reached answering the question The points are calculated from the given answers including checks for all special scoring options in the test container.
 isHTML ($a_text)
 Checks if a given string contains HTML or not.
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=FALSE)
 Prepares a string for a text area output in tests.
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string.
 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.
 createNewImageFileName ($image_filename)
 _setReachedPoints ($active_id, $question_id, $points, $maxpoints, $pass=NULL, $manualscoring=FALSE)
 Sets the points, a learner has reached answering the question Additionally objective results are updated.
 getQuestion ()
 Gets the question string of the question object.
 setQuestion ($question="")
 Sets the question string of the question object.
 getQuestionTypeID ()
 Returns the question type of the question.
 getFeedbackGeneric ($correctness)
 Returns the generic feedback for a given question state.
 cleanupMediaObjectUsage ()
 synchronises appearances of media objects in the question with media object usage table
getInstances ()
 Gets all instances of the question.
 _needsManualScoring ($question_id)
 getActiveUserData ($active_id)
 Returns the user id and the test id for a given active id.
_instanciateQuestionGUI ($question_id)
 Creates an instance of a question gui with a given question id.
 getNrOfTries ()
 setNrOfTries ($a_nr_of_tries)
 setExportImagePath ($a_path)
 _questionExistsInTest ($question_id, $test_id)
 formatSAQuestion ($a_q)
 Format self assessment question.

Protected Member Functions

 getFileUploadPath ($test_id, $active_id, $question_id=null)
 Returns the filesystem path for file uploads.
 deleteUploadedFiles ($files, $test_id, $active_id)
 Delete uploaded files.
 handleSubmission ($active_id, $pass)
 This method is called after an user submitted one or more files.
- Protected Member Functions inherited from assQuestion
 deletePageOfQuestion ($question_id)
 Deletes the page object of a question with a given ID.
 onDuplicate ($originalParentId, $originalQuestionId, $duplicateParentId, $duplicateQuestionId)
 Will be called when a question is duplicated (inside a question pool or for insertion in a test)
 onCopy ($source_questionpool_id, $source_question_id)
 Will be called when a question is copied (into another question pool)
 duplicateSuggestedSolutionFiles ($parent_id, $question_id)
 Duplicates the files of a suggested solution if the question is duplicated.
 syncSuggestedSolutionFiles ($original_id)
 Syncs the files of a suggested solution if the question is synced.
 copySuggestedSolutionFiles ($source_questionpool_id, $source_question_id)

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

Additional Inherited Members

- Static Public Member Functions inherited from assQuestion
static _getSuggestedSolutionCount ($question_id)
 Returns the number of suggested solutions associated with a question.
static _getSuggestedSolutionOutput ($question_id)
 Returns the output of the suggested solution.
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)
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.
static _areAnswered ($a_user_id, $a_question_ids)
 Checks if an array of question ids is answered by an user or not.
static _includeClass ($question_type, $gui=0)
 Include the php class file for a given question type.
static _getQuestionTypeName ($type_tag)
 Return the translation for a given question type tag.

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
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
Id:
class.assFileUpload.php 47446 2014-01-22 17:07:12Z bheyser

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

Constructor & Destructor Documentation

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

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

Member Function Documentation

assFileUpload::__get (   $value)

Object getter.

Reimplemented from assQuestion.

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

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

{
switch ($value)
{
case "maxsize":
return $this->getMaxSize();
break;
case "allowedextensions":
return $this->getAllowedExtensions();
break;
case 'completion_by_submission':
break;
default:
return parent::__get($value);
break;
}
}

+ Here is the call graph for this function:

assFileUpload::__set (   $key,
  $value 
)

Object setter.

Reimplemented from assQuestion.

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

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

{
switch ($key)
{
case "maxsize":
$this->setMaxSize($value);
break;
case "allowedextensions":
$this->setAllowedExtensions($value);
break;
case 'completion_by_submission':
$this->setCompletionBySubmission($value);
break;
default:
parent::__set($key, $value);
break;
}
}

+ Here is the call graph for this function:

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

Returns the points, a learner has reached answering the question The points are calculated from the given answers including checks for all special scoring options in the test container.

Parameters
integer$user_idThe database ID of the learner
integer$test_idThe database Id of the test containing the question

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

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

{
global $ilDB;
if (is_null($pass))
{
$pass = $this->getSolutionMaxPass($active_id);
}
$points = 0;
return $points;
}

+ Here is the call graph for this function:

assFileUpload::checkUpload ( )

Check file upload.

Returns
boolean Input ok, true/false

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

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

Referenced by saveWorkingData().

{
$this->lng->loadLanguageModule("form");
// remove trailing '/'
while (substr($_FILES["upload"]["name"],-1) == '/')
{
$_FILES["upload"]["name"] = substr($_FILES["upload"]["name"],0,-1);
}
$filename = $_FILES["upload"]["name"];
$filename_arr = pathinfo($_FILES["upload"]["name"]);
$suffix = $filename_arr["extension"];
$mimetype = $_FILES["upload"]["type"];
$size_bytes = $_FILES["upload"]["size"];
$temp_name = $_FILES["upload"]["tmp_name"];
$error = $_FILES["upload"]["error"];
if ($size_bytes > $this->getMaxFilesizeInBytes())
{
ilUtil::sendInfo($this->lng->txt("form_msg_file_size_exceeds"), true);
return false;
}
// error handling
if ($error > 0)
{
switch ($error)
{
case UPLOAD_ERR_INI_SIZE:
ilUtil::sendInfo($this->lng->txt("form_msg_file_size_exceeds"), true);
return false;
break;
case UPLOAD_ERR_FORM_SIZE:
ilUtil::sendInfo($this->lng->txt("form_msg_file_size_exceeds"), true);
return false;
break;
case UPLOAD_ERR_PARTIAL:
ilUtil::sendInfo($this->lng->txt("form_msg_file_partially_uploaded"), true);
return false;
break;
case UPLOAD_ERR_NO_FILE:
ilUtil::sendInfo($this->lng->txt("form_msg_file_no_upload"), true);
return false;
break;
case UPLOAD_ERR_NO_TMP_DIR:
ilUtil::sendInfo($this->lng->txt("form_msg_file_missing_tmp_dir"), true);
return false;
break;
case UPLOAD_ERR_CANT_WRITE:
ilUtil::sendInfo($this->lng->txt("form_msg_file_cannot_write_to_disk"), true);
return false;
break;
case UPLOAD_ERR_EXTENSION:
ilUtil::sendInfo($this->lng->txt("form_msg_file_upload_stopped_ext"), true);
return false;
break;
}
}
// check suffixes
if (strlen($suffix) && count($this->getAllowedExtensionsArray()))
{
if (!in_array(strtolower($suffix), $this->getAllowedExtensionsArray()))
{
ilUtil::sendInfo($this->lng->txt("form_msg_file_wrong_file_type"), true);
return false;
}
}
// virus handling
if (strlen($temp_name))
{
$vir = ilUtil::virusHandling($temp_name, $filename);
if ($vir[0] == false)
{
ilUtil::sendInfo($this->lng->txt("form_msg_file_virus_found")."<br />".$vir[1], true);
return false;
}
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Copies an assFileUpload object.

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

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

{
if ($this->id <= 0)
{
// The question has not been saved. It cannot be duplicated
return;
}
// duplicate the question in database
$clone = $this;
include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
$clone->id = -1;
$source_questionpool = $this->getObjId();
$clone->setObjId($target_questionpool);
if ($title)
{
$clone->setTitle($title);
}
$clone->saveToDb();
// copy question page content
$clone->copyPageOfQuestion($original_id);
// copy XHTML media objects
$clone->copyXHTMLMediaObjectsOfQuestion($original_id);
// duplicate the generic feedback
$clone->duplicateFeedbackGeneric($original_id);
$clone->onCopy($this->getObjId(), $this->getId());
return $clone->id;
}

+ Here is the call graph for this function:

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

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

Delete uploaded files.

Parameters
arrayArray with ID's of the file datasets

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

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

Referenced by saveWorkingData().

{
global $ilDB;
$pass = null;
$active_id = null;
foreach ($files as $solution_id)
{
$result = $ilDB->queryF("SELECT * FROM tst_solutions WHERE solution_id = %s",
array("integer"),
array($solution_id)
);
if ($result->numRows() == 1)
{
$data = $ilDB->fetchAssoc($result);
$pass = $data['pass'];
$active_id = $data['active_fi'];
@unlink($this->getFileUploadPath($test_id, $active_id) . $data['value1']);
}
}
foreach ($files as $solution_id)
{
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_solutions WHERE solution_id = %s",
array("integer"),
array($solution_id)
);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Duplicates an assFileUpload.

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

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

{
if ($this->id <= 0)
{
// The question has not been saved. It cannot be duplicated
return;
}
// duplicate the question in database
$this_id = $this->getId();
if( (int)$testObjId > 0 )
{
$thisObjId = $this->getObjId();
}
$clone = $this;
include_once ("./Modules/TestQuestionPool/classes/class.assQuestion.php");
$clone->id = -1;
if( (int)$testObjId > 0 )
{
$clone->setObjId($testObjId);
}
if ($title)
{
$clone->setTitle($title);
}
if ($author)
{
$clone->setAuthor($author);
}
if ($owner)
{
$clone->setOwner($owner);
}
if ($for_test)
{
$clone->saveToDb($original_id);
}
else
{
$clone->saveToDb();
}
// copy question page content
$clone->copyPageOfQuestion($this_id);
// copy XHTML media objects
$clone->copyXHTMLMediaObjectsOfQuestion($this_id);
// duplicate the generic feedback
$clone->duplicateFeedbackGeneric($this_id);
$clone->onDuplicate($thisObjId, $this_id, $clone->getObjId(), $clone->getId());
return $clone->id;
}

+ Here is the call graph for this function:

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

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

Referenced by loadFromDb(), and saveToDb().

{
return "qpl_qst_fileupload";
}

+ Here is the caller graph for this function:

assFileUpload::getAllowedExtensions ( )

Get allowed file extensions.

Returns
string Allowed file extensions

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

References $allowedextensions.

Referenced by __get(), and saveToDb().

+ Here is the caller graph for this function:

assFileUpload::getAllowedExtensionsArray ( )

Get allowed file extensions.

Returns
array Allowed file extensions

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

Referenced by checkUpload().

{
if (strlen($this->allowedextensions))
{
return split(",", $this->allowedextensions);
}
return array();
}

+ Here is the caller graph for this function:

assFileUpload::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name

Reimplemented from assQuestion.

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

{
return "";
}
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 790 of file class.assFileUpload.php.

{
$user_solution = array();
return $user_solution;
}
assFileUpload::getFileUploadPath (   $test_id,
  $active_id,
  $question_id = null 
)
protected

Returns the filesystem path for file uploads.

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

References assQuestion\getId().

Referenced by deleteUploadedFiles(), and saveWorkingData().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

Referenced by getUploadedFilesForWeb().

{
if (is_null($question_id)) $question_id = $this->getId();
include_once "./Services/Utilities/classes/class.ilUtil.php";
$webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/tst_$test_id/$active_id/$question_id/files/";
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

References $size, and getMaxFilesizeInBytes().

{
if ($size < 1024)
{
$max_filesize = sprintf("%.1f Bytes",$size);
}
else if ($size < 1024*1024)
{
$max_filesize = sprintf("%.1f KB",$size/1024);
}
else
{
$max_filesize = sprintf("%.1f MB",$size/1024/1024);
}
return $max_filesize;
}

+ Here is the call graph for this function:

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

References getMaxSize().

Referenced by checkUpload(), and getMaxFilesizeAsString().

{
if (strlen($this->getMaxSize()))
{
return $this->getMaxSize();
}
else
{
// get the value for the maximal uploadable filesize from the php.ini (if available)
$umf = get_cfg_var("upload_max_filesize");
// get the value for the maximal post data from the php.ini (if available)
$pms = get_cfg_var("post_max_size");
//convert from short-string representation to "real" bytes
$multiplier_a=array("K"=>1024, "M"=>1024*1024, "G"=>1024*1024*1024);
$umf_parts=preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
$pms_parts=preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
// use the smaller one as limit
$max_filesize = min($umf, $pms);
if (!$max_filesize) $max_filesize=max($umf, $pms);
return $max_filesize;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assFileUpload::getMaximumPoints ( )

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

See Also
$points

Reimplemented from assQuestion.

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

References assQuestion\getPoints().

Referenced by isComplete().

{
return $this->getPoints();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assFileUpload::getMaxSize ( )

Get max file size.

Returns
double Max file size

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

References $maxsize.

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

{
}

+ Here is the caller graph for this function:

assFileUpload::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question

Reimplemented from assQuestion.

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

{
return "assFileUpload";
}
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 716 of file class.assFileUpload.php.

{
return $text;
}
assFileUpload::getUploadedFiles (   $active_id,
  $pass = null 
)

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

Returns
array Results

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

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

Referenced by getUploadedFilesForWeb(), and handleSubmission().

{
global $ilDB;
if (is_null($pass))
{
$pass = $this->getSolutionMaxPass($active_id);
}
$result = $ilDB->queryF("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s ORDER BY tstamp",
array("integer", "integer", "integer"),
array($active_id, $this->getId(), $pass)
);
$found = array();
while ($data = $ilDB->fetchAssoc($result))
{
array_push($found, $data);
}
return $found;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

{
global $ilDB;
$found = $this->getUploadedFiles($active_id, $pass);
$result = $ilDB->queryF("SELECT test_fi FROM tst_active WHERE active_id = %s",
array('integer'),
array($active_id)
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
$test_id = $row["test_fi"];
$path = $this->getFileUploadPathWeb($test_id, $active_id);
foreach ($found as $idx => $data)
{
$found[$idx]['webpath'] = $path;
}
}
return $found;
}

+ Here is the call graph for this function:

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

{
global $ilObjDataCache;
{
$maxpoints = assQuestion::_getMaximumPoints($this->getId());
if($this->getUploadedFiles($active_id, $pass))
{
$points = $maxpoints;
}
else
{
$points = 0;
}
assQuestion::_setReachedPoints($active_id, $this->getId(), $points, $maxpoints, $pass, 1);
// update learning progress
include_once 'Modules/Test/classes/class.ilObjTestAccess.php';
include_once 'Services/Tracking/classes/class.ilLPStatusWrapper.php';
);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assFileUpload::hasFileUploads (   $test_id)

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

Returns
boolean TRUE if file uploads exist, FALSE otherwise

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

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

{
global $ilDB;
$result = $ilDB->queryF("
SELECT tst_solutions.solution_id
FROM tst_solutions, tst_active, qpl_questions
WHERE tst_solutions.active_fi = tst_active.active_id
AND tst_solutions.question_fi = qpl_questions.question_id
AND qpl_questions.question_id = %s
AND tst_active.test_fi = %s
",
array("integer", "integer"),
array($this->getId(), $test_id)
);
if ($result->numRows() > 0)
{
return true;
}
else
{
return false;
}
}

+ Here is the call graph for this function:

assFileUpload::isComplete ( )

Returns true, if a single choice question is complete for use.

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

Reimplemented from assQuestion.

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

References getMaximumPoints().

{
if (strlen($this->title) and ($this->author) and ($this->question) and ($this->getMaximumPoints() >= 0) and is_numeric($this->getMaximumPoints()))
{
return true;
}
else
{
return false;
}
}

+ Here is the call graph for this function:

assFileUpload::isCompletionBySubmissionEnabled ( )

Checks whether completion by submission is enabled or not.

Returns
boolean public

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

References $completion_by_submission.

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

+ Here is the caller graph for this function:

assFileUpload::loadFromDb (   $question_id)

Loads a assFileUpload object from a database.

Parameters
object$dbA pear DB object
integer$question_idA unique key which defines the question in the database

Reimplemented from assQuestion.

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

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

{
global $ilDB;
$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",
array("integer"),
array($question_id)
);
if ($result->numRows() == 1)
{
$data = $ilDB->fetchAssoc($result);
$this->setId($question_id);
$this->setTitle($data["title"]);
$this->setComment($data["description"]);
$this->setNrOfTries($data['nr_of_tries']);
$this->setSuggestedSolution($data["solution_hint"]);
$this->setOriginalId($data["original_id"]);
$this->setObjId($data["obj_fi"]);
$this->setAuthor($data["author"]);
$this->setOwner($data["owner"]);
$this->setPoints($data["points"]);
include_once("./Services/RTE/classes/class.ilRTE.php");
$this->setEstimatedWorkingTime(substr($data["working_time"], 0, 2), substr($data["working_time"], 3, 2), substr($data["working_time"], 6, 2));
$this->setMaxSize($data["maxsize"]);
$this->setAllowedExtensions($data["allowedextensions"]);
$this->setCompletionBySubmission($data['compl_by_submission'] == 1 ? true : false);
}
parent::loadFromDb($question_id);
}

+ Here is the call graph for this function:

assFileUpload::saveToDb (   $original_id = "")

Saves a assFileUpload object to a database.

Reimplemented from assQuestion.

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

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

{
global $ilDB;
// save additional data
$affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
array("integer"),
array($this->getId())
);
$affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, maxsize, allowedextensions, compl_by_submission) VALUES (%s, %s, %s, %s)",
array("integer", "float", "text", "integer"),
array(
$this->getId(),
(strlen($this->getMaxSize())) ? $this->getMaxSize() : NULL,
(strlen($this->getAllowedExtensions())) ? $this->getAllowedExtensions() : NULL,
)
);
}

+ Here is the call graph for this function:

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

Saves the learners input of the question to the database.

  @param integer $test_id The database id of the test containing this question
Returns
boolean Indicates the save status (true if saved successful, false otherwise)
See Also
$answers

Reimplemented from assQuestion.

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

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

{
global $ilDB;
global $ilUser;
if (is_null($pass))
{
include_once "./Modules/Test/classes/class.ilObjTest.php";
$pass = ilObjTest::_getPass($active_id);
}
$result = $ilDB->queryF("SELECT test_fi FROM tst_active WHERE active_id = %s",
array('integer'),
array($active_id)
);
$test_id = 0;
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
$test_id = $row["test_fi"];
}
$entered_values = false;
if (strcmp($_POST['cmd']['gotoquestion'], $this->lng->txt('delete')) == 0)
{
$deletefiles = $_POST['file'];
if (is_array($deletefiles) && count($deletefiles) > 0)
{
$this->deleteUploadedFiles($deletefiles, $test_id, $active_id);
}
else
{
ilUtil::sendInfo($this->lng->txt('no_checkbox'), true);
}
}
else
{
if (strlen($_FILES["upload"]["tmp_name"]))
{
if ($this->checkUpload())
{
if (!@file_exists($this->getFileUploadPath($test_id, $active_id))) ilUtil::makeDirParents($this->getFileUploadPath($test_id, $active_id));
$version = time();
$filename_arr = pathinfo($_FILES["upload"]["name"]);
$extension = $filename_arr["extension"];
$newfile = "file_" . $active_id . "_" . $pass . "_" . $version . "." . $extension;
ilUtil::moveUploadedFile($_FILES["upload"]["tmp_name"], $_FILES["upload"]["name"], $this->getFileUploadPath($test_id, $active_id) . $newfile);
$next_id = $ilDB->nextId('tst_solutions');
$affectedRows = $ilDB->insert("tst_solutions", array(
"solution_id" => array("integer", $next_id),
"active_fi" => array("integer", $active_id),
"question_fi" => array("integer", $this->getId()),
"value1" => array("clob", $newfile),
"value2" => array("clob", $_FILES['upload']['name']),
"pass" => array("integer", $pass),
"tstamp" => array("integer", time())
));
$entered_values = true;
}
}
}
if ($entered_values)
{
include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
{
$this->logAction($this->lng->txtlng("assessment", "log_user_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
}
}
else
{
include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
{
$this->logAction($this->lng->txtlng("assessment", "log_user_not_entered_values", ilObjAssessmentFolder::_getLogLanguage()), $active_id, $this->getId());
}
}
$this->handleSubmission($active_id, $pass);
return true;
}

+ Here is the call graph for this function:

assFileUpload::setAllowedExtensions (   $a_value)

Set allowed file extensions.

Parameters
string$a_valueAllowed file extensions

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

Referenced by __set(), and loadFromDb().

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

+ Here is the caller graph for this function:

assFileUpload::setCompletionBySubmission (   $bool)

Enabled/Disable completion by submission.

Parameters
boolean
Returns
assFileUpload public

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

Referenced by __set(), and loadFromDb().

{
$this->completion_by_submission = (bool)$bool;
return $this;
}

+ Here is the caller graph for this function:

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

Reimplemented from assQuestion.

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

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

{
include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
$worksheet->writeString($startrow, 0, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())), $format_title);
$worksheet->writeString($startrow, 1, ilExcelUtils::_convert_text($this->getTitle()), $format_title);
$i = 1;
$solutions = $this->getSolutionValues($active_id, $pass);
foreach ($solutions as $solution)
{
$worksheet->writeString($startrow + $i, 0, ilExcelUtils::_convert_text($this->lng->txt("result")), $format_bold);
if (strlen($solution["value1"]))
{
$worksheet->write($startrow + $i, 1, ilExcelUtils::_convert_text($solution["value1"]));
$worksheet->write($startrow + $i, 2, ilExcelUtils::_convert_text($solution["value2"]));
}
$i++;
}
return $startrow + $i + 1;
}

+ Here is the call graph for this function:

assFileUpload::setMaxSize (   $a_value)

Set max file size.

Parameters
double$a_valueMax file size

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

Referenced by __set(), and loadFromDb().

{
$this->maxsize = $a_value;
}

+ Here is the caller graph for this function:

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

{
include_once "./Modules/TestQuestionPool/classes/export/qti12/class.assFileUploadExport.php";
$export = new assFileUploadExport($this);
return $export->toXML($a_include_header, $a_include_binary, $a_shuffle, $test_output, $force_image_references);
}

Field Documentation

assFileUpload::$allowedextensions
protected

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

Referenced by getAllowedExtensions().

assFileUpload::$completion_by_submission = false
protected

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

Referenced by isCompletionBySubmissionEnabled().

assFileUpload::$maxsize
protected

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

Referenced by getMaxSize().


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