Basic class for all assessment question types. More...
Public Member Functions | |
assQuestion ($title="", $comment="", $author="", $owner=-1) | |
assQuestion constructor | |
_assQuestion () | |
to_xml () | |
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. | |
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. | |
logAction ($logtext="", $active_id="", $question_id="") | |
Logs an action into the Test&Assessment log. | |
getJavaPath () | |
Returns the image path for web accessable images of a question. | |
getImagePath () | |
Returns the image path for web accessable images 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. | |
& | 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 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) | |
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. | |
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. | |
_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. | |
getSolutionCommentMCScoring ($active_id) | |
getSolutionCommentScoreCutting ($active_id) | |
getSolutionCommentCountSystem ($active_id) | |
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) | |
& | getInstances () |
Gets all instances of the question. | |
getActiveUserData ($active_id) | |
Returns the user id and the test id for a given active id. | |
Data Fields | |
$id | |
$title | |
$comment | |
$owner | |
$author | |
$points | |
$est_working_time | |
$shuffle | |
$test_id | |
$obj_id | |
$ilias | |
$tpl | |
$lng | |
$domxml | |
$outputType | |
$suggested_solutions |
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.
class.assQuestion.php Assessment
Definition at line 37 of file class.assQuestion.php.
assQuestion::_areAnswered | ( | $ | a_user_id, | |
$ | a_question_ids | |||
) |
Checks if an array of question ids is answered by an user or not.
int | user_id | |
array | $question_ids user id array |
Definition at line 2108 of file class.assQuestion.php.
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; }
assQuestion::_assQuestion | ( | ) |
Definition at line 226 of file class.assQuestion.php.
{
if (!empty($this->domxml))
{
$this->domxml->free();
}
}
assQuestion::_getInternalLinkHref | ( | $ | target = "" |
) |
Definition at line 1694 of file class.assQuestion.php.
References $target_id, and $type.
Referenced by assTextSubsetGUI::editQuestion(), assTextQuestionGUI::editQuestion(), assSingleChoiceGUI::editQuestion(), assOrderingQuestionGUI::editQuestion(), assNumericGUI::editQuestion(), assMultipleChoiceGUI::editQuestion(), assMatchingQuestionGUI::editQuestion(), assJavaAppletGUI::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 "./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 = "./content/lm_presentation.php?obj_type=" . $linktypes[$type] . "&cmd=media&ref_id=".$_GET["ref_id"]."&mob_id=".$target_id; break; } } return $href; }
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
integer | $question_id The database Id of the question public |
Definition at line 672 of file class.assQuestion.php.
References $points, $query, $result, and $row.
Referenced by _getTotalRightAnswers(), ilObjTest::getTestResult(), and ilObjQuestionPoolGUI::questionsObject().
{ 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(DB_FETCHMODE_ASSOC); $points = $row["points"]; } return $points; }
assQuestion::_getOriginalId | ( | $ | question_id | ) |
Returns the original id of a question.
Returns the original id of a question
integer | $question_id The database id of the question |
Definition at line 1739 of file class.assQuestion.php.
References $query, $result, and $row.
Referenced by ilObjTest::_clone(), assTextSubset::copyObject(), assTextQuestion::copyObject(), assSingleChoice::copyObject(), assQuestionTypeTemplate::copyObject(), assOrderingQuestion::copyObject(), assNumeric::copyObject(), assMultipleChoice::copyObject(), assMatchingQuestion::copyObject(), assJavaApplet::copyObject(), assImagemapQuestion::copyObject(), assClozeTest::copyObject(), assTextSubset::duplicate(), assTextQuestion::duplicate(), assSingleChoice::duplicate(), assQuestionTypeTemplate::duplicate(), assOrderingQuestion::duplicate(), assNumeric::duplicate(), assMultipleChoice::duplicate(), assMatchingQuestion::duplicate(), assJavaApplet::duplicate(), assImagemapQuestion::duplicate(), assClozeTest::duplicate(), ilObjTest::logAction(), and 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(DB_FETCHMODE_ASSOC); if ($row["original_id"] > 0) { return $row["original_id"]; } else { return $row["question_id"]; } } else { return ""; } }
& assQuestion::_getQuestionInfo | ( | $ | question_id | ) |
Returns question information from the database.
Returns question information from the database
integer | $question_id The database Id of the question |
Definition at line 698 of file class.assQuestion.php.
References $query, and $result.
Referenced by 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(DB_FETCHMODE_ASSOC); } else return array(); }
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
integer | $question_id The database id of the question |
Definition at line 1428 of file class.assQuestion.php.
References $data, $query, 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(DB_FETCHMODE_ASSOC); return $data["title"]; } else { return ""; } }
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
integer | $question_id The database id of the question |
Definition at line 1401 of file class.assQuestion.php.
References $data, $query, and $result.
Referenced by ilObjTest::_instanciateQuestion(), _instanciateQuestion(), and ilObjQuestionPoolGUI::printObject().
{ 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(DB_FETCHMODE_OBJECT); return $data->type_tag; } else { return ""; } }
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
integer | $user_id The database ID of the learner | |
integer | $test_id The database Id of the test containing the question | |
integer | $question_id The database Id of the question public static |
Definition at line 776 of file class.assQuestion.php.
References $points, $query, $result, $row, and _getSolutionMaxPass().
Referenced by ilObjTestAccess::_getTestResult(), and ilObjTest::getTestResult().
{ global $ilDB; $points = 0; if (is_null($pass)) { include_once "./assessment/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(DB_FETCHMODE_ASSOC); $points = $row["points"]; } return $points; }
assQuestion::_getSolutionMaxPass | ( | $ | question_id, | |
$ | active_id | |||
) |
Returns the maximum pass a users question solution.
Returns the maximum pass a users question solution
return | integer The maximum pass of the users solution public |
Definition at line 1936 of file class.assQuestion.php.
References $query, $result, and $row.
Referenced by _getReachedPoints(), _isWorkedThrough(), assTextQuestion::_setReachedPoints(), getSolutionMaxPass(), and ilObjTest::getTextAnswer().
{ 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(DB_FETCHMODE_ASSOC); return $row["maxpass"]; } else { return 0; } }
& 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
integer | $question_id The database Id of the question | |
integer | $subquestion_index The index of a subquestion (i.e. a close test gap). Usually 0 |
Definition at line 743 of file class.assQuestion.php.
References $query, $result, and $row.
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(DB_FETCHMODE_ASSOC); return array( "internal_link" => $row["internal_link"], "import_id" => $row["import_id"] ); } else { return array(); } }
assQuestion::_getSuggestedSolutionCount | ( | $ | question_id | ) |
Returns the number of suggested solutions associated with a question.
Returns the number of suggested solutions associated with a question
integer | $question_id The database Id of the question |
Definition at line 722 of file class.assQuestion.php.
References $query, and $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(); }
assQuestion::_getTitle | ( | $ | a_q_id | ) |
Returns the title of a question.
int | $a_q_id question id |
Definition at line 1342 of file class.assQuestion.php.
References $query, $result, and $row.
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(DB_FETCHMODE_ASSOC); return $row["title"]; } else { return ""; } }
assQuestion::_getTotalAnswers | ( | $ | a_q_id | ) |
get number of answers for question id (static) note: do not use $this inside this method
int | $a_q_id question id |
Definition at line 1256 of file class.assQuestion.php.
References $query, $result, and $row.
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(DB_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(); }
assQuestion::_getTotalRightAnswers | ( | $ | a_q_id | ) |
get number of answers for question id (static) note: do not use $this inside this method
int | $a_q_id question id |
Definition at line 1292 of file class.assQuestion.php.
References $key, $query, $result, $row, 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(DB_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(DB_FETCHMODE_OBJECT)) { $reached = $row->points; include_once "./assessment/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; } }
& 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
integer | $question_id The question id |
Definition at line 1835 of file class.assQuestion.php.
References _getQuestionType().
{ if (strcmp($question_id, "") != 0) { include_once "./assessment/classes/class.assQuestion.php"; $question_type = assQuestion::_getQuestionType($question_id); include_once "./assessment/classes/class.".$question_type.".php"; $question = new $question_type(); $question->loadFromDb($question_id); return $question; } }
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
Definition at line 2000 of file class.assQuestion.php.
References $query, and $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(); }
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
integer | $user_id The database ID of the learner | |
integer | $test_id The database Id of the test containing the question | |
integer | $question_id The database Id of the question public static |
Definition at line 2056 of file class.assQuestion.php.
References $points, $query, $result, and _getSolutionMaxPass().
Referenced by ilObjTest::getAnsweredQuestionCount(), and ilObjTest::getTestResult().
{ global $ilDB; $points = 0; if (is_null($pass)) { include_once "./assessment/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; } }
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
integer | $question_id The database id of the question | |
integer | $user_id The database id of the user |
Definition at line 1966 of file class.assQuestion.php.
References $query, $result, $row, and $user_id.
Referenced by assQuestionGUI::save(), and assQuestionGUI::saveEdit().
{ 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(DB_FETCHMODE_ASSOC); $qpl_object_id = $row["obj_fi"]; include_once "./assessment/classes/class.ilObjQuestionPool.php"; return ilObjQuestionPool::_isWriteable($qpl_object_id, $user_id); } else { return false; } }
assQuestion::_questionExists | ( | $ | question_id | ) |
Returns true if the question already exists in the database.
Returns true if the question already exists in the database
integer | $question_id The database id of the question |
Definition at line 1803 of file class.assQuestion.php.
assQuestion::_resolveInternalLink | ( | $ | internal_link | ) |
Definition at line 1605 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 "./content/classes/Pages/class.ilInternalLink.php"; include_once "./content/classes/class.ilLMObject.php"; include_once "./content/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; }
assQuestion::_resolveIntLinks | ( | $ | question_id | ) |
Definition at line 1642 of file class.assQuestion.php.
References $query, $result, $row, 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(DB_FETCHMODE_ASSOC)) { $internal_link = $row["internal_link"]; include_once "./assessment/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 "./content/classes/Pages/class.ilInternalLink.php"; ilInternalLink::_deleteAllLinksOfSource("qst", $question_id); $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(DB_FETCHMODE_ASSOC)) { if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $row["internal_link"], $matches)) { ilInternalLink::_saveLink("qst", $question_id, $matches[2], $matches[3], $matches[1]); } } } } }
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.
object | $a_xml_writer Reference to the ILIAS XML writer | |
string | $a_material plain text or html text containing the material |
Definition at line 2223 of file class.assQuestion.php.
References $mobs, ilObjMediaObject::_getMobsOfObject(), ilRTE::_replaceMediaObjectImageSrc(), getId(), and isHTML().
Referenced by assTextSubset::to_xml(), assTextQuestion::to_xml(), assSingleChoice::to_xml(), assOrderingQuestion::to_xml(), assNumeric::to_xml(), assMultipleChoice::to_xml(), assMatchingQuestion::to_xml(), assJavaApplet::to_xml(), assImagemapQuestion::to_xml(), and assClozeTest::to_xml().
{ include_once "./Services/RTE/classes/class.ilRTE.php"; include_once("./content/classes/Media/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) { $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $this->getId()); foreach ($mobs as $mob) { $mob_obj =& new ilObjMediaObject($mob); $imgattrs = array( "label" => "il_" . IL_INST_ID . "_mob_" . $mob, "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"); }
assQuestion::assQuestion | ( | $ | title = "" , |
|
$ | comment = "" , |
|||
$ | author = "" , |
|||
$ | owner = -1 | |||
) |
assQuestion constructor
The constructor takes possible arguments an creates an instance of the assQuestion object.
string | $title A title string to describe the question | |
string | $comment A comment string to describe the question | |
string | $author A string containing the name of the questions author | |
integer | $owner A numerical ID to identify the owner/creator public |
Definition at line 190 of file class.assQuestion.php.
References $author, $comment, $ilias, $lng, $owner, $title, $tpl, and setEstimatedWorkingTime().
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->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')); }
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.
integer | $user_id The database ID of the learner | |
integer | $test_id The database Id of the test containing the question public |
Definition at line 2023 of file class.assQuestion.php.
References $points, ilObjTest::_getCountSystem(), ilObjTest::_getScoreCutting(), and getMaximumPoints().
Referenced by saveWorkingData().
{ include_once "./assessment/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; }
assQuestion::copyPageOfQuestion | ( | $ | a_q_id | ) |
Definition at line 1370 of file class.assQuestion.php.
{ if ($a_q_id > 0) { include_once "./content/classes/Pages/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(); } }
assQuestion::copyXHTMLMediaObjectsOfQuestion | ( | $ | a_q_id | ) |
Definition at line 1360 of file class.assQuestion.php.
References $mobs, ilObjMediaObject::_getMobsOfObject(), ilObjMediaObject::_saveUsage(), and getId().
{ include_once("./content/classes/Media/class.ilObjMediaObject.php"); $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $a_q_id); foreach ($mobs as $mob) { ilObjMediaObject::_saveUsage($mob, "qpl:html", $this->getId()); } }
assQuestion::createNewImageFileName | ( | $ | image_filename | ) |
Definition at line 2254 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 614 of file class.assQuestion.php.
References getId(), and getObjId().
Referenced by assTextSubset::saveToDb(), assTextQuestion::saveToDb(), assSingleChoice::saveToDb(), assQuestionTypeTemplate::saveToDb(), assOrderingQuestion::saveToDb(), assNumeric::saveToDb(), assMultipleChoice::saveToDb(), assMatchingQuestion::saveToDb(), assJavaApplet::saveToDb(), assImagemapQuestion::saveToDb(), and assClozeTest::saveToDb().
{ $qpl_id = $this->getObjId(); include_once "./content/classes/Pages/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(); }
assQuestion::createRandomSolution | ( | $ | test_id, | |
$ | user_id | |||
) |
assQuestion::delete | ( | $ | question_id | ) |
Deletes a question from the database.
Deletes a question and all materials from the database
integer | $question_id The database id of the question private |
Definition at line 1177 of file class.assQuestion.php.
References $mobs, $obj_id, $query, $result, $row, ilObjMediaObject::_getMobsOfObject(), ilObjMediaObject::_removeUsage(), ilObjQuestionPool::_updateQuestionCount(), ilUtil::delDir(), deleteAdditionalTableData(), and deleteAnswers().
{ 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(DB_FETCHMODE_ASSOC); $obj_id = $row["obj_fi"]; } else { return; } include_once "./content/classes/Pages/class.ilPageObject.php"; $page = new ilPageObject("qpl", $question_id); $page->delete(); $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 "./classes/class.ilUtil.php"; ilUtil::delDir($directory); } include_once("./content/classes/Media/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 "./assessment/classes/class.ilObjQuestionPool.php"; ilObjQuestionPool::_updateQuestionCount($this->obj_id); }
assQuestion::deleteAdditionalTableData | ( | $ | question_id | ) |
Deletes datasets from the additional question table in the database.
Deletes datasets from the additional question table in the database
integer | $question_id The question id which should be deleted in the additional question table public |
Definition at line 1159 of file class.assQuestion.php.
References $query, $result, and getAdditionalTableName().
Referenced by delete().
{ global $ilDB; $additional_table_name = $this->getAdditionalTableName(); $query = sprintf("DELETE FROM $additional_table_name WHERE question_fi = %s", $ilDB->quote($question_id . "") ); $result = $ilDB->query($query); }
assQuestion::deleteAnswers | ( | $ | question_id | ) |
Deletes datasets from answers tables.
Deletes datasets from answers tables
integer | $question_id The question id which should be deleted in the answers table public |
Definition at line 1138 of file class.assQuestion.php.
References $query, $result, and getAnswerTableName().
Referenced by delete().
{ global $ilDB; $answer_table_name = $this->getAnswerTableName(); if (strlen($answer_table_name)) { $query = sprintf("DELETE FROM $answer_table_name WHERE question_fi = %s", $ilDB->quote($question_id . "") ); $result = $ilDB->query($query); } }
assQuestion::deleteSuggestedSolutions | ( | ) |
Deletes all suggestes solutions in the database.
Deletes all suggestes solutions in the database
public
Definition at line 1519 of file class.assQuestion.php.
References $query, $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 "./content/classes/Pages/class.ilInternalLink.php"; ilInternalLink::_deleteAllLinksOfSource("qst", $this->getId()); }
assQuestion::getActiveUserData | ( | $ | active_id | ) |
Returns the user id and the test id for a given active id.
integer | $active_id Active id for a test/user |
Definition at line 2326 of file class.assQuestion.php.
References $query, $result, and $row.
{ 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(DB_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
Reimplemented in assClozeTest, assImagemapQuestion, assJavaApplet, assMatchingQuestion, assMultipleChoice, assNumeric, assOrderingQuestion, assQuestionTypeTemplate, assSingleChoice, assTextQuestion, and assTextSubset.
Definition at line 1112 of file class.assQuestion.php.
Referenced by deleteAdditionalTableData().
{ return ""; }
assQuestion::getAnswerTableName | ( | ) |
Returns the name of the answer table in the database.
Returns the name of the answer table in the database
Reimplemented in assClozeTest, assImagemapQuestion, assMatchingQuestion, assMultipleChoice, assOrderingQuestion, assQuestionTypeTemplate, assSingleChoice, and assTextSubset.
Definition at line 1125 of file class.assQuestion.php.
Referenced by deleteAnswers().
{ return ""; }
assQuestion::getAuthor | ( | ) |
Gets the authors name.
Gets the authors name of the assQuestion object
Definition at line 564 of file class.assQuestion.php.
Referenced by assQuestionTypeTemplate::isComplete(), assTextSubset::to_xml(), assTextQuestion::to_xml(), assSingleChoice::to_xml(), assOrderingQuestion::to_xml(), assNumeric::to_xml(), assMultipleChoice::to_xml(), assMatchingQuestion::to_xml(), assJavaApplet::to_xml(), assImagemapQuestion::to_xml(), and assClozeTest::to_xml().
{
return $this->author;
}
assQuestion::getComment | ( | ) |
Gets the comment.
Gets the comment string of the assQuestion object
Definition at line 518 of file class.assQuestion.php.
Referenced by assTextSubset::to_xml(), assTextQuestion::to_xml(), assSingleChoice::to_xml(), assOrderingQuestion::to_xml(), assNumeric::to_xml(), assMultipleChoice::to_xml(), assMatchingQuestion::to_xml(), assJavaApplet::to_xml(), assImagemapQuestion::to_xml(), and assClozeTest::to_xml().
{
return $this->comment;
}
assQuestion::getEstimatedWorkingTime | ( | ) |
Gets the estimated working time of a question.
Gets the estimated working time of a question
Definition at line 546 of file class.assQuestion.php.
Referenced by assTextSubset::saveToDb(), assTextQuestion::saveToDb(), assSingleChoice::saveToDb(), assQuestionTypeTemplate::saveToDb(), assOrderingQuestion::saveToDb(), assNumeric::saveToDb(), assMultipleChoice::saveToDb(), assMatchingQuestion::saveToDb(), assJavaApplet::saveToDb(), assImagemapQuestion::saveToDb(), assClozeTest::saveToDb(), assTextSubset::syncWithOriginal(), assTextQuestion::syncWithOriginal(), assSingleChoice::syncWithOriginal(), assQuestionTypeTemplate::syncWithOriginal(), assOrderingQuestion::syncWithOriginal(), assNumeric::syncWithOriginal(), assMultipleChoice::syncWithOriginal(), assMatchingQuestion::syncWithOriginal(), assJavaApplet::syncWithOriginal(), assImagemapQuestion::syncWithOriginal(), assClozeTest::syncWithOriginal(), assTextSubset::to_xml(), assTextQuestion::to_xml(), assSingleChoice::to_xml(), assOrderingQuestion::to_xml(), assNumeric::to_xml(), assMultipleChoice::to_xml(), assMatchingQuestion::to_xml(), assJavaApplet::to_xml(), assImagemapQuestion::to_xml(), and assClozeTest::to_xml().
{ if (!$this->est_working_time) { $this->est_working_time = array("h" => 0, "m" => 0, "s" => 0); } return $this->est_working_time; }
assQuestion::getId | ( | ) |
Gets the id.
Gets the id of the assQuestion object
Definition at line 476 of file class.assQuestion.php.
Referenced by addQTIMaterial(), assTextSubset::calculateReachedPoints(), assTextQuestion::calculateReachedPoints(), assSingleChoice::calculateReachedPoints(), assQuestionTypeTemplate::calculateReachedPoints(), assOrderingQuestion::calculateReachedPoints(), assNumeric::calculateReachedPoints(), assMultipleChoice::calculateReachedPoints(), assMatchingQuestion::calculateReachedPoints(), assJavaApplet::calculateReachedPoints(), assImagemapQuestion::calculateReachedPoints(), assClozeTest::calculateReachedPoints(), assQuestionTypeTemplate::copyObject(), copyXHTMLMediaObjectsOfQuestion(), createPageObject(), deleteSuggestedSolutions(), assTextSubset::duplicate(), assTextQuestion::duplicate(), assSingleChoice::duplicate(), assOrderingQuestion::duplicate(), assNumeric::duplicate(), assMultipleChoice::duplicate(), assMatchingQuestion::duplicate(), assJavaApplet::duplicate(), assImagemapQuestion::duplicate(), assClozeTest::duplicate(), assTextSubset::fromXML(), assTextQuestion::fromXML(), assSingleChoice::fromXML(), assOrderingQuestion::fromXML(), assNumeric::fromXML(), assMultipleChoice::fromXML(), assMatchingQuestion::fromXML(), assJavaApplet::fromXML(), assImagemapQuestion::fromXML(), assClozeTest::fromXML(), assJavaApplet::getReachedInformation(), getReachedPoints(), getSolutionMaxPass(), getSolutionValues(), insertIntoTest(), assTextSubset::saveToDb(), assTextQuestion::saveToDb(), assSingleChoice::saveToDb(), assQuestionTypeTemplate::saveToDb(), saveToDb(), assOrderingQuestion::saveToDb(), assNumeric::saveToDb(), assMultipleChoice::saveToDb(), assMatchingQuestion::saveToDb(), assJavaApplet::saveToDb(), assImagemapQuestion::saveToDb(), assClozeTest::saveToDb(), assTextSubset::saveWorkingData(), assTextQuestion::saveWorkingData(), assSingleChoice::saveWorkingData(), assQuestionTypeTemplate::saveWorkingData(), saveWorkingData(), assOrderingQuestion::saveWorkingData(), assNumeric::saveWorkingData(), assMultipleChoice::saveWorkingData(), assMatchingQuestion::saveWorkingData(), assImagemapQuestion::saveWorkingData(), assClozeTest::saveWorkingData(), and assTextQuestion::setReachedPoints().
{
return $this->id;
}
assQuestion::getImagePath | ( | ) |
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 926 of file class.assQuestion.php.
Referenced by assImagemapQuestion::copyImage(), assSingleChoice::copyImages(), assOrderingQuestion::copyImages(), assMultipleChoice::copyImages(), assMatchingQuestion::copyImages(), assSingleChoice::deleteImage(), assMultipleChoice::deleteImage(), assImagemapQuestion::duplicateImage(), assSingleChoice::duplicateImages(), assOrderingQuestion::duplicateImages(), assMultipleChoice::duplicateImages(), assMatchingQuestion::duplicateImages(), assSingleChoice::fromXML(), assOrderingQuestion::fromXML(), assMultipleChoice::fromXML(), assMatchingQuestion::fromXML(), assImagemapQuestion::fromXML(), assSingleChoice::loadFromDb(), assMultipleChoice::loadFromDb(), assSingleChoice::setImageFile(), assOrderingQuestion::setImageFile(), assMultipleChoice::setImageFile(), assMatchingQuestion::setImageFile(), assImagemapQuestion::setImageFilename(), assSingleChoice::to_xml(), assOrderingQuestion::to_xml(), assMultipleChoice::to_xml(), assMatchingQuestion::to_xml(), and assImagemapQuestion::to_xml().
{ return CLIENT_WEB_DIR . "/assessment/$this->obj_id/$this->id/images/"; }
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 954 of file class.assQuestion.php.
References ilUtil::removeTrailingPathSeparators().
Referenced by assSingleChoice::to_xml(), assOrderingQuestion::to_xml(), assMultipleChoice::to_xml(), assMatchingQuestion::to_xml(), and assImagemapQuestion::to_xml().
{ include_once "./classes/class.ilUtil.php"; $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/$this->obj_id/$this->id/images/"; return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir); }
& assQuestion::getInstances | ( | ) |
Gets all instances of the question.
Definition at line 2270 of file class.assQuestion.php.
References $key, $query, $result, $row, 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(DB_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(DB_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(DB_FETCHMODE_ASSOC)) { $instances[$row["obj_id"]] = $row["title"]; } } include_once "./assessment/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(DB_FETCHMODE_ASSOC)) { array_push($refs, $row["ref_id"]); } $instances[$key] = array("obj_id" => $key, "title" => $value, "author" => ilObjTest::_lookupAuthor($key), "refs" => $refs); } return $instances; }
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 914 of file class.assQuestion.php.
Referenced by assJavaApplet::copyApplet(), assJavaApplet::deleteJavaAppletFilename(), assJavaApplet::duplicateApplet(), assJavaApplet::fromXML(), assJavaApplet::setJavaAppletFilename(), and assJavaApplet::to_xml().
{ return CLIENT_WEB_DIR . "/assessment/$this->obj_id/$this->id/java/"; }
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 939 of file class.assQuestion.php.
References ilUtil::removeTrailingPathSeparators().
{ include_once "./classes/class.ilUtil.php"; $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/$this->obj_id/$this->id/java/"; return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir); }
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
Reimplemented in assClozeTest, assImagemapQuestion, assJavaApplet, assMatchingQuestion, assMultipleChoice, assNumeric, assOrderingQuestion, assQuestionTypeTemplate, assSingleChoice, assTextQuestion, and assTextSubset.
Definition at line 841 of file class.assQuestion.php.
Referenced by calculateReachedPoints().
{
return 0;
}
assQuestion::getMultilineAnswerSetting | ( | ) |
Definition at line 2082 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
Definition at line 592 of file class.assQuestion.php.
Referenced by assTextSubset::copyObject(), assTextQuestion::copyObject(), assSingleChoice::copyObject(), assQuestionTypeTemplate::copyObject(), assOrderingQuestion::copyObject(), assNumeric::copyObject(), assMultipleChoice::copyObject(), assMatchingQuestion::copyObject(), assJavaApplet::copyObject(), assImagemapQuestion::copyObject(), assClozeTest::copyObject(), and createPageObject().
{
return $this->obj_id;
}
assQuestion::getOutputType | ( | ) |
Gets the output type.
Gets the output type
Reimplemented in assMultipleChoice, and assSingleChoice.
Definition at line 532 of file class.assQuestion.php.
Referenced by assOrderingQuestion::checkSaveData(), assOrderingQuestion::saveWorkingData(), assOrderingQuestion::to_xml(), and assMatchingQuestion::to_xml().
{
return $this->outputType;
}
assQuestion::getOwner | ( | ) |
Gets the creator/owner.
Gets the creator/owner ID of the assQuestion object
Definition at line 578 of file class.assQuestion.php.
{
return $this->owner;
}
assQuestion::getPageOfQuestion | ( | ) |
Definition at line 1385 of file class.assQuestion.php.
{ include_once "./content/classes/Pages/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
Definition at line 1856 of file class.assQuestion.php.
Referenced by assTextQuestion::saveToDb(), assTextQuestion::setReachedPoints(), assClozeTest::testGapSolution(), assTextSubset::to_xml(), assTextQuestion::to_xml(), and assJavaApplet::to_xml().
{ if (strcmp($this->points, "") == 0) { return 0; } else { return $this->points; } }
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 1091 of file class.assQuestion.php.
References $data, $query, 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(DB_FETCHMODE_OBJECT); return $data->type_tag; }
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.
integer | $user_id The database ID of the learner | |
integer | $test_id The database Id of the test containing the question public |
Definition at line 810 of file class.assQuestion.php.
References $points, $query, $result, $row, getId(), and getSolutionMaxPass().
{ global $ilDB; $points = 0; if (is_null($pass)) { $pass = $this->getSolutionMaxPass($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($this->getId() . ""), $ilDB->quote($pass . "") ); $result = $ilDB->query($query); if ($result->numRows() == 1) { $row = $result->fetchRow(DB_FETCHMODE_ASSOC); $points = $row["points"]; } return $points; }
assQuestion::getShuffle | ( | ) |
Gets the shuffle flag.
Gets the shuffle flag
Definition at line 490 of file class.assQuestion.php.
Referenced by assSingleChoice::to_xml(), assOrderingQuestion::to_xml(), assMultipleChoice::to_xml(), assMatchingQuestion::to_xml(), assClozeTest::to_xml(), and assClozeTest::updateAllGapParams().
{
return $this->shuffle;
}
assQuestion::getSolutionCommentCountSystem | ( | $ | active_id | ) |
Definition at line 1904 of file class.assQuestion.php.
References $result, and ilObjTest::_getCountSystem().
{ $result = ""; include_once "./assessment/classes/class.ilObjTest.php"; if (ilObjTest::_getCountSystem($active_id) == COUNT_CORRECT_SOLUTIONS ) { $result = $this->lng->txt("solution_comment_count_system"); } return $result; }
assQuestion::getSolutionCommentMCScoring | ( | $ | active_id | ) |
Definition at line 1882 of file class.assQuestion.php.
References $result, and ilObjTest::_getMCScoring().
{ $result = ""; include_once "./assessment/classes/class.ilObjTest.php"; if (ilObjTest::_getMCScoring($active_id) == SCORE_ZERO_POINTS_WHEN_UNANSWERED) { $result = $this->lng->txt("solution_comment_mc_scoring"); } return $result; }
assQuestion::getSolutionCommentScoreCutting | ( | $ | active_id | ) |
Definition at line 1893 of file class.assQuestion.php.
References $result, and ilObjTest::_getScoreCutting().
{ $result = ""; include_once "./assessment/classes/class.ilObjTest.php"; if (ilObjTest::_getScoreCutting($active_id) == SCORE_CUT_QUESTION) { $result = $this->lng->txt("solution_comment_score_cutting"); } return $result; }
assQuestion::getSolutionMaxPass | ( | $ | active_id | ) |
Returns the maximum pass a users question solution.
Returns the maximum pass a users question solution
return | integer The maximum pass of the users solution public |
Definition at line 1923 of file class.assQuestion.php.
References _getSolutionMaxPass(), and getId().
Referenced by assTextSubset::calculateReachedPoints(), assTextQuestion::calculateReachedPoints(), assSingleChoice::calculateReachedPoints(), assQuestionTypeTemplate::calculateReachedPoints(), assOrderingQuestion::calculateReachedPoints(), assNumeric::calculateReachedPoints(), assMultipleChoice::calculateReachedPoints(), assMatchingQuestion::calculateReachedPoints(), assJavaApplet::calculateReachedPoints(), assImagemapQuestion::calculateReachedPoints(), assClozeTest::calculateReachedPoints(), assJavaApplet::getReachedInformation(), getReachedPoints(), and assTextQuestion::setReachedPoints().
{ return $this->_getSolutionMaxPass($this->getId(), $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
integer | $test_id The database id of the test containing this question public |
Definition at line 970 of file class.assQuestion.php.
References $query, $result, $row, and getId().
{ global $ilDB; $values = array(); if (is_null($pass)) { $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(DB_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(DB_FETCHMODE_ASSOC)) { array_push($values, $row); } return $values; }
assQuestion::getSuggestedSolution | ( | $ | subquestion_index = 0 |
) |
Returns a suggested solution for a given subquestion index.
Returns a suggested solution for a given subquestion index
integer | $subquestion_index The index of a subquestion (i.e. a close test gap). Usually 0 |
Definition at line 1541 of file class.assQuestion.php.
Referenced by assTextSubset::to_xml(), assTextQuestion::to_xml(), assSingleChoice::to_xml(), assOrderingQuestion::to_xml(), assNumeric::to_xml(), assMultipleChoice::to_xml(), assMatchingQuestion::to_xml(), assJavaApplet::to_xml(), assImagemapQuestion::to_xml(), and assClozeTest::to_xml().
{ 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
integer | $subquestion_index The index of a subquestion (i.e. a close test gap). Usually 0 |
Definition at line 1563 of file class.assQuestion.php.
References $title.
assQuestion::getTestId | ( | ) |
Gets the test id.
Gets the test id of the assQuestion object
Definition at line 504 of file class.assQuestion.php.
Referenced by assTextSubset::saveToDb(), assTextQuestion::saveToDb(), assSingleChoice::saveToDb(), assQuestionTypeTemplate::saveToDb(), assOrderingQuestion::saveToDb(), assNumeric::saveToDb(), assMultipleChoice::saveToDb(), assMatchingQuestion::saveToDb(), assJavaApplet::saveToDb(), assImagemapQuestion::saveToDb(), and assClozeTest::saveToDb().
{
return $this->test_id;
}
assQuestion::getTitle | ( | ) |
Gets the title string.
Gets the title string of the assQuestion object
Definition at line 462 of file class.assQuestion.php.
Referenced by assQuestionTypeTemplate::isComplete(), assTextSubset::to_xml(), assTextQuestion::to_xml(), assSingleChoice::to_xml(), assOrderingQuestion::to_xml(), assNumeric::to_xml(), assMultipleChoice::to_xml(), assMatchingQuestion::to_xml(), assJavaApplet::to_xml(), assImagemapQuestion::to_xml(), and assClozeTest::to_xml().
{
return $this->title;
}
assQuestion::getTotalAnswers | ( | ) |
get total number of answers
Definition at line 1245 of file class.assQuestion.php.
References _getTotalAnswers().
{ return $this->_getTotalAnswers($this->id); }
assQuestion::insertIntoTest | ( | $ | test_id | ) |
Insert the question into a test.
Insert the question into a test
integer | $test_id The database id of the test private |
Definition at line 636 of file class.assQuestion.php.
References $data, $query, $result, $test_id, and getId().
Referenced by assTextSubset::saveToDb(), assTextQuestion::saveToDb(), assSingleChoice::saveToDb(), assQuestionTypeTemplate::saveToDb(), assOrderingQuestion::saveToDb(), assNumeric::saveToDb(), assMultipleChoice::saveToDb(), assMatchingQuestion::saveToDb(), assJavaApplet::saveToDb(), assImagemapQuestion::saveToDb(), and assClozeTest::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(DB_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 ($result != DB_OK) { // Fehlermeldung } }
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
Definition at line 1037 of file class.assQuestion.php.
References $query, $result, and $row.
{ 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(DB_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
Reimplemented in assClozeTest, assImagemapQuestion, assJavaApplet, assMatchingQuestion, assMultipleChoice, assNumeric, assOrderingQuestion, assQuestionTypeTemplate, assSingleChoice, assTextQuestion, and assTextSubset.
Definition at line 256 of file class.assQuestion.php.
{ return false; }
assQuestion::isHTML | ( | $ | a_text | ) |
Checks if a given string contains HTML or not.
string | $a_text Text which should be checked |
Definition at line 2128 of file class.assQuestion.php.
Referenced by addQTIMaterial(), prepareTextareaOutput(), and assMatchingQuestion::to_xml().
{ if (preg_match("/<[^>]*?>/", $a_text)) { return TRUE; } else { return FALSE; } }
assQuestion::isInUse | ( | $ | question_id = "" |
) |
Checks whether the question is in use or not.
Checks whether the question is in use or not
Definition at line 1016 of file class.assQuestion.php.
References $query, $result, and $row.
{ global $ilDB; if ($question_id < 1) $question_id = $this->id; $query = sprintf("SELECT COUNT(question_id) AS question_count FROM qpl_questions WHERE original_id = %s", $ilDB->quote($question_id . "") ); $result = $ilDB->query($query); $row = $result->fetchRow(DB_FETCHMODE_OBJECT); return $row->question_count; }
assQuestion::keyInArray | ( | $ | searchkey, | |
$ | array | |||
) |
returns TRUE if the key occurs in an array
returns TRUE if the key occurs in an array
string | $arraykey A key to an element in array | |
array | $array An array to be searched public |
Definition at line 406 of file class.assQuestion.php.
References $key.
assQuestion::loadFromDb | ( | $ | question_id | ) |
Loads the question from the database.
Loads the question from the database
integer | $question_id A unique key which defines the question in the database public |
Reimplemented in assClozeTest, assImagemapQuestion, assJavaApplet, assMatchingQuestion, assMultipleChoice, assNumeric, assOrderingQuestion, assQuestionTypeTemplate, assSingleChoice, assTextQuestion, and assTextSubset.
Definition at line 1454 of file class.assQuestion.php.
References $query, $result, and $row.
{ 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(DB_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
string | $logtext The log text | |
integer | $question_id If given, saves the question id to the database public |
Definition at line 891 of file class.assQuestion.php.
References ilObjAssessmentFolder::_addLog(), ilObjTest::_getObjectIDFromActiveID(), and _getOriginalId().
Referenced by assTextSubset::saveWorkingData(), assTextQuestion::saveWorkingData(), assSingleChoice::saveWorkingData(), saveWorkingData(), assOrderingQuestion::saveWorkingData(), assNumeric::saveWorkingData(), assMultipleChoice::saveWorkingData(), assMatchingQuestion::saveWorkingData(), assImagemapQuestion::saveWorkingData(), and assClozeTest::saveWorkingData().
{ global $ilUser; $original_id = ""; if (strcmp($question_id, "") != 0) { include_once "./assessment/classes/class.assQuestion.php"; $original_id = assQuestion::_getOriginalId($question_id); } include_once "./classes/class.ilObjAssessmentFolder.php"; include_once "./assessment/classes/class.ilObjTest.php"; ilObjAssessmentFolder::_addLog($ilUser->id, ilObjTest::_getObjectIDFromActiveID($active_id), $logtext, $question_id, $original_id); }
assQuestion::pcArrayShuffle | ( | $ | array | ) |
Shuffles the values of a given array.
Shuffles the values of a given array
array | $array An array which should be shuffled public |
Definition at line 1065 of file class.assQuestion.php.
Referenced by assSingleChoice::to_xml(), assOrderingQuestion::to_xml(), assMultipleChoice::to_xml(), assMatchingQuestion::to_xml(), and assClozeTest::to_xml().
{ 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.
string | $txt_output String which should be prepared for output public |
Definition at line 2146 of file class.assQuestion.php.
References $result, ilUtil::insertLatexImages(), and isHTML().
{ include_once "./classes/class.ilObjAdvancedEditing.php"; $result = $txt_output; $is_html = $this->isHTML($result); if ($prepare_for_latex_output) { $result = ilUtil::insertLatexImages($result, "<span class\=\"latex\">", "<\/span>", URL_TO_LATEX); $result = ilUtil::insertLatexImages($result, "\[tex\]", "\[\/tex\]", URL_TO_LATEX); } if (!$is_html) { // if the string does not contain HTML code, replace the newlines with HTML line breaks $result = preg_replace("/[\n]/", "<br />", $result); } else { // patch for problems with the <pre> tags in tinyMCE if (preg_match_all("/(<pre>.*?<\/pre>)/ims", $result, $matches)) { foreach ($matches[0] as $found) { $replacement = ""; if (strpos("\n", $found) === FALSE) { $replacement = "\n"; } $removed = preg_replace("/<br\s*?\/>/ims", $replacement, $found); $result = str_replace($found, $removed, $result); } } } $result = str_replace("{", "{", $result); $result = str_replace("}", "}", $result); $result = str_replace("\\", "\", $result); return $result; }
assQuestion::QTIMaterialToString | ( | $ | a_material | ) |
Reads an QTI material tag an creates a text string.
string | $a_material QTI material tag |
Definition at line 2191 of file class.assQuestion.php.
References $_SESSION, and $result.
Referenced by assTextSubset::fromXML(), assTextQuestion::fromXML(), assSingleChoice::fromXML(), assOrderingQuestion::fromXML(), assNumeric::fromXML(), assMultipleChoice::fromXML(), assMatchingQuestion::fromXML(), assJavaApplet::fromXML(), assImagemapQuestion::fromXML(), and assClozeTest::fromXML().
{ $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
string | $title The title of the question |
Definition at line 270 of file class.assQuestion.php.
References $query, $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 (strcmp(strtolower(get_class($result)), db_result) == 0) { if ($result->numRows() == 1) { return TRUE; } } return FALSE; }
assQuestion::saveToDb | ( | $ | original_id = "" |
) |
Saves the question to the database.
Saves the question to the database
integer | $original_id public |
Reimplemented in assClozeTest, assImagemapQuestion, assJavaApplet, assMatchingQuestion, assMultipleChoice, assNumeric, assOrderingQuestion, assQuestionTypeTemplate, assSingleChoice, assTextQuestion, and assTextSubset.
Definition at line 1483 of file class.assQuestion.php.
References $query, $result, ilInternalLink::_deleteAllLinksOfSource(), ilInternalLink::_saveLink(), ilObjQuestionPool::_updateQuestionCount(), and getId().
{ global $ilDB; include_once "./content/classes/Pages/class.ilInternalLink.php"; $query = sprintf("DELETE FROM qpl_suggested_solutions WHERE question_fi = %s", $ilDB->quote($this->getId() . "") ); $result = $ilDB->query($query); ilInternalLink::_deleteAllLinksOfSource("qst", $this->getId()); 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]); } } // update question count of question pool include_once "./assessment/classes/class.ilObjQuestionPool.php"; ilObjQuestionPool::_updateQuestionCount($this->obj_id); }
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
*
integer | $test_id The database id of the test containing this question public |
Reimplemented in assClozeTest, assImagemapQuestion, assJavaApplet, assMatchingQuestion, assMultipleChoice, assNumeric, assOrderingQuestion, assQuestionTypeTemplate, assSingleChoice, assTextQuestion, and assTextSubset.
Definition at line 855 of file class.assQuestion.php.
References $query, $result, ilObjAssessmentFolder::_enabledAssessmentLogging(), ilObjAssessmentFolder::_getLogLanguage(), ilObjTest::_getPass(), ilCourseObjectiveResult::_updateObjectiveResult(), calculateReachedPoints(), getId(), and logAction().
{ global $ilDB; global $ilUser; include_once "./assessment/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 ("./classes/class.ilObjAssessmentFolder.php"); if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $this->logAction(sprintf($this->lng->txtlng("assessment", "log_user_answered_question", ilObjAssessmentFolder::_getLogLanguage()), $reached_points), $active_id, $this->getId()); } // Update objective status include_once 'course/classes/class.ilCourseObjectiveResult.php'; ilCourseObjectiveResult::_updateObjectiveResult($ilUser->getId(),$active_id,$this->getId()); }
assQuestion::setAuthor | ( | $ | author = "" |
) |
Sets the authors name.
Sets the authors name of the assQuestion object
string | $author A string containing the name of the questions author public |
Definition at line 430 of file class.assQuestion.php.
References $author.
Referenced by assTextSubset::fromXML(), assTextQuestion::fromXML(), assSingleChoice::fromXML(), assOrderingQuestion::fromXML(), assNumeric::fromXML(), assMultipleChoice::fromXML(), assMatchingQuestion::fromXML(), assJavaApplet::fromXML(), assImagemapQuestion::fromXML(), and assClozeTest::fromXML().
assQuestion::setComment | ( | $ | comment = "" |
) |
Sets the comment.
Sets the comment string of the assQuestion object
string | $comment A comment string to describe the question public |
Definition at line 340 of file class.assQuestion.php.
References $comment.
Referenced by assTextSubset::fromXML(), assTextQuestion::fromXML(), assSingleChoice::fromXML(), assOrderingQuestion::fromXML(), assNumeric::fromXML(), assMultipleChoice::fromXML(), assMatchingQuestion::fromXML(), assJavaApplet::fromXML(), assImagemapQuestion::fromXML(), assClozeTest::fromXML(), and assQuestionTypeTemplate::loadFromDb().
{ $this->comment = $comment; }
assQuestion::setEstimatedWorkingTime | ( | $ | hour = 0 , |
|
$ | min = 0 , |
|||
$ | sec = 0 | |||
) |
Sets the estimated working time of a question.
Sets the estimated working time of a question
integer | $hour Hour | |
integer | $min Minutes | |
integer | $sec Seconds public |
Definition at line 392 of file class.assQuestion.php.
Referenced by assQuestion(), assTextSubset::fromXML(), assTextQuestion::fromXML(), assSingleChoice::fromXML(), assOrderingQuestion::fromXML(), assNumeric::fromXML(), assMultipleChoice::fromXML(), assMatchingQuestion::fromXML(), assJavaApplet::fromXML(), assImagemapQuestion::fromXML(), assClozeTest::fromXML(), assTextSubset::loadFromDb(), assTextQuestion::loadFromDb(), assSingleChoice::loadFromDb(), assOrderingQuestion::loadFromDb(), assNumeric::loadFromDb(), assMultipleChoice::loadFromDb(), assMatchingQuestion::loadFromDb(), assJavaApplet::loadFromDb(), assImagemapQuestion::loadFromDb(), and assClozeTest::loadFromDb().
{ $this->est_working_time = array("h" => (int)$hour, "m" => (int)$min, "s" => (int)$sec); }
assQuestion::setId | ( | $ | id = -1 |
) |
Sets the id.
Sets the id of the assQuestion object
integer | $id A unique integer value public |
Definition at line 312 of file class.assQuestion.php.
References $id.
Referenced by assQuestionTypeTemplate::loadFromDb(), and assQuestionTypeTemplate::saveToDb().
{ $this->id = $id; }
assQuestion::setMultilineAnswerSetting | ( | $ | a_setting = 0 |
) |
Definition at line 2094 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
integer | $obj_id The object id of the container object public |
Definition at line 606 of file class.assQuestion.php.
References $obj_id.
Referenced by assTextSubset::fromXML(), assTextQuestion::fromXML(), assSingleChoice::fromXML(), assOrderingQuestion::fromXML(), assNumeric::fromXML(), assMultipleChoice::fromXML(), assMatchingQuestion::fromXML(), assJavaApplet::fromXML(), assImagemapQuestion::fromXML(), and assClozeTest::fromXML().
{ $this->obj_id = $obj_id; }
assQuestion::setOutputType | ( | $ | outputType = OUTPUT_HTML |
) |
Sets the output type.
Sets the output type
integer | $outputType The output type of the question public |
Reimplemented in assMultipleChoice, and assSingleChoice.
Definition at line 354 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
integer | $owner A numerical ID to identify the owner/creator public |
Definition at line 448 of file class.assQuestion.php.
References $owner.
Referenced by assTextSubset::fromXML(), assTextQuestion::fromXML(), assSingleChoice::fromXML(), assOrderingQuestion::fromXML(), assNumeric::fromXML(), assMultipleChoice::fromXML(), assMatchingQuestion::fromXML(), assJavaApplet::fromXML(), assImagemapQuestion::fromXML(), and assClozeTest::fromXML().
{ $this->owner = $owner; }
assQuestion::setPoints | ( | $ | a_points | ) |
Sets the maximum available points for the question.
Sets the maximum available points for the question
integer | $a_points The points public |
Definition at line 1877 of file class.assQuestion.php.
Referenced by assTextQuestion::fromXML(), and assJavaApplet::fromXML().
{ $this->points = $a_points; }
assQuestion::setShuffle | ( | $ | shuffle = true |
) |
Sets the shuffle flag.
Sets the shuffle flag
boolean | $shuffle A flag indicating whether the answers are shuffled or not public |
Definition at line 369 of file class.assQuestion.php.
References $shuffle.
Referenced by assSingleChoice::fromXML(), assOrderingQuestion::fromXML(), assMultipleChoice::fromXML(), assMatchingQuestion::fromXML(), assSingleChoice::loadFromDb(), and assMultipleChoice::loadFromDb().
{ if ($shuffle) { $this->shuffle = 1; } else { $this->shuffle = 0; } }
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.
string | $solution_id An internal link pointing to the suggested solution | |
integer | $subquestion_index The index of a subquestion (i.e. a close test gap). Usually 0 | |
boolean | $is_import A boolean indication that the internal link was imported from another ILIAS installation public |
Definition at line 1588 of file class.assQuestion.php.
References _resolveInternalLink().
Referenced by assTextSubset::fromXML(), assTextQuestion::fromXML(), assSingleChoice::fromXML(), assOrderingQuestion::fromXML(), assNumeric::fromXML(), assMultipleChoice::fromXML(), assMatchingQuestion::fromXML(), assJavaApplet::fromXML(), assImagemapQuestion::fromXML(), and assClozeTest::fromXML().
{ 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 ); } }
assQuestion::setTestId | ( | $ | id = -1 |
) |
Sets the test id.
Sets the test id of the assQuestion object
integer | $id A unique integer value public |
Definition at line 326 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
string | $title A title string to describe the question public |
Definition at line 298 of file class.assQuestion.php.
References $title.
Referenced by assTextSubset::fromXML(), assTextQuestion::fromXML(), assSingleChoice::fromXML(), assOrderingQuestion::fromXML(), assNumeric::fromXML(), assMultipleChoice::fromXML(), assMatchingQuestion::fromXML(), assJavaApplet::fromXML(), assImagemapQuestion::fromXML(), assClozeTest::fromXML(), and assQuestionTypeTemplate::loadFromDb().
{ $this->title = $title; }
assQuestion::syncWithOriginal | ( | ) |
Reimplemented in assClozeTest, assImagemapQuestion, assJavaApplet, assMatchingQuestion, assMultipleChoice, assNumeric, assOrderingQuestion, assQuestionTypeTemplate, assSingleChoice, assTextQuestion, and assTextSubset.
Definition at line 1764 of file class.assQuestion.php.
References $query, $result, ilInternalLink::_deleteAllLinksOfSource(), and ilInternalLink::_saveLink().
{ global $ilDB; include_once "./content/classes/Pages/class.ilInternalLink.php"; $query = sprintf("DELETE FROM qpl_suggested_solutions WHERE question_fi = %s", $ilDB->quote($this->original_id . "") ); $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->original_id . ""), $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->original_id, $matches[2], $matches[3], $matches[1]); } } }
assQuestion::to_xml | ( | ) |
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
Definition at line 243 of file class.assQuestion.php.
{
// to be implemented in the successor classes of assQuestion
}
assQuestion::$author |
Definition at line 84 of file class.assQuestion.php.
Referenced by assClozeTest::assClozeTest(), assImagemapQuestion::assImagemapQuestion(), assJavaApplet::assJavaApplet(), assMatchingQuestion::assMatchingQuestion(), assMultipleChoice::assMultipleChoice(), assNumeric::assNumeric(), assOrderingQuestion::assOrderingQuestion(), assQuestion(), assQuestionTypeTemplate::assQuestionTypeTemplate(), assSingleChoice::assSingleChoice(), assTextQuestion::assTextQuestion(), assTextSubset::assTextSubset(), assTextSubset::duplicate(), assTextQuestion::duplicate(), assSingleChoice::duplicate(), assQuestionTypeTemplate::duplicate(), assOrderingQuestion::duplicate(), assNumeric::duplicate(), assMultipleChoice::duplicate(), assMatchingQuestion::duplicate(), assJavaApplet::duplicate(), assImagemapQuestion::duplicate(), assClozeTest::duplicate(), and setAuthor().
assQuestion::$comment |
Definition at line 64 of file class.assQuestion.php.
Referenced by assClozeTest::assClozeTest(), assImagemapQuestion::assImagemapQuestion(), assJavaApplet::assJavaApplet(), assMatchingQuestion::assMatchingQuestion(), assMultipleChoice::assMultipleChoice(), assNumeric::assNumeric(), assOrderingQuestion::assOrderingQuestion(), assQuestion(), assQuestionTypeTemplate::assQuestionTypeTemplate(), assSingleChoice::assSingleChoice(), assTextQuestion::assTextQuestion(), assTextSubset::assTextSubset(), and setComment().
assQuestion::$domxml |
Definition at line 167 of file class.assQuestion.php.
assQuestion::$est_working_time |
Definition at line 104 of file class.assQuestion.php.
assQuestion::$id |
Definition at line 46 of file class.assQuestion.php.
Referenced by setId(), and setTestId().
assQuestion::$ilias |
Definition at line 140 of file class.assQuestion.php.
Referenced by assQuestion().
assQuestion::$lng |
Definition at line 158 of file class.assQuestion.php.
Referenced by assQuestion(), and assClozeTest::updateAllGapParams().
assQuestion::$obj_id |
Definition at line 131 of file class.assQuestion.php.
Referenced by delete(), and setObjId().
assQuestion::$outputType |
Definition at line 176 of file class.assQuestion.php.
Referenced by setOutputType().
assQuestion::$owner |
Definition at line 74 of file class.assQuestion.php.
Referenced by assClozeTest::assClozeTest(), assImagemapQuestion::assImagemapQuestion(), assJavaApplet::assJavaApplet(), assMatchingQuestion::assMatchingQuestion(), assMultipleChoice::assMultipleChoice(), assNumeric::assNumeric(), assOrderingQuestion::assOrderingQuestion(), assQuestion(), assQuestionTypeTemplate::assQuestionTypeTemplate(), assSingleChoice::assSingleChoice(), assTextQuestion::assTextQuestion(), assTextSubset::assTextSubset(), assTextSubset::duplicate(), assTextQuestion::duplicate(), assSingleChoice::duplicate(), assQuestionTypeTemplate::duplicate(), assOrderingQuestion::duplicate(), assNumeric::duplicate(), assMultipleChoice::duplicate(), assMatchingQuestion::duplicate(), assJavaApplet::duplicate(), assImagemapQuestion::duplicate(), assClozeTest::duplicate(), and setOwner().
assQuestion::$points |
Definition at line 95 of file class.assQuestion.php.
Referenced by _getMaximumPoints(), _getReachedPoints(), _isWorkedThrough(), assTextQuestion::_setReachedPoints(), assMatchingQuestion::add_matchingpair(), assTextSubset::addAnswer(), assSingleChoice::addAnswer(), assOrderingQuestion::addAnswer(), assMultipleChoice::addAnswer(), assImagemapQuestion::addAnswer(), assClozeTest::addAnswer(), assMatchingQuestion::addMatchingPair(), assNumeric::addRange(), assTextSubset::calculateReachedPoints(), assTextQuestion::calculateReachedPoints(), assSingleChoice::calculateReachedPoints(), assQuestionTypeTemplate::calculateReachedPoints(), calculateReachedPoints(), assOrderingQuestion::calculateReachedPoints(), assNumeric::calculateReachedPoints(), assMultipleChoice::calculateReachedPoints(), assMatchingQuestion::calculateReachedPoints(), assJavaApplet::calculateReachedPoints(), assImagemapQuestion::calculateReachedPoints(), assClozeTest::calculateReachedPoints(), assNumeric::fromXML(), assClozeTest::getMaximumGapPoints(), assTextSubset::getMaximumPoints(), assSingleChoice::getMaximumPoints(), assQuestionTypeTemplate::getMaximumPoints(), assOrderingQuestion::getMaximumPoints(), assMultipleChoice::getMaximumPoints(), assMatchingQuestion::getMaximumPoints(), assImagemapQuestion::getMaximumPoints(), assClozeTest::getMaximumPoints(), getReachedPoints(), assClozeTest::setGapPoints(), assTextQuestion::setReachedPoints(), assClozeTest::setSingleAnswerPoints(), and assTextSubset::to_xml().
assQuestion::$shuffle |
Definition at line 113 of file class.assQuestion.php.
Referenced by assClozeTest::addAnswer(), assClozeTest::createCloseTextFromArray(), assTextSubset::fromXML(), assSingleChoice::fromXML(), assOrderingQuestion::fromXML(), assMultipleChoice::fromXML(), assMatchingQuestion::fromXML(), assClozeTest::fromXML(), assClozeTest::setClozeText(), assClozeTest::setGapShuffle(), and setShuffle().
assQuestion::$suggested_solutions |
Definition at line 178 of file class.assQuestion.php.
assQuestion::$test_id |
Definition at line 122 of file class.assQuestion.php.
Referenced by insertIntoTest().
assQuestion::$title |
Definition at line 55 of file class.assQuestion.php.
Referenced by assClozeTest::assClozeTest(), assImagemapQuestion::assImagemapQuestion(), assJavaApplet::assJavaApplet(), assMatchingQuestion::assMatchingQuestion(), assMultipleChoice::assMultipleChoice(), assNumeric::assNumeric(), assOrderingQuestion::assOrderingQuestion(), assQuestion(), assQuestionTypeTemplate::assQuestionTypeTemplate(), assSingleChoice::assSingleChoice(), assTextQuestion::assTextQuestion(), assTextSubset::assTextSubset(), assTextSubset::copyObject(), assTextQuestion::copyObject(), assSingleChoice::copyObject(), assQuestionTypeTemplate::copyObject(), assOrderingQuestion::copyObject(), assNumeric::copyObject(), assMultipleChoice::copyObject(), assMatchingQuestion::copyObject(), assJavaApplet::copyObject(), assImagemapQuestion::copyObject(), assClozeTest::copyObject(), assTextSubset::duplicate(), assTextQuestion::duplicate(), assSingleChoice::duplicate(), assQuestionTypeTemplate::duplicate(), assOrderingQuestion::duplicate(), assNumeric::duplicate(), assMultipleChoice::duplicate(), assMatchingQuestion::duplicate(), assJavaApplet::duplicate(), assImagemapQuestion::duplicate(), assClozeTest::duplicate(), getSuggestedSolutionTitle(), questionTitleExists(), and setTitle().
assQuestion::$tpl |
Definition at line 149 of file class.assQuestion.php.
Referenced by assQuestion().