ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
assQuestion Class Reference

Basic class for all assessment question types. More...

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

Public Member Functions

 assQuestion ($title="", $comment="", $author="", $owner=-1, $question="")
 assQuestion constructor
 _assQuestion ()
 fromXML (&$item, &$questionpool_id, &$tst_id, &$tst_object, &$question_counter, &$import_mapping)
 Creates a question from a QTI file.
 toXML ($a_include_header=true, $a_include_binary=true, $a_shuffle=false, $test_output=false, $force_image_references=false)
 Returns a QTI xml representation of the question.
 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.
 setId ($id=-1)
 Sets the id.
 setTestId ($id=-1)
 Sets the test id.
 setComment ($comment="")
 Sets the comment.
 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.
 setOwner ($owner="")
 Sets the creator/owner.
 getTitle ()
 Gets the title string.
 getId ()
 Gets the id.
 getShuffle ()
 Gets the shuffle flag.
 getTestId ()
 Gets the test id.
 getComment ()
 Gets the comment.
 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.
 getOwner ()
 Gets the creator/owner.
 getObjId ()
 Get the object id of the container object.
 setObjId ($obj_id=0)
 Set the object id of the container object.
 createPageObject ()
 create page object of question
 insertIntoTest ($test_id)
 Insert the question into a test.
 _getMaximumPoints ($question_id)
 Returns the maximum points, a learner can reach answering the question.
_getQuestionInfo ($question_id)
 Returns question information from the database.
 _getSuggestedSolutionCount ($question_id)
 Returns the number of suggested solutions associated with a question.
_getSuggestedSolution ($question_id, $subquestion_index=0)
 Returns a suggested solution for a given subquestion index.
 _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.
 getMaximumPoints ()
 Returns the maximum points, a learner can reach answering the question.
 saveWorkingData ($active_id, $pass=NULL)
 Saves the learners input of the question to the database.
 _updateTestPassResults ($active_id, $pass)
 logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log.
 _logAction ($logtext="", $active_id="", $question_id="")
 Logs an action into the Test&Assessment log.
 moveUploadedMediaFile ($file, $name)
 Move an uploaded media file to an public accessible temp dir to present it.
 getJavaPath ()
 Returns the image path for web accessable images of a question.
 getImagePath ()
 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.
 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.
 copyXHTMLMediaObjectsOfQuestion ($a_q_id)
 syncXHTMLMediaObjectsOfQuestion ()
 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.
 saveToDb ($original_id="")
 Saves the question to the database.
 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.
 saveSuggestedSolution ($solution_id="", $subquestion_index=0)
 Saves 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.
_instanciateQuestion ($question_id)
 Creates an instance of a question with a given question id.
 getPoints ()
 Returns the maximum available points for the question.
 setPoints ($a_points)
 Sets the maximum available points for the question.
 getSolutionMaxPass ($active_id)
 Returns the maximum pass a users question solution.
 _getSolutionMaxPass ($question_id, $active_id)
 Returns the maximum pass a users question solution.
 _isWriteable ($question_id, $user_id)
 Returns true if the question is writeable by a certain user.
 _isUsedInRandomTest ($question_id="")
 Checks whether the question is used in a random test or not.
 calculateReachedPoints ($active_id, $pass=NULL, $points=0)
 Returns the points, a learner has reached answering the question.
 _isWorkedThrough ($active_id, $question_id, $pass=NULL)
 Returns true if the question was worked through in the given pass.
 getMultilineAnswerSetting ()
 setMultilineAnswerSetting ($a_setting=0)
 _areAnswered ($a_user_id, $a_question_ids)
 Checks if an array of question ids is answered by an user or not.
 isHTML ($a_text)
 Checks if a given string contains HTML or not.
 prepareTextareaOutput ($txt_output, $prepare_for_latex_output=FALSE)
 Prepares a string for a text area output in tests.
 QTIMaterialToString ($a_material)
 Reads an QTI material tag an creates a text string.
 addQTIMaterial (&$a_xml_writer, $a_material, $close_material_tag=TRUE, $add_mobs=TRUE)
 Creates a QTI material tag from a plain text or xhtml text.
 createNewImageFileName ($image_filename)
 _setReachedPoints ($active_id, $question_id, $points, $maxpoints, $pass=NULL)
 Sets the points, a learner has reached answering the question Additionally objective results are updated.
 getQuestion ()
 Gets the question text.
 setQuestion ($question="")
 Sets the question text.
 getQuestionType ()
 Returns the question type of the question.
 getQuestionTypeID ()
 Returns the question type of the question.
 saveFeedbackGeneric ($correctness, $feedback)
 Saves generic feedback to the database.
 getFeedbackGeneric ($correctness)
 Returns the generic feedback for a given question state.
 duplicateFeedbackGeneric ($original_id)
 Duplicates the generic feedback of a question.
 syncFeedbackGeneric ()
 getRTETextWithMediaObjects ()
 Collects all text in the question which could contain media objects which were created with the Rich Text Editor.
 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.

Static Public Member Functions

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.

Data Fields

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

Protected Member Functions

 deletePageOfQuestion ($question_id)
 Deletes the page object of a question with a given ID.

Detailed Description

Basic class for all assessment question types.

The assQuestion class defines and encapsulates basic methods and attributes for assessment question types to be used for all parent 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
Version
Id:
class.assQuestion.php 19957 2009-05-12 12:19:03Z hschottm

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

Member Function Documentation

assQuestion::_areAnswered (   $a_user_id,
  $a_question_ids 
)

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

Parameters
intuser_id
array$question_idsuser id array
Returns
boolean public static

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

References $res.

Referenced by ilCourseObjectiveResult\getStatus().

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

+ Here is the caller graph for this function:

assQuestion::_assQuestion ( )

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

{
if (!empty($this->domxml))
{
$this->domxml->free();
}
}
assQuestion::_getInternalLinkHref (   $target = "")

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

References $target_id.

Referenced by assTextQuestionGUI\editQuestion(), assTextSubsetGUI\editQuestion(), assJavaAppletGUI\editQuestion(), assMatchingQuestionGUI\editQuestion(), assNumericGUI\editQuestion(), assSingleChoiceGUI\editQuestion(), assMultipleChoiceGUI\editQuestion(), assOrderingQuestionGUI\editQuestion(), assImagemapQuestionGUI\editQuestion(), assClozeTestGUI\editQuestion(), and ilObjTest\getTestResult().

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

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

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

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

References $points, and $result.

Referenced by _getTotalRightAnswers(), ilCourseObjectiveQuestion\_lookupMaximumPointsOfQuestion(), ilObjTest\getTestResult(), ilObjQuestionPoolGUI\questionsObject(), and ilTestScoringGUI\setPointsManual().

{
global $ilDB;
$points = 0;
$query = sprintf("SELECT points FROM qpl_questions WHERE question_id = %s",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
$points = $row["points"];
}
return $points;
}

+ Here is the caller graph for this function:

assQuestion::_getOriginalId (   $question_id)

Returns the original id of a question.

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 1996 of file class.assQuestion.php.

References $result.

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

{
global $ilDB;
$query = sprintf("SELECT * FROM qpl_questions WHERE question_id = %s",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
if ($result->numRows() > 0)
{
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
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.

Returns question information from the database

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

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

References $result.

Referenced by ilObjMediaObject\getParentObjectIdForUsage(), and ilObjTest\getTestResult().

{
global $ilDB;
$query = sprintf("SELECT qpl_questions.*, qpl_question_type.type_tag FROM qpl_question_type, qpl_questions WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_question_type.question_type_id",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
if ($result->numRows())
{
return $result->fetchRow(MDB2_FETCHMODE_ASSOC);
}
else return array();
}

+ Here is the caller graph for this function:

assQuestion::_getQuestionTitle (   $question_id)

Returns the question title of a question with a given 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 1632 of file class.assQuestion.php.

References $data, and $result.

Referenced by ilObjAssessmentFolderGUI\logsObject().

{
global $ilDB;
if ($question_id < 1)
return "";
$query = sprintf("SELECT title FROM qpl_questions WHERE qpl_questions.question_id = %s",
$ilDB->quote($question_id)
);
$result = $ilDB->query($query);
if ($result->numRows() == 1) {
$data = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
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.

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 1605 of file class.assQuestion.php.

References $data, and $result.

Referenced by _instanciateQuestion(), _instanciateQuestionGUI(), and _needsManualScoring().

{
global $ilDB;
if ($question_id < 1)
return "";
$query = sprintf("SELECT type_tag FROM qpl_questions, qpl_question_type WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_question_type.question_type_id",
$ilDB->quote($question_id)
);
$result = $ilDB->query($query);
if ($result->numRows() == 1) {
$data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
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 2923 of file class.assQuestion.php.

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

Referenced by ilObjTestGUI\createRandomSelectionObject(), ilObjQuestionPoolGUI\deleteQuestionsObject(), assQuestionGUI\outQuestionType(), ilObjQuestionPoolGUI\printObject(), ilObjTestGUI\questionBrowser(), ilObjQuestionPoolGUI\questionsObject(), ilObjTestGUI\questionsObject(), and ilObjTestGUI\removeQuestionsForm().

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

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 public static

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

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

Referenced by ilTestServiceGUI\getPassListOfAnswersWithScoring(), getReachedPoints(), and ilObjTest\getTestResult().

{
global $ilDB;
$points = 0;
if (is_null($pass))
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$pass = assQuestion::_getSolutionMaxPass($question_id, $active_id);
}
$query = sprintf("SELECT * FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
$ilDB->quote($active_id . ""),
$ilDB->quote($question_id . ""),
$ilDB->quote($pass . "")
);
$result = $ilDB->query($query);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
$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.

Returns the maximum pass a users question solution

Parameters
returninteger The maximum pass of the users solution public

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

References $result.

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;
$query = sprintf("SELECT MAX(pass) as maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
$ilDB->quote($active_id . ""),
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
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.

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 790 of file class.assQuestion.php.

References $result.

Referenced by ilObjTest\getTestResult().

{
global $ilDB;
$query = sprintf("SELECT * FROM qpl_suggested_solutions WHERE question_fi = %s AND subquestion_index = %s",
$ilDB->quote($question_id . ""),
$ilDB->quote($subquestion_index . "")
);
$result = $ilDB->query($query);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
return array(
"internal_link" => $row["internal_link"],
"import_id" => $row["import_id"]
);
}
else
{
return array();
}
}

+ Here is the caller graph for this function:

assQuestion::_getSuggestedSolutionCount (   $question_id)

Returns the number of suggested solutions associated with a question.

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 public static

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

References $result.

Referenced by ilObjTest\getTestResult().

{
global $ilDB;
$query = sprintf("SELECT suggested_solution_id FROM qpl_suggested_solutions WHERE question_fi = %s",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
return $result->numRows();
}

+ 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 1536 of file class.assQuestion.php.

References $result.

Referenced by ilObjQuestionPoolGUI\assessmentObject().

{
global $ilDB;
$query = sprintf("SELECT title FROM qpl_questions WHERE question_id = %s",
$ilDB->quote($a_q_id)
);
$result = $ilDB->query($query);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
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 1450 of file class.assQuestion.php.

References $result.

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

{
global $ilDB;
// get all question references to the question id
$query = sprintf("SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
$ilDB->quote($a_q_id),
$ilDB->quote($a_q_id)
);
$result = $ilDB->query($query);
if ($result->numRows() == 0)
{
return 0;
}
$found_id = array();
while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
{
array_push($found_id, $row->question_id);
}
$query = sprintf("SELECT * FROM tst_test_result WHERE question_fi IN ('%s')",
join($found_id, "','"));
$result = $ilDB->query($query);
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 1486 of file class.assQuestion.php.

References $result, and _getMaximumPoints().

Referenced by ilObjQuestionPoolGUI\assessmentObject().

{
global $ilDB;
$query = sprintf("SELECT question_id FROM qpl_questions WHERE original_id = %s OR question_id = %s",
$ilDB->quote($a_q_id),
$ilDB->quote($a_q_id)
);
$result = $ilDB->query($query);
if ($result->numRows() == 0)
{
return 0;
}
$found_id = array();
while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
{
array_push($found_id, $row->question_id);
}
$query = sprintf("SELECT * FROM tst_test_result WHERE question_fi IN ('%s')",
join($found_id, "','"));
$result = $ilDB->query($query);
$answers = array();
while ($row = $result->fetchRow(MDB2_FETCHMODE_OBJECT))
{
$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 2894 of file class.assQuestion.php.

References ilPlugin\getPluginObject(), and IL_COMP_MODULE.

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

{
$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:

& assQuestion::_instanciateQuestion (   $question_id)

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

Creates an instance of a question with a given question id

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

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

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

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

+ Here is the call graph for this function:

& assQuestion::_instanciateQuestionGUI (   $question_id)

Creates an instance of a question gui with a given 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 2955 of file class.assQuestion.php.

References _getQuestionType(), and _includeClass().

Referenced by ilObjQuestionPool\createQuestion(), and ilObjQuestionPoolGUI\printObject().

{
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:

assQuestion::_isUsedInRandomTest (   $question_id = "")

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

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 2248 of file class.assQuestion.php.

References $result.

Referenced by ilObjQuestionPool\getDeleteableQuestionDetails(), and ilObjQuestionPool\getUsedQuestionDetails().

{
global $ilDB;
if ($question_id < 1) return 0;
$query = sprintf("SELECT test_random_question_id FROM tst_test_random_question WHERE question_fi = %s",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
return $result->numRows();
}

+ Here is the caller graph for this function:

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

Returns true if the question was worked through in the given pass.

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 public static

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

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

Referenced by ilObjTest\getAnsweredQuestionCount(), and ilObjTest\getTestResult().

{
global $ilDB;
$points = 0;
if (is_null($pass))
{
include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
$pass = assQuestion::_getSolutionMaxPass($question_id, $active_id);
}
$query = sprintf("SELECT solution_id FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
$ilDB->quote($active_id . ""),
$ilDB->quote($question_id . ""),
$ilDB->quote($pass . "")
);
$result = $ilDB->query($query);
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.

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 2214 of file class.assQuestion.php.

References $result.

Referenced by assQuestionGUI\save(), assQuestionGUI\saveEdit(), and assQuestionGUI\saveFeedback().

{
global $ilDB;
if (($question_id < 1) || ($user_id < 1))
{
return false;
}
$query = sprintf("SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
$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.

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 976 of file class.assQuestion.php.

References $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 2847 of file class.assQuestion.php.

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

Referenced by 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.

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 2078 of file class.assQuestion.php.

References $result.

{
global $ilDB;
if ($question_id < 1)
{
return false;
}
$query = sprintf("SELECT question_id FROM qpl_questions WHERE question_id = %s",
$ilDB->quote($question_id)
);
$result = $ilDB->query($query);
if ($result->numRows() == 1)
{
return true;
}
else
{
return false;
}
}
assQuestion::_resolveInternalLink (   $internal_link)

Definition at line 1862 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 1899 of file class.assQuestion.php.

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

Referenced by ilContObjParser\processPagesToParse().

{
global $ilDB;
$resolvedlinks = 0;
$query = sprintf("SELECT * FROM qpl_suggested_solutions WHERE question_fi = %s",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
if ($result->numRows())
{
while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
{
$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
$queryupdate = sprintf("UPDATE qpl_suggested_solutions SET internal_link = %s WHERE suggested_solution_id = %s",
$ilDB->quote($resolved_link),
$ilDB->quote($row["suggested_solution_id"] . "")
);
$updateresult = $ilDB->query($queryupdate);
$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";
$query = sprintf("SELECT * FROM qpl_suggested_solutions WHERE question_fi = %s",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
if ($result->numRows())
{
while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
{
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 = NULL 
)

Sets the points, a learner has reached answering the question Additionally objective results are updated.

Sets 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$pointsThe points the user has reached answering the question
Returns
boolean true on success, otherwise false public

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

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

Referenced by ilTestScoringGUI\setPointsManual().

{
global $ilDB;
if ($points <= $maxpoints)
{
if (is_null($pass))
{
$pass = assQuestion::_getSolutionMaxPass($question_id, $active_id);
}
// retrieve the already given points
$old_points = 0;
$query = sprintf("SELECT points FROM tst_test_result WHERE active_fi = %s AND question_fi = %s AND pass = %s",
$ilDB->quote($active_id . ""),
$ilDB->quote($question_id . ""),
$ilDB->quote($pass . "")
);
$result = $ilDB->query($query);
if ($result->numRows())
{
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
$old_points = $row["points"];
$query = sprintf("UPDATE tst_test_result SET points = %s WHERE active_fi = %s AND question_fi = %s AND pass = %s",
$ilDB->quote($points . ""),
$ilDB->quote($active_id . ""),
$ilDB->quote($question_id . ""),
$ilDB->quote($pass . "")
);
}
else
{
$query = sprintf("INSERT INTO tst_test_result (active_fi, question_fi, points, pass) VALUES (%s, %s, %s, %s)",
$ilDB->quote($active_id . ""),
$ilDB->quote($question_id . ""),
$ilDB->quote($points . ""),
$ilDB->quote($pass . "")
);
}
$result = $ilDB->query($query);
if (PEAR::isError($result))
{
global $ilias;
$ilias->raiseError($result->getMessage());
}
// 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 
)

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

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

Referenced by _setReachedPoints(), saveWorkingData(), and assTextQuestion\setReachedPoints().

{
global $ilDB;
include_once "./Modules/Test/classes/class.ilObjTest.php";
// update test pass results
$query = sprintf("SELECT SUM(points) AS reachedpoints, COUNT(question_fi) AS answeredquestions FROM tst_test_result WHERE active_fi = %s AND pass = %s",
$ilDB->quote($active_id . ""),
$ilDB->quote($pass . "")
);
$result = $ilDB->query($query);
if ($result->numRows() > 0)
{
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
$newresultquery = sprintf("REPLACE INTO tst_test_pass_result SET active_fi = %s, pass = %s, points = %s, maxpoints = %s, questioncount = %s, answeredquestions = %s, workingtime = %s",
$ilDB->quote($active_id . ""),
$ilDB->quote($pass . ""),
$ilDB->quote((($row["reachedpoints"]) ? $row["reachedpoints"] : 0) . ""),
$ilDB->quote($data["points"]),
$ilDB->quote($data["count"]),
$ilDB->quote($row["answeredquestions"]),
$ilDB->quote($time)
);
$ilDB->query($newresultquery);
}
}

+ 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 2438 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::assQuestion (   $title = "",
  $comment = "",
  $author = "",
  $owner = -1,
  $question = "" 
)

assQuestion constructor

The constructor takes possible arguments an creates an instance of the assQuestion object.

Parameters
string$titleA title string to describe the question
string$commentA comment string to describe the question
string$authorA string containing the name of the questions author
integer$ownerA numerical ID to identify the owner/creator public

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

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

Referenced by assClozeTest\assClozeTest(), assImagemapQuestion\assImagemapQuestion(), assJavaApplet\assJavaApplet(), assMatchingQuestion\assMatchingQuestion(), assMultipleChoice\assMultipleChoice(), assNumeric\assNumeric(), assOrderingQuestion\assOrderingQuestion(), assQuestionTypeTemplate\assQuestionTypeTemplate(), assSingleChoice\assSingleChoice(), assTextQuestion\assTextQuestion(), and assTextSubset\assTextSubset().

{
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->author = $author;
if (!$this->author)
{
$this->author = $this->ilias->account->fullname;
}
$this->owner = $owner;
if ($this->owner == -1)
{
$this->owner = $this->ilias->account->id;
}
$this->id = -1;
$this->test_id = -1;
$this->suggested_solutions = array();
$this->shuffle = 1;
$this->setEstimatedWorkingTime(0,1,0);
$this->outputType = OUTPUT_HTML;
register_shutdown_function(array(&$this, '_assQuestion'));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::calculateReachedPoints (   $active_id,
  $pass = NULL,
  $points = 0 
)

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

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

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

Reimplemented in assClozeTest.

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

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

Referenced by saveWorkingData().

{
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::cleanupMediaObjectUsage ( )

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

Definition at line 2786 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 1574 of file class.assQuestion.php.

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::copyXHTMLMediaObjectsOfQuestion (   $a_q_id)

Definition at line 1554 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 2475 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::createPageObject ( )

create page object of question

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

References getId(), and getObjId().

Referenced by assQuestionTypeTemplate\saveToDb(), assNumeric\saveToDb(), assOrderingQuestion\saveToDb(), assMultipleChoice\saveToDb(), assSingleChoice\saveToDb(), assMatchingQuestion\saveToDb(), assTextQuestion\saveToDb(), assTextSubset\saveToDb(), assImagemapQuestion\saveToDb(), assClozeTest\saveToDb(), assJavaApplet\saveToDb(), 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 assTextQuestion.

Definition at line 2065 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 1371 of file class.assQuestion.php.

References $mobs, $obj_id, $result, ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), ilObjQuestionPool\_updateQuestionCount(), ilUtil\delDir(), deleteAdditionalTableData(), deleteAnswers(), and deletePageOfQuestion().

{
global $ilDB;
if ($question_id < 1)
return;
$query = sprintf("SELECT obj_fi FROM qpl_questions WHERE question_id = %s",
$ilDB->quote($question_id)
);
$result = $ilDB->query($query);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
$obj_id = $row["obj_fi"];
}
else
{
return;
}
$this->deletePageOfQuestion($question_id);
$query = sprintf("DELETE FROM qpl_questions WHERE question_id = %s",
$ilDB->quote($question_id)
);
$result = $ilDB->query($query);
$this->deleteAdditionalTableData($question_id);
$this->deleteAnswers($question_id);
// delete the question in the tst_test_question table (list of test questions)
$querydelete = sprintf("DELETE FROM tst_test_question WHERE question_fi = %s", $ilDB->quote($question_id));
$deleteresult = $ilDB->query($querydelete);
// delete suggested solutions contained in the question
$querydelete = sprintf("DELETE FROM qpl_suggested_solutions WHERE question_fi = %s", $ilDB->quote($question_id));
$deleteresult = $ilDB->query($querydelete);
$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);
}
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();
}
}
// update question count of question pool
include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
}

+ Here is the call graph for this function:

assQuestion::deleteAdditionalTableData (   $question_id)

Deletes datasets from the additional question table in the database.

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 1323 of file class.assQuestion.php.

References $result, and 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))
{
$query = sprintf("DELETE FROM $table WHERE question_fi = %s",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
}
}
}
else
{
if (strlen($additional_table_name))
{
$query = sprintf("DELETE FROM $additional_table_name WHERE question_fi = %s",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
}
}
}

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

Deletes datasets from answers tables

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

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

References $result, and 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))
{
$query = sprintf("DELETE FROM $table WHERE question_fi = %s",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
}
}
}
else
{
if (strlen($answer_table_name))
{
$query = sprintf("DELETE FROM $answer_table_name WHERE question_fi = %s",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
}
}
}

+ Here is the call graph for this function:

+ 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 1358 of file class.assQuestion.php.

Referenced by delete(), and syncWithOriginal().

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

+ Here is the caller graph for this function:

assQuestion::deleteSuggestedSolutions ( )

Deletes all suggestes solutions in the database.

Deletes all suggestes solutions in the database

public

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

References $result, ilInternalLink\_deleteAllLinksOfSource(), and getId().

{
global $ilDB;
// delete the links in the qpl_suggested_solutions table
$query = sprintf("DELETE FROM qpl_suggested_solutions WHERE question_fi = %s",
$ilDB->quote($this->getId() . "")
);
$result = $ilDB->query($query);
// 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:

assQuestion::duplicateFeedbackGeneric (   $original_id)

Duplicates the generic feedback of a question.

Duplicates the generic feedback of a question

Parameters
integer$original_idThe database ID of the original question public

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

References $original_id, and $result.

{
global $ilDB;
$feedback = "";
$query = sprintf("SELECT * FROM qpl_feedback_generic WHERE question_fi = %s",
$ilDB->quote($original_id . "")
);
$result = $ilDB->query($query);
if ($result->numRows())
{
while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
{
$duplicatequery = sprintf("INSERT INTO qpl_feedback_generic VALUES (NULL, %s, %s, %s, NULL)",
$ilDB->quote($this->getId() . ""),
$ilDB->quote($row["correctness"] . ""),
$ilDB->quote($row["feedback"] . "")
);
$duplicateresult = $ilDB->query($duplicatequery);
}
}
}
assQuestion::fromXML ( $item,
$questionpool_id,
$tst_id,
$tst_object,
$question_counter,
$import_mapping 
)

Creates a question from a QTI file.

Receives parameters from a QTI parser and creates a valid ILIAS question object

Parameters
object$itemThe QTI item object
integer$questionpool_idThe id of the parent questionpool
integer$tst_idThe id of the parent test if the question is part of a test
object$tst_objectA reference to the parent test object
integer$question_counterA reference to a question counter to count the questions of an imported question pool
array$import_mappingAn array containing references to included ILIAS objects public

Definition at line 259 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 2869 of file class.assQuestion.php.

References $result.

{
global $ilDB;
$query = sprintf("SELECT * FROM tst_active WHERE active_id = %s",
$ilDB->quote($active_id . "")
);
$result = $ilDB->query($query);
if ($result->numRows())
{
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
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 the name of the additional question data table in the database

Returns
string The additional table name public

Reimplemented in assClozeTest, assMatchingQuestion, assJavaApplet, assOrderingQuestion, assImagemapQuestion, assTextSubset, assMultipleChoice, assSingleChoice, assTextQuestion, assNumeric, and assQuestionTypeTemplate.

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

Referenced by deleteAdditionalTableData().

{
return "";
}

+ Here is the caller graph for this function:

assQuestion::getAnswerTableName ( )

Returns the name of the answer table in the database.

Returns the name of the answer table in the database

Returns
string The answer table name public

Reimplemented in assClozeTest, assMatchingQuestion, assOrderingQuestion, assImagemapQuestion, assTextSubset, assMultipleChoice, assSingleChoice, and assQuestionTypeTemplate.

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

Referenced by deleteAnswers().

{
return "";
}

+ Here is the caller graph for this function:

assQuestion::getAuthor ( )

Gets the authors name.

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 610 of file class.assQuestion.php.

References $author.

Referenced by assQuestionTypeTemplate\isComplete(), assClozeTest\isComplete(), and assClozeTest\saveToDb().

{
return $this->author;
}

+ Here is the caller graph for this function:

assQuestion::getComment ( )

Gets the comment.

Gets the comment string of the assQuestion object

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

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

References $comment.

Referenced by assClozeTest\saveToDb().

{
}

+ Here is the caller graph for this function:

assQuestion::getEstimatedWorkingTime ( )

Gets the estimated working time of a question.

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 592 of file class.assQuestion.php.

References $est_working_time.

Referenced by assQuestionTypeTemplate\saveToDb(), assNumeric\saveToDb(), assOrderingQuestion\saveToDb(), assMultipleChoice\saveToDb(), assSingleChoice\saveToDb(), assMatchingQuestion\saveToDb(), assTextQuestion\saveToDb(), assTextSubset\saveToDb(), assImagemapQuestion\saveToDb(), assClozeTest\saveToDb(), and assJavaApplet\saveToDb().

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

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 2685 of file class.assQuestion.php.

References $result, and ilRTE\_replaceMediaObjectImageSrc().

Referenced by getRTETextWithMediaObjects().

{
global $ilDB;
$feedback = "";
$query = sprintf("SELECT * FROM qpl_feedback_generic WHERE question_fi = %s AND correctness = %s",
$ilDB->quote($this->getId() . ""),
$ilDB->quote($correctness . "")
);
$result = $ilDB->query($query);
if ($result->numRows())
{
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
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::getFlashPath ( )

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

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 1048 of file class.assQuestion.php.

{
return CLIENT_WEB_DIR . "/assessment/$this->obj_id/$this->id/flash/";
}
assQuestion::getFlashPathWeb ( )

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

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 1091 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::getId ( )

Gets the id.

Gets the id of the assQuestion object

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

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

References $id.

Referenced by addQTIMaterial(), assQuestionTypeTemplate\calculateReachedPoints(), assTextQuestion\calculateReachedPoints(), assNumeric\calculateReachedPoints(), assSingleChoice\calculateReachedPoints(), assMultipleChoice\calculateReachedPoints(), assTextSubset\calculateReachedPoints(), assOrderingQuestion\calculateReachedPoints(), assJavaApplet\calculateReachedPoints(), assImagemapQuestion\calculateReachedPoints(), assMatchingQuestion\calculateReachedPoints(), assClozeTest\calculateReachedPoints(), cleanupMediaObjectUsage(), assQuestionTypeTemplate\copyObject(), assClozeTest\copyObject(), copyXHTMLMediaObjectsOfQuestion(), createPageObject(), deleteSuggestedSolutions(), assTextQuestion\duplicate(), assImagemapQuestion\duplicate(), assOrderingQuestion\duplicate(), assSingleChoice\duplicate(), assTextSubset\duplicate(), assMultipleChoice\duplicate(), assNumeric\duplicate(), assMatchingQuestion\duplicate(), assJavaApplet\duplicate(), assClozeTest\duplicate(), assJavaApplet\getReachedInformation(), getReachedPoints(), getSolutionMaxPass(), getSolutionValues(), insertIntoTest(), saveSuggestedSolution(), assQuestionTypeTemplate\saveToDb(), assClozeTest\saveToDb(), saveToDb(), assQuestionTypeTemplate\saveWorkingData(), assTextQuestion\saveWorkingData(), assNumeric\saveWorkingData(), assSingleChoice\saveWorkingData(), assMultipleChoice\saveWorkingData(), assTextSubset\saveWorkingData(), assImagemapQuestion\saveWorkingData(), assOrderingQuestion\saveWorkingData(), saveWorkingData(), assMatchingQuestion\saveWorkingData(), assClozeTest\saveWorkingData(), assTextQuestion\setReachedPoints(), syncWithOriginal(), and syncXHTMLMediaObjectsOfQuestion().

{
return $this->id;
}

+ Here is the caller graph for this function:

assQuestion::getImagePathWeb ( )

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

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 1076 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/images/";
}

+ Here is the call graph for this function:

& assQuestion::getInstances ( )

Gets all instances of the question.

Returns
array All instances of question and its copies

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

References $result, and ilObjTest\_lookupAuthor().

{
global $ilDB;
$query = sprintf("SELECT question_id FROM qpl_questions WHERE original_id = %s",
$ilDB->quote($this->getId())
);
$result = $ilDB->query($query);
$instances = array();
$ids = array();
while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
{
array_push($ids, $row["question_id"]);
}
foreach ($ids as $question_id)
{
$query = sprintf("SELECT DISTINCT object_data.obj_id, object_data.title FROM tst_test_question, object_data, tst_tests WHERE question_fi = %s AND tst_tests.test_id = tst_test_question.test_fi AND object_data.obj_id = tst_tests.obj_fi",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
{
$instances[$row["obj_id"]] = $row["title"];
}
$query = sprintf("SELECT DISTINCT object_data.obj_id, object_data.title FROM tst_test_random_question, tst_active, object_data, tst_tests WHERE tst_test_random_question.active_fi = tst_active.active_id AND tst_test_random_question.question_fi = %s AND tst_tests.test_id = tst_active.test_fi AND object_data.obj_id = tst_tests.obj_fi",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
{
$instances[$row["obj_id"]] = $row["title"];
}
}
include_once "./Modules/Test/classes/class.ilObjTest.php";
foreach ($instances as $key => $value)
{
$query = sprintf("SELECT object_reference.ref_id FROM object_reference WHERE obj_id = %s",
$ilDB->quote($key . "")
);
$result = $ilDB->query($query);
$refs = array();
while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
{
array_push($refs, $row["ref_id"]);
}
$instances[$key] = array("obj_id" => $key, "title" => $value, "author" => ilObjTest::_lookupAuthor($key), "refs" => $refs);
}
return $instances;
}

+ Here is the call graph for this function:

assQuestion::getJavaPath ( )

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

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

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

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

public

See Also
$points

Reimplemented in assMatchingQuestion, assClozeTest, assOrderingQuestion, assImagemapQuestion, assMultipleChoice, assSingleChoice, assJavaApplet, assNumeric, assTextSubset, assTextQuestion, and assQuestionTypeTemplate.

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

Referenced by calculateReachedPoints().

{
return 0;
}

+ Here is the caller graph for this function:

assQuestion::getMultilineAnswerSetting ( )

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

{
global $ilUser;
$multilineAnswerSetting = $ilUser->getPref("tst_multiline_answers");
if ($multilineAnswerSetting != 1)
{
$multilineAnswerSetting = 0;
}
return $multilineAnswerSetting;
}
assQuestion::getObjId ( )

Get the object id of the container object.

Get the object id of the container object

Returns
integer The object id of the container object public
See Also
$obj_id

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

References $obj_id.

Referenced by assQuestionTypeTemplate\copyObject(), assTextQuestion\copyObject(), assImagemapQuestion\copyObject(), assOrderingQuestion\copyObject(), assSingleChoice\copyObject(), assTextSubset\copyObject(), assMultipleChoice\copyObject(), assNumeric\copyObject(), assMatchingQuestion\copyObject(), assJavaApplet\copyObject(), assClozeTest\copyObject(), createPageObject(), and assClozeTest\saveToDb().

{
return $this->obj_id;
}

+ Here is the caller graph for this function:

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

Gets the output type.

Gets the output type

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

Reimplemented in assMultipleChoice, and assSingleChoice.

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

References $outputType.

Referenced by assOrderingQuestion\checkSaveData().

{
}

+ Here is the caller graph for this function:

assQuestion::getOwner ( )

Gets the creator/owner.

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 624 of file class.assQuestion.php.

References $owner.

Referenced by assClozeTest\saveToDb().

{
return $this->owner;
}

+ Here is the caller graph for this function:

assQuestion::getPageOfQuestion ( )

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

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

Returns the maximum available points for the question.

Returns the maximum available points for the question

Returns
integer The points public

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

References $points.

Referenced by assTextQuestion\saveToDb(), and assTextQuestion\setReachedPoints().

{
if (strcmp($this->points, "") == 0)
{
return 0;
}
else
{
return $this->points;
}
}

+ Here is the caller graph for this function:

assQuestion::getQuestion ( )

Gets the question text.

Gets the question string of the question object

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

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

References $question.

Referenced by getRTETextWithMediaObjects(), and assQuestionTypeTemplate\isComplete().

{
}

+ Here is the caller graph for this function:

assQuestion::getQuestionType ( )

Returns the question type of the question.

Returns the question type of the question

Returns
integer The question type of the question public

Reimplemented in assClozeTest, assMatchingQuestion, assJavaApplet, assOrderingQuestion, assImagemapQuestion, assMultipleChoice, assSingleChoice, assTextSubset, assNumeric, assTextQuestion, and assQuestionTypeTemplate.

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

Referenced by fromXML(), 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 1239 of file class.assQuestion.php.

References $data, and $result.

Referenced by assQuestionGUI\_getGUIClassNameForId(), assQuestionGUI\_getQuestionGUI(), and ilObjQuestionPoolGUI\getEmbeddedTabs().

{
global $ilDB;
$query = sprintf("SELECT qpl_question_type.type_tag FROM qpl_question_type, qpl_questions WHERE qpl_questions.question_id = %s AND qpl_questions.question_type_fi = qpl_question_type.question_type_id",
$ilDB->quote($question_id));
$result = $ilDB->query($query);
$data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
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 2616 of file class.assQuestion.php.

References $result.

Referenced by assNumeric\saveToDb(), assOrderingQuestion\saveToDb(), assMultipleChoice\saveToDb(), assMatchingQuestion\saveToDb(), assTextQuestion\saveToDb(), assTextSubset\saveToDb(), assImagemapQuestion\saveToDb(), assClozeTest\saveToDb(), and assJavaApplet\saveToDb().

{
global $ilDB;
$query = sprintf("SELECT question_type_id FROM qpl_question_type WHERE type_tag = %s",
$ilDB->quote($this->getQuestionType() . "")
);
$result = $ilDB->query($query);
if ($result->numRows() == 1)
{
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
return $row["question_type_id"];
}
return 0;
}

+ Here is the caller graph for this function:

assQuestion::getReachedPoints (   $active_id,
  $pass = NULL 
)

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

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 857 of file class.assQuestion.php.

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

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

+ 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, assJavaApplet, assImagemapQuestion, assOrderingQuestion, assTextSubset, assTextQuestion, assNumeric, and assQuestionTypeTemplate.

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

References getFeedbackGeneric(), and getQuestion().

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);
return $collected;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::getShuffle ( )

Gets the shuffle flag.

Gets the shuffle flag

Returns
boolean The shuffle flag public
See Also
$shuffle

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

References $shuffle.

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

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

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 1107 of file class.assQuestion.php.

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

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

{
global $ilDB;
$values = array();
if (is_null($pass))
{
$pass = $this->getSolutionMaxPass($active_id);
/*
$query = sprintf("SELECT MAX(pass) AS maxpass FROM tst_test_result WHERE active_fi = %s AND question_fi = %s",
$ilDB->quote($active_id . ""),
$ilDB->quote($this->getId() . "")
);
$result = $ilDB->query($query);
if ($result->numRows())
{
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
$pass = $row["maxpass"];
}
else
{
return $values;
}
*/
}
$query = sprintf("SELECT * FROM tst_solutions WHERE active_fi = %s AND question_fi = %s AND pass = %s",
$ilDB->quote($active_id . ""),
$ilDB->quote($this->getId() . ""),
$ilDB->quote($pass . "")
);
$result = $ilDB->query($query);
while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
{
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.

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 1764 of file class.assQuestion.php.

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

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

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

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 537 of file class.assQuestion.php.

References $test_id.

Referenced by assQuestionTypeTemplate\saveToDb(), assNumeric\saveToDb(), assOrderingQuestion\saveToDb(), assMultipleChoice\saveToDb(), assSingleChoice\saveToDb(), assMatchingQuestion\saveToDb(), assTextQuestion\saveToDb(), assTextSubset\saveToDb(), assImagemapQuestion\saveToDb(), assClozeTest\saveToDb(), and assJavaApplet\saveToDb().

{
}

+ Here is the caller graph for this function:

assQuestion::getTotalAnswers ( )

get total number of answers

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

References _getTotalAnswers().

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

+ Here is the call graph for this function:

assQuestion::insertIntoTest (   $test_id)

Insert the question into a test.

Insert the question into a test

Parameters
integer$test_idThe database id of the test private

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

References $data, $ilias, $result, $test_id, and getId().

Referenced by assQuestionTypeTemplate\saveToDb(), assNumeric\saveToDb(), assOrderingQuestion\saveToDb(), assMultipleChoice\saveToDb(), assSingleChoice\saveToDb(), assMatchingQuestion\saveToDb(), assTextQuestion\saveToDb(), assTextSubset\saveToDb(), assImagemapQuestion\saveToDb(), assClozeTest\saveToDb(), and assJavaApplet\saveToDb().

{
global $ilDB;
// get maximum sequence index in test
$query = sprintf("SELECT MAX(sequence) AS seq FROM dum_test_question WHERE test_fi=%s",
$ilDB->quote($test_id)
);
$result = $ilDB->query($query);
$sequence = 1;
if ($result->numRows() == 1)
{
$data = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
$sequence = $data->seq + 1;
}
$query = sprintf("INSERT INTO dum_test_question (test_question_id, test_fi, question_fi, sequence, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)",
$ilDB->quote($test_id),
$ilDB->quote($this->getId()),
$ilDB->quote($sequence)
);
$result = $ilDB->query($query);
if (PEAR::isError($result))
{
global $ilias;
$ilias->raiseError($result->getMessage());
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

assQuestion::isClone (   $question_id = "")

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

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 1185 of file class.assQuestion.php.

References $id, and $result.

{
global $ilDB;
if ($question_id < 1) $question_id = $this->id;
$query = sprintf("SELECT original_id FROM qpl_questions WHERE question_id = %s",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
$row = $result->fetchRow(MDB2_FETCHMODE_OBJECT);
if ($row->original_id > 0)
{
return TRUE;
}
else
{
return FALSE;
}
}
assQuestion::isComplete ( )

Returns true, if a question is complete for use.

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, assImagemapQuestion, assTextQuestion, assTextSubset, assMatchingQuestion, assMultipleChoice, assSingleChoice, assNumeric, assOrderingQuestion, and assQuestionTypeTemplate.

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

{
return false;
}
assQuestion::isHTML (   $a_text)

Checks if a given string contains HTML or not.

Parameters
string$a_textText which should be checked
Returns
boolean public

Definition at line 2375 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.

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 1156 of file class.assQuestion.php.

References $id, and $result.

{
global $ilDB;
if ($question_id < 1) $question_id = $this->id;
$query = sprintf("SELECT COUNT(qpl_questions.question_id) AS question_count FROM qpl_questions, tst_test_question WHERE qpl_questions.original_id = %s AND qpl_questions.question_id = tst_test_question.question_fi",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
$row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
$count = $row["question_count"];
$query = sprintf("SELECT DISTINCT tst_active.test_fi, qpl_questions.question_id FROM qpl_questions, tst_test_random_question, tst_active WHERE qpl_questions.original_id = %s AND qpl_questions.question_id = tst_test_random_question.question_fi AND tst_test_random_question.active_fi = tst_active.active_id",
$ilDB->quote($question_id . "")
);
$result = $ilDB->query($query);
$count += $result->numRows();
return $count;
}
assQuestion::keyInArray (   $searchkey,
  $array 
)

returns TRUE if the key occurs in an 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 439 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.

Loads the question from the database

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

Reimplemented in assImagemapQuestion, assJavaApplet, assMatchingQuestion, assTextSubset, assMultipleChoice, assSingleChoice, assNumeric, assOrderingQuestion, assTextQuestion, assQuestionTypeTemplate, and assClozeTest.

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

References $result.

{
global $ilDB;
$query = sprintf("SELECT * FROM qpl_suggested_solutions WHERE question_fi = %s",
$ilDB->quote($this->getId() . "")
);
$result = $ilDB->query($query);
$this->suggested_solutions = array();
if ($result->numRows())
{
while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
{
$this->suggested_solutions[$row["subquestion_index"]] = array(
"internal_link" => $row["internal_link"],
"import_id" => $row["import_id"]
);
}
}
}
assQuestion::logAction (   $logtext = "",
  $active_id = "",
  $question_id = "" 
)

Logs an action into the Test&Assessment log.

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 952 of file class.assQuestion.php.

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

Referenced by assTextQuestion\saveWorkingData(), assNumeric\saveWorkingData(), assSingleChoice\saveWorkingData(), assMultipleChoice\saveWorkingData(), assTextSubset\saveWorkingData(), assImagemapQuestion\saveWorkingData(), assOrderingQuestion\saveWorkingData(), saveWorkingData(), assMatchingQuestion\saveWorkingData(), and assClozeTest\saveWorkingData().

{
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::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 998 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::pcArrayShuffle (   $array)

Shuffles the values of a given array.

Shuffles the values of a given array

Parameters
array$arrayAn array which should be shuffled public

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

{
mt_srand((double)microtime()*1000000);
$i = count($array);
if ($i > 0)
{
while(--$i)
{
$j = mt_rand(0, $i);
if ($i != $j)
{
// swap elements
$tmp = $array[$j];
$array[$j] = $array[$i];
$array[$i] = $tmp;
}
}
}
return $array;
}
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 2393 of file class.assQuestion.php.

{
include_once "./Services/Utilities/classes/class.ilUtil.php";
return ilUtil::prepareTextareaOutput($txt_output, $prepare_for_latex_output);
}
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 2406 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.

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 306 of file class.assQuestion.php.

References $result, and $title.

{
global $ilDB;
$query = sprintf("SELECT * FROM qpl_questions WHERE obj_fi = %s AND title = %s",
$ilDB->quote($questionpool_id . ""),
$ilDB->quote($title)
);
$result = $ilDB->query($query);
if ($result->numRows() == 1)
{
return TRUE;
}
return FALSE;
}
assQuestion::saveFeedbackGeneric (   $correctness,
  $feedback 
)

Saves generic feedback to the database.

Saves generic feedback to the database. Generic feedback is either feedback for 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
string$feedbackFeedback text public

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

References $result, and ilRTE\_replaceMediaObjectImageSrc().

{
global $ilDB;
switch ($correctness)
{
case 0:
$correctness = 0;
break;
case 1:
default:
$correctness = 1;
break;
}
$query = sprintf("DELETE FROM qpl_feedback_generic WHERE question_fi = %s AND correctness = %s",
$ilDB->quote($this->getId() . ""),
$ilDB->quote($correctness . "")
);
$result = $ilDB->query($query);
if (strlen($feedback))
{
include_once("./Services/RTE/classes/class.ilRTE.php");
$query = sprintf("INSERT INTO qpl_feedback_generic VALUES (NULL, %s, %s, %s, NULL)",
$ilDB->quote($this->getId() . ""),
$ilDB->quote($correctness . ""),
$ilDB->quote(ilRTE::_replaceMediaObjectImageSrc($feedback, 0))
);
$result = $ilDB->query($query);
}
}

+ Here is the call graph for this function:

assQuestion::saveSuggestedSolution (   $solution_id = "",
  $subquestion_index = 0 
)

Saves 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 1837 of file class.assQuestion.php.

References $data, and getId().

{
global $ilDB;
$statement = $ilDB->prepareManip("DELETE FROM qpl_suggested_solutions WHERE question_fi = ? AND subquestion_index = ?",
array("integer", "integer")
);
$data = array(
$this->getId(),
$subquestion_index
);
$affectedRows = $ilDB->execute($statement, $data);
$statement = $ilDB->prepareManip("INSERT INTO qpl_suggested_solutions (question_fi, internal_link, import_id, subquestion_index) VALUES (?, ?, ?, ?)",
array("integer", "text", "text", "integer")
);
$data = array(
$this->getId(),
$solution_id,
"",
$subquestion_index
);
$affectedRows = $ilDB->execute($statement, $data);
}

+ Here is the call graph for this function:

assQuestion::saveToDb (   $original_id = "")

Saves the question to the database.

Saves the question to the database

Parameters
integer$original_idpublic

Reimplemented in assJavaApplet, assClozeTest, assImagemapQuestion, assTextQuestion, assTextSubset, assMatchingQuestion, assSingleChoice, assMultipleChoice, assNumeric, assOrderingQuestion, and assQuestionTypeTemplate.

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

References $result, ilInternalLink\_deleteAllLinksOfSource(), ilInternalLink\_saveLink(), ilObjQuestionPool\_updateQuestionCount(), cleanupMediaObjectUsage(), and getId().

Referenced by syncWithOriginal().

{
global $ilDB;
include_once "./Services/COPage/classes/class.ilInternalLink.php";
$query = sprintf("DELETE FROM qpl_suggested_solutions WHERE question_fi = %s",
$ilDB->quote($this->getId() . "")
);
$result = $ilDB->query($query);
foreach ($this->suggested_solutions as $index => $solution)
{
$query = sprintf("INSERT INTO qpl_suggested_solutions (suggested_solution_id, question_fi, internal_link, import_id, subquestion_index, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL)",
$ilDB->quote($this->getId() . ""),
$ilDB->quote($solution["internal_link"] . ""),
$ilDB->quote($solution["import_id"] . ""),
$ilDB->quote($index . "")
);
$ilDB->query($query);
if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches))
{
ilInternalLink::_saveLink("qst", $this->getId(), $matches[2], $matches[3], $matches[1]);
}
}
// remove unused media objects from ILIAS
// update question count of question pool
include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
// update the question time stamp
$query = sprintf("UPDATE qpl_questions SET TIMESTAMP = NULL WHERE question_id = %s",
$this->getId()
);
$ilDB->query($query);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Saves the learners input of the question to the database.

Saves the learners input of the question to the database

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

Reimplemented in assClozeTest, assMatchingQuestion, assJavaApplet, assOrderingQuestion, assImagemapQuestion, assTextSubset, assMultipleChoice, assSingleChoice, assNumeric, assTextQuestion, and assQuestionTypeTemplate.

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

References $pass, $result, ilObjAssessmentFolder\_enabledAssessmentLogging(), ilObjAssessmentFolder\_getLogLanguage(), ilObjTest\_getPass(), ilCourseObjectiveResult\_updateObjectiveResult(), _updateTestPassResults(), calculateReachedPoints(), getId(), and logAction().

{
global $ilDB;
global $ilUser;
if (is_null($pass))
{
include_once "./Modules/Test/classes/class.ilObjTest.php";
$pass = ilObjTest::_getPass($active_id);
}
$reached_points = $this->calculateReachedPoints($active_id, $pass);
$query = sprintf("REPLACE INTO tst_test_result (active_fi, question_fi, pass, points) VALUES (%s, %s, %s, %s)",
$ilDB->quote($active_id . ""),
$ilDB->quote($this->getId() . ""),
$ilDB->quote($pass . ""),
$ilDB->quote($reached_points . "")
);
$result = $ilDB->query($query);
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);
// 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:

assQuestion::setAuthor (   $author = "")

Sets the authors name.

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

References $author.

Referenced by assClozeTest\loadFromDb().

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

+ Here is the caller graph for this function:

assQuestion::setComment (   $comment = "")

Sets the comment.

Sets the comment string of the assQuestion object

Parameters
string$commentA comment string to describe the question public
See Also
$comment

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

References $comment.

Referenced by assClozeTest\loadFromDb(), and assQuestionTypeTemplate\loadFromDb().

{
$this->comment = $comment;
}

+ Here is the caller graph for this function:

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

Sets the estimated working time of a question.

Sets the estimated working time of a question

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

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

Referenced by assQuestion(), assClozeTest\loadFromDb(), assTextQuestion\loadFromDb(), assOrderingQuestion\loadFromDb(), assNumeric\loadFromDb(), assSingleChoice\loadFromDb(), assMultipleChoice\loadFromDb(), assTextSubset\loadFromDb(), assMatchingQuestion\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, assJavaApplet, assImagemapQuestion, assOrderingQuestion, assTextSubset, assTextQuestion, assNumeric, and assQuestionTypeTemplate.

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

{
return $startrow;
}
assQuestion::setId (   $id = -1)

Sets the id.

Sets the id of the assQuestion object

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

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

References $id.

Referenced by assClozeTest\loadFromDb(), assQuestionTypeTemplate\loadFromDb(), assQuestionTypeTemplate\saveToDb(), assClozeTest\saveToDb(), and syncWithOriginal().

{
$this->id = $id;
}

+ Here is the caller graph for this function:

assQuestion::setMultilineAnswerSetting (   $a_setting = 0)

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

{
global $ilUser;
$ilUser->writePref("tst_multiline_answers", $a_setting);
}
assQuestion::setObjId (   $obj_id = 0)

Set the object id of the container object.

Set the object id of the container object

Parameters
integer$obj_idThe object id of the container object public
See Also
$obj_id

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

References $obj_id.

Referenced by assClozeTest\loadFromDb().

{
$this->obj_id = $obj_id;
}

+ Here is the caller graph for this function:

assQuestion::setOriginalId (   $original_id)

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

References $original_id.

Referenced by assClozeTest\loadFromDb(), and syncWithOriginal().

{
$this->original_id = $original_id;
}

+ Here is the caller graph for this function:

assQuestion::setOutputType (   $outputType = OUTPUT_HTML)

Sets the output type.

Sets the output type

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

Reimplemented in assMultipleChoice, and assSingleChoice.

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

References $outputType.

{
$this->outputType = $outputType;
}
assQuestion::setOwner (   $owner = "")

Sets the creator/owner.

Sets the creator/owner ID of the assQuestion object

Parameters
integer$ownerA numerical ID to identify the owner/creator public
See Also
$owner

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

References $owner.

Referenced by assClozeTest\loadFromDb().

{
$this->owner = $owner;
}

+ Here is the caller graph for this function:

assQuestion::setPoints (   $a_points)

Sets the maximum available points for the question.

Sets the maximum available points for the question

Parameters
integer$a_pointsThe points public

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

Referenced by assClozeTest\loadFromDb().

{
$this->points = $a_points;
}

+ Here is the caller graph for this function:

assQuestion::setQuestion (   $question = "")

Sets the question text.

Sets the question string of the question object

Parameters
string$questionA string containing the question text public
See Also
$question

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

References $question.

Referenced by assQuestion(), and assClozeTest\loadFromDb().

{
$this->question = $question;
}

+ Here is the caller graph for this function:

assQuestion::setShuffle (   $shuffle = true)

Sets the shuffle flag.

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 402 of file class.assQuestion.php.

References $shuffle.

Referenced by 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.

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 1811 of file class.assQuestion.php.

References _resolveInternalLink().

{
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:

assQuestion::setTestId (   $id = -1)

Sets the test id.

Sets the test id of the assQuestion object

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

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

References $id.

{
$this->test_id = $id;
}
assQuestion::setTitle (   $title = "")

Sets the title string.

Sets the title string of the assQuestion object

Parameters
string$titleA title string to describe the question public
See Also
$title

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

References $title.

Referenced by assClozeTest\loadFromDb(), and assQuestionTypeTemplate\loadFromDb().

{
$this->title = $title;
}

+ Here is the caller graph for this function:

assQuestion::supportsJavascriptOutput ( )

Returns true if the question type supports JavaScript output.

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 578 of file class.assQuestion.php.

{
return FALSE;
}
assQuestion::syncFeedbackGeneric ( )

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

References $result.

Referenced by syncWithOriginal().

{
global $ilDB;
$feedback = "";
// delete generic feedback of the original
$deletequery = sprintf("DELETE FROM qpl_feedback_generic WHERE question_fi = %s",
$ilDB->quote($this->original_id . "")
);
$result = $ilDB->query($deletequery);
// get generic feedback of the actual question
$query = sprintf("SELECT * FROM qpl_feedback_generic WHERE question_fi = %s",
$ilDB->quote($this->getId() . "")
);
$result = $ilDB->query($query);
// save generic feedback to the original
if ($result->numRows())
{
while ($row = $result->fetchRow(MDB2_FETCHMODE_ASSOC))
{
$duplicatequery = sprintf("INSERT INTO qpl_feedback_generic VALUES (NULL, %s, %s, %s, NULL)",
$ilDB->quote($this->original_id . ""),
$ilDB->quote($row["correctness"] . ""),
$ilDB->quote($row["feedback"] . "")
);
$duplicateresult = $ilDB->query($duplicatequery);
}
}
}

+ Here is the caller graph for this function:

assQuestion::syncWithOriginal ( )

Reimplemented in assImagemapQuestion, assMultipleChoice, assSingleChoice, and assQuestionTypeTemplate.

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

References $id, $result, ilInternalLink\_deleteAllLinksOfSource(), ilInternalLink\_saveLink(), copyPageOfQuestion(), createPageObject(), deletePageOfQuestion(), getId(), getOriginalId(), saveToDb(), setId(), setOriginalId(), syncFeedbackGeneric(), and syncXHTMLMediaObjectsOfQuestion().

{
global $ilDB;
if ($this->getOriginalId())
{
$id = $this->getId();
$original = $this->getOriginalId();
$this->setId($this->getOriginalId());
$this->setOriginalId(NULL);
$this->saveToDb();
$this->deletePageOfQuestion($original);
$this->createPageObject();
$this->setId($id);
$this->setOriginalId($original);
include_once "./Services/COPage/classes/class.ilInternalLink.php";
$query = sprintf("DELETE FROM qpl_suggested_solutions WHERE question_fi = %s",
$ilDB->quote($this->getOriginalId() . "")
);
$result = $ilDB->query($query);
ilInternalLink::_deleteAllLinksOfSource("qst", $this->original_id);
foreach ($this->suggested_solutions as $index => $solution)
{
$query = sprintf("INSERT INTO qpl_suggested_solutions (suggested_solution_id, question_fi, internal_link, import_id, subquestion_index, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL)",
$ilDB->quote($this->getOriginalId() . ""),
$ilDB->quote($solution["internal_link"] . ""),
$ilDB->quote($solution["import_id"] . ""),
$ilDB->quote($index . "")
);
$ilDB->query($query);
if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $solution["internal_link"], $matches))
{
ilInternalLink::_saveLink("qst", $this->getOriginalId(), $matches[2], $matches[3], $matches[1]);
}
}
}
}

+ Here is the call graph for this function:

assQuestion::syncXHTMLMediaObjectsOfQuestion ( )

Definition at line 1564 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 a QTI xml representation of the question and sets the internal domxml variable with the DOM XML representation of the QTI xml representation

Returns
string The QTI xml representation of the question public

Definition at line 276 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::$domxml

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

assQuestion::$est_working_time

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

Referenced by getEstimatedWorkingTime().

assQuestion::$lng

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

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

assQuestion::$obj_id

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

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

assQuestion::$outputType

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

Referenced by getOutputType(), and setOutputType().

assQuestion::$shuffle
assQuestion::$suggested_solutions

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

assQuestion::$test_id

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

Referenced by getTestId(), and insertIntoTest().

assQuestion::$tpl

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

Referenced by assQuestion().


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