ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
assQuestion Class Reference

Abstract basic class which is to be extended by the concrete assessment question type classes. More...

+ Inheritance diagram for assQuestion:
+ Collaboration diagram for assQuestion:

Public Member Functions

 __construct ($title="", $comment="", $author="", $owner=-1, $question="")
 assQuestion constructor
 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.
 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.
 isComplete ()
 Returns true, if a question is complete for use.
 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.
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question.
 getAdjustedReachedPoints ($active_id, $pass=NULL)
 returns the reached points ...
 calculateResultsFromSolution ($active_id, $pass=NULL, $obligationsEnabled=false)
 Calculates the question results from a previously saved question solution.
 persistWorkingState ($active_id, $pass=NULL, $obligationsEnabled=false)
 persists the working state for current testactive and testpass
 saveWorkingData ($active_id, $pass=NULL)
 Saves the learners input of the question to the database.
 _updateTestResultCache ($active_id)
 _updateTestPassResults ($active_id, $pass, $obligationsEnabled=false)
 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
 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.
 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 ()
 loadFromDb ($question_id)
 Loads the question from the database.
 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="")
 saveToDb ($original_id="")
 Saves the question to the database.
 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.
 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, $returndetails=FALSE)
 Returns the points, a learner has reached answering the question.
 adjustReachedPointsByScoringOptions ($points, $active_id, $pass=NULL)
 Adjust the given reached points by 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, $manualscoring, $obligationsEnabled)
 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.
 getQuestionType ()
 Returns the question type of the question.
 getQuestionTypeID ()
 Returns the question type of the question.
 getFeedbackGeneric ($correctness)
 Returns the generic feedback for a given question state.
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor.
 getFeedbackSingleAnswer ($answer_index)
 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.
 setExportDetailsXLS (&$worksheet, $startrow, $active_id, $pass, &$format_title, &$format_bold)
 Creates an Excel worksheet for the detailed cumulated results of this question.
 __get ($value)
 Object getter.
 __set ($key, $value)
 Object setter.
 getNrOfTries ()
 setNrOfTries ($a_nr_of_tries)
 setExportImagePath ($a_path)
 _questionExistsInTest ($question_id, $test_id)
 formatSAQuestion ($a_q)
 Format self assessment question.
 isAnswered ($active_id, $pass=null)
 returns boolean wether the question is answered during test pass or not
 setObligationsToBeConsidered ($obligationsToBeConsidered=true)
 sets the flag wether obligations are to be considered or not
 areObligationsToBeConsidered ()
 gets the flag wether obligations are to be considered or not
 isAutosaveable ()
 getHtmlUserSolutionPurifier ()

Static Public Member Functions

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 _instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id.
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.
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.
static isObligationPossible ($questionId)
 returns boolean wether it is possible to set this question type as obligatory or not considering the current question configuration

Protected Member Functions

 reworkWorkingData ($active_id, $pass, $obligationsAnswered)
 Reworks the allready saved working data if neccessary.
 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)
 duplicateQuestionHints ($originalQuestionId, $duplicateQuestionId)
 deleteFeedbackSpecific ($question_id)

Static Protected Member Functions

static doesSolutionRecordsExist ($activeId, $pass, $questionId)
 checks wether there are existing solution records for the given test active / pass and given question id

Protected Attributes

 $id
 $title
 $comment
 $owner
 $author
 $question
 $points
 $est_working_time
 $shuffle
 $test_id
 $obj_id
 $ilias
 $tpl
 $lng
 $outputType
 $suggested_solutions
 $original_id
 $page

Private Member Functions

 deleteFeedbackGeneric ($question_id)

Private Attributes

 $nr_of_tries
 Number of tries.
 $arrData
 Associative array to store properties.
 $export_image_path
 (Web) Path to images
 $obligationsToBeConsidered = false

Detailed Description

Abstract basic class which is to be extended by the concrete assessment question type classes.

The assQuestion class defines and encapsulates basic/common methods and attributes as well as it provides abstract methods that are to be implemented by concrete question type classes.

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
Version
$Id$

Definition at line 21 of file class.assQuestion.php.

Constructor & Destructor Documentation

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

assQuestion constructor

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$questionQuestion text public

Reimplemented in assClozeTest, assTextQuestion, assTextSubset, assNumeric, assFileUpload, assFlashQuestion, assErrorText, and assOrderingHorizontal.

Definition at line 182 of file class.assQuestion.php.

References $author, $comment, $ilias, $lng, $owner, $question, $title, $tpl, OUTPUT_HTML, setEstimatedWorkingTime(), and setQuestion().

{
global $ilias;
global $lng;
global $tpl;
$this->ilias =& $ilias;
$this->lng =& $lng;
$this->tpl =& $tpl;
$this->original_id = null;
$this->title = $title;
$this->comment = $comment;
$this->page = null;
$this->author = $author;
if (!$this->author)
{
$this->author = $this->ilias->account->fullname;
}
$this->owner = $owner;
if ($this->owner <= 0)
{
$this->owner = $this->ilias->account->id;
}
$this->id = -1;
$this->test_id = -1;
$this->suggested_solutions = array();
$this->shuffle = 1;
$this->nr_of_tries = "";
$this->setEstimatedWorkingTime(0,1,0);
$this->outputType = OUTPUT_HTML;
$this->arrData = array();
}

+ Here is the call graph for this function:

Member Function Documentation

assQuestion::__get (   $value)

Object getter.

Reimplemented in assFileUpload, assErrorText, and assOrderingHorizontal.

Definition at line 3540 of file class.assQuestion.php.

References $ilias, $page, $tpl, getAuthor(), getComment(), getEstimatedWorkingTime(), getId(), getObjId(), getOriginalId(), getOutputType(), getOwner(), getPoints(), getQuestion(), getShuffle(), getSuggestedSolutions(), getTestId(), and getTitle().

{
switch ($value)
{
case "id":
return $this->getId();
break;
case "title":
return $this->getTitle();
break;
case "comment":
return $this->getComment();
break;
case "owner":
return $this->getOwner();
break;
case "author":
return $this->getAuthor();
break;
case "question":
return $this->getQuestion();
break;
case "points":
return $this->getPoints();
break;
case "est_working_time":
return $this->getEstimatedWorkingTime();
break;
case "shuffle":
return $this->getShuffle();
break;
case "test_id":
return $this->getTestId();
break;
case "obj_id":
return $this->getObjId();
break;
case "ilias":
return $this->ilias;
break;
case "tpl":
return $this->tpl;
break;
case "page":
return $this->page;
break;
case "outputType":
return $this->getOutputType();
break;
case "suggested_solutions":
return $this->getSuggestedSolutions();
break;
case "original_id":
return $this->getOriginalId();
break;
default:
if (array_key_exists($value, $this->arrData))
{
return $this->arrData[$value];
}
else
{
return null;
}
break;
}
}

+ Here is the call graph for this function:

assQuestion::__set (   $key,
  $value 
)

Object setter.

Reimplemented in assFileUpload, assErrorText, and assOrderingHorizontal.

Definition at line 3611 of file class.assQuestion.php.

References setAuthor(), setComment(), setEstimatedWorkingTime(), setId(), setObjId(), setOriginalId(), setOutputType(), setOwner(), setPoints(), setQuestion(), setShuffle(), setTestId(), and setTitle().

{
switch ($key)
{
case "id":
$this->setId($value);
break;
case "title":
$this->setTitle($value);
break;
case "comment":
$this->setComment($value);
break;
case "owner":
$this->setOwner($value);
break;
case "author":
$this->setAuthor($value);
break;
case "question":
$this->setQuestion($value);
break;
case "points":
$this->setPoints($value);
break;
case "est_working_time":
if (is_array($value))
{
$this->setEstimatedWorkingTime($value["h"], $value["m"], $value["s"]);
}
break;
case "shuffle":
$this->setShuffle($value);
break;
case "test_id":
$this->setTestId($value);
break;
case "obj_id":
$this->setObjId($value);
break;
case "outputType":
$this->setOutputType($value);
break;
case "original_id":
$this->setOriginalId($value);
break;
case "page":
$this->page =& $value;
break;
default:
$this->arrData[$key] = $value;
break;
}
}

+ Here is the call graph for this function:

static assQuestion::_areAnswered (   $a_user_id,
  $a_question_ids 
)
static

Checks if an array of question ids is answered by an user or not.

Parameters
intuser_id
array$question_idsuser id array
Returns
boolean

Definition at line 2876 of file class.assQuestion.php.

References $res.

Referenced by ilCourseObjectiveResult\getStatus().

{
global $ilDB;
$res = $ilDB->queryF("SELECT DISTINCT(question_fi) FROM tst_test_result JOIN tst_active ".
"ON (active_id = active_fi) ".
"WHERE " . $ilDB->in('question_fi', $a_question_ids, false, 'integer') .
" AND user_fi = %s",
array('integer'),
array($a_user_id)
);
return ($res->numRows() == count($a_question_ids)) ? true : false;
}

+ Here is the caller graph for this function:

assQuestion::_getInternalLinkHref (   $target = "")

Definition at line 2456 of file class.assQuestion.php.

References $target_id.

Referenced by getSuggestedSolutionOutput(), and assQuestionGUI\suggestedsolution().

{
global $ilDB;
$linktypes = array(
"lm" => "LearningModule",
"pg" => "PageObject",
"st" => "StructureObject",
"git" => "GlossaryItem",
"mob" => "MediaObject"
);
$href = "";
if (preg_match("/il__(\w+)_(\d+)/", $target, $matches))
{
$type = $matches[1];
$target_id = $matches[2];
include_once "./Services/Utilities/classes/class.ilUtil.php";
switch($linktypes[$matches[1]])
{
case "LearningModule":
$href = "./goto.php?target=" . $type . "_" . $target_id;
break;
case "PageObject":
case "StructureObject":
$href = "./goto.php?target=" . $type . "_" . $target_id;
break;
case "GlossaryItem":
$href = "./goto.php?target=" . $type . "_" . $target_id;
break;
case "MediaObject":
$href = "./ilias.php?baseClass=ilLMPresentationGUI&obj_type=" . $linktypes[$type] . "&cmd=media&ref_id=".$_GET["ref_id"]."&mob_id=".$target_id;
break;
}
}
return $href;
}

+ Here is the caller graph for this function:

assQuestion::_getMaximumPoints (   $question_id)

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

Parameters
integer$question_idThe database Id of the question
See Also
$points

Definition at line 582 of file class.assQuestion.php.

References $points, $result, and $row.

Referenced by _getTotalRightAnswers(), ilCourseObjectiveQuestion\_lookupMaximumPointsOfQuestion(), ilTestScoringGUI\buildManScoringParticipantForm(), assFileUpload\handleSubmission(), and ilTestScoringGUI\saveManScoringParticipantScreen().

{
global $ilDB;
$points = 0;
$result = $ilDB->queryF("SELECT points FROM qpl_questions WHERE question_id = %s",
array('integer'),
array($question_id)
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
$points = $row["points"];
}
return $points;
}

+ Here is the caller graph for this function:

assQuestion::_getOriginalId (   $question_id)

Returns the original id of a question.

Parameters
integer$question_idThe database id of the question
Returns
integer The database id of the original question public

Definition at line 2499 of file class.assQuestion.php.

References $result, and $row.

Referenced by _logAction(), ilObjTest\cloneObject(), assOrderingHorizontal\copyObject(), assFileUpload\copyObject(), assImagemapQuestion\copyObject(), assFlashQuestion\copyObject(), assErrorText\copyObject(), assNumeric\copyObject(), assTextQuestion\copyObject(), assOrderingQuestion\copyObject(), assTextSubset\copyObject(), assMatchingQuestion\copyObject(), assSingleChoice\copyObject(), assMultipleChoice\copyObject(), assJavaApplet\copyObject(), assClozeTest\copyObject(), assOrderingHorizontal\duplicate(), assFileUpload\duplicate(), assImagemapQuestion\duplicate(), assFlashQuestion\duplicate(), assErrorText\duplicate(), assNumeric\duplicate(), assTextQuestion\duplicate(), assOrderingQuestion\duplicate(), assTextSubset\duplicate(), assMatchingQuestion\duplicate(), assSingleChoice\duplicate(), assMultipleChoice\duplicate(), assJavaApplet\duplicate(), assClozeTest\duplicate(), logAction(), and ilObjTest\logAction().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM qpl_questions WHERE question_id = %s",
array('integer'),
array($question_id)
);
if ($result->numRows() > 0)
{
$row = $ilDB->fetchAssoc($result);
if ($row["original_id"] > 0)
{
return $row["original_id"];
}
else
{
return $row["question_id"];
}
}
else
{
return "";
}
}

+ Here is the caller graph for this function:

& assQuestion::_getQuestionInfo (   $question_id)

Returns question information from the database.

Parameters
integer$question_idThe database Id of the question
Returns
array The database row containing the question data

Definition at line 605 of file class.assQuestion.php.

References $result.

Referenced by ilObjMediaObject\getParentObjectIdForUsage().

{
global $ilDB;
$result = $ilDB->queryF("SELECT qpl_questions.*, qpl_qst_type.type_tag FROM qpl_qst_type, qpl_questions WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id",
array('integer'),
array($question_id)
);
if ($result->numRows())
{
return $ilDB->fetchAssoc($result);
}
else return array();
}

+ Here is the caller graph for this function:

assQuestion::_getQuestionText (   $a_q_id)

Returns question text.

Parameters
int$a_q_idquestion id

Definition at line 1763 of file class.assQuestion.php.

References $result, and $row.

Referenced by ilLMQuestionListTableGUI\fillRow().

{
global $ilDB;
$result = $ilDB->queryF("SELECT question_text FROM qpl_questions WHERE question_id = %s",
array('integer'),
array($a_q_id)
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
return $row["question_text"];
}
else
{
return "";
}
}

+ Here is the caller graph for this function:

assQuestion::_getQuestionTitle (   $question_id)

Returns the question title of a question with a given id.

Parameters
integer$question_idThe database id of the question
Returns
string The question title private

Definition at line 1874 of file class.assQuestion.php.

References $data, and $result.

Referenced by ilObjAssessmentFolderGUI\exportLogObject(), ilObjectivesAlignmentTableGUI\fillRow(), and ilAssessmentFolderLogTableGUI\fillRow().

{
global $ilDB;
if ($question_id < 1) return "";
$result = $ilDB->queryF("SELECT title FROM qpl_questions WHERE qpl_questions.question_id = %s",
array('integer'),
array($question_id)
);
if ($result->numRows() == 1)
{
$data = $ilDB->fetchAssoc($result);
return $data["title"];
}
else
{
return "";
}
}

+ Here is the caller graph for this function:

assQuestion::_getQuestionType (   $question_id)

Returns the question type of a question with a given id.

Parameters
integer$question_idThe database id of the question
Returns
string The question type string private

Definition at line 1847 of file class.assQuestion.php.

References $data, and $result.

Referenced by _instanciateQuestionGUI(), _instantiateQuestion(), _needsManualScoring(), ilObjectivesAlignmentTableGUI\fillRow(), ilObjTest\isQuestionObligationPossible(), and ilPCQuestionGUI\setTabs().

{
global $ilDB;
if ($question_id < 1) return "";
$result = $ilDB->queryF("SELECT type_tag FROM qpl_questions, qpl_qst_type WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id",
array('integer'),
array($question_id)
);
if ($result->numRows() == 1)
{
$data = $ilDB->fetchAssoc($result);
return $data["type_tag"];
}
else
{
return "";
}
}

+ Here is the caller graph for this function:

static assQuestion::_getQuestionTypeName (   $type_tag)
static

Return the translation for a given question type tag.

Parameters
string$type_tagThe type tag of the question type public

Definition at line 3477 of file class.assQuestion.php.

References $lng, ilPlugin\getPluginObject(), and IL_COMP_MODULE.

Referenced by ilObjQuestionPoolGUI\addLocatorItems(), ilObjTestGUI\createRandomSelectionObject(), ilCopySelfAssQuestionTableGUI\fillRow(), ilTestQuestionsTableGUI\fillRow(), ilTestQuestionBrowserTableGUI\fillRow(), ilQuestionBrowserTableGUI\fillRow(), assQuestionGUI\outQuestionType(), ilObjTestGUI\removeQuestionsForm(), and ilObjQuestionPoolGUI\setTitleAndDescription().

{
if (file_exists("./Modules/TestQuestionPool/classes/class.".$type_tag.".php"))
{
global $lng;
return $lng->txt($type_tag);
}
else
{
global $ilPluginAdmin;
$pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst");
foreach ($pl_names as $pl_name)
{
$pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pl_name);
if (strcmp($pl->getQuestionType(), $type_tag) == 0)
{
return $pl->getQuestionTypeTranslation();
}
}
}
return "";
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::_getReachedPoints (   $active_id,
  $question_id,
  $pass = NULL 
)

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

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

Definition at line 726 of file class.assQuestion.php.

References $pass, $points, $result, $row, and _getSolutionMaxPass().

Referenced by ilTestScoringGUI\buildManScoringParticipantForm(), ilTestServiceGUI\getPassListOfAnswersWithScoring(), and getReachedPoints().

{
global $ilDB;
$points = 0;
if (is_null($pass))
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$pass = assQuestion::_getSolutionMaxPass($question_id, $active_id);
}
$result = $ilDB->queryF("SELECT * FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
array('integer','integer','integer'),
array($active_id, $question_id, $pass)
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
$points = $row["points"];
}
return $points;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::_getSolutionMaxPass (   $question_id,
  $active_id 
)

Returns the maximum pass a users question solution.

Parameters
returninteger The maximum pass of the users solution public

Definition at line 2714 of file class.assQuestion.php.

References $result, and $row.

Referenced by _getReachedPoints(), _isWorkedThrough(), _setReachedPoints(), getSolutionMaxPass(), and ilObjTest\getTextAnswer().

{
/* include_once "./Modules/Test/classes/class.ilObjTest.php";
$pass = ilObjTest::_getPass($active_id);
return $pass;*/
// the following code was the old solution which added the non answered
// questions of a pass from the answered questions of the previous pass
// with the above solution, only the answered questions of the last pass are counted
global $ilDB;
$result = $ilDB->queryF("SELECT MAX(pass) maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
array('integer','integer'),
array($active_id, $question_id)
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
return $row["maxpass"];
}
else
{
return 0;
}
}

+ Here is the caller graph for this function:

& assQuestion::_getSuggestedSolution (   $question_id,
  $subquestion_index = 0 
)

Returns a suggested solution for a given subquestion index.

Parameters
integer$question_idThe database Id of the question
integer$subquestion_indexThe index of a subquestion (i.e. a close test gap). Usually 0
Returns
array A suggested solution array containing the internal link public

Definition at line 687 of file class.assQuestion.php.

References $result, and $row.

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM qpl_sol_sug WHERE question_fi = %s AND subquestion_index = %s",
array('integer','integer'),
array($question_id, $subquestion_index)
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
return array(
"internal_link" => $row["internal_link"],
"import_id" => $row["import_id"]
);
}
else
{
return array();
}
}
static assQuestion::_getSuggestedSolutionCount (   $question_id)
static

Returns the number of suggested solutions associated with a question.

Parameters
integer$question_idThe database Id of the question
Returns
integer The number of suggested solutions

Definition at line 626 of file class.assQuestion.php.

References $result.

{
global $ilDB;
$result = $ilDB->queryF("SELECT suggested_solution_id FROM qpl_sol_sug WHERE question_fi = %s",
array('integer'),
array($question_id)
);
return $result->numRows();
}
static assQuestion::_getSuggestedSolutionOutput (   $question_id)
static

Returns the output of the suggested solution.

Parameters
integer$question_idThe database Id of the question
Returns
string Suggested solution

Definition at line 643 of file class.assQuestion.php.

References $question, and _instanciateQuestion().

Referenced by ilObjTest\getTestResult().

{
if (!is_object($question)) return "";
return $question->getSuggestedSolutionOutput();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::_getTitle (   $a_q_id)

Returns the title of a question.

Parameters
int$a_q_idquestion id

Definition at line 1740 of file class.assQuestion.php.

References $result, and $row.

Referenced by ilObjQuestionPoolGUI\assessmentObject(), and ilSCORM2004ScoGUI\sahs_questions().

{
global $ilDB;
$result = $ilDB->queryF("SELECT title FROM qpl_questions WHERE question_id = %s",
array('integer'),
array($a_q_id)
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
return $row["title"];
}
else
{
return "";
}
}

+ Here is the caller graph for this function:

assQuestion::_getTotalAnswers (   $a_q_id)

get number of answers for question id (static) note: do not use $this inside this method

Parameters
int$a_q_idquestion id

Definition at line 1662 of file class.assQuestion.php.

References $result, and $row.

Referenced by ilObjQuestionPoolGUI\assessmentObject(), and getTotalAnswers().

{
global $ilDB;
// get all question references to the question id
$result = $ilDB->queryF("SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
array('integer','integer'),
array($a_q_id, $a_q_id)
);
if ($result->numRows() == 0)
{
return 0;
}
$found_id = array();
while ($row = $ilDB->fetchAssoc($result))
{
array_push($found_id, $row["question_id"]);
}
$result = $ilDB->query("SELECT * FROM tst_test_result WHERE " . $ilDB->in('question_fi', $found_id, false, 'integer'));
return $result->numRows();
}

+ Here is the caller graph for this function:

assQuestion::_getTotalRightAnswers (   $a_q_id)

get number of answers for question id (static) note: do not use $this inside this method

Parameters
int$a_q_idquestion id

Definition at line 1693 of file class.assQuestion.php.

References $result, $row, and _getMaximumPoints().

Referenced by ilObjQuestionPoolGUI\assessmentObject().

{
global $ilDB;
$result = $ilDB->queryF("SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
array('integer','integer'),
array($a_q_id, $a_q_id)
);
if ($result->numRows() == 0)
{
return 0;
}
$found_id = array();
while ($row = $ilDB->fetchAssoc($result))
{
array_push($found_id, $row["question_id"]);
}
$result = $ilDB->query("SELECT * FROM tst_test_result WHERE " . $ilDB->in('question_fi', $found_id, false, 'integer'));
$answers = array();
while ($row = $ilDB->fetchAssoc($result))
{
$reached = $row["points"];
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$max = assQuestion::_getMaximumPoints($row["question_fi"]);
array_push($answers, array("reached" => $reached, "max" => $max));
}
$max = 0.0;
$reached = 0.0;
foreach ($answers as $key => $value)
{
$max += $value["max"];
$reached += $value["reached"];
}
if ($max > 0)
{
return $reached / $max;
}
else
{
return 0;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static assQuestion::_includeClass (   $question_type,
  $gui = 0 
)
static

Include the php class file for a given question type.

Parameters
string$question_typeThe type tag of the question type
Returns
integer 0 if the class should be included, 1 if the GUI class should be included public

Definition at line 3448 of file class.assQuestion.php.

References ilPlugin\getPluginObject(), and IL_COMP_MODULE.

Referenced by assQuestionGUI\_getQuestionGUI(), _instanciateQuestionGUI(), _instantiateQuestion(), ilObjQuestionPool\createQuestion(), ilObjTest\createQuestionGUI(), ilQTIParser\handlerParseEndTag(), and ilObjTest\isQuestionObligationPossible().

{
$type = $question_type;
if ($gui) $type .= "GUI";
if (file_exists("./Modules/TestQuestionPool/classes/class.".$type.".php"))
{
include_once "./Modules/TestQuestionPool/classes/class.".$type.".php";
}
else
{
global $ilPluginAdmin;
$pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst");
foreach ($pl_names as $pl_name)
{
$pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pl_name);
if (strcmp($pl->getQuestionType(), $question_type) == 0)
{
$pl->includeClass("class.".$type.".php");
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static assQuestion::_instanciateQuestion (   $question_id)
static

Creates an instance of a question with a given question id.

Parameters
integer$question_idThe question id
Returns
assQuestion The question instance
Deprecated:
use assQuestion::_instantiateQuestion() instead.

Definition at line 2649 of file class.assQuestion.php.

References _instantiateQuestion().

Referenced by _getSuggestedSolutionOutput(), ilObjTestGUI\copyAndLinkQuestionsToPoolObject(), ilObjTestGUI\copyAndLinkToQuestionpoolObject(), ilPCQuestion\copyPoolQuestionIntoPage(), ilSCORM2004Asset\exportPDFPrepareXmlNFiles(), ilSCORM2004Asset\exportXMLPageObjects(), ilPageObject\newQuestionCopies(), ilSoapTestAdministration\saveQuestion(), and ilSoapTestAdministration\saveQuestionSolution().

{
return self::_instantiateQuestion($question_id);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& assQuestion::_instanciateQuestionGUI (   $question_id)

Creates an instance of a question gui with a given question id.

Parameters
integer$question_idThe question id
Returns
object The question gui instance public

Definition at line 3507 of file class.assQuestion.php.

References _getQuestionType(), and _includeClass().

Referenced by ilObjTestGUI\copyQuestionObject(), ilObjQuestionPool\createQuestion(), and ilQuestionPoolPrintViewTableGUI\fillRow().

{
if (strcmp($question_id, "") != 0)
{
$question_type = assQuestion::_getQuestionType($question_id);
$question_type_gui = $question_type . "GUI";
assQuestion::_includeClass($question_type, 1);
$question_gui = new $question_type_gui();
$question_gui->object->loadFromDb($question_id);
return $question_gui;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static assQuestion::_instantiateQuestion (   $question_id)
static

Definition at line 2654 of file class.assQuestion.php.

References $question, _getQuestionType(), and _includeClass().

Referenced by _instanciateQuestion(), and ilAssIncompleteQuestionPurger\purgeQuestionIds().

{
if (strcmp($question_id, "") != 0)
{
$question_type = assQuestion::_getQuestionType($question_id);
if (!strlen($question_type)) return null;
assQuestion::_includeClass($question_type);
$question = new $question_type();
$question->loadFromDb($question_id);
return $question;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::_isUsedInRandomTest (   $question_id = "")

Checks whether the question is used in a random test or not.

Returns
boolean The number how often the question is used in a random test public

Definition at line 2780 of file class.assQuestion.php.

References $result.

Referenced by ilObjQuestionPool\getDeleteableQuestionDetails().

{
global $ilDB;
if ($question_id < 1) return 0;
$result = $ilDB->queryF("SELECT test_random_question_id FROM tst_test_rnd_qst WHERE question_fi = %s",
array('integer'),
array($question_id)
);
return $result->numRows();
}

+ Here is the caller graph for this function:

static assQuestion::_isWorkedThrough (   $active_id,
  $question_id,
  $pass = NULL 
)
static

Returns true if the question was worked through in the given pass Worked through means that the user entered at least one value.

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

Definition at line 2845 of file class.assQuestion.php.

References $pass, $points, $result, and _getSolutionMaxPass().

Referenced by ilObjTest\getAnsweredQuestionCount().

{
global $ilDB;
$points = 0;
if (is_null($pass))
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$pass = assQuestion::_getSolutionMaxPass($question_id, $active_id);
}
$result = $ilDB->queryF("SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
array('integer','integer','integer'),
array($active_id, $question_id, $pass)
);
if ($result->numRows())
{
return TRUE;
}
else
{
return FALSE;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::_isWriteable (   $question_id,
  $user_id 
)

Returns true if the question is writeable by a certain user.

Parameters
integer$question_idThe database id of the question
integer$user_idThe database id of the user
Returns
boolean True, if the question exists, otherwise False public

Definition at line 2748 of file class.assQuestion.php.

References $result, and $row.

Referenced by ilAssQuestionHintsGUI\performDeleteCmd(), assQuestionGUI\save(), assQuestionGUI\saveEdit(), assQuestionGUI\saveFeedback(), ilAssQuestionHintGUI\saveFormCmd(), ilAssQuestionHintsGUI\saveListOrderCmd(), assQuestionGUI\saveReturn(), and assQuestionGUI\suggestedsolution().

{
global $ilDB;
if (($question_id < 1) || ($user_id < 1))
{
return false;
}
$result = $ilDB->queryF("SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
array('integer'),
array($question_id)
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
$qpl_object_id = $row["obj_fi"];
include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
return ilObjQuestionPool::_isWriteable($qpl_object_id, $user_id);
}
else
{
return false;
}
}

+ Here is the caller graph for this function:

assQuestion::_logAction (   $logtext = "",
  $active_id = "",
  $question_id = "" 
)

Logs an action into the Test&Assessment log.

Parameters
string$logtextThe log text
integer$question_idIf given, saves the question id to the database public

Definition at line 1142 of file class.assQuestion.php.

References $ilUser, $original_id, ilObjAssessmentFolder\_addLog(), ilObjTest\_getObjectIDFromActiveID(), and _getOriginalId().

Referenced by _setReachedPoints().

{
global $ilUser;
if (strcmp($question_id, "") != 0)
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
}
include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
include_once "./Modules/Test/classes/class.ilObjTest.php";
ilObjAssessmentFolder::_addLog($ilUser->id, ilObjTest::_getObjectIDFromActiveID($active_id), $logtext, $question_id, $original_id);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::_needsManualScoring (   $question_id)

Definition at line 3401 of file class.assQuestion.php.

References ilObjAssessmentFolder\_getManualScoringTypes(), and _getQuestionType().

Referenced by ilTestExpressPageObjectGUI\insertQuestions(), and ilObjTestGUI\insertQuestionsObject().

{
include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
$questiontype = assQuestion::_getQuestionType($question_id);
if (in_array($questiontype, $scoring))
{
return TRUE;
}
else
{
return FALSE;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::_questionExists (   $question_id)

Returns true if the question already exists in the database.

Parameters
integer$question_idThe database id of the question
Returns
boolean True, if the question exists, otherwise False public

Definition at line 2589 of file class.assQuestion.php.

References $result.

{
global $ilDB;
if ($question_id < 1)
{
return false;
}
$result = $ilDB->queryF("SELECT question_id FROM qpl_questions WHERE question_id = %s",
array('integer'),
array($question_id)
);
if ($result->numRows() == 1)
{
return true;
}
else
{
return false;
}
}
assQuestion::_questionExistsInPool (   $question_id)

Returns true if the question already exists in the database and is assigned to a question pool.

Parameters
integer$question_idThe database id of the question
Returns
boolean True, if the question exists, otherwise False public

Definition at line 2619 of file class.assQuestion.php.

References $result.

Referenced by assQuestionGUI\outQuestionType().

{
global $ilDB;
if ($question_id < 1)
{
return false;
}
$result = $ilDB->queryF("SELECT question_id FROM qpl_questions INNER JOIN object_data ON obj_fi = obj_id WHERE question_id = %s AND type = 'qpl'",
array('integer'),
array($question_id)
);
if ($result->numRows() == 1)
{
return true;
}
else
{
return false;
}
}

+ Here is the caller graph for this function:

assQuestion::_questionExistsInTest (   $question_id,
  $test_id 
)

Definition at line 3681 of file class.assQuestion.php.

References $result, and $test_id.

Referenced by assQuestionGUI\save(), and assQuestionGUI\saveReturn().

{
global $ilDB;
if ($question_id < 1)
{
return false;
}
$result = $ilDB->queryF("SELECT question_fi FROM tst_test_question WHERE question_fi = %s AND test_fi = %s",
array('integer', 'integer'),
array($question_id, $test_id)
);
if ($result->numRows() == 1)
{
return true;
}
else
{
return false;
}
}

+ Here is the caller graph for this function:

assQuestion::_resolveInternalLink (   $internal_link)

Definition at line 2368 of file class.assQuestion.php.

References ilInternalLink\_getIdForImportId(), and ilLMObject\_getIdForImportId().

Referenced by _resolveIntLinks(), and setSuggestedSolution().

{
if (preg_match("/il_(\d+)_(\w+)_(\d+)/", $internal_link, $matches))
{
include_once "./Services/COPage/classes/class.ilInternalLink.php";
include_once "./Modules/LearningModule/classes/class.ilLMObject.php";
include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php";
switch ($matches[2])
{
case "lm":
$resolved_link = ilLMObject::_getIdForImportId($internal_link);
break;
case "pg":
$resolved_link = ilInternalLink::_getIdForImportId("PageObject", $internal_link);
break;
case "st":
$resolved_link = ilInternalLink::_getIdForImportId("StructureObject", $internal_link);
break;
case "git":
$resolved_link = ilInternalLink::_getIdForImportId("GlossaryItem", $internal_link);
break;
case "mob":
$resolved_link = ilInternalLink::_getIdForImportId("MediaObject", $internal_link);
break;
}
if (strcmp($resolved_link, "") == 0)
{
$resolved_link = $internal_link;
}
}
else
{
$resolved_link = $internal_link;
}
return $resolved_link;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::_resolveIntLinks (   $question_id)

Definition at line 2405 of file class.assQuestion.php.

References $result, $row, ilInternalLink\_deleteAllLinksOfSource(), _resolveInternalLink(), and ilInternalLink\_saveLink().

Referenced by ilContObjParser\processPagesToParse().

{
global $ilDB;
$resolvedlinks = 0;
$result = $ilDB->queryF("SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
array('integer'),
array($question_id)
);
if ($result->numRows())
{
while ($row = $ilDB->fetchAssoc($result))
{
$internal_link = $row["internal_link"];
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$resolved_link = assQuestion::_resolveInternalLink($internal_link);
if (strcmp($internal_link, $resolved_link) != 0)
{
// internal link was resolved successfully
$affectedRows = $ilDB->manipulateF("UPDATE qpl_sol_sug SET internal_link = %s WHERE suggested_solution_id = %s",
array('text','integer'),
array($resolved_link, $row["suggested_solution_id"])
);
$resolvedlinks++;
}
}
}
if ($resolvedlinks)
{
// there are resolved links -> reenter theses links to the database
// delete all internal links from the database
include_once "./Services/COPage/classes/class.ilInternalLink.php";
$result = $ilDB->queryF("SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
array('integer'),
array($question_id)
);
if ($result->numRows())
{
while ($row = $ilDB->fetchAssoc($result))
{
if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $row["internal_link"], $matches))
{
ilInternalLink::_saveLink("qst", $question_id, $matches[2], $matches[3], $matches[1]);
}
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::_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.

Parameters
integer$user_idThe database ID of the learner
integer$test_idThe database Id of the test containing the question
integer$pointsThe points the user has reached answering the question
Returns
boolean true on success, otherwise false public

Definition at line 3019 of file class.assQuestion.php.

References $ilUser, $lng, $pass, $points, $result, $row, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTestAccess\_getParticipantData(), _getSolutionMaxPass(), ilObjTest\_getUserIdFromActiveId(), _logAction(), ilCourseObjectiveResult\_updateObjectiveResult(), and _updateTestPassResults().

Referenced by assFileUpload\handleSubmission(), and ilTestScoringGUI\saveManScoringParticipantScreen().

{
global $ilDB;
if ($points <= $maxpoints)
{
if (is_null($pass))
{
$pass = assQuestion::_getSolutionMaxPass($question_id, $active_id);
}
// retrieve the already given points
$old_points = 0;
$result = $ilDB->queryF("SELECT points FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
array('integer','integer','integer'),
array($active_id, $question_id, $pass)
);
$manual = ($manualscoring) ? 1 : 0;
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
$old_points = $row["points"];
$affectedRows = $ilDB->manipulateF("UPDATE tst_test_result SET points = %s, manual = %s, tstamp = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s",
array('float', 'integer', 'integer', 'integer', 'integer', 'integer'),
array($points, $manual, time(), $active_id, $question_id, $pass)
);
}
else
{
$next_id = $ilDB->nextId('tst_test_result');
$affectedRows = $ilDB->manipulateF("INSERT INTO tst_test_result (test_result_id, active_fi, question_fi, points, pass, manual, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
array('integer', 'integer','integer', 'float', 'integer', 'integer','integer'),
array($next_id, $active_id, $question_id, $points, $pass, $manual, time())
);
}
assQuestion::_updateTestPassResults($active_id, $pass, $obligationsEnabled);
// finally update objective result
include_once "./Modules/Test/classes/class.ilObjTest.php";
include_once './Modules/Course/classes/class.ilCourseObjectiveResult.php';
include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
{
global $lng, $ilUser;
include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
$username = ilObjTestAccess::_getParticipantData($active_id);
assQuestion::_logAction(sprintf($lng->txtlng("assessment", "log_answer_changed_points", ilObjAssessmentFolder::_getLogLanguage()), $username, $old_points, $points, $ilUser->getFullname() . " (" . $ilUser->getLogin() . ")"), $active_id, $question_id);
}
return TRUE;
}
else
{
return FALSE;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::_updateTestPassResults (   $active_id,
  $pass,
  $obligationsEnabled = false 
)

Definition at line 1004 of file class.assQuestion.php.

References $data, $pass, $query, $result, $row, ilObjTest\_getQuestionCountAndPointsForPassOfParticipant(), ilObjTest\_getWorkingTimeOfParticipantForPass(), and _updateTestResultCache().

Referenced by ilObjTestAccess\_isPassed(), _setReachedPoints(), calculateResultsFromSolution(), ilTestOutputGUI\redirectQuestion(), and assTextQuestion\setReachedPoints().

{
global $ilDB;
include_once "./Modules/Test/classes/class.ilObjTest.php";
// update test pass results
$result = $ilDB->queryF("
SELECT SUM(points) reachedpoints,
SUM(hint_count) hint_count,
SUM(hint_points) hint_points,
COUNT(question_fi) answeredquestions
FROM tst_test_result
WHERE active_fi = %s
AND pass = %s
",
array('integer','integer'),
array($active_id, $pass)
);
if ($result->numRows() > 0)
{
if( $obligationsEnabled )
{
$query = '
SELECT count(*) cnt,
min( answered ) answ
FROM tst_test_question
INNER JOIN tst_active
ON active_id = %s
AND tst_test_question.test_fi = tst_active.test_fi
LEFT JOIN tst_test_result
ON tst_test_result.active_fi = %s
AND tst_test_result.pass = %s
AND tst_test_question.question_fi = tst_test_result.question_fi
WHERE obligatory = 1';
$result_obligatory = $ilDB->queryF(
$query, array('integer','integer','integer'), array($active_id, $active_id, $pass)
);
$row_obligatory = $ilDB->fetchAssoc($result_obligatory);
if ($row_obligatory['cnt'] == 0)
{
$obligations_answered = 1;
}
else
{
$obligations_answered = (int) $row_obligatory['answ'];
}
}
else
{
$obligations_answered = 1;
}
$row = $ilDB->fetchAssoc($result);
if( $row['hint_count'] === null ) $row['hint_count'] = 0;
if( $row['hint_points'] === null ) $row['hint_points'] = 0;
$query = "
DELETE FROM tst_pass_result
WHERE active_fi = %s
AND pass = %s
";
$affectedRows = $ilDB->manipulateF(
$query, array('integer','integer'), array($active_id, $pass)
);
$ilDB->insert('tst_pass_result', array(
'active_fi' => array('integer', $active_id),
'pass' => array('integer', strlen($pass) ? $pass : 0),
'points' => array('float', $row['reachedpoints'] ? $row['reachedpoints'] : 0),
'maxpoints' => array('float', $data['points']),
'questioncount' => array('integer', $data['count']),
'answeredquestions' => array('integer', $row['answeredquestions']),
'workingtime' => array('integer', $time),
'tstamp' => array('integer', time()),
'hint_count' => array('integer', $row['hint_count']),
'hint_points' => array('float', $row['hint_points']),
'obligations_answered' => array('integer', $obligations_answered)
));
}
return array(
'active_fi' => $active_id,
'pass' => $pass,
'points' => ($row["reachedpoints"]) ? $row["reachedpoints"] : 0,
'maxpoints' => $data["points"],
'questioncount' => $data["count"],
'answeredquestions' => $row["answeredquestions"],
'workingtime' => $time,
'tstamp' => time(),
'hint_count' => $row['hint_count'],
'hint_points' => $row['hint_points'],
'obligations_answered' => $obligations_answered
);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::_updateTestResultCache (   $active_id)

Definition at line 943 of file class.assQuestion.php.

References $pass, $query, $result, $row, ASS_MarkSchema\_getMatchingMarkFromActiveId(), and ilObjTest\_getResultPass().

Referenced by ilObjTestAccess\_getPassedUsers(), ilObjTestAccess\_isPassed(), _updateTestPassResults(), ilObjTest\getResultsForActiveId(), and ilTestEvaluationGUI\performDeletePass().

{
global $ilDB;
include_once "./Modules/Test/classes/class.ilObjTest.php";
include_once "./Modules/Test/classes/class.assMarkSchema.php";
$query = "
SELECT tst_pass_result.*
FROM tst_pass_result
WHERE active_fi = %s
AND pass = %s
";
$result = $ilDB->queryF(
$query, array('integer','integer'), array($active_id, $pass)
);
$row = $ilDB->fetchAssoc($result);
$max = $row['maxpoints'];
$reached = $row['points'];
$obligationsAnswered = (int)$row['obligations_answered'];
include_once "./Modules/Test/classes/class.assMarkSchema.php";
$percentage = (!$max) ? 0 : ($reached / $max) * 100.0;
$mark = ASS_MarkSchema::_getMatchingMarkFromActiveId($active_id, $percentage);
$isPassed = ( $mark["passed"] ? 1 : 0 );
$isFailed = ( !$mark["passed"] ? 1 : 0 );
$query = "
DELETE FROM tst_result_cache
WHERE active_fi = %s
";
$affectedRows = $ilDB->manipulateF(
$query, array('integer'), array($active_id)
);
$ilDB->insert('tst_result_cache', array(
'active_fi'=> array('integer', $active_id),
'pass'=> array('integer', strlen($pass) ? $pass : 0),
'max_points'=> array('float', strlen($max) ? $max : 0),
'reached_points'=> array('float', strlen($reached) ? $reached : 0),
'mark_short'=> array('text', strlen($mark["short_name"]) ? $mark["short_name"] : " "),
'mark_official'=> array('text', strlen($mark["official_name"]) ? $mark["official_name"] : " "),
'passed'=> array('integer', $isPassed),
'failed'=> array('integer', $isFailed),
'tstamp'=> array('integer', time()),
'hint_count'=> array('integer', $row['hint_count']),
'hint_points'=> array('float', $row['hint_points']),
'obligations_answered' => array('integer', $obligationsAnswered)
));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::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.

Parameters
object$a_xml_writerReference to the ILIAS XML writer
string$a_materialplain text or html text containing the material
Returns
string QTI material tag public

Definition at line 2961 of file class.assQuestion.php.

References $mobs, ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilRTE\_replaceMediaObjectImageSrc(), getId(), and isHTML().

{
include_once "./Services/RTE/classes/class.ilRTE.php";
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
$a_xml_writer->xmlStartTag("material");
$attrs = array(
"texttype" => "text/plain"
);
if ($this->isHTML($a_material))
{
$attrs["texttype"] = "text/xhtml";
}
$a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
if ($add_mobs)
{
foreach ($mobs as $mob)
{
$moblabel = "il_" . IL_INST_ID . "_mob_" . $mob;
if (strpos($a_material, "mm_$mob") !== FALSE)
{
{
$mob_obj =& new ilObjMediaObject($mob);
$imgattrs = array(
"label" => $moblabel,
"uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle()
);
}
$a_xml_writer->xmlElement("matimage", $imgattrs, NULL);
}
}
}
if ($close_material_tag) $a_xml_writer->xmlEndTag("material");
}

+ Here is the call graph for this function:

assQuestion::adjustReachedPointsByScoringOptions (   $points,
  $active_id,
  $pass = NULL 
)
final

Adjust the given reached points by checks for all special scoring options in the test container.

public

Parameters
integer$points
integer$active_id
integer$pass

Definition at line 2815 of file class.assQuestion.php.

References $points, ilObjTest\_getCountSystem(), ilObjTest\_getScoreCutting(), and getMaximumPoints().

Referenced by calculateResultsFromSolution(), and getAdjustedReachedPoints().

{
include_once "./Modules/Test/classes/class.ilObjTest.php";
$count_system = ilObjTest::_getCountSystem($active_id);
if ($count_system == 1)
{
if ($points != $this->getMaximumPoints())
{
$points = 0;
}
}
$score_cutting = ilObjTest::_getScoreCutting($active_id);
if ($score_cutting == 0)
{
if ($points < 0)
{
$points = 0;
}
}
return $points;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::areObligationsToBeConsidered ( )

gets the flag wether obligations are to be considered or not

Returns
bool $obligationsToBeConsidered

Definition at line 3796 of file class.assQuestion.php.

References $obligationsToBeConsidered.

assQuestion::calculateReachedPoints (   $active_id,
  $pass = NULL,
  $returndetails = FALSE 
)
abstract

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

Reimplemented in assClozeTest, assMatchingQuestion, assJavaApplet, assOrderingQuestion, assImagemapQuestion, assMultipleChoice, assSingleChoice, assTextSubset, assTextQuestion, assFlashQuestion, assNumeric, assErrorText, assFileUpload, and assOrderingHorizontal.

Referenced by calculateResultsFromSolution(), and getAdjustedReachedPoints().

+ Here is the caller graph for this function:

assQuestion::calculateResultsFromSolution (   $active_id,
  $pass = NULL,
  $obligationsEnabled = false 
)
final

Calculates the question results from a previously saved question solution.

ilDB $ilDB ilObjUser $ilUser

Parameters
integer$active_idActive id of the user
integer$passTest pass

Definition at line 814 of file class.assQuestion.php.

References $ilUser, $pass, $query, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), ilCourseObjectiveResult\_updateObjectiveResult(), _updateTestPassResults(), adjustReachedPointsByScoringOptions(), calculateReachedPoints(), getId(), ilAssQuestionHintTracking\getRequestStatisticDataByQuestionAndTestpass(), isAnswered(), ilObjTest\isQuestionObligatory(), and logAction().

Referenced by persistWorkingState().

{
global $ilDB, $ilUser;
if( is_null($pass) )
{
include_once "./Modules/Test/classes/class.ilObjTest.php";
$pass = ilObjTest::_getPass($active_id);
}
// determine reached points for submitted solution
$reached_points = $this->calculateReachedPoints($active_id, $pass);
// deduct points for requested hints from reached points
require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
$reached_points = $reached_points - $requestsStatisticData->getRequestsPoints();
// adjust reached points regarding to tests scoring options
$reached_points = $this->adjustReachedPointsByScoringOptions($reached_points, $active_id, $pass);
if( $obligationsEnabled && ilObjTest::isQuestionObligatory($this->getId()) )
{
$isAnswered = $this->isAnswered($active_id, $pass);
}
else
{
$isAnswered = true;
}
if( is_null($reached_points) ) $reached_points = 0;
$query = "
DELETE FROM tst_test_result
WHERE active_fi = %s
AND question_fi = %s
AND pass = %s
";
$affectedRows = $ilDB->manipulateF(
$query, array("integer", "integer", "integer"), array($active_id, $this->getId(), $pass)
);
$next_id = $ilDB->nextId("tst_test_result");
$ilDB->insert('tst_test_result', array(
'test_result_id' => array('integer', $next_id),
'active_fi' => array('integer', $active_id),
'question_fi' => array('integer', $this->getId()),
'pass' => array('integer', $pass),
'points' => array('float', $reached_points),
'tstamp' => array('integer', time()),
'hint_count' => array('integer', $requestsStatisticData->getRequestsCount()),
'hint_points' => array('float', $requestsStatisticData->getRequestsPoints()),
'answered' => array('integer', $isAnswered)
));
include_once ("./Modules/Test/classes/class.ilObjAssessmentFolder.php");
{
$this->logAction(
sprintf(
$this->lng->txtlng(
"assessment", "log_user_answered_question", ilObjAssessmentFolder::_getLogLanguage()
),
$reached_points
),
$active_id,
$this->getId()
);
}
// update test pass results
$this->_updateTestPassResults($active_id, $pass, $obligationsEnabled);
// Update objective status
include_once 'Modules/Course/classes/class.ilCourseObjectiveResult.php';
ilCourseObjectiveResult::_updateObjectiveResult($ilUser->getId(),$active_id,$this->getId());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::cleanupMediaObjectUsage ( )

synchronises appearances of media objects in the question with media object usage table

Definition at line 3346 of file class.assQuestion.php.

References ilRTE\_cleanupMediaObjectUsage(), getId(), and getRTETextWithMediaObjects().

Referenced by saveToDb().

{
$combinedtext = $this->getRTETextWithMediaObjects();
include_once("./Services/RTE/classes/class.ilRTE.php");
ilRTE::_cleanupMediaObjectUsage($combinedtext, "qpl:html", $this->getId());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::copyPageOfQuestion (   $a_q_id)

Definition at line 1819 of file class.assQuestion.php.

References $page.

Referenced by syncWithOriginal().

{
if ($a_q_id > 0)
{
include_once "./Services/COPage/classes/class.ilPageObject.php";
$page = new ilPageObject("qpl", $a_q_id);
$xml = str_replace("il__qst_".$a_q_id, "il__qst_".$this->id, $page->getXMLContent());
$this->page->setXMLContent($xml);
$this->page->saveMobUsage($xml);
$this->page->updateFromXML();
}
}

+ Here is the caller graph for this function:

assQuestion::copySuggestedSolutionFiles (   $source_questionpool_id,
  $source_question_id 
)
protected

Definition at line 2252 of file class.assQuestion.php.

References $filename, $ilLog, getSuggestedSolutionPath(), and ilUtil\makeDirParents().

Referenced by onCopy().

{
global $ilLog;
foreach ($this->suggested_solutions as $index => $solution)
{
if (strcmp($solution["type"], "file") == 0)
{
$filepath = $this->getSuggestedSolutionPath();
$filepath_original = str_replace("/$this->obj_id/$this->id/solution", "/$source_questionpool_id/$source_question_id/solution", $filepath);
if (!file_exists($filepath))
{
}
$filename = $solution["value"]["name"];
if (strlen($filename))
{
if (!copy($filepath_original . $filename, $filepath . $filename))
{
$ilLog->write("File could not be copied!!!!", $ilLog->ERROR);
$ilLog->write("object: " . print_r($this, TRUE), $ilLog->ERROR);
}
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::copyXHTMLMediaObjectsOfQuestion (   $a_q_id)

Definition at line 1782 of file class.assQuestion.php.

References $mobs, ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_saveUsage(), and getId().

{
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
$mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $a_q_id);
foreach ($mobs as $mob)
{
ilObjMediaObject::_saveUsage($mob, "qpl:html", $this->getId());
}
}

+ Here is the call graph for this function:

assQuestion::createNewImageFileName (   $image_filename)

Definition at line 2998 of file class.assQuestion.php.

{
$extension = "";
if (preg_match("/.*\.(png|jpg|gif|jpeg)$/i", $image_filename, $matches))
{
$extension = "." . $matches[1];
}
$image_filename = md5($image_filename) . $extension;
return $image_filename;
}
assQuestion::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.

Returns
integer ID of the new question

Definition at line 1942 of file class.assQuestion.php.

References $_GET, $_POST, $ilUser, $obj_id, ilObject\_lookupObjId(), createPageObject(), getAuthor(), getEstimatedWorkingTime(), getId(), getObjId(), getQuestionTypeID(), and setId().

{
global $ilDB, $ilUser;
$complete = "0";
$estw_time = $this->getEstimatedWorkingTime();
$estw_time = sprintf("%02d:%02d:%02d", $estw_time['h'], $estw_time['m'], $estw_time['s']);
$obj_id = ($this->getObjId() <= 0) ? (ilObject::_lookupObjId((strlen($_GET["ref_id"])) ? $_GET["ref_id"] : $_POST["sel_qpl"])) : $this->getObjId();
if ($obj_id > 0)
{
if($a_create_page)
{
$tstamp = 0;
}
else
{
// question pool must not try to purge
$tstamp = time();
}
$next_id = $ilDB->nextId('qpl_questions');
$affectedRows = $ilDB->insert("qpl_questions", array(
"question_id" => array("integer", $next_id),
"question_type_fi" => array("integer", $this->getQuestionTypeID()),
"obj_fi" => array("integer", $obj_id),
"title" => array("text", NULL),
"description" => array("text", NULL),
"author" => array("text", $this->getAuthor()),
"owner" => array("integer", $ilUser->getId()),
"question_text" => array("clob", NULL),
"points" => array("float", 0),
"nr_of_tries" => array("integer", 1),
"working_time" => array("text", $estw_time),
"complete" => array("text", $complete),
"created" => array("integer", time()),
"original_id" => array("integer", NULL),
"tstamp" => array("integer", $tstamp)
));
$this->setId($next_id);
if($a_create_page)
{
// create page object of question
$this->createPageObject();
}
}
return $this->getId();
}

+ Here is the call graph for this function:

assQuestion::createPageObject ( )

create page object of question

Definition at line 1805 of file class.assQuestion.php.

References getId(), and getObjId().

Referenced by createNewQuestion(), saveQuestionDataToDb(), and syncWithOriginal().

{
$qpl_id = $this->getObjId();
include_once "./Services/COPage/classes/class.ilPageObject.php";
$this->page = new ilPageObject("qpl", 0);
$this->page->setId($this->getId());
$this->page->setParentId($qpl_id);
$this->page->setXMLContent("<PageObject><PageContent>".
"<Question QRef=\"il__qst_".$this->getId()."\"/>".
"</PageContent></PageObject>");
$this->page->create();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::createRandomSolution (   $test_id,
  $user_id 
)

Reimplemented in assSingleChoice, and assTextQuestion.

Definition at line 2578 of file class.assQuestion.php.

{
}
assQuestion::delete (   $question_id)

Deletes a question and all materials from the database.

Parameters
integer$question_idThe database id of the question private

Definition at line 1513 of file class.assQuestion.php.

References $ilLog, $mobs, $obj_id, $result, $row, ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), ilObjQuestionPool\_updateQuestionCount(), ilUtil\delDir(), deleteAdditionalTableData(), deleteAnswers(), deleteFeedbackGeneric(), deleteFeedbackSpecific(), ilAssQuestionHintList\deleteHintsByQuestionIds(), deletePageOfQuestion(), ilAssQuestionHintTracking\deleteRequestsByQuestionIds(), and getObjId().

{
global $ilDB, $ilLog;
if ($question_id < 1) return true; // nothing to do
$result = $ilDB->queryF("SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
array('integer'),
array($question_id)
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
$obj_id = $row["obj_fi"];
}
else
{
return true; // nothing to do
}
try
{
$this->deletePageOfQuestion($question_id);
}
catch (Exception $e)
{
$ilLog->write("EXCEPTION: Could not delete page of question $question_id: $e");
return false;
}
$affectedRows = $ilDB->manipulateF("DELETE FROM qpl_questions WHERE question_id = %s",
array('integer'),
array($question_id)
);
if ($affectedRows == 0) return false;
try
{
$this->deleteAdditionalTableData($question_id);
$this->deleteAnswers($question_id);
$this->deleteFeedbackGeneric($question_id);
$this->deleteFeedbackSpecific($question_id);
}
catch (Exception $e)
{
$ilLog->write("EXCEPTION: Could not delete additional table data of question $question_id: $e");
return false;
}
try
{
// delete the question in the tst_test_question table (list of test questions)
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_test_question WHERE question_fi = %s",
array('integer'),
array($question_id)
);
}
catch (Exception $e)
{
$ilLog->write("EXCEPTION: Could not delete delete question $question_id from a test: $e");
return false;
}
try
{
// delete suggested solutions contained in the question
$affectedRows = $ilDB->manipulateF("DELETE FROM qpl_sol_sug WHERE question_fi = %s",
array('integer'),
array($question_id)
);
}
catch (Exception $e)
{
$ilLog->write("EXCEPTION: Could not delete suggested solutions of question $question_id: $e");
return false;
}
try
{
$directory = CLIENT_WEB_DIR . "/assessment/" . $obj_id . "/$question_id";
if (preg_match("/\d+/", $obj_id) and preg_match("/\d+/", $question_id) and is_dir($directory))
{
include_once "./Services/Utilities/classes/class.ilUtil.php";
ilUtil::delDir($directory);
}
}
catch (Exception $e)
{
$ilLog->write("EXCEPTION: Could not delete question file directory $directory of question $question_id: $e");
return false;
}
try
{
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
$mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $question_id);
// remaining usages are not in text anymore -> delete them
// and media objects (note: delete method of ilObjMediaObject
// checks whether object is used in another context; if yes,
// the object is not deleted!)
foreach($mobs as $mob)
{
ilObjMediaObject::_removeUsage($mob, "qpl:html", $question_id);
{
$mob_obj =& new ilObjMediaObject($mob);
$mob_obj->delete();
}
}
}
catch (Exception $e)
{
$ilLog->write("EXCEPTION: Error deleting the media objects of question $question_id: $e");
return false;
}
require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintList.php';
try
{
// update question count of question pool
include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
}
catch (Exception $e)
{
$ilLog->write("EXCEPTION: Error updating the question pool question count of question pool " . $this->getObjId() . " when deleting question $question_id: $e");
return false;
}
return true;
}

+ Here is the call graph for this function:

assQuestion::deleteAdditionalTableData (   $question_id)

Deletes datasets from the additional question table in the database.

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

Definition at line 1464 of file class.assQuestion.php.

References getAdditionalTableName().

Referenced by delete().

{
global $ilDB;
$additional_table_name = $this->getAdditionalTableName();
if (is_array($additional_table_name))
{
foreach ($additional_table_name as $table)
{
if (strlen($table))
{
$affectedRows = $ilDB->manipulateF("DELETE FROM $table WHERE question_fi = %s",
array('integer'),
array($question_id)
);
}
}
}
else
{
if (strlen($additional_table_name))
{
$affectedRows = $ilDB->manipulateF("DELETE FROM $additional_table_name WHERE question_fi = %s",
array('integer'),
array($question_id)
);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::deleteAnswers (   $question_id)

Deletes datasets from answers tables.

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

Reimplemented in assFileUpload, assFlashQuestion, and assOrderingHorizontal.

Definition at line 1429 of file class.assQuestion.php.

References getAnswerTableName().

Referenced by delete().

{
global $ilDB;
$answer_table_name = $this->getAnswerTableName();
if (is_array($answer_table_name))
{
foreach ($answer_table_name as $table)
{
if (strlen($table))
{
$affectedRows = $ilDB->manipulateF("DELETE FROM $table WHERE question_fi = %s",
array('integer'),
array($question_id)
);
}
}
}
else
{
if (strlen($answer_table_name))
{
$affectedRows = $ilDB->manipulateF("DELETE FROM $answer_table_name WHERE question_fi = %s",
array('integer'),
array($question_id)
);
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::deleteFeedbackGeneric (   $question_id)
private

Definition at line 3737 of file class.assQuestion.php.

Referenced by delete().

{
global $ilDB;
$ilDB->manipulateF(
'DELETE FROM qpl_fb_generic WHERE question_fi = %s',
array('integer'),
array($question_id)
);
}

+ Here is the caller graph for this function:

assQuestion::deleteFeedbackSpecific (   $question_id)
protected

Reimplemented in assClozeTest, assMatchingQuestion, assErrorText, and assTextQuestion.

Definition at line 3732 of file class.assQuestion.php.

Referenced by delete().

{
return;
}

+ Here is the caller graph for this function:

assQuestion::deletePageOfQuestion (   $question_id)
protected

Deletes the page object of a question with a given ID.

Parameters
integer$question_idThe database id of the question protected

Definition at line 1499 of file class.assQuestion.php.

References $page.

Referenced by delete(), and syncWithOriginal().

{
include_once "./Services/COPage/classes/class.ilPageObject.php";
$page = new ilPageObject("qpl", $question_id);
$page->delete();
return true;
}

+ Here is the caller graph for this function:

assQuestion::deleteSuggestedSolutions ( )

Deletes all suggestes solutions in the database.

Definition at line 2105 of file class.assQuestion.php.

References ilInternalLink\_deleteAllLinksOfSource(), ilUtil\delDir(), getId(), and getSuggestedSolutionPath().

{
global $ilDB;
// delete the links in the qpl_sol_sug table
$affectedRows = $ilDB->manipulateF("DELETE FROM qpl_sol_sug WHERE question_fi = %s",
array('integer'),
array($this->getId())
);
// delete the links in the int_link table
include_once "./Services/COPage/classes/class.ilInternalLink.php";
$this->suggested_solutions = array();
}

+ Here is the call graph for this function:

static assQuestion::doesSolutionRecordsExist (   $activeId,
  $pass,
  $questionId 
)
staticprotected

checks wether there are existing solution records for the given test active / pass and given question id

protected ilDB $ilDB

Parameters
integer$activeId
integer$pass
integer$questionId
Returns
boolean $solutionRecordsExist

Definition at line 3818 of file class.assQuestion.php.

References $pass, $query, $res, and $row.

Referenced by assFileUpload\isAnswered(), assTextQuestion\isAnswered(), assSingleChoice\isAnswered(), and assMultipleChoice\isAnswered().

{
// check if a solution was stored in tst_solution
global $ilDB;
$query = "
SELECT count(active_fi) cnt
FROM tst_solutions
WHERE active_fi = %s
AND question_fi = %s
AND pass = %s
";
$res = $ilDB->queryF(
$query, array('integer','integer','integer'),
array($activeId, $questionId, $pass)
);
$row = $ilDB->fetchAssoc($res);
$solutionRecordsExist = (
0 < (int)$row['cnt'] ? true : false
);
return $solutionRecordsExist;
}

+ Here is the caller graph for this function:

assQuestion::duplicateQuestionHints (   $originalQuestionId,
  $duplicateQuestionId 
)
protected

Definition at line 3726 of file class.assQuestion.php.

References ilAssQuestionHintList\duplicateListForQuestion().

Referenced by onDuplicate().

{
require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintList.php';
ilAssQuestionHintList::duplicateListForQuestion($originalQuestionId, $duplicateQuestionId);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::duplicateSuggestedSolutionFiles (   $parent_id,
  $question_id 
)
protected

Duplicates the files of a suggested solution if the question is duplicated.

Definition at line 2190 of file class.assQuestion.php.

References $filename, $ilLog, getSuggestedSolutionPath(), and ilUtil\makeDirParents().

Referenced by onDuplicate().

{
global $ilLog;
foreach ($this->suggested_solutions as $index => $solution)
{
if (strcmp($solution["type"], "file") == 0)
{
$filepath = $this->getSuggestedSolutionPath();
$filepath_original = str_replace(
"/{$this->obj_id}/{$this->id}/solution",
"/$parent_id/$question_id/solution",
$filepath
);
if (!file_exists($filepath))
{
}
$filename = $solution["value"]["name"];
if (strlen($filename))
{
if (!copy($filepath_original . $filename, $filepath . $filename))
{
$ilLog->write("File could not be duplicated!!!!", $ilLog->ERROR);
$ilLog->write("object: " . print_r($this, TRUE), $ilLog->ERROR);
}
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::formatSAQuestion (   $a_q)

Format self assessment question.

Parameters
@return

Definition at line 3710 of file class.assQuestion.php.

References ilRTE\_replaceMediaObjectImageSrc(), and ilUtil\insertLatexImages().

Referenced by assOrderingHorizontal\toJSON(), assTextSubset\toJSON(), assTextQuestion\toJSON(), assErrorText\toJSON(), assImagemapQuestion\toJSON(), assOrderingQuestion\toJSON(), assSingleChoice\toJSON(), assMultipleChoice\toJSON(), assMatchingQuestion\toJSON(), and assClozeTest\toJSON().

{
include_once("./Services/RTE/classes/class.ilRTE.php");
$a_q = nl2br((string) ilRTE::_replaceMediaObjectImageSrc($a_q, 0));
$a_q = str_replace("</li><br />", "</li>", $a_q);
$a_q = str_replace("</li><br>", "</li>", $a_q);
$a_q = ilUtil::insertLatexImages($a_q, "\[tex\]", "\[\/tex\]");
$a_q = ilUtil::insertLatexImages($a_q, "<span class\=\"latex\">", "<\/span>");
$a_q = str_replace('{', '&#123;', $a_q);
$a_q = str_replace('}', '&#125;', $a_q);
return $a_q;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::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.

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 public

Reimplemented in assFileUpload, assFlashQuestion, assOrderingHorizontal, and assErrorText.

Definition at line 234 of file class.assQuestion.php.

References getQuestionType().

{
include_once "./Modules/TestQuestionPool/classes/import/qti12/class." . $this->getQuestionType() . "Import.php";
$classname = $this->getQuestionType() . "Import";
$import = new $classname($this);
$import->fromXML($item, $questionpool_id, $tst_id, $tst_object, $question_counter, $import_mapping);
}

+ Here is the call graph for this function:

assQuestion::getActiveUserData (   $active_id)

Returns the user id and the test id for a given active id.

Parameters
integer$active_idActive id for a test/user
Returns
array Result array containing the user_id and test_id public

Definition at line 3423 of file class.assQuestion.php.

References $result, and $row.

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM tst_active WHERE active_id = %s",
array('integer'),
array($active_id)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
return array("user_id" => $row["user_fi"], "test_id" => $row["test_fi"]);
}
else
{
return array();
}
}
assQuestion::getAdditionalTableName ( )

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

Returns
string The additional table name public

Reimplemented in assClozeTest, assMatchingQuestion, assOrderingQuestion, assJavaApplet, assMultipleChoice, assSingleChoice, assTextQuestion, assTextSubset, assImagemapQuestion, assFileUpload, assNumeric, assFlashQuestion, assOrderingHorizontal, and assErrorText.

Definition at line 1407 of file class.assQuestion.php.

Referenced by deleteAdditionalTableData().

{
return "";
}

+ Here is the caller graph for this function:

assQuestion::getAdjustedReachedPoints (   $active_id,
  $pass = NULL 
)
final

returns the reached points ...

  • calculated by concrete question type class
  • adjusted by hint point deduction
  • adjusted by scoring options ... for given testactive and testpass
Parameters
integer$active_id
integer$pass
Returns
integer $reached_points

Definition at line 783 of file class.assQuestion.php.

References $pass, ilObjTest\_getPass(), adjustReachedPointsByScoringOptions(), calculateReachedPoints(), getId(), and ilAssQuestionHintTracking\getRequestStatisticDataByQuestionAndTestpass().

{
if (is_null($pass))
{
include_once "./Modules/Test/classes/class.ilObjTest.php";
$pass = ilObjTest::_getPass($active_id);
}
// determine reached points for submitted solution
$reached_points = $this->calculateReachedPoints($active_id, $pass);
// deduct points for requested hints from reached points
require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
$reached_points = $reached_points - $requestsStatisticData->getRequestsPoints();
// adjust reached points regarding to tests scoring options
$reached_points = $this->adjustReachedPointsByScoringOptions($reached_points, $active_id, $pass);
return $reached_points;
}

+ Here is the call graph for this function:

assQuestion::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns
string The answer table name public

Reimplemented in assClozeTest, assMatchingQuestion, assOrderingQuestion, assTextQuestion, assMultipleChoice, assSingleChoice, assTextSubset, assImagemapQuestion, assFileUpload, assFlashQuestion, assOrderingHorizontal, and assErrorText.

Definition at line 1418 of file class.assQuestion.php.

Referenced by deleteAnswers().

{
return "";
}

+ Here is the caller graph for this function:

assQuestion::getAuthor ( )

Gets the authors name of the assQuestion object.

Returns
string The string containing the name of the questions author public
See Also
$author

Definition at line 535 of file class.assQuestion.php.

References $author.

Referenced by __get(), createNewQuestion(), assClozeTest\isComplete(), and saveQuestionDataToDb().

{
return $this->author;
}

+ Here is the caller graph for this function:

assQuestion::getComment ( )

Gets the comment string of the assQuestion object.

Returns
string The comment string to describe the question public
See Also
$comment

Definition at line 484 of file class.assQuestion.php.

References $comment.

Referenced by __get(), and saveQuestionDataToDb().

{
}

+ Here is the caller graph for this function:

assQuestion::getEstimatedWorkingTime ( )

Gets the estimated working time of a question.

Returns
array Estimated Working Time of a question public
See Also
$est_working_time

Definition at line 519 of file class.assQuestion.php.

References $est_working_time.

Referenced by __get(), createNewQuestion(), and saveQuestionDataToDb().

{
if (!$this->est_working_time)
{
$this->est_working_time = array("h" => 0, "m" => 0, "s" => 0);
}
}

+ Here is the caller graph for this function:

assQuestion::getFeedbackGeneric (   $correctness)

Returns the generic feedback for a given question state.

The state is either the complete solution of the question or at least one incorrect answer

Parameters
integer$correctness0 for at least one incorrect answer, 1 for the correct solution
Returns
string Feedback text public

Definition at line 3191 of file class.assQuestion.php.

References $result, $row, ilRTE\_replaceMediaObjectImageSrc(), and getId().

Referenced by getRTETextWithMediaObjects(), assOrderingHorizontal\toJSON(), assTextSubset\toJSON(), assErrorText\toJSON(), assImagemapQuestion\toJSON(), assOrderingQuestion\toJSON(), assSingleChoice\toJSON(), assMultipleChoice\toJSON(), assMatchingQuestion\toJSON(), and assClozeTest\toJSON().

{
global $ilDB;
$feedback = "";
$result = $ilDB->queryF("SELECT * FROM qpl_fb_generic WHERE question_fi = %s AND correctness = %s",
array('integer', 'text'),
array($this->getId(), $correctness)
);
if ($result->numRows())
{
$row = $ilDB->fetchAssoc($result);
include_once("./Services/RTE/classes/class.ilRTE.php");
$feedback = ilRTE::_replaceMediaObjectImageSrc($row["feedback"], 1);
}
return $feedback;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::getFeedbackSingleAnswer (   $answer_index)

Reimplemented in assClozeTest, assMatchingQuestion, assTextQuestion, assErrorText, assMultipleChoice, assSingleChoice, and assImagemapQuestion.

Definition at line 3337 of file class.assQuestion.php.

Referenced by getRTETextWithMediaObjects().

{
return '';
}

+ Here is the caller graph for this function:

assQuestion::getFlashPath ( )

Returns the image path for web accessable flash files of a question.

The image path is under the CLIENT_WEB_DIR in assessment/REFERENCE_ID_OF_QUESTION_POOL/ID_OF_QUESTION/flash

public

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

Referenced by assFlashQuestion\copyApplet(), assFlashQuestion\deleteApplet(), assFlashQuestion\duplicateApplet(), assFlashQuestion\moveUploadedFile(), and assFlashQuestion\saveToDb().

{
return CLIENT_WEB_DIR . "/assessment/$this->obj_id/$this->id/flash/";
}

+ Here is the caller graph for this function:

assQuestion::getFlashPathWeb ( )

Returns the web image path for web accessable flash applications of a question.

The image path is under the web accessable data dir in assessment/REFERENCE_ID_OF_QUESTION_POOL/ID_OF_QUESTION/flash

public

Definition at line 1283 of file class.assQuestion.php.

References ILIAS_ABSOLUTE_PATH, and ilUtil\removeTrailingPathSeparators().

{
include_once "./Services/Utilities/classes/class.ilUtil.php";
$webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/$this->obj_id/$this->id/flash/";
}

+ Here is the call graph for this function:

assQuestion::getHtmlUserSolutionPurifier ( )
Returns
ilAssHtmlUserSolutionPurifier

Definition at line 3851 of file class.assQuestion.php.

References ilHtmlPurifierFactory\_getInstanceByType().

{
require_once 'Services/Html/classes/class.ilHtmlPurifierFactory.php';
return ilHtmlPurifierFactory::_getInstanceByType('qpl_usersolution');
}

+ Here is the call graph for this function:

assQuestion::getId ( )

Gets the id of the assQuestion object.

Returns
integer The id of the assQuestion object public
See Also
$id

Definition at line 448 of file class.assQuestion.php.

References $id.

Referenced by ilAssQuestionHintsOrderingClipboard\__construct(), __get(), addQTIMaterial(), assOrderingHorizontal\calculateReachedPoints(), assErrorText\calculateReachedPoints(), assNumeric\calculateReachedPoints(), assFlashQuestion\calculateReachedPoints(), assTextQuestion\calculateReachedPoints(), assTextSubset\calculateReachedPoints(), assSingleChoice\calculateReachedPoints(), assImagemapQuestion\calculateReachedPoints(), assMultipleChoice\calculateReachedPoints(), assOrderingQuestion\calculateReachedPoints(), assJavaApplet\calculateReachedPoints(), assMatchingQuestion\calculateReachedPoints(), assClozeTest\calculateReachedPoints(), calculateResultsFromSolution(), assMatchingQuestion\checkSaveData(), cleanupMediaObjectUsage(), assOrderingHorizontal\copyObject(), assFileUpload\copyObject(), assImagemapQuestion\copyObject(), assFlashQuestion\copyObject(), assErrorText\copyObject(), assNumeric\copyObject(), assTextQuestion\copyObject(), assOrderingQuestion\copyObject(), assTextSubset\copyObject(), assMatchingQuestion\copyObject(), assSingleChoice\copyObject(), assMultipleChoice\copyObject(), assJavaApplet\copyObject(), assClozeTest\copyObject(), copyXHTMLMediaObjectsOfQuestion(), createNewQuestion(), createPageObject(), deleteSuggestedSolutions(), assOrderingHorizontal\duplicate(), assFileUpload\duplicate(), assImagemapQuestion\duplicate(), assFlashQuestion\duplicate(), assErrorText\duplicate(), assNumeric\duplicate(), assTextQuestion\duplicate(), assOrderingQuestion\duplicate(), assTextSubset\duplicate(), assMatchingQuestion\duplicate(), assSingleChoice\duplicate(), assMultipleChoice\duplicate(), assJavaApplet\duplicate(), assClozeTest\duplicate(), assTextQuestion\duplicateAnswers(), getAdjustedReachedPoints(), getFeedbackGeneric(), assImagemapQuestion\getFeedbackSingleAnswer(), assSingleChoice\getFeedbackSingleAnswer(), assMultipleChoice\getFeedbackSingleAnswer(), assErrorText\getFeedbackSingleAnswer(), assTextQuestion\getFeedbackSingleAnswer(), assMatchingQuestion\getFeedbackSingleAnswer(), assClozeTest\getFeedbackSingleAnswer(), assFileUpload\getFileUploadPath(), assFileUpload\getFileUploadPathWeb(), getInstances(), assJavaApplet\getReachedInformation(), getReachedPoints(), getSolutionMaxPass(), getSolutionValues(), assFileUpload\getUploadedFiles(), assFileUpload\handleSubmission(), assFileUpload\hasFileUploads(), assFileUpload\isAnswered(), assTextQuestion\isAnswered(), assSingleChoice\isAnswered(), assMultipleChoice\isAnswered(), isInUse(), assTextQuestion\loadFromDb(), loadFromDb(), assOrderingHorizontal\moveRight(), onDuplicate(), assMultipleChoice\saveFeedbackSetting(), saveQuestionDataToDb(), assOrderingHorizontal\saveToDb(), assErrorText\saveToDb(), assFlashQuestion\saveToDb(), assFileUpload\saveToDb(), assNumeric\saveToDb(), assTextSubset\saveToDb(), assMultipleChoice\saveToDb(), assOrderingQuestion\saveToDb(), assImagemapQuestion\saveToDb(), assSingleChoice\saveToDb(), assTextQuestion\saveToDb(), assMatchingQuestion\saveToDb(), assClozeTest\saveToDb(), assJavaApplet\saveToDb(), saveToDb(), assOrderingHorizontal\saveWorkingData(), assErrorText\saveWorkingData(), assNumeric\saveWorkingData(), assFileUpload\saveWorkingData(), assTextSubset\saveWorkingData(), assSingleChoice\saveWorkingData(), assTextQuestion\saveWorkingData(), assImagemapQuestion\saveWorkingData(), assMultipleChoice\saveWorkingData(), assOrderingQuestion\saveWorkingData(), assMatchingQuestion\saveWorkingData(), assClozeTest\saveWorkingData(), setNewOriginalId(), assTextQuestion\setReachedPoints(), syncWithOriginal(), syncXHTMLMediaObjectsOfQuestion(), assErrorText\toggleSelection(), assOrderingHorizontal\toJSON(), assTextSubset\toJSON(), assTextQuestion\toJSON(), assErrorText\toJSON(), assImagemapQuestion\toJSON(), assOrderingQuestion\toJSON(), assSingleChoice\toJSON(), assMultipleChoice\toJSON(), assMatchingQuestion\toJSON(), and assClozeTest\toJSON().

{
return $this->id;
}

+ Here is the caller graph for this function:

assQuestion::getImagePath (   $question_id = null,
  $object_id = null 
)

Returns the image path for web accessable images of a question.

The image path is under the CLIENT_WEB_DIR in assessment/REFERENCE_ID_OF_QUESTION_POOL/ID_OF_QUESTION/images

public

Definition at line 1206 of file class.assQuestion.php.

References $id, and $obj_id.

Referenced by assOrderingQuestion\cleanImagefiles(), assImagemapQuestion\copyImage(), assOrderingQuestion\copyImages(), assMatchingQuestion\copyImages(), assSingleChoice\copyImages(), assMultipleChoice\copyImages(), assErrorText\createErrorTextOutput(), assSingleChoice\deleteImage(), assMultipleChoice\deleteImage(), assImagemapQuestion\deleteImage(), assOrderingQuestion\deleteImagefile(), assMatchingQuestion\deleteImagefile(), assImagemapQuestion\duplicateImage(), assOrderingQuestion\duplicateImages(), assMatchingQuestion\duplicateImages(), assSingleChoice\duplicateImages(), assMultipleChoice\duplicateImages(), assSingleChoice\loadFromDb(), assMultipleChoice\loadFromDb(), assSingleChoice\rebuildThumbnails(), assMultipleChoice\rebuildThumbnails(), assOrderingQuestion\rebuildThumbnails(), assMatchingQuestion\rebuildThumbnails(), assMultipleChoice\saveToDb(), assSingleChoice\saveToDb(), assMatchingQuestion\setExportDetailsXLS(), assOrderingQuestion\setImageFile(), assSingleChoice\setImageFile(), assMultipleChoice\setImageFile(), assMatchingQuestion\setImageFile(), assImagemapQuestion\setImageFilename(), assSingleChoice\syncImages(), and assMultipleChoice\syncImages().

{
if( $question_id === null)
{
$question_id = $this->id;
}
if( $object_id === null)
{
$object_id = $this->obj_id;
}
return CLIENT_WEB_DIR . "/assessment/$object_id/$question_id/images/";
}

+ Here is the caller graph for this function:

assQuestion::getImagePathWeb ( )

Returns the web image path for web accessable images of a question.

The image path is under the web accessable data dir in assessment/REFERENCE_ID_OF_QUESTION_POOL/ID_OF_QUESTION/images

public

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

References $export_image_path, ILIAS_ABSOLUTE_PATH, and ilUtil\removeTrailingPathSeparators().

Referenced by assImagemapQuestion\toJSON(), assOrderingQuestion\toJSON(), assSingleChoice\toJSON(), and assMultipleChoice\toJSON().

{
if(!$this->export_image_path)
{
include_once "./Services/Utilities/classes/class.ilUtil.php";
$webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/$this->obj_id/$this->id/images/";
}
else
{
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& assQuestion::getInstances ( )

Gets all instances of the question.

Returns
array All instances of question and its copies

Definition at line 3358 of file class.assQuestion.php.

References $result, $row, ilObject\_getAllReferences(), ilObjTest\_lookupAuthor(), ilObject\_lookupTitle(), and getId().

{
global $ilDB;
$result = $ilDB->queryF("SELECT question_id FROM qpl_questions WHERE original_id = %s",
array("integer"),
array($this->getId())
);
$instances = array();
$ids = array();
while ($row = $ilDB->fetchAssoc($result))
{
array_push($ids, $row["question_id"]);
}
foreach ($ids as $question_id)
{
// check non random tests
$result = $ilDB->queryF("SELECT tst_tests.obj_fi FROM tst_tests, tst_test_question WHERE tst_test_question.question_fi = %s AND tst_test_question.test_fi = tst_tests.test_id",
array("integer"),
array($question_id)
);
while ($row = $ilDB->fetchAssoc($result))
{
$instances[$row['obj_fi']] = ilObject::_lookupTitle($row['obj_fi']);
}
// check random tests
$result = $ilDB->queryF("SELECT tst_tests.obj_fi FROM tst_tests, tst_test_rnd_qst, tst_active WHERE tst_test_rnd_qst.active_fi = tst_active.active_id AND tst_test_rnd_qst.question_fi = %s AND tst_tests.test_id = tst_active.test_fi",
array("integer"),
array($question_id)
);
while ($row = $ilDB->fetchAssoc($result))
{
$instances[$row['obj_fi']] = ilObject::_lookupTitle($row['obj_fi']);
}
}
include_once "./Modules/Test/classes/class.ilObjTest.php";
foreach ($instances as $key => $value)
{
$instances[$key] = array("obj_id" => $key, "title" => $value, "author" => ilObjTest::_lookupAuthor($key), "refs" => ilObject::_getAllReferences($key));
}
return $instances;
}

+ Here is the call graph for this function:

assQuestion::getJavaPath ( )

Returns the image path for web accessable images of a question.

The image path is under the CLIENT_WEB_DIR in assessment/REFERENCE_ID_OF_QUESTION_POOL/ID_OF_QUESTION/images

public

Definition at line 1196 of file class.assQuestion.php.

Referenced by assJavaApplet\copyApplet(), assJavaApplet\deleteJavaAppletFilename(), assJavaApplet\duplicateApplet(), and assJavaApplet\setJavaAppletFilename().

{
return CLIENT_WEB_DIR . "/assessment/$this->obj_id/$this->id/java/";
}

+ Here is the caller graph for this function:

assQuestion::getJavaPathWeb ( )

Returns the web image path for web accessable java applets of a question.

The image path is under the web accessable data dir in assessment/REFERENCE_ID_OF_QUESTION_POOL/ID_OF_QUESTION/java

public

Definition at line 1238 of file class.assQuestion.php.

References ILIAS_ABSOLUTE_PATH, and ilUtil\removeTrailingPathSeparators().

{
include_once "./Services/Utilities/classes/class.ilUtil.php";
$webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/$this->obj_id/$this->id/java/";
}

+ Here is the call graph for this function:

assQuestion::getMaximumPoints ( )

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

public

See Also
$points

Reimplemented in assMatchingQuestion, assClozeTest, assOrderingQuestion, assImagemapQuestion, assMultipleChoice, assSingleChoice, assTextSubset, assTextQuestion, assFlashQuestion, assNumeric, assErrorText, assFileUpload, and assOrderingHorizontal.

Definition at line 767 of file class.assQuestion.php.

References $points.

Referenced by adjustReachedPointsByScoringOptions(), and saveQuestionDataToDb().

{
return $this->points;
}

+ Here is the caller graph for this function:

assQuestion::getOriginalId ( )
assQuestion::getOutputType ( )

Gets the output type.

Returns
integer The output type of the question public
See Also
$outputType

Reimplemented in assMultipleChoice, and assSingleChoice.

Definition at line 496 of file class.assQuestion.php.

References $outputType.

Referenced by __get(), and assOrderingQuestion\checkSaveData().

{
}

+ Here is the caller graph for this function:

assQuestion::getOwner ( )

Gets the creator/owner ID of the assQuestion object.

Returns
integer The numerical ID to identify the owner/creator public
See Also
$owner

Definition at line 547 of file class.assQuestion.php.

References $owner.

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

{
return $this->owner;
}

+ Here is the caller graph for this function:

assQuestion::getPageOfQuestion ( )

Definition at line 1833 of file class.assQuestion.php.

References $page.

{
include_once "./Services/COPage/classes/class.ilPageObject.php";
$page = new ilPageObject("qpl", $this->id);
return $page->getXMLContent();
}
assQuestion::getQuestion ( )

Gets the question string of the question object.

Returns
string The question string of the question object public
See Also
$question

Definition at line 3084 of file class.assQuestion.php.

References $question.

Referenced by __get(), getRTETextWithMediaObjects(), saveQuestionDataToDb(), assOrderingHorizontal\toJSON(), assTextSubset\toJSON(), assTextQuestion\toJSON(), assErrorText\toJSON(), assImagemapQuestion\toJSON(), assOrderingQuestion\toJSON(), assSingleChoice\toJSON(), assMultipleChoice\toJSON(), assMatchingQuestion\toJSON(), and assClozeTest\toJSON().

{
}

+ Here is the caller graph for this function:

assQuestion::getQuestionType ( )

Returns the question type of the question.

Returns
integer The question type of the question public

Reimplemented in assClozeTest, assMatchingQuestion, assOrderingQuestion, assJavaApplet, assMultipleChoice, assSingleChoice, assTextQuestion, assImagemapQuestion, assFileUpload, assTextSubset, assNumeric, assFlashQuestion, assOrderingHorizontal, and assErrorText.

Definition at line 3107 of file class.assQuestion.php.

Referenced by fromXML(), getQuestionTypeID(), and toXML().

{
// must be overwritten in every parent class
return "";
}

+ Here is the caller graph for this function:

assQuestion::getQuestionTypeFromDb (   $question_id)

get question type for question id

note: please don't use $this in this class to allow static calls

Definition at line 1389 of file class.assQuestion.php.

References $data, and $result.

Referenced by assQuestionGUI\_getGUIClassNameForId(), assQuestionGUI\_getQuestionGUI(), and ilObjTestGUI\executeCommand().

{
global $ilDB;
$result = $ilDB->queryF("SELECT qpl_qst_type.type_tag FROM qpl_qst_type, qpl_questions WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_qst_type.question_type_id",
array('integer'),
array($question_id)
);
$data = $ilDB->fetchAssoc($result);
return $data["type_tag"];
}

+ Here is the caller graph for this function:

assQuestion::getQuestionTypeID ( )

Returns the question type of the question.

Returns the question type of the question

Returns
integer The question type of the question public

Definition at line 3121 of file class.assQuestion.php.

References $result, $row, and getQuestionType().

Referenced by createNewQuestion(), and saveQuestionDataToDb().

{
global $ilDB;
$result = $ilDB->queryF("SELECT question_type_id FROM qpl_qst_type WHERE type_tag = %s",
array('text'),
array($this->getQuestionType())
);
if ($result->numRows() == 1)
{
$row = $ilDB->fetchAssoc($result);
return $row["question_type_id"];
}
return 0;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::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.

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

Definition at line 756 of file class.assQuestion.php.

References $pass, _getReachedPoints(), and getId().

{
return round($this->_getReachedPoints($active_id, $this->getId(), $pass), 2);
}

+ Here is the call graph for this function:

assQuestion::getRTETextWithMediaObjects ( )

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

Reimplemented in assClozeTest, assMatchingQuestion, assMultipleChoice, assSingleChoice, assOrderingQuestion, assJavaApplet, assImagemapQuestion, assTextQuestion, assTextSubset, assFileUpload, assNumeric, assFlashQuestion, assOrderingHorizontal, and assErrorText.

Definition at line 3319 of file class.assQuestion.php.

References getFeedbackGeneric(), getFeedbackSingleAnswer(), getQuestion(), and getTotalAnswers().

Referenced by cleanupMediaObjectUsage().

{
// must be called in parent classes. add additional RTE text in the parent
// classes and call this method to add the standard RTE text
$collected = $this->getQuestion();
$collected .= $this->getFeedbackGeneric(0);
$collected .= $this->getFeedbackGeneric(1);
for( $i = 0; $i <= $this->getTotalAnswers(); $i++ )
{
$collected .= $this->getFeedbackSingleAnswer($i);
}
foreach ($this->suggested_solutions as $solution_array)
{
$collected .= $solution_array["value"];
}
return $collected;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::getShuffle ( )

Gets the shuffle flag.

Returns
boolean The shuffle flag public
See Also
$shuffle

Definition at line 460 of file class.assQuestion.php.

References $shuffle.

Referenced by __get(), assMultipleChoice\saveToDb(), assSingleChoice\saveToDb(), assTextQuestion\toJSON(), assErrorText\toJSON(), assImagemapQuestion\toJSON(), assSingleChoice\toJSON(), assMultipleChoice\toJSON(), and assClozeTest\toJSON().

{
}

+ Here is the caller graph for this function:

& assQuestion::getSolutionValues (   $active_id,
  $pass = NULL 
)

Loads solutions of a given user from the database an returns it.

Parameters
integer$test_idThe database id of the test containing this question public
See Also
$answers

Definition at line 1297 of file class.assQuestion.php.

References $pass, $result, $row, getId(), and getSolutionMaxPass().

Referenced by assOrderingHorizontal\moveRight(), assErrorText\setExportDetailsXLS(), assOrderingHorizontal\setExportDetailsXLS(), assNumeric\setExportDetailsXLS(), assFileUpload\setExportDetailsXLS(), assTextSubset\setExportDetailsXLS(), assTextQuestion\setExportDetailsXLS(), assImagemapQuestion\setExportDetailsXLS(), assJavaApplet\setExportDetailsXLS(), assOrderingQuestion\setExportDetailsXLS(), assSingleChoice\setExportDetailsXLS(), assMultipleChoice\setExportDetailsXLS(), assMatchingQuestion\setExportDetailsXLS(), and assClozeTest\setExportDetailsXLS().

{
global $ilDB;
$values = array();
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 solution_id",
array('integer','integer','integer'),
array($active_id, $this->getId(), $pass)
);
while ($row = $ilDB->fetchAssoc($result))
{
array_push($values, $row);
}
return $values;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::getSuggestedSolution (   $subquestion_index = 0)

Returns a suggested solution for a given subquestion index.

Parameters
integer$subquestion_indexThe index of a subquestion (i.e. a close test gap). Usually 0
Returns
array A suggested solution array containing the internal link public

Definition at line 2127 of file class.assQuestion.php.

{
if (array_key_exists($subquestion_index, $this->suggested_solutions))
{
return $this->suggested_solutions[$subquestion_index];
}
else
{
return array();
}
}
assQuestion::getSuggestedSolutionOutput ( )

Definition at line 650 of file class.assQuestion.php.

References _getInternalLinkHref(), getSuggestedSolutionPathWeb(), ilUtil\prepareFormOutput(), and prepareTextareaOutput().

{
$output = array();
foreach ($this->suggested_solutions as $solution)
{
switch ($solution["type"])
{
case "lm":
case "st":
case "pg":
case "git":
array_push($output, '<a href="' . assQuestion::_getInternalLinkHref($solution["internal_link"]) . '">' . $this->lng->txt("solution_hint") . '</a>');
break;
case "file":
$possible_texts = array_values(array_filter(array(
ilUtil::prepareFormOutput($solution['value']['filename']),
ilUtil::prepareFormOutput($solution['value']['name']),
$this->lng->txt('tst_show_solution_suggested')
)));
array_push($output, '<a href="' . $this->getSuggestedSolutionPathWeb() . $solution["value"]["name"] . '">' . $possible_texts[0] . '</a>');
break;
case "text":
array_push($output, $this->prepareTextareaOutput($solution["value"]));
break;
}
}
return join($output, "<br />");
}

+ Here is the call graph for this function:

assQuestion::getSuggestedSolutionPath ( )

Returns the path for a suggested solution.

public

Definition at line 1186 of file class.assQuestion.php.

Referenced by copySuggestedSolutionFiles(), deleteSuggestedSolutions(), duplicateSuggestedSolutionFiles(), and syncSuggestedSolutionFiles().

{
return CLIENT_WEB_DIR . "/assessment/$this->obj_id/$this->id/solution/";
}

+ Here is the caller graph for this function:

assQuestion::getSuggestedSolutionPathWeb ( )

Returns the web path for a suggested solution.

public

Definition at line 1250 of file class.assQuestion.php.

References ILIAS_ABSOLUTE_PATH, and ilUtil\removeTrailingPathSeparators().

Referenced by getSuggestedSolutionOutput().

{
include_once "./Services/Utilities/classes/class.ilUtil.php";
$webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/$this->obj_id/$this->id/solution/";
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::getSuggestedSolutions ( )

Return the suggested solutions.

Returns
array Suggested solutions

Definition at line 714 of file class.assQuestion.php.

References $suggested_solutions.

Referenced by __get().

+ Here is the caller graph for this function:

assQuestion::getSuggestedSolutionTitle (   $subquestion_index = 0)

Returns the title of a suggested solution at a given subquestion_index.

This can be usable for displaying suggested solutions

Parameters
integer$subquestion_indexThe index of a subquestion (i.e. a close test gap). Usually 0
Returns
string A string containing the type and title of the internal link public

Definition at line 2147 of file class.assQuestion.php.

References $title.

{
if (array_key_exists($subquestion_index, $this->suggested_solutions))
{
$title = $this->suggested_solutions[$subquestion_index]["internal_link"];
// TO DO: resolve internal link an get link type and title
}
else
{
$title = "";
}
return $title;
}
assQuestion::getTestId ( )

Gets the test id of the assQuestion object.

Returns
integer The test id of the assQuestion object public
See Also
$test_id

Definition at line 472 of file class.assQuestion.php.

References $test_id.

Referenced by __get().

{
}

+ Here is the caller graph for this function:

assQuestion::getTotalAnswers ( )

get total number of answers

Definition at line 1651 of file class.assQuestion.php.

References _getTotalAnswers().

Referenced by getRTETextWithMediaObjects().

{
return $this->_getTotalAnswers($this->id);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

method can be overwritten in derived classes, but be aware of also overwrite the method assQuestion::isObligationPossible()

Parameters
integer$active_id
integer$pass
Returns
boolean $answered

Reimplemented in assMultipleChoice, assSingleChoice, assTextQuestion, and assFileUpload.

Definition at line 3759 of file class.assQuestion.php.

Referenced by calculateResultsFromSolution().

{
return true;
}

+ Here is the caller graph for this function:

assQuestion::isAutosaveable ( )

Reimplemented in assFileUpload, assJavaApplet, and assFlashQuestion.

Definition at line 3801 of file class.assQuestion.php.

{
return TRUE;
}
assQuestion::isClone (   $question_id = "")

Checks whether the question is a clone of another question or not.

Returns
boolean TRUE if the question is a clone, otherwise FALSE public

Definition at line 1353 of file class.assQuestion.php.

References $id, $result, and $row.

{
global $ilDB;
if ($question_id < 1) $question_id = $this->id;
$result = $ilDB->queryF("SELECT original_id FROM qpl_questions WHERE question_id = %s",
array('integer'),
array($question_id)
);
$row = $ilDB->fetchAssoc($result);
return ($row["original_id"] > 0) ? TRUE : FALSE;
}
assQuestion::isComplete ( )

Returns true, if a question is complete for use.

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

Reimplemented in assJavaApplet, assClozeTest, assMatchingQuestion, assTextQuestion, assOrderingQuestion, assImagemapQuestion, assMultipleChoice, assSingleChoice, assTextSubset, assNumeric, assFileUpload, assFlashQuestion, assErrorText, and assOrderingHorizontal.

Definition at line 262 of file class.assQuestion.php.

Referenced by saveToDb().

{
return false;
}

+ Here is the caller graph for this function:

assQuestion::isHTML (   $a_text)

Checks if a given string contains HTML or not.

Parameters
string$a_textText which should be checked
Returns
boolean public
Deprecated:
use ilUtil::isHTML() instead

Definition at line 2898 of file class.assQuestion.php.

Referenced by addQTIMaterial(), and assTextQuestion\saveWorkingData().

{
if (preg_match("/<[^>]*?>/", $a_text))
{
return TRUE;
}
else
{
return FALSE;
}
}

+ Here is the caller graph for this function:

assQuestion::isInUse (   $question_id = "")

Checks whether the question is in use or not.

Returns
boolean The number of datasets which are affected by the use of the query. public

Definition at line 1326 of file class.assQuestion.php.

References $result, $row, and getId().

{
global $ilDB;
if ($question_id < 1) $question_id = $this->getId();
$result = $ilDB->queryF("SELECT COUNT(qpl_questions.question_id) question_count FROM qpl_questions, tst_test_question WHERE qpl_questions.original_id = %s AND qpl_questions.question_id = tst_test_question.question_fi",
array('integer'),
array($question_id)
);
$row = $ilDB->fetchAssoc($result);
$count = $row["question_count"];
$result = $ilDB->queryF("SELECT DISTINCT tst_active.test_fi, qpl_questions.question_id FROM qpl_questions, tst_test_rnd_qst, tst_active WHERE qpl_questions.original_id = %s AND qpl_questions.question_id = tst_test_rnd_qst.question_fi AND tst_test_rnd_qst.active_fi = tst_active.active_id",
array('integer'),
array($question_id)
);
$count += $result->numRows();
return $count;
}

+ Here is the call graph for this function:

static assQuestion::isObligationPossible (   $questionId)
static

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

method can be overwritten in derived classes, but be aware of also overwrite the method assQuestion::isAnswered()

Parameters
integer$questionId
Returns
boolean $obligationPossible

Reimplemented in assMultipleChoice, assSingleChoice, assTextQuestion, and assFileUpload.

Definition at line 3776 of file class.assQuestion.php.

{
return false;
}
assQuestion::keyInArray (   $searchkey,
  $array 
)

returns TRUE if the key occurs in an array

Parameters
string$arraykeyA key to an element in array
array$arrayAn array to be searched public

Definition at line 386 of file class.assQuestion.php.

{
if ($searchkey)
{
foreach ($array as $key => $value)
{
if (strcmp($key, $searchkey)==0)
{
return true;
}
}
}
return false;
}
assQuestion::loadFromDb (   $question_id)

Loads the question from the database.

Parameters
integer$question_idA unique key which defines the question in the database public

Reimplemented in assImagemapQuestion, assJavaApplet, assMultipleChoice, assSingleChoice, assMatchingQuestion, assOrderingQuestion, assTextQuestion, assTextSubset, assClozeTest, assNumeric, assErrorText, assFlashQuestion, assFileUpload, and assOrderingHorizontal.

Definition at line 1911 of file class.assQuestion.php.

References $result, $row, ilRTE\_replaceMediaObjectImageSrc(), and getId().

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM qpl_sol_sug WHERE question_fi = %s",
array('integer'),
array($this->getId())
);
$this->suggested_solutions = array();
if ($result->numRows())
{
include_once("./Services/RTE/classes/class.ilRTE.php");
while ($row = $ilDB->fetchAssoc($result))
{
$value = (is_array(unserialize($row["value"]))) ? unserialize($row["value"]) : ilRTE::_replaceMediaObjectImageSrc($row["value"], 1);
$this->suggested_solutions[$row["subquestion_index"]] = array(
"type" => $row["type"],
"value" => $value,
"internal_link" => $row["internal_link"],
"import_id" => $row["import_id"]
);
}
}
}

+ Here is the call graph for this function:

assQuestion::logAction (   $logtext = "",
  $active_id = "",
  $question_id = "" 
)

Logs an action into the Test&Assessment log.

Parameters
string$logtextThe log text
integer$question_idIf given, saves the question id to the database public

Definition at line 1120 of file class.assQuestion.php.

References $ilUser, $original_id, ilObjAssessmentFolder\_addLog(), ilObjTest\_getObjectIDFromActiveID(), and _getOriginalId().

Referenced by calculateResultsFromSolution(), assOrderingHorizontal\moveRight(), assOrderingHorizontal\saveWorkingData(), assErrorText\saveWorkingData(), assNumeric\saveWorkingData(), assFileUpload\saveWorkingData(), assTextSubset\saveWorkingData(), assSingleChoice\saveWorkingData(), assTextQuestion\saveWorkingData(), assImagemapQuestion\saveWorkingData(), assMultipleChoice\saveWorkingData(), assOrderingQuestion\saveWorkingData(), assMatchingQuestion\saveWorkingData(), assClozeTest\saveWorkingData(), and assErrorText\toggleSelection().

{
global $ilUser;
if (strcmp($question_id, "") != 0)
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
}
include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
include_once "./Modules/Test/classes/class.ilObjTest.php";
ilObjAssessmentFolder::_addLog($ilUser->id, ilObjTest::_getObjectIDFromActiveID($active_id), $logtext, $question_id, $original_id);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static assQuestion::lookupOriginalParentObjId (   $originalQuestionId)
static

returns the parent object id for given original question id (should be a qpl id, but theoretically it can be a tst id, too)

ilDB $ilDB

Parameters
integer$originalQuestionId
Returns
integer $originalQuestionParentObjectId

Definition at line 2566 of file class.assQuestion.php.

References $query, $res, and $row.

Referenced by assMultipleChoice\syncImages(), and syncWithOriginal().

{
global $ilDB;
$query = "SELECT obj_fi FROM qpl_questions WHERE question_id = %s";
$res = $ilDB->queryF($query, array('integer'), array((int)$originalQuestionId));
$row = $ilDB->fetchAssoc($res);
return $row['obj_fi'];
}

+ Here is the caller graph for this function:

assQuestion::moveUploadedMediaFile (   $file,
  $name 
)

Move an uploaded media file to an public accessible temp dir to present it.

Parameters
string$fileFile path
string$nameName of the file public

Definition at line 1164 of file class.assQuestion.php.

References $file, ilUtil\createDirectory(), and ilUtil\moveUploadedFile().

{
$mediatempdir = CLIENT_WEB_DIR . "/assessment/temp";
if (!@is_dir($mediatempdir)) ilUtil::createDirectory($mediatempdir);
$temp_name = tempnam($mediatempdir, $name . "_____");
$temp_name = str_replace("\\", "/", $temp_name);
@unlink($temp_name);
if (!ilUtil::moveUploadedFile($file, $name, $temp_name))
{
return FALSE;
}
else
{
return $temp_name;
}
}

+ Here is the call graph for this function:

assQuestion::onCopy (   $source_questionpool_id,
  $source_question_id 
)
protected

Will be called when a question is copied (into another question pool)

Definition at line 2097 of file class.assQuestion.php.

References copySuggestedSolutionFiles().

{
$this->copySuggestedSolutionFiles($source_questionpool_id, $source_question_id);
}

+ Here is the call graph for this function:

assQuestion::onDuplicate (   $originalParentId,
  $originalQuestionId,
  $duplicateParentId,
  $duplicateQuestionId 
)
protected

Will be called when a question is duplicated (inside a question pool or for insertion in a test)

Definition at line 2086 of file class.assQuestion.php.

References duplicateQuestionHints(), duplicateSuggestedSolutionFiles(), and getId().

{
$this->duplicateSuggestedSolutionFiles($originalParentId, $originalQuestionId);
// duplicate question hints
$this->duplicateQuestionHints($originalQuestionId, $this->getId());
}

+ Here is the call graph for this function:

assQuestion::pcArrayShuffle (   $array)

Shuffles the values of a given array.

Parameters
array$arrayAn array which should be shuffled public

Definition at line 1372 of file class.assQuestion.php.

References $result.

Referenced by assOrderingQuestion\toJSON().

{
$keys = array_keys($array);
shuffle($keys);
$result = array();
foreach ($keys as $key)
{
$result[$key] = $array[$key];
}
return $result;
}

+ Here is the caller graph for this function:

assQuestion::persistWorkingState (   $active_id,
  $pass = NULL,
  $obligationsEnabled = false 
)
final

persists the working state for current testactive and testpass

public

Parameters
integer$active_idActive id of the user
integer$passTest pass

Definition at line 904 of file class.assQuestion.php.

References $pass, ilObjTest\_getPass(), calculateResultsFromSolution(), reworkWorkingData(), and saveWorkingData().

{
if( $pass === null )
{
require_once 'Modules/Test/classes/class.ilObjTest.php';
$pass = ilObjTest::_getPass($active_id);
}
$saveStatus = $this->saveWorkingData($active_id, $pass);
$this->calculateResultsFromSolution($active_id, $pass, $obligationsEnabled);
$this->reworkWorkingData($active_id, $pass, $obligationsEnabled);
return $saveStatus;
}

+ Here is the call graph for this function:

assQuestion::prepareTextareaOutput (   $txt_output,
  $prepare_for_latex_output = FALSE 
)

Prepares a string for a text area output in tests.

Parameters
string$txt_outputString which should be prepared for output public

Definition at line 2916 of file class.assQuestion.php.

Referenced by getSuggestedSolutionOutput(), and assClozeTest\updateClozeTextFromGaps().

{
include_once "./Services/Utilities/classes/class.ilUtil.php";
return ilUtil::prepareTextareaOutput($txt_output, $prepare_for_latex_output);
}

+ Here is the caller graph for this function:

assQuestion::QTIMaterialToString (   $a_material)

Reads an QTI material tag an creates a text string.

Parameters
string$a_materialQTI material tag
Returns
string text or xhtml string public

Definition at line 2929 of file class.assQuestion.php.

References $_SESSION, and $result.

{
$result = "";
for ($i = 0; $i < $a_material->getMaterialCount(); $i++)
{
$material = $a_material->getMaterial($i);
if (strcmp($material["type"], "mattext") == 0)
{
$result .= $material["material"]->getContent();
}
if (strcmp($material["type"], "matimage") == 0)
{
$matimage = $material["material"];
if (preg_match("/(il_([0-9]+)_mob_([0-9]+))/", $matimage->getLabel(), $matches))
{
// import an mediaobject which was inserted using tiny mce
if (!is_array($_SESSION["import_mob_xhtml"])) $_SESSION["import_mob_xhtml"] = array();
array_push($_SESSION["import_mob_xhtml"], array("mob" => $matimage->getLabel(), "uri" => $matimage->getUri()));
}
}
}
return $result;
}
assQuestion::questionTitleExists (   $questionpool_id,
  $title 
)

Returns TRUE if the question title exists in the database.

Parameters
string$titleThe title of the question
Returns
boolean The result of the title check public

Definition at line 274 of file class.assQuestion.php.

References $result, and $title.

{
global $ilDB;
$result = $ilDB->queryF("SELECT * FROM qpl_questions WHERE obj_fi = %s AND title = %s",
array('integer','text'),
array($questionpool_id, $title)
);
return ($result->numRows() == 1) ? TRUE : FALSE;
}
assQuestion::reworkWorkingData (   $active_id,
  $pass,
  $obligationsAnswered 
)
abstractprotected

Reworks the allready saved working data if neccessary.

protected

Parameters
integer$active_id
integer$pass
boolean$obligationsAnswered

Reimplemented in assClozeTest, assMatchingQuestion, assOrderingQuestion, assJavaApplet, assTextQuestion, assMultipleChoice, assSingleChoice, assImagemapQuestion, assTextSubset, assFileUpload, assNumeric, assFlashQuestion, assErrorText, and assOrderingHorizontal.

Referenced by persistWorkingState().

+ Here is the caller graph for this function:

assQuestion::saveQuestionDataToDb (   $original_id = "")

Definition at line 1991 of file class.assQuestion.php.

References $original_id, ilRTE\_replaceMediaObjectImageSrc(), createPageObject(), getAuthor(), getComment(), getEstimatedWorkingTime(), getId(), getMaximumPoints(), getNrOfTries(), getObjId(), getOwner(), getQuestion(), getQuestionTypeID(), getTitle(), and setId().

Referenced by assOrderingHorizontal\saveToDb(), assErrorText\saveToDb(), assFlashQuestion\saveToDb(), assFileUpload\saveToDb(), assNumeric\saveToDb(), assTextSubset\saveToDb(), assMultipleChoice\saveToDb(), assOrderingQuestion\saveToDb(), assImagemapQuestion\saveToDb(), assTextQuestion\saveToDb(), assSingleChoice\saveToDb(), assMatchingQuestion\saveToDb(), assClozeTest\saveToDb(), and assJavaApplet\saveToDb().

{
global $ilDB;
$estw_time = $this->getEstimatedWorkingTime();
$estw_time = sprintf("%02d:%02d:%02d", $estw_time['h'], $estw_time['m'], $estw_time['s']);
// cleanup RTE images which are not inserted into the question text
include_once("./Services/RTE/classes/class.ilRTE.php");
if ($this->getId() == -1)
{
// Neuen Datensatz schreiben
$next_id = $ilDB->nextId('qpl_questions');
$affectedRows = $ilDB->insert("qpl_questions", array(
"question_id" => array("integer", $next_id),
"question_type_fi" => array("integer", $this->getQuestionTypeID()),
"obj_fi" => array("integer", $this->getObjId()),
"title" => array("text", $this->getTitle()),
"description" => array("text", $this->getComment()),
"author" => array("text", $this->getAuthor()),
"owner" => array("integer", $this->getOwner()),
"question_text" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestion(), 0)),
"points" => array("float", $this->getMaximumPoints()),
"working_time" => array("text", $estw_time),
"nr_of_tries" => array("integer", (strlen($this->getNrOfTries())) ? $this->getNrOfTries() : 1),
"created" => array("integer", time()),
"original_id" => array("integer", ($original_id) ? $original_id : NULL),
"tstamp" => array("integer", time())
));
$this->setId($next_id);
// create page object of question
$this->createPageObject();
}
else
{
// Vorhandenen Datensatz aktualisieren
$affectedRows = $ilDB->update("qpl_questions", array(
"obj_fi" => array("integer", $this->getObjId()),
"title" => array("text", $this->getTitle()),
"description" => array("text", $this->getComment()),
"author" => array("text", $this->getAuthor()),
"question_text" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestion(), 0)),
"points" => array("float", $this->getMaximumPoints()),
"nr_of_tries" => array("integer", (strlen($this->getNrOfTries())) ? $this->getNrOfTries() : 1),
"working_time" => array("text", $estw_time),
"tstamp" => array("integer", time())
), array(
"question_id" => array("integer", $this->getId())
));
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::saveToDb (   $original_id = "")

Saves the question to the database.

Parameters
integer$original_idpublic

Reimplemented in assJavaApplet, assClozeTest, assMatchingQuestion, assSingleChoice, assTextQuestion, assImagemapQuestion, assOrderingQuestion, assMultipleChoice, assTextSubset, assNumeric, assFileUpload, assFlashQuestion, assErrorText, and assOrderingHorizontal.

Definition at line 2049 of file class.assQuestion.php.

References ilObjQuestionPool\_updateQuestionCount(), cleanupMediaObjectUsage(), getId(), getOwner(), and isComplete().

Referenced by syncWithOriginal().

{
global $ilDB;
$this->updateSuggestedSolutions();
// remove unused media objects from ILIAS
$complete = "0";
if ($this->isComplete())
{
$complete = "1";
}
// update the question time stamp and completion status
$affectedRows = $ilDB->manipulateF("UPDATE qpl_questions SET tstamp = %s, owner = %s, complete = %s WHERE question_id = %s",
array('integer','integer', 'integer','text'),
array(time(), ($this->getOwner() <= 0) ? $this->ilias->account->id : $this->getOwner(), $complete, $this->getId())
);
// update question count of question pool
include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::saveWorkingData (   $active_id,
  $pass = NULL 
)
abstract

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

Reimplemented in assClozeTest, assMatchingQuestion, assJavaApplet, assOrderingQuestion, assMultipleChoice, assImagemapQuestion, assTextQuestion, assSingleChoice, assTextSubset, assFileUpload, assFlashQuestion, assNumeric, assErrorText, and assOrderingHorizontal.

Referenced by persistWorkingState().

+ Here is the caller graph for this function:

assQuestion::setAuthor (   $author = "")

Sets the authors name of the assQuestion object.

Parameters
string$authorA string containing the name of the questions author public
See Also
$author

Definition at line 408 of file class.assQuestion.php.

References $author.

Referenced by __set(), assOrderingHorizontal\loadFromDb(), assFileUpload\loadFromDb(), assFlashQuestion\loadFromDb(), assErrorText\loadFromDb(), assNumeric\loadFromDb(), assClozeTest\loadFromDb(), assTextSubset\loadFromDb(), assTextQuestion\loadFromDb(), assOrderingQuestion\loadFromDb(), assMatchingQuestion\loadFromDb(), assSingleChoice\loadFromDb(), assMultipleChoice\loadFromDb(), assJavaApplet\loadFromDb(), and assImagemapQuestion\loadFromDb().

{
if (!$author)
{
$author = $this->ilias->account->fullname;
}
$this->author = $author;
}

+ Here is the caller graph for this function:

assQuestion::setComment (   $comment = "")
assQuestion::setEstimatedWorkingTime (   $hour = 0,
  $min = 0,
  $sec = 0 
)

Sets the estimated working time of a question.

Parameters
integer$hourHour
integer$minMinutes
integer$secSeconds public
See Also
$comment

Definition at line 374 of file class.assQuestion.php.

Referenced by __construct(), __set(), assOrderingHorizontal\loadFromDb(), assFileUpload\loadFromDb(), assFlashQuestion\loadFromDb(), assErrorText\loadFromDb(), assNumeric\loadFromDb(), assClozeTest\loadFromDb(), assTextSubset\loadFromDb(), assTextQuestion\loadFromDb(), assOrderingQuestion\loadFromDb(), assMatchingQuestion\loadFromDb(), assSingleChoice\loadFromDb(), assMultipleChoice\loadFromDb(), assJavaApplet\loadFromDb(), and assImagemapQuestion\loadFromDb().

{
$this->est_working_time = array("h" => (int)$hour, "m" => (int)$min, "s" => (int)$sec);
}

+ Here is the caller graph for this function:

assQuestion::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 public

Reimplemented in assClozeTest, assMatchingQuestion, assMultipleChoice, assSingleChoice, assOrderingQuestion, assJavaApplet, assImagemapQuestion, assTextQuestion, assTextSubset, assFileUpload, assNumeric, assFlashQuestion, assOrderingHorizontal, and assErrorText.

Definition at line 3532 of file class.assQuestion.php.

{
return $startrow;
}
assQuestion::setExportImagePath (   $a_path)

Definition at line 3676 of file class.assQuestion.php.

{
$this->export_image_path = (string)$a_path;
}
assQuestion::setNewOriginalId (   $newId)

Definition at line 2075 of file class.assQuestion.php.

References getId().

{
global $ilDB;
$ilDB->manipulateF("UPDATE qpl_questions SET tstamp = %s, original_id = %s WHERE question_id = %s",
array('integer','integer', 'text'),
array(time(), $newId, $this->getId())
);
}

+ Here is the call graph for this function:

assQuestion::setObjId (   $obj_id = 0)
assQuestion::setObligationsToBeConsidered (   $obligationsToBeConsidered = true)

sets the flag wether obligations are to be considered or not

Parameters
bool$obligationsToBeConsidered

Definition at line 3786 of file class.assQuestion.php.

References $obligationsToBeConsidered.

{
$this->obligationsToBeConsidered = (bool)$obligationsToBeConsidered;
}
assQuestion::setOutputType (   $outputType = OUTPUT_HTML)

Sets the output type.

Parameters
integer$outputTypeThe output type of the question public
See Also
$outputType

Reimplemented in assMultipleChoice, and assSingleChoice.

Definition at line 340 of file class.assQuestion.php.

References $outputType.

Referenced by __set().

{
$this->outputType = $outputType;
}

+ Here is the caller graph for this function:

assQuestion::setOwner (   $owner = "")
assQuestion::setPoints (   $a_points)
assQuestion::setQuestion (   $question = "")
assQuestion::setShuffle (   $shuffle = true)

Sets the shuffle flag.

Parameters
boolean$shuffleA flag indicating whether the answers are shuffled or not public
See Also
$shuffle

Reimplemented in assMatchingQuestion.

Definition at line 353 of file class.assQuestion.php.

References $shuffle.

Referenced by __set(), assTextQuestion\loadFromDb(), assSingleChoice\loadFromDb(), and assMultipleChoice\loadFromDb().

{
if ($shuffle)
{
$this->shuffle = 1;
}
else
{
$this->shuffle = 0;
}
}

+ Here is the caller graph for this function:

assQuestion::setSuggestedSolution (   $solution_id = "",
  $subquestion_index = 0,
  $is_import = false 
)

Sets a suggested solution for the question.

If there is more than one subquestion (i.e. close questions) may enter a subquestion index.

Parameters
string$solution_idAn internal link pointing to the suggested solution
integer$subquestion_indexThe index of a subquestion (i.e. a close test gap). Usually 0
boolean$is_importA boolean indication that the internal link was imported from another ILIAS installation public

Definition at line 2170 of file class.assQuestion.php.

References _resolveInternalLink().

Referenced by assFileUpload\loadFromDb(), and assFlashQuestion\loadFromDb().

{
if (strcmp($solution_id, "") != 0)
{
$import_id = "";
if ($is_import)
{
$import_id = $solution_id;
$solution_id = $this->_resolveInternalLink($import_id);
}
$this->suggested_solutions[$subquestion_index] = array(
"internal_link" => $solution_id,
"import_id" => $import_id
);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::setTestId (   $id = -1)

Sets the test id of the assQuestion object.

Parameters
integer$idA unique integer value public
See Also
$test_id

Definition at line 316 of file class.assQuestion.php.

References $id.

Referenced by __set().

{
$this->test_id = $id;
}

+ Here is the caller graph for this function:

assQuestion::setTitle (   $title = "")
assQuestion::supportsJavascriptOutput ( )

Returns true if the question type supports JavaScript output.

Returns
boolean TRUE if the question type supports JavaScript output, FALSE otherwise public

Reimplemented in assMatchingQuestion, and assOrderingQuestion.

Definition at line 507 of file class.assQuestion.php.

{
return FALSE;
}
assQuestion::syncSuggestedSolutionFiles (   $original_id)
protected

Syncs the files of a suggested solution if the question is synced.

Definition at line 2224 of file class.assQuestion.php.

References $filename, $ilLog, ilUtil\delDir(), getSuggestedSolutionPath(), and ilUtil\makeDirParents().

{
global $ilLog;
$filepath = $this->getSuggestedSolutionPath();
$filepath_original = str_replace("/$this->id/solution", "/$original_id/solution", $filepath);
ilUtil::delDir($filepath_original);
foreach ($this->suggested_solutions as $index => $solution)
{
if (strcmp($solution["type"], "file") == 0)
{
if (!file_exists($filepath_original))
{
ilUtil::makeDirParents($filepath_original);
}
$filename = $solution["value"]["name"];
if (strlen($filename))
{
if (!@copy($filepath . $filename, $filepath_original . $filename))
{
$ilLog->write("File could not be duplicated!!!!", $ilLog->ERROR);
$ilLog->write("object: " . print_r($this, TRUE), $ilLog->ERROR);
}
}
}
}
}

+ Here is the call graph for this function:

assQuestion::syncWithOriginal ( )

Reimplemented in assMultipleChoice, assSingleChoice, and assImagemapQuestion.

Definition at line 2524 of file class.assQuestion.php.

References $id, copyPageOfQuestion(), createPageObject(), deletePageOfQuestion(), getId(), getOriginalId(), lookupOriginalParentObjId(), saveToDb(), setId(), setObjId(), setOriginalId(), and syncXHTMLMediaObjectsOfQuestion().

{
global $ilDB;
if( !$this->getOriginalId() )
{
return;
}
$originalObjId = self::lookupOriginalParentObjId($this->getOriginalId());
if ( !$originalObjId )
{
return;
}
$id = $this->getId();
$original = $this->getOriginalId();
$this->setId($this->getOriginalId());
$this->setOriginalId(NULL);
$this->setObjId($originalObjId);
$this->saveToDb();
$this->deletePageOfQuestion($original);
$this->createPageObject();
$this->setId($id);
$this->setOriginalId($original);
$this->updateSuggestedSolutions($original);
$this->syncFeedbackGeneric();
$this->syncHints();
}

+ Here is the call graph for this function:

assQuestion::syncXHTMLMediaObjectsOfQuestion ( )

Definition at line 1792 of file class.assQuestion.php.

References $mobs, ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_saveUsage(), and getId().

Referenced by syncWithOriginal().

{
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
foreach ($mobs as $mob)
{
ilObjMediaObject::_saveUsage($mob, "qpl:html", $this->original_id);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::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.

Returns
string The QTI xml representation of the question public

Reimplemented in assFileUpload, assFlashQuestion, assOrderingHorizontal, and assErrorText.

Definition at line 248 of file class.assQuestion.php.

References getQuestionType().

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

+ Here is the call graph for this function:

Field Documentation

assQuestion::$arrData
private

Associative array to store properties.

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

assQuestion::$est_working_time
protected

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

Referenced by getEstimatedWorkingTime().

assQuestion::$export_image_path
private

(Web) Path to images

Definition at line 162 of file class.assQuestion.php.

Referenced by getImagePathWeb().

assQuestion::$ilias
protected

Definition at line 105 of file class.assQuestion.php.

Referenced by __construct(), and __get().

assQuestion::$lng
protected

Definition at line 119 of file class.assQuestion.php.

Referenced by __construct(), _getQuestionTypeName(), and _setReachedPoints().

assQuestion::$nr_of_tries
private

Number of tries.

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

Referenced by getNrOfTries().

assQuestion::$obj_id
protected

Definition at line 98 of file class.assQuestion.php.

Referenced by createNewQuestion(), delete(), getImagePath(), getObjId(), and setObjId().

assQuestion::$obligationsToBeConsidered = false
private
assQuestion::$outputType
protected

Definition at line 126 of file class.assQuestion.php.

Referenced by getOutputType(), and setOutputType().

assQuestion::$page
protected
assQuestion::$points
protected

Definition at line 70 of file class.assQuestion.php.

Referenced by _getMaximumPoints(), _getReachedPoints(), _isWorkedThrough(), _setReachedPoints(), assTextSubset\addAnswer(), assSingleChoice\addAnswer(), assImagemapQuestion\addAnswer(), assMultipleChoice\addAnswer(), assTextQuestion\addAnswer(), assErrorText\addErrorData(), assMatchingQuestion\addMatchingPair(), adjustReachedPointsByScoringOptions(), assOrderingHorizontal\calculateReachedPoints(), assFileUpload\calculateReachedPoints(), assErrorText\calculateReachedPoints(), assNumeric\calculateReachedPoints(), assFlashQuestion\calculateReachedPoints(), assTextQuestion\calculateReachedPoints(), assTextSubset\calculateReachedPoints(), assSingleChoice\calculateReachedPoints(), assImagemapQuestion\calculateReachedPoints(), assMultipleChoice\calculateReachedPoints(), assOrderingQuestion\calculateReachedPoints(), assJavaApplet\calculateReachedPoints(), assMatchingQuestion\calculateReachedPoints(), assClozeTest\calculateReachedPoints(), assErrorText\getBestSelection(), assClozeTest\getMaximumGapPoints(), assFlashQuestion\getMaximumPoints(), assTextQuestion\getMaximumPoints(), assTextSubset\getMaximumPoints(), assSingleChoice\getMaximumPoints(), assMultipleChoice\getMaximumPoints(), assImagemapQuestion\getMaximumPoints(), assClozeTest\getMaximumPoints(), getMaximumPoints(), assMatchingQuestion\getMaximumPoints(), assTextQuestion\getMinimumPoints(), getPoints(), assErrorText\getPointsForSelectedPositions(), assFileUpload\handleSubmission(), assMatchingQuestion\insertMatchingPair(), assErrorText\setErrorData(), assClozeTest\setGapAnswerPoints(), assTextQuestion\setReachedPoints(), and assMatchingQuestion\toJSON().

assQuestion::$suggested_solutions
protected

Definition at line 133 of file class.assQuestion.php.

Referenced by getSuggestedSolutions().

assQuestion::$tpl
protected

Definition at line 112 of file class.assQuestion.php.

Referenced by __construct(), and __get().


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