Public Member Functions | |
ilObjTest ($a_id=0, $a_call_by_reference=true) | |
Constructor public. | |
create ($a_upload=false) | |
create test object | |
update () | |
update object data | |
createReference () | |
Creates a database reference id for the object. | |
getCallingScript () | |
Returns the calling script of the class. | |
read ($a_force_db=false) | |
read object data from db into object | |
ilClone ($a_parent_ref) | |
copy all entries of your object. | |
delete () | |
delete object and all related data | |
deleteTest () | |
Deletes the test and all related objects, files and database entries. | |
initDefaultRoles () | |
init default roles settings | |
notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0) | |
notifys an object about an event occured Based on the event happend, each object may decide how it reacts. | |
createExportDirectory () | |
creates data directory for export files (data_dir/tst_data/tst_<id>/export, depending on data directory that is set in ILIAS setup/ini) | |
getExportDirectory () | |
Get the location of the export directory for the test. | |
getExportFiles ($dir) | |
Get a list of the already exported files in the export directory. | |
createImportDirectory () | |
creates data directory for import files (data_dir/tst_data/tst_<id>/import, depending on data directory that is set in ILIAS setup/ini) | |
getImportDirectory () | |
Get the import directory location of the test. | |
retrieveTestTypes () | |
Retrieves the test types from the database. | |
testTitleExists ($title) | |
Returns TRUE if the test title exists in the database. | |
duplicate () | |
Duplicates the ilObjTest object. | |
isComplete () | |
Returns true, if a test is complete for use. | |
_isComplete ($obj_id) | |
Returns true, if a test is complete for use. | |
saveECTSStatus ($ects_output=0, $fx_support="", $ects_a=90, $ects_b=65, $ects_c=35, $ects_d=10, $ects_e=0) | |
Saves the ECTS status (output of ECTS grades in a test) to the database. | |
saveCompleteStatus () | |
Checks if the test is complete and saves the status in the database. | |
saveToDb ($properties_only=FALSE) | |
Saves a ilObjTest object to a database. | |
saveQuestionsToDb () | |
Saves the test questions to the database. | |
saveRandomQuestion ($question_id) | |
Saves a random question to the database. | |
saveRandomQuestionCount ($total_questions="NULL") | |
Saves the total amount of a tests random questions to the database. | |
saveRandomQuestionpools ($qpl_array) | |
Saves the question pools used for a random test. | |
& | getRandomQuestionpools () |
Returns an array containing the random questionpools saved to the database. | |
loadFromDb () | |
Loads a ilObjTest object from a database. | |
loadQuestions ($user_id="") | |
Load the test question id's from the database. | |
setAuthor ($author="") | |
Sets the authors name. | |
setIntroduction ($introduction="") | |
Sets the introduction. | |
getAuthor () | |
Gets the authors name. | |
isRandomTest () | |
Gets the status of the $random_test attribute. | |
getRandomQuestionCount () | |
Gets the number of random questions used for a random test. | |
getIntroduction () | |
Gets the introduction. | |
getTestId () | |
Gets the database id of the additional test data. | |
setSequenceSettings ($sequence_settings=0) | |
Sets the sequence settings. | |
setTestType ($type=TYPE_ASSESSMENT) | |
Sets the test type. | |
setScoreReporting ($score_reporting=0) | |
Sets the score reporting. | |
setRandomTest ($a_random_test=0) | |
Sets the random test indicator. | |
setRandomQuestionCount ($a_random_question_count="") | |
Sets the random question count. | |
setReportingDate ($reporting_date) | |
Sets the reporting date. | |
getSequenceSettings () | |
Gets the sequence settings. | |
getScoreReporting () | |
Gets the score reporting. | |
getTestType () | |
Gets the test type. | |
getReportingDate () | |
Gets the reporting date. | |
getNrOfTries () | |
Returns the nr of tries for the test. | |
getProcessingTime () | |
Returns the processing time for the test. | |
getProcessingTimeInSeconds () | |
Returns the processing time for the test in seconds. | |
getEnableProcessingTime () | |
Returns the state of the processing time (enabled/disabled). | |
getStartingTime () | |
Returns the starting time of the test. | |
getEndingTime () | |
Returns the ending time of the test. | |
setNrOfTries ($nr_of_tries=0) | |
Sets the nr of tries for the test. | |
setProcessingTime ($processing_time="00:00:00") | |
Sets the processing time for the test. | |
setEnableProcessingTime ($enable=0) | |
Sets the processing time enabled or disabled. | |
setStartingTime ($starting_time="") | |
Sets the starting time for the test. | |
setEndingTime ($ending_time="") | |
Sets the ending time for the test. | |
removeQuestion ($question_id) | |
Removes a question from the test object. | |
clearEvalSelectedUsers () | |
Removes all selected users for the test evaluation. | |
clearEvalSelectedGroups () | |
Removes all selected groups for the test evaluation. | |
removeAllTestEditings ($question_id="") | |
Removes all references to the question in executed tests in case the question has been changed. | |
deleteActiveTests () | |
Deletes all active references to this test. | |
deleteResults ($user_id="", $a_delete_active=false) | |
Removes all question solutions for a given user. | |
questionMoveUp ($question_id) | |
Moves a question up in order. | |
questionMoveDown ($question_id) | |
Moves a question down in order. | |
duplicateQuestionForTest ($question_id) | |
Takes a question and creates a copy of the question for use in the test. | |
insertQuestion ($question_id) | |
Insert a question in the list of questions. | |
& | getQuestionTitles () |
Returns the titles of the test questions in question sequence. | |
getQuestionTitle ($sequence) | |
Returns the title of a question with a given sequence number. | |
getQuestionDataset ($question_id) | |
Returns the dataset for a given question id. | |
& | get_qpl_titles () |
Get the titles of all available questionpools for the current user. | |
& | getExistingQuestions () |
Get the id's of the questions which are already part of the test. | |
getQuestionType ($question_id) | |
Returns the question type of a question with a given id. | |
startWorkingTime ($user_id) | |
Write the initial entry for the tests working time to the database. | |
updateWorkingTime ($times_id) | |
Update the working time of a test when a question is answered. | |
getQuestionIdFromActiveUserSequence ($sequence) | |
Calculate the question id from a test sequence number. | |
& | getAllQuestionsForActiveUser () |
Returns all questions of a test in users order. | |
getWrongAnsweredQuestions () | |
incrementSequenceByResult ($a_sequence) | |
increments sequence to the next wrong answered question | |
decrementSequenceByResult ($a_sequence) | |
decrements sequence to the next wrong answered question | |
getFirstSequence () | |
& | getWorkedQuestions () |
Gets the id's of all questions a user already worked through. | |
& | getAllQuestions () |
Returns all questions of a test in test order. | |
getActiveTestUser ($user_id="") | |
Gets the database row of the tst_active table for the active user. | |
_getActiveTestUser ($user_id="", $test_id="") | |
Gets the database row of the tst_active table for the active user. | |
setActiveTestUser ($lastindex=1, $postpone="", $addTries=false) | |
Update the data of the tst_active table for the current user. | |
& | getTestResult ($user_id) |
Calculates the results of a test for a given user. | |
& | _getTestResult ($user_id, $test_obj_id) |
Calculates the results of a test for a given user. | |
_checkCondition ($a_exc_id, $a_operator, $a_value) | |
Returns a result for a condition check on the class. | |
& | _getMark ($user_id, $test_obj_id) |
Returns the resulting mark of a test for a given user. | |
assignMetaData (&$a_meta_data) | |
assign a meta data object to glossary object | |
& | getMetaData () |
get meta data object of glossary object | |
initMeta () | |
init meta data object if needed | |
evalTotalPersons () | |
Returns the number of persons who started the test. | |
canViewResults () | |
Returns true, if the test results can be viewed. | |
evalLoadStatisticalSettings ($user_id) | |
Retrieves the user settings for the statistical evaluation tool. | |
evalSaveStatisticalSettings ($settings_array, $user_id) | |
Saves the user settings for the statistical evaluation tool. | |
getCompleteWorkingTime ($user_id) | |
Returns the complete working time in seconds a user worked on the test. | |
& | evalStatistical ($user_id) |
Returns the statistical evaluation of the test for a specified user. | |
& | getTotalPointsArray () |
Returns an array with the total points of all users who participated the test. | |
& | getTotalPointsPassedArray () |
Returns an array with the total points of all users who passed the test. | |
& | evalTotalPersonsArray () |
Returns all persons who started the test. | |
evalTotalFinished () | |
Returns the number of total finished tests. | |
evalTotalFinishedPassed () | |
Returns the total passed tests and the average reached points. | |
evalTotalFinishedAverageTime () | |
Returns the average processing time for total finished tests. | |
& | getForbiddenQuestionpools () |
Gets a list of all inaccessable question pools for the active user. | |
& | getAvailableQuestionpoolIDs () |
Returns the object id's of the available question pools for the active user. | |
& | getAvailableQuestionpools ($use_object_id=false) |
Returns the available question pools for the active user. | |
getEstimatedWorkingTime () | |
Returns the estimated working time for the test calculated from the working time of the contained questions. | |
randomSelectQuestions ($nr_of_questions, $questionpool, $use_obj_id=0, $qpls="") | |
Returns a random selection of questions. | |
getImagePath () | |
Returns the image path for web accessable images of a test. | |
getImagePathWeb () | |
Returns the web image path for web accessable images of a test. | |
& | createQuestionGUI ($question_type, $question_id=-1) |
Creates a question GUI instance of a given question type. | |
& | _instanciateQuestion ($question_id) |
Creates an instance of a question with a given question id. | |
moveQuestions ($move_questions, $target_index, $insert_mode) | |
Move questions to another position. | |
startingTimeReached () | |
Returns true if the starting time of a test is reached. | |
endingTimeReached () | |
Returns true if the ending time of a test is reached. | |
getQuestionsTable ($sortoptions, $filter_text, $sel_filter_type, $startrow=0, $completeonly=0, $filter_question_type="", $filter_questionpool="") | |
Calculates the data for the output of the questionpool. | |
_getTestType ($test_id) | |
Returns the test type for a given test id. | |
& | _getQuestiontypes () |
Creates a list of all available question types. | |
to_xml () | |
Returns a QTI xml representation of the test. | |
exportPagesXML (&$a_xml_writer, $a_inst, $a_target_dir, &$expLog) | |
export pages of test to xml (see ilias_co.dtd) | |
exportXMLMetaData (&$a_xml_writer) | |
export content objects meta data to xml (see ilias_co.dtd) | |
modifyExportIdentifier ($a_tag, $a_param, $a_value) | |
Returns the installation id for a given identifier. | |
exportXMLPageObjects (&$a_xml_writer, $a_inst, &$expLog) | |
export page objects to xml (see ilias_co.dtd) | |
exportXMLMediaObjects (&$a_xml_writer, $a_inst, $a_target_dir, &$expLog) | |
export media objects to xml (see ilias_co.dtd) | |
exportFileItems ($a_target_dir, &$expLog) | |
export files of file itmes | |
from_xml ($xml_text) | |
Imports the test properties from XML into the test object. | |
importObject ($source, $questionpool_id) | |
Imports a test from XML into the ILIAS database. | |
getImportMapping () | |
get array of (two) new created questions for import id | |
getECTSGrade ($reached_points, $max_points) | |
checkMarks () | |
updateTitleAndDescription () | |
Set the title and the description for the meta data. | |
updateMetaData () | |
update meta data only | |
& | _getAvailableTests ($use_object_id=false) |
Returns the available question pools for the active user. | |
cloneRandomQuestions ($new_id) | |
Duplicates the source random questionpools for another test. | |
_clone ($obj_id) | |
Creates a 1:1 copy of the object and places the copy in a given repository. | |
_getRefIdFromObjId ($obj_id) | |
createRandomSolutionsForAllUsers () | |
& | getEvaluationUsers ($user_id) |
Returns an array of users who are selected for a test evaluation of a given user. | |
& | getEvaluationGroups ($user_id) |
Returns an array of groups who are selected for a test evaluation of a given user. | |
removeSelectedUser ($user_id, $evaluator_id) | |
Disinvites a user from a survey. | |
addSelectedUser ($user_id, $evaluator_id) | |
Invites a user to a survey. | |
removeSelectedGroup ($group_id, $evaluator_id) | |
Disinvites a group from a survey. | |
addSelectedGroup ($group_id, $evaluator_id) | |
Invites a group to a survey. | |
getQuestionCount () | |
Returns the number of questions in the test. | |
_goto ($a_target) | |
Redirect script to call a test with the test reference id. | |
removeNonRandomTestData () | |
Removes all test data of a non random test when a test was set to random test. | |
removeRandomTestData () | |
Removes all test data of a random test when a test was set to non random test. | |
logAction ($logtext="", $question_id="") | |
Logs an action into the Test&Assessment log. | |
_getObjectIDFromTestID ($test_id) | |
Returns the ILIAS test object id for a given test id. | |
_getTestIDFromObjectID ($object_id) | |
Returns the ILIAS test id for a given object id. | |
getTextAnswer ($user_id, $question_id) | |
Returns the text answer of a given user for a given question. | |
getQuestiontext ($question_id) | |
Returns the question text for a given question. | |
& | processCSVRow ($row, $quoteAll=FALSE, $separator=";") |
Convertes an array for CSV usage. | |
Static Public Member Functions | |
_hasFinished ($a_user_id, $a_test_id) | |
Returns information if a specific user has finished a test. | |
Data Fields | |
$test_id | |
$author | |
$metadata | |
$questions | |
$introduction | |
$mark_schema | |
$sequence_settings | |
$score_reporting | |
$reporting_date | |
$evaluation_data | |
$test_type | |
$nr_of_tries | |
$processing_time | |
$enable_processing_time | |
$starting_time | |
$ending_time | |
$ects_output | |
$ects_fx | |
$test_types | |
$ects_grades | |
$random_test | |
$random_question_count |
Definition at line 57 of file class.ilObjTest.php.
ilObjTest::_checkCondition | ( | $ | a_exc_id, | |
$ | a_operator, | |||
$ | a_value | |||
) |
Returns a result for a condition check on the class.
Calculates the results of a test for a given user and returns true if the user passed the test, else false
integer | $a_exc_id object id of the test object | |
string | $a_operator The operator which should be checked | |
mixed | $a_value ??? |
Reimplemented from ilObject.
Definition at line 2772 of file class.ilObjTest.php.
References ilObject::$ilias, $result, _getTestResult(), and _hasFinished().
Referenced by ilCourseContentInterface::cci_start_objects(), and ilCourseStart::isFullfilled().
{ global $ilias; switch($a_operator) { case 'passed': $result = ilObjTest::_getTestResult($ilias->account->getId(), $a_exc_id); if ($result["test"]["passed"]) { return true; } else { return false; } break; case 'finished': return ilObjTest::_hasFinished($ilias->account->getId(),$a_exc_id); case 'not_finished': return !ilObjTest::_hasFinished($ilias->account->getId(),$a_exc_id); default: return true; } return true; }
ilObjTest::_clone | ( | $ | obj_id | ) |
Creates a 1:1 copy of the object and places the copy in a given repository.
Creates a 1:1 copy of the object and places the copy in a given repository
public
Definition at line 4936 of file class.ilObjTest.php.
References $_GET, $counter, $obj_id, $xml, ASS_Question::_getOriginalId(), _instanciateQuestion(), domxml_open_mem(), and ilObjTest().
Referenced by ilObjTestGUI::cloneAllObject().
{ $original = new ilObjTest($obj_id, false); $original->loadFromDb(); $newObj = new ilObjTest(); $newObj->setType("tst"); $counter = 2; while ($newObj->testTitleExists($newObj->getTitle() . " ($counter)")) { $counter++; } $newObj->setTitle($original->getTitle() . " ($counter)"); $newObj->setDescription($original->getDescription()); $newObj->create(true); $newObj->createReference(); $newObj->putInTree($_GET["ref_id"]); $newObj->setPermissions($_GET["ref_id"]); // $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId()); $newObj->$author = $original->getAuthor(); $newObj->introduction = $original->getIntroduction(); $newObj->mark_schema = $original->mark_schema; $newObj->sequence_settings = $original->getSequenceSettings(); $newObj->score_reporting = $original->getScoreReporting(); $newObj->reporting_date = $original->getReportingDate(); $newObj->test_type = $original->getTestType(); $newObj->nr_of_tries = $original->getNrOfTries(); $newObj->processing_time = $original->getProcessingTime(); $newObj->enable_processing_time = $original->getEnableProcessingTime(); $newObj->starting_time = $original->getStartingTime(); $newObj->ending_time = $original->getEndingTime(); $newObj->ects_output = $original->ects_output; $newObj->ects_fx = $original->ects_fx; $newObj->ects_grades = $original->ects_grades; $newObj->random_test = $original->random_test; $newObj->random_question_count = $original->random_question_count; $newObj->saveToDb(); if ($original->isRandomTest()) { $newObj->saveRandomQuestionCount($newObj->random_question_count); $original->cloneRandomQuestions($newObj->getTestId()); } else { // clone the questions foreach ($original->questions as $key => $question_id) { $question = ilObjTest::_instanciateQuestion($question_id); $newObj->questions[$key] = $question->duplicate(); // $question->id = -1; $original_id = ASS_Question::_getOriginalId($question_id); $question = ilObjTest::_instanciateQuestion($newObj->questions[$key]); $question->saveToDb($original_id); } } $newObj->saveToDb(); // clone meta data $meta_data =& new ilMetaData($original->getType(), $original->getId()); include_once("./classes/class.ilNestedSetXML.php"); $nested = new ilNestedSetXML(); $nested->dom = domxml_open_mem($meta_data->nested_obj->dom->dump_mem(0)); $nodes = $nested->getDomContent("//MetaData/General", "Identifier"); if (is_array($nodes)) { $nodes[0]["Entry"] = "il__" . $newObj->getType() . "_" . $newObj->getId(); $nested->updateDomContent("//MetaData/General", "Identifier", 0, $nodes[0]); } $xml = $nested->dom->dump_mem(0); $nested->import($xml, $newObj->getId(), $newObj->getType()); }
ilObjTest::_getActiveTestUser | ( | $ | user_id = "" , |
|
$ | test_id = "" | |||
) |
Gets the database row of the tst_active table for the active user.
Gets the database row of the tst_active table for the active user
integer | $user_id The database id of the user | |
integer | $test_id The database id of the test |
Definition at line 2554 of file class.ilObjTest.php.
References $ilUser, $query, $result, $test_id, and $user_id.
{ global $ilDB; global $ilUser; $db =& $ilDB->db; if (!$user_id) { $user_id = $ilUser->id; } if (!$test_id) { return ""; } $query = sprintf("SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s", $db->quote($user_id), $db->quote($test_id) ); $result = $db->query($query); if ($result->numRows()) { return $result->fetchRow(DB_FETCHMODE_OBJECT); } else { return ""; } }
& ilObjTest::_getAvailableTests | ( | $ | use_object_id = false |
) |
Returns the available question pools for the active user.
Returns the available question pools for the active user
Definition at line 4872 of file class.ilObjTest.php.
References $query, $rbacsystem, $result, $row, and ilObject::_hasUntrashedReference().
Referenced by ilObjTestGUI::createObject(), and ilObjAssessmentFolderGUI::logsObject().
{ global $rbacsystem; global $ilDB; $result_array = array(); $query = "SELECT object_data.*, object_data.obj_id, object_reference.ref_id FROM object_data, object_reference WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'tst' ORDER BY object_data.title"; $result = $ilDB->query($query); while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)) { if ($rbacsystem->checkAccess("write", $row->ref_id) && (ilObject::_hasUntrashedReference($row->obj_id))) { if ($use_object_id) { $result_array[$row->obj_id] = $row->title; } else { $result_array[$row->ref_id] = $row->title; } } } return $result_array; }
& ilObjTest::_getMark | ( | $ | user_id, | |
$ | test_obj_id | |||
) |
Returns the resulting mark of a test for a given user.
Returns the resulting mark of a test for a given user
integer | $user_id Database id of the user | |
integer | $test_obj_id Object id of the test |
Definition at line 2834 of file class.ilObjTest.php.
References $result, $user_id, and ilObjTest().
{ $test = new ilObjTest($test_obj_id, false); $test->loadFromDb(); $result =& $test->getTestResult($user_id); if ($result["test"]["total_max_points"] == 0) { $pct = 0; } else { $pct = ($result["test"]["total_reached_points"] / $result["test"]["total_max_points"]) * 100.0; } $mark = $test->mark_schema->get_matching_mark($pct); return $mark; }
ilObjTest::_getObjectIDFromTestID | ( | $ | test_id | ) |
Returns the ILIAS test object id for a given test id.
Returns the ILIAS test object id for a given test id
integer | $test_id The test id |
Definition at line 5361 of file class.ilObjTest.php.
References $query, $result, $row, and $test_id.
Referenced by ASS_MarkSchema::logAction().
{ global $ilDB; $object_id = FALSE; $query = sprintf("SELECT obj_fi FROM tst_tests WHERE test_id = %s", $ilDB->quote($test_id . "") ); $result = $ilDB->query($query); if ($result->numRows()) { $row = $result->fetchRow(DB_FETCHMODE_ASSOC); $object_id = $row["obj_fi"]; } return $object_id; }
& ilObjTest::_getQuestiontypes | ( | ) |
Creates a list of all available question types.
Creates a list of all available question types
Definition at line 4036 of file class.ilObjTest.php.
ilObjTest::_getRefIdFromObjId | ( | $ | obj_id | ) |
Definition at line 5009 of file class.ilObjTest.php.
ilObjTest::_getTestIDFromObjectID | ( | $ | object_id | ) |
Returns the ILIAS test id for a given object id.
Returns the ILIAS test id for a given object id
integer | $object_id The object id |
Definition at line 5386 of file class.ilObjTest.php.
References $query, $result, $row, and $test_id.
Referenced by ilObjAssessmentFolder::getLog().
{ global $ilDB; $test_id = FALSE; $query = sprintf("SELECT test_id FROM tst_tests WHERE obj_fi = %s", $ilDB->quote($object_id . "") ); $result = $ilDB->query($query); if ($result->numRows()) { $row = $result->fetchRow(DB_FETCHMODE_ASSOC); $test_id = $row["test_id"]; } return $test_id; }
& ilObjTest::_getTestResult | ( | $ | user_id, | |
$ | test_obj_id | |||
) |
Calculates the results of a test for a given user.
Calculates the results of a test for a given user and returns an array with all test results
Definition at line 2752 of file class.ilObjTest.php.
References $result, $user_id, and ilObjTest().
Referenced by _checkCondition().
{ $test = new ilObjTest($test_obj_id, false); $test->loadFromDb(); $result =& $test->getTestResult($user_id); return $result; }
ilObjTest::_getTestType | ( | $ | test_id | ) |
Returns the test type for a given test id.
Returns the test type for a given test id
integer | $test_id The database id of the test |
Definition at line 4011 of file class.ilObjTest.php.
References $query, $result, $row, and $test_id.
Referenced by ASS_JavaApplet::to_xml().
{ global $ilDB; $result = ""; $query = sprintf("SELECT tst_test_type.type_tag FROM tst_test_type, tst_tests WHERE tst_test_type.test_type_id = tst_tests.test_type_fi AND tst_tests.test_id = %s", $ilDB->quote($test_id) ); $query_result = $ilDB->query($query); if ($query_result->numRows()) { $row = $query_result->fetchRow(DB_FETCHMODE_ASSOC); $result = $row["type_tag"]; } return $result; }
ilObjTest::_goto | ( | $ | a_target | ) |
Redirect script to call a test with the test reference id.
Redirect script to call a test with the test reference id
integer | $a_target The reference id of the test public |
Definition at line 5255 of file class.ilObjTest.php.
References $ilErr, ilObject::$lng, $rbacsystem, ilSearch::_checkParentConditions(), and ilUtil::redirect().
{ global $rbacsystem, $ilErr, $lng; include_once 'classes/class.ilSearch.php'; // Added this additional check (ParentConditions) to avoid calls of objects inside e.g courses. // Will be replaced in future releases by ilAccess::checkAccess() if ($rbacsystem->checkAccess("read", $a_target) and ilSearch::_checkParentConditions($a_target)) { ilUtil::redirect("assessment/test.php?cmd=run&ref_id=$a_target"); } else { $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL); } }
ilObjTest::_hasFinished | ( | $ | a_user_id, | |
$ | a_test_id | |||
) | [static] |
Returns information if a specific user has finished a test.
integer | $user_id Database id of the user | |
integer | test obj_id |
Definition at line 2809 of file class.ilObjTest.php.
References $query, $res, and ilObjTest().
Referenced by _checkCondition(), and ilCourseObjectiveResult::isSuggested().
{ global $ilDB; $tmp_test =& new ilObjTest($a_test_id,false); $query = "SELECT * FROM tst_active ". "WHERE user_fi = '".$a_user_id."' ". "AND test_fi = '".$tmp_test->getTestId()."' ". "AND tries > '0'"; $res = $ilDB->query($query); return $res->numRows() ? true : false; }
& ilObjTest::_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 3703 of file class.ilObjTest.php.
References ASS_Question::_getQuestionType().
Referenced by ilCourseObjectiveQuestion::__read(), _clone(), ilCourseObjectivesGUI::askDeassignQuestion(), ilCourseObjectivesGUI::assignQuestionSelect(), createRandomSolutionsForAllUsers(), duplicateQuestionForTest(), getEstimatedWorkingTime(), ilCourseObjectiveQuestion::getMaxPointsByObjective(), ilCourseObjectiveQuestion::getMaxPointsByTest(), getTestResult(), ilCourseObjectivesGUI::listAssignedQuestions(), and to_xml().
{ if (strcmp($question_id, "") != 0) { $question_type = ASS_Question::_getQuestionType($question_id); switch ($question_type) { case "qt_cloze": $question = new ASS_ClozeTest(); break; case "qt_matching": $question = new ASS_MatchingQuestion(); break; case "qt_ordering": $question = new ASS_OrderingQuestion(); break; case "qt_imagemap": $question = new ASS_ImagemapQuestion(); break; case "qt_multiple_choice_sr": case "qt_multiple_choice_mr": $question = new ASS_MultipleChoice(); break; case "qt_javaapplet": $question = new ASS_JavaApplet(); break; case "qt_text": $question = new ASS_TextQuestion(); break; default: // Return false if question id does not exists or type is unknown return false; } $question->loadFromDb($question_id); return $question; } }
ilObjTest::_isComplete | ( | $ | obj_id | ) |
Returns true, if a test is complete for use.
Returns true, if a test is complete for use
Definition at line 887 of file class.ilObjTest.php.
References $obj_id, and ilObjTest().
Referenced by ilCourseContentInterface::cci_view().
ilObjTest::addSelectedGroup | ( | $ | group_id, | |
$ | evaluator_id | |||
) |
Invites a group to a survey.
Invites a group to a survey
integer | $group_id The database id of the invited group public |
Definition at line 5194 of file class.ilObjTest.php.
References $query, and $result.
{ $query = sprintf("SELECT group_fi FROM tst_eval_groups WHERE test_fi = %s AND evaluator_fi = %s AND group_fi = %s", $this->ilias->db->quote($this->getTestId() . ""), $this->ilias->db->quote($evaluator_id . ""), $this->ilias->db->quote($group_id . "") ); $result = $this->ilias->db->query($query); if ($result->numRows() < 1) { $query = sprintf("INSERT INTO tst_eval_groups (eval_groups_id, test_fi, evaluator_fi, group_fi, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)", $this->ilias->db->quote($this->getTestId() . ""), $this->ilias->db->quote($evaluator_id . ""), $this->ilias->db->quote($group_id . "") ); $result = $this->ilias->db->query($query); } }
ilObjTest::addSelectedUser | ( | $ | user_id, | |
$ | evaluator_id | |||
) |
Invites a user to a survey.
Invites a user to a survey
integer | $user_id The database id of the invited user public |
Definition at line 5149 of file class.ilObjTest.php.
References $query, $result, and $user_id.
{ $query = sprintf("SELECT user_fi FROM tst_eval_users WHERE test_fi = %s AND evaluator_fi = %s AND user_fi = %s", $this->ilias->db->quote($this->getTestId() . ""), $this->ilias->db->quote($evaluator_id . ""), $this->ilias->db->quote($user_id . "") ); $result = $this->ilias->db->query($query); if ($result->numRows() < 1) { $query = sprintf("INSERT INTO tst_eval_users (eval_users_id, test_fi, evaluator_fi, user_fi, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)", $this->ilias->db->quote($this->getTestId() . ""), $this->ilias->db->quote($evaluator_id . ""), $this->ilias->db->quote($user_id . "") ); $result = $this->ilias->db->query($query); } }
ilObjTest::assignMetaData | ( | &$ | a_meta_data | ) |
assign a meta data object to glossary object
object | $a_meta_data meta data object |
Definition at line 2856 of file class.ilObjTest.php.
Referenced by ilObjTest(), and initMeta().
{ $this->meta_data =& $a_meta_data; }
ilObjTest::canViewResults | ( | ) |
Returns true, if the test results can be viewed.
Returns true, if the test results can be viewed
Definition at line 2916 of file class.ilObjTest.php.
References $result, getReportingDate(), and getTestType().
{ $result = true; if ($this->getTestType() == TYPE_ASSESSMENT) { if ($this->getReportingDate()) { preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->getReportingDate(), $matches); $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); $now = mktime(); if ($now < $epoch_time) { $result = false; } } } return $result; }
ilObjTest::checkMarks | ( | ) |
Definition at line 4828 of file class.ilObjTest.php.
{
return $this->mark_schema->checkMarks();
}
ilObjTest::clearEvalSelectedGroups | ( | ) |
Removes all selected groups for the test evaluation.
Removes all selected groups for the test evaluation
public
Definition at line 1836 of file class.ilObjTest.php.
References $query, and $result.
Referenced by removeAllTestEditings().
{ $query = sprintf("DELETE FROM tst_eval_groups WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); }
ilObjTest::clearEvalSelectedUsers | ( | ) |
Removes all selected users for the test evaluation.
Removes all selected users for the test evaluation
public
Definition at line 1821 of file class.ilObjTest.php.
References $query, and $result.
Referenced by removeAllTestEditings().
{ $query = sprintf("DELETE FROM tst_eval_users WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); }
ilObjTest::cloneRandomQuestions | ( | $ | new_id | ) |
Duplicates the source random questionpools for another test.
Duplicates the source random questionpools for another test
integer | $new_id Test id of the new test which should take the random questionpools public |
Definition at line 4905 of file class.ilObjTest.php.
References $query, $result, and $row.
{ if ($new_id > 0) { $query = sprintf("SELECT * FROM tst_test_random WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId() . "") ); $result = $this->ilias->db->query($query); if ($result->numRows()) { while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { $query = sprintf("INSERT INTO tst_test_random (test_random_id, test_fi, questionpool_fi, num_of_q, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)", $this->ilias->db->quote($new_id . ""), $this->ilias->db->quote($row["questionpool_fi"] . ""), $this->ilias->db->quote($row["num_of_q"] . "") ); $insertresult = $this->ilias->db->query($query); } } } }
ilObjTest::create | ( | $ | a_upload = false |
) |
create test object
Definition at line 325 of file class.ilObjTest.php.
References ilObject::create(), ilObject::getDescription(), ilObject::getId(), ilObject::getTitle(), and ilObject::getType().
{ parent::create(); if (!$a_upload) { $this->meta_data->setId($this->getId()); $this->meta_data->setType($this->getType()); $this->meta_data->setTitle($this->getTitle()); $this->meta_data->setDescription($this->getDescription()); $this->meta_data->setObject($this); $this->meta_data->create(); } }
ilObjTest::createExportDirectory | ( | ) |
creates data directory for export files (data_dir/tst_data/tst_<id>/export, depending on data directory that is set in ILIAS setup/ini)
Definition at line 621 of file class.ilObjTest.php.
References ilUtil::getDataDir(), ilObject::getId(), and ilUtil::makeDir().
{ $tst_data_dir = ilUtil::getDataDir()."/tst_data"; ilUtil::makeDir($tst_data_dir); if(!is_writable($tst_data_dir)) { $this->ilias->raiseError("Test Data Directory (".$tst_data_dir .") not writeable.",$this->ilias->error_obj->MESSAGE); } // create learning module directory (data_dir/lm_data/lm_<id>) $tst_dir = $tst_data_dir."/tst_".$this->getId(); ilUtil::makeDir($tst_dir); if(!@is_dir($tst_dir)) { $this->ilias->raiseError("Creation of Test Directory failed.",$this->ilias->error_obj->MESSAGE); } // create Export subdirectory (data_dir/lm_data/lm_<id>/Export) $export_dir = $tst_dir."/export"; ilUtil::makeDir($export_dir); if(!@is_dir($export_dir)) { $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->MESSAGE); } }
ilObjTest::createImportDirectory | ( | ) |
creates data directory for import files (data_dir/tst_data/tst_<id>/import, depending on data directory that is set in ILIAS setup/ini)
Definition at line 711 of file class.ilObjTest.php.
References ilUtil::getDataDir(), ilObject::getId(), and ilUtil::makeDir().
{ $tst_data_dir = ilUtil::getDataDir()."/tst_data"; ilUtil::makeDir($tst_data_dir); if(!is_writable($tst_data_dir)) { $this->ilias->raiseError("Test Data Directory (".$tst_data_dir .") not writeable.",$this->ilias->error_obj->FATAL); } // create test directory (data_dir/tst_data/tst_<id>) $tst_dir = $tst_data_dir."/tst_".$this->getId(); ilUtil::makeDir($tst_dir); if(!@is_dir($tst_dir)) { $this->ilias->raiseError("Creation of Test Directory failed.",$this->ilias->error_obj->FATAL); } // create import subdirectory (data_dir/tst_data/tst_<id>/import) $import_dir = $tst_dir."/import"; ilUtil::makeDir($import_dir); if(!@is_dir($import_dir)) { $this->ilias->raiseError("Creation of Import Directory failed.",$this->ilias->error_obj->FATAL); } }
& ilObjTest::createQuestionGUI | ( | $ | question_type, | |
$ | question_id = -1 | |||
) |
Creates a question GUI instance of a given question type.
Creates a question GUI instance of a given question type
integer | $question_type The question type of the question | |
integer | $question_id The question id of the question, if available |
Definition at line 3652 of file class.ilObjTest.php.
References getQuestionType().
{ if ((!$question_type) and ($question_id > 0)) { $question_type = $this->getQuestionType($question_id); } switch ($question_type) { case "qt_multiple_choice_sr": $question =& new ASS_MultipleChoiceGUI(); $question->object->set_response(RESPONSE_SINGLE); break; case "qt_multiple_choice_mr": $question =& new ASS_MultipleChoiceGUI(); $question->object->set_response(RESPONSE_MULTIPLE); break; case "qt_cloze": $question =& new ASS_ClozeTestGUI(); break; case "qt_matching": $question =& new ASS_MatchingQuestionGUI(); break; case "qt_ordering": $question =& new ASS_OrderingQuestionGUI(); break; case "qt_imagemap": $question =& new ASS_ImagemapQuestionGUI(); break; case "qt_javaapplet": $question =& new ASS_JavaAppletGUI(); break; case "qt_text": $question =& new ASS_TextQuestionGUI(); break; } if ($question_id > 0) { $question->object->loadFromDb($question_id); } return $question; }
ilObjTest::createRandomSolutionsForAllUsers | ( | ) |
Definition at line 5026 of file class.ilObjTest.php.
References $ilUser, $query, $user_id, ilObjUser::_getAllUserData(), _instanciateQuestion(), getActiveTestUser(), and getTestId().
{ global $ilDB; global $ilUser; $db =& $ilDB->db; $sequence_arr = array_flip($this->questions); $sequence = join($sequence_arr, ","); require_once("./classes/class.ilObjUser.php"); $logins = ilObjUser::_getAllUserData(array("login")); foreach ($logins as $login) { $user_id = $login["usr_id"]; $old_active = $this->getActiveTestUser($user_id); if ($old_active) { $query = sprintf("UPDATE tst_active SET lastindex = %s, sequence = %s, postponed = %s, tries = %s WHERE user_fi = %s AND test_fi = %s", $db->quote("0"), $db->quote($sequence), $db->quote(""), $db->quote("1"), $db->quote($user_id), $db->quote($this->getTestId()) ); } else { $sequence_arr = array_flip($this->questions); $sequence = join($sequence_arr, ","); $query = sprintf("INSERT INTO tst_active (active_id, user_fi, test_fi, sequence, postponed, lastindex, tries, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, NULL)", $db->quote($user_id), $db->quote($this->getTestId()), $db->quote($sequence), $db->quote(""), $db->quote("0"), $db->quote("1") ); } $db->query($query); } foreach ($this->questions as $question_id) { $question =& ilObjTest::_instanciateQuestion($question_id); foreach ($logins as $login) { $question->createRandomSolution($this->getTestId(), $login["usr_id"]); } } }
ilObjTest::createReference | ( | ) |
Creates a database reference id for the object.
Creates a database reference id for the object (saves the object to the database and creates a reference id in the database)
public
Reimplemented from ilObject.
Definition at line 365 of file class.ilObjTest.php.
References $result, and saveToDb().
{ $result = parent::createReference(); $this->saveToDb(); return $result; }
ilObjTest::decrementSequenceByResult | ( | $ | a_sequence | ) |
decrements sequence to the next wrong answered question
int | sequence |
Definition at line 2413 of file class.ilObjTest.php.
References $ilUser, $result, getQuestionIdFromActiveUserSequence(), and getTestResult().
{ for($i = $a_sequence; $i > 0; $i--) { $qid = $this->getQuestionIdFromActiveUserSequence($i); foreach($this->getTestResult($ilUser->getId()) as $result) { if($qid == $result['qid']) { if($result['max'] != $result['reached']) { return $i; } } } } return 1; }
ilObjTest::delete | ( | ) |
delete object and all related data
public
Reimplemented from ilObject.
Definition at line 429 of file class.ilObjTest.php.
References deleteTest().
{ // always call parent delete function first!! if (!parent::delete()) { return false; } //put here your module specific stuff $this->deleteTest(); return true; }
ilObjTest::deleteActiveTests | ( | ) |
Deletes all active references to this test.
Deletes all active references to this test. This is necessary, if the test has been changed to guarantee the same conditions for all users.
public
Definition at line 1896 of file class.ilObjTest.php.
References $query, and $result.
Referenced by removeAllTestEditings().
{ $query = sprintf("DELETE FROM tst_active WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); }
ilObjTest::deleteResults | ( | $ | user_id = "" , |
|
$ | a_delete_active = false | |||
) |
Removes all question solutions for a given user.
Removes all question solutions for a given user The tst_active table is not affected. Only the existing solutions for all questions the user answered will be removed. This resets the test to the default values
public
Definition at line 1914 of file class.ilObjTest.php.
References $query, $result, $user_id, and getTestId().
{ if ($user_id) { $query = sprintf("DELETE FROM tst_solutions WHERE test_fi = %s AND user_fi = %s", $this->ilias->db->quote($this->getTestId()), $this->ilias->db->quote($user_id) ); $result = $this->ilias->db->query($query); $sequence_arr = array_flip($this->questions); $sequence = join($sequence_arr, ","); $query = sprintf("UPDATE tst_active SET sequence = %s, lastindex = %s WHERE test_fi = %s and user_fi = %s", $this->ilias->db->quote($sequence), $this->ilias->db->quote("1"), $this->ilias->db->quote($this->getTestId()), $this->ilias->db->quote($user_id) ); $result = $this->ilias->db->query($query); if($a_delete_active) { $query = "DELETE FROM tst_active ". "WHERE user_fi = '".$user_id."' ". "AND test_fi = '".$this->getTestId()."'"; $this->ilias->db->query($query); } } }
ilObjTest::deleteTest | ( | ) |
Deletes the test and all related objects, files and database entries.
Deletes the test and all related objects, files and database entries
public
Definition at line 450 of file class.ilObjTest.php.
References $query, $result, $row, ilUtil::getDataDir(), ilObject::getId(), removeAllTestEditings(), and removeQuestion().
Referenced by delete().
{ $query = sprintf("SELECT active_id FROM tst_active WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); $active_array = array(); while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { array_push($active_array, $row["active_id"]); } $query = sprintf("DELETE FROM tst_active WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); if (count($active_array)) { foreach ($active_array as $active_id) { $query = sprintf("DELETE FROM tst_times WHERE active_fi = %s", $this->ilias->db->quote($active_id) ); $result = $this->ilias->db->query($query); } } $query = sprintf("DELETE FROM tst_mark WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); $query = sprintf("SELECT question_fi FROM tst_test_question WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)) { $this->removeQuestion($row->question_fi); } $query = sprintf("DELETE FROM tst_tests WHERE test_id = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); $query = sprintf("DELETE FROM tst_test_random WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); $query = sprintf("DELETE FROM tst_test_random_question WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); $this->removeAllTestEditings(); $query = sprintf("DELETE FROM tst_test_question WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); // delete export files $tst_data_dir = ilUtil::getDataDir()."/tst_data"; $directory = $tst_data_dir."/tst_".$this->getId(); if (is_dir($directory)) { $directory = escapeshellarg($directory); exec("rm -rf $directory"); } }
ilObjTest::duplicate | ( | ) |
Duplicates the ilObjTest object.
Duplicates the ilObjTest object
public
Definition at line 815 of file class.ilObjTest.php.
References $counter, $data, $query, $result, and testTitleExists().
{ $clone = $this; $clone->set_id(-1); $counter = 2; while ($this->testTitleExists($this->get_title() . " ($counter)")) { $counter++; } $clone->set_title($this->get_title() . " ($counter)"); $clone->set_owner($this->ilias->account->id); $clone->setAuthor($this->ilias->account->fullname); $clone->saveToDb($this->ilias->db); // Duplicate questions $query = sprintf("SELECT * FROM tst_test_question WHERE test_fi = %s", $this->ilias->db->quote($this->getId()) ); $result = $this->ilias->db->query($query); while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT)) { $query = sprintf("INSERT INTO tst_test_question (test_question_id, test_fi, question_fi, sequence, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)", $this->ilias->db->quote($clone->getId()), $this->ilias->db->quote($data->question_fi), $this->ilias->db->quote($data->sequence) ); $insert_result = $this->ilias->db->query($query); } }
ilObjTest::duplicateQuestionForTest | ( | $ | question_id | ) |
Takes a question and creates a copy of the question for use in the test.
Takes a question and creates a copy of the question for use in the test
integer | $question_id The database id of the question |
Definition at line 2045 of file class.ilObjTest.php.
References $ilUser, and _instanciateQuestion().
Referenced by insertQuestion().
{ global $ilUser; $question =& ilObjTest::_instanciateQuestion($question_id); $duplicate_id = $question->duplicate(true); return $duplicate_id; }
ilObjTest::endingTimeReached | ( | ) |
Returns true if the ending time of a test is reached.
Returns true if the ending time of a test is reached An ending time is not available for self assessment tests
Definition at line 3829 of file class.ilObjTest.php.
References getEndingTime(), and getTestType().
{ if ($this->getTestType() == TYPE_ASSESSMENT) { if ($this->getEndingTime()) { preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->getEndingTime(), $matches); $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); $now = mktime(); if ($now > $epoch_time) { // ending time reached return true; } } } return false; }
ilObjTest::evalLoadStatisticalSettings | ( | $ | user_id | ) |
Retrieves the user settings for the statistical evaluation tool.
Retrieves the user settings for the statistical evaluation tool
Definition at line 2943 of file class.ilObjTest.php.
References $q, $result, and $row.
{ $q = sprintf("SELECT * FROM tst_eval_settings WHERE user_fi = %s", $this->ilias->db->quote("$user_id") ); $result = $this->ilias->db->query($q); if (!$result->numRows()) { $row = array( "qworkedthrough" => "1", "pworkedthrough" => "1", "timeofwork" => "1", "atimeofwork" => "1", "firstvisit" => "1", "lastvisit" => "1", "resultspoints" => "1", "resultsmarks" => "1", "distancemedian" => "1" ); } else { $row = $result->fetchRow(DB_FETCHMODE_ASSOC); unset($row["eval_settings_id"]); } return $row; }
ilObjTest::evalSaveStatisticalSettings | ( | $ | settings_array, | |
$ | user_id | |||
) |
Saves the user settings for the statistical evaluation tool.
Saves the user settings for the statistical evaluation tool
array | $settings_array An array containing the user settings public |
Definition at line 2979 of file class.ilObjTest.php.
References $q, $result, and $row.
{ $q = sprintf("SELECT * FROM tst_eval_settings WHERE user_fi = %s", $this->ilias->db->quote("$user_id") ); $result = $this->ilias->db->query($q); if ($result->numRows() > 0) { $row = $result->fetchRow(DB_FETCHMODE_ASSOC); } $update = $row["eval_settings_id"]; if (!$update) { $q = sprintf("INSERT INTO tst_eval_settings ". "(eval_settings_id, user_fi, qworkedthrough, pworkedthrough, timeofwork, atimeofwork, firstvisit, " . "lastvisit, resultspoints, resultsmarks, distancemedian, TIMESTAMP) VALUES " . "(NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL)", $this->ilias->db->quote("$user_id"), $this->ilias->db->quote(sprintf("%01d", $settings_array["qworkedthrough"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["pworkedthrough"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["timeofwork"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["atimeofwork"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["firstvisit"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["lastvisit"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["resultspoints"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["resultsmarks"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["distancemedian"])) ); } else { $q = sprintf("UPDATE tst_eval_settings SET ". "qworkedthrough = %s, pworkedthrough = %s, timeofwork = %s, atimeofwork = %s, firstvisit = %s, " . "lastvisit = %s, resultspoints = %s, resultsmarks = %s, distancemedian = %s " . "WHERE eval_settings_id = %s", $this->ilias->db->quote(sprintf("%01d", $settings_array["qworkedthrough"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["pworkedthrough"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["timeofwork"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["atimeofwork"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["firstvisit"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["lastvisit"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["resultspoints"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["resultsmarks"])), $this->ilias->db->quote(sprintf("%01d", $settings_array["distancemedian"])), $this->ilias->db->quote("$update") ); } $result = $this->ilias->db->query($q); }
& ilObjTest::evalStatistical | ( | $ | user_id | ) |
Returns the statistical evaluation of the test for a specified user.
Returns the statistical evaluation of the test for a specified user
Definition at line 3063 of file class.ilObjTest.php.
References $q, $result, $row, $user_id, getTestId(), and getTestResult().
{ // global $ilBench; $test_result =& $this->getTestResult($user_id); $q = sprintf("SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_times.active_fi AND tst_active.user_fi = %s", $this->ilias->db->quote($this->getTestId()), $this->ilias->db->quote($user_id) ); $result = $this->ilias->db->query($q); $times = array(); $first_visit = ""; $last_visit = ""; while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)) { preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row->started, $matches); $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); if (!$first_visit) { $first_visit = $epoch_1; } if ($epoch_1 < $first_visit) { $first_visit = $epoch_1; } preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row->finished, $matches); $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); if (!$last_visit) { $last_visit = $epoch_2; } if ($epoch_2 > $last_visit) { $last_visit = $epoch_2; } $times[$row->active_fi] += ($epoch_2 - $epoch_1); } $max_time = 0; foreach ($times as $key => $value) { $max_time += $value; } if ((!$test_result["test"]["total_reached_points"]) or (!$test_result["test"]["total_max_points"])) { $percentage = 0.0; } else { $percentage = ($test_result["test"]["total_reached_points"] / $test_result["test"]["total_max_points"]) * 100.0; } $mark_obj = $this->mark_schema->get_matching_mark($percentage); $first_date = getdate($first_visit); $last_date = getdate($last_visit); $qworkedthrough = 0; $query_worked_through = sprintf("SELECT DISTINCT(question_fi) FROM tst_solutions WHERE user_fi = %s AND test_fi = %s", $this->ilias->db->quote("$user_id"), $this->ilias->db->quote($this->getTestId()) ); $worked_through_result = $this->ilias->db->query($query_worked_through); if (!$worked_through_result->numRows()) { $atimeofwork = 0; } else { $atimeofwork = $max_time / $worked_through_result->numRows(); } $result_mark = ""; $passed = ""; if ($mark_obj) { $result_mark = $mark_obj->get_short_name(); if ($mark_obj->get_passed()) { $passed = 1; } else { $passed = 0; } } $result_array = array( "qworkedthrough" => $worked_through_result->numRows(), "qmax" => count($this->questions), "pworkedthrough" => ($worked_through_result->numRows()) / count($this->questions), "timeofwork" => $max_time, "atimeofwork" => $atimeofwork, "firstvisit" => $first_date, "lastvisit" => $last_date, "resultspoints" => $test_result["test"]["total_reached_points"], "maxpoints" => $test_result["test"]["total_max_points"], "resultsmarks" => $result_mark, "passed" => $passed, "distancemedian" => "0" ); foreach ($test_result as $key => $value) { if (preg_match("/\d+/", $key)) { $result_array[$key] = $value; } } return $result_array; }
ilObjTest::evalTotalFinished | ( | ) |
Returns the number of total finished tests.
Returns the number of total finished tests
Definition at line 3248 of file class.ilObjTest.php.
ilObjTest::evalTotalFinishedAverageTime | ( | ) |
Returns the average processing time for total finished tests.
Returns the average processing time for total finished tests
Definition at line 3333 of file class.ilObjTest.php.
References $counter, $q, $result, and $row.
{ $q = sprintf("SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.test_fi = %s AND tst_active.tries > 0 AND tst_active.active_id = tst_times.active_fi", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($q); $times = array(); while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)) { preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row->started, $matches); $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row->finished, $matches); $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); $times[$row->active_fi] += ($epoch_2 - $epoch_1); } $max_time = 0; $counter = 0; foreach ($times as $key => $value) { $max_time += $value; $counter++; } if ($counter) { $average_time = round($max_time / $counter); } else { $average_time = 0; } return $average_time; }
ilObjTest::evalTotalFinishedPassed | ( | ) |
Returns the total passed tests and the average reached points.
Returns the total passed tests and the average reached points
Definition at line 3267 of file class.ilObjTest.php.
References $counter, $q, $res, $result, $row, and getTestResult().
{ $q = sprintf("SELECT * FROM tst_active WHERE test_fi = %s AND tries > 0", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($q); $points = array(); $passed_tests = 0; $failed_tests = 0; $maximum_points = 0; while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)) { $res =& $this->getTestResult($row->user_fi); if ((!$res["test"]["total_reached_points"]) or (!$res["test"]["total_max_points"])) { $percentage = 0.0; } else { $percentage = ($res["test"]["total_reached_points"] / $res["test"]["total_max_points"]) * 100.0; } $mark_obj = $this->mark_schema->get_matching_mark($percentage); $maximum_points = $res["test"]["total_max_points"]; if ($mark_obj) { if ($mark_obj->get_passed()) { $passed_tests++; array_push($points, $res["test"]["total_reached_points"]); } else { $failed_tests++; } } } $reached_points = 0; $counter = 0; foreach ($points as $key => $value) { $reached_points += $value; $counter++; } if ($counter) { $average_points = round($reached_points / $counter); } else { $average_points = 0; } return array( "total_passed" => $passed_tests, "total_failed" => $failed_tests, "average_points" => $average_points, "maximum_points" => $maximum_points ); }
ilObjTest::evalTotalPersons | ( | ) |
Returns the number of persons who started the test.
Returns the number of persons who started the test
Definition at line 2898 of file class.ilObjTest.php.
& ilObjTest::evalTotalPersonsArray | ( | ) |
Returns all persons who started the test.
Returns all persons who started the test
Definition at line 3219 of file class.ilObjTest.php.
References $q, $result, and $row.
Referenced by getTotalPointsArray(), and getTotalPointsPassedArray().
{ $q = sprintf("SELECT tst_active.user_fi, usr_data.firstname, usr_data.lastname, usr_data.title FROM tst_active LEFT JOIN usr_data ON tst_active.user_fi = usr_data.usr_id WHERE tst_active.test_fi = %s ORDER BY usr_data.lastname", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($q); $persons_array = array(); while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)) { if (strlen($row->firstname.$row->lastname.$row->title) == 0) { $persons_array[$row->user_fi] = $this->lng->txt("deleted_user"); } else { $persons_array[$row->user_fi] = trim("$row->lastname, $row->firstname $row->title"); } } return $persons_array; }
ilObjTest::exportFileItems | ( | $ | a_target_dir, | |
&$ | expLog | |||
) |
export files of file itmes
Definition at line 4434 of file class.ilObjTest.php.
References $file_obj.
Referenced by exportPagesXML().
{ include_once("classes/class.ilObjFile.php"); foreach ($this->file_ids as $file_id) { $expLog->write(date("[y-m-d H:i:s] ")."File Item ".$file_id); $file_obj = new ilObjFile($file_id, false); $file_obj->export($a_target_dir); unset($file_obj); } }
ilObjTest::exportPagesXML | ( | &$ | a_xml_writer, | |
$ | a_inst, | |||
$ | a_target_dir, | |||
&$ | expLog | |||
) |
export pages of test to xml (see ilias_co.dtd)
object | $a_xml_writer ilXmlWriter object that receives the xml data |
Definition at line 4277 of file class.ilObjTest.php.
References $ilBench, exportFileItems(), exportXMLMediaObjects(), exportXMLMetaData(), and exportXMLPageObjects().
{ global $ilBench; $this->mob_ids = array(); $this->file_ids = array(); $attrs = array(); $attrs["Type"] = "Test"; $a_xml_writer->xmlStartTag("ContentObject", $attrs); // MetaData $this->exportXMLMetaData($a_xml_writer); // PageObjects $expLog->write(date("[y-m-d H:i:s] ")."Start Export Page Objects"); $ilBench->start("ContentObjectExport", "exportPageObjects"); $this->exportXMLPageObjects($a_xml_writer, $a_inst, $expLog); $ilBench->stop("ContentObjectExport", "exportPageObjects"); $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Page Objects"); // MediaObjects $expLog->write(date("[y-m-d H:i:s] ")."Start Export Media Objects"); $ilBench->start("ContentObjectExport", "exportMediaObjects"); $this->exportXMLMediaObjects($a_xml_writer, $a_inst, $a_target_dir, $expLog); $ilBench->stop("ContentObjectExport", "exportMediaObjects"); $expLog->write(date("[y-m-d H:i:s] ")."Finished Export Media Objects"); // FileItems $expLog->write(date("[y-m-d H:i:s] ")."Start Export File Items"); $ilBench->start("ContentObjectExport", "exportFileItems"); $this->exportFileItems($a_target_dir, $expLog); $ilBench->stop("ContentObjectExport", "exportFileItems"); $expLog->write(date("[y-m-d H:i:s] ")."Finished Export File Items"); $a_xml_writer->xmlEndTag("ContentObject"); }
ilObjTest::exportXMLMediaObjects | ( | &$ | a_xml_writer, | |
$ | a_inst, | |||
$ | a_target_dir, | |||
&$ | expLog | |||
) |
export media objects to xml (see ilias_co.dtd)
object | $a_xml_writer ilXmlWriter object that receives the xml data |
Definition at line 4416 of file class.ilObjTest.php.
Referenced by exportPagesXML().
{ include_once("content/classes/Media/class.ilObjMediaObject.php"); foreach ($this->mob_ids as $mob_id) { $expLog->write(date("[y-m-d H:i:s] ")."Media Object ".$mob_id); $media_obj = new ilObjMediaObject($mob_id); $media_obj->exportXML($a_xml_writer, $a_inst); $media_obj->exportFiles($a_target_dir); unset($media_obj); } }
ilObjTest::exportXMLMetaData | ( | &$ | a_xml_writer | ) |
export content objects meta data to xml (see ilias_co.dtd)
object | $a_xml_writer ilXmlWriter object that receives the xml data |
Definition at line 4321 of file class.ilObjTest.php.
References ilObject::getType().
Referenced by exportPagesXML().
{ $nested = new ilNestedSetXML(); $nested->setParameterModifier($this, "modifyExportIdentifier"); $a_xml_writer->appendXML($nested->export($this->getId(), $this->getType())); }
ilObjTest::exportXMLPageObjects | ( | &$ | a_xml_writer, | |
$ | a_inst, | |||
&$ | expLog | |||
) |
export page objects to xml (see ilias_co.dtd)
object | $a_xml_writer ilXmlWriter object that receives the xml data |
Definition at line 4353 of file class.ilObjTest.php.
References $ilBench, and $xml.
Referenced by exportPagesXML().
{ global $ilBench; include_once "./content/classes/class.ilLMPageObject.php"; foreach ($this->questions as $question_id) { $ilBench->start("ContentObjectExport", "exportPageObject"); $expLog->write(date("[y-m-d H:i:s] ")."Page Object ".$question_id); $attrs = array(); $a_xml_writer->xmlStartTag("PageObject", $attrs); // export xml to writer object $ilBench->start("ContentObjectExport", "exportPageObject_XML"); $page_object = new ilPageObject("qpl", $question_id); $page_object->buildDom(); $page_object->insertInstIntoIDs($a_inst); $mob_ids = $page_object->collectMediaObjects(false); $file_ids = $page_object->collectFileItems(); $xml = $page_object->getXMLFromDom(false, false, false, "", true); $xml = str_replace("&","&", $xml); $a_xml_writer->appendXML($xml); $page_object->freeDom(); unset ($page_object); $ilBench->stop("ContentObjectExport", "exportPageObject_XML"); // collect media objects $ilBench->start("ContentObjectExport", "exportPageObject_CollectMedia"); //$mob_ids = $page_obj->getMediaObjectIDs(); foreach($mob_ids as $mob_id) { $this->mob_ids[$mob_id] = $mob_id; } $ilBench->stop("ContentObjectExport", "exportPageObject_CollectMedia"); // collect all file items $ilBench->start("ContentObjectExport", "exportPageObject_CollectFileItems"); //$file_ids = $page_obj->getFileItemIds(); foreach($file_ids as $file_id) { $this->file_ids[$file_id] = $file_id; } $ilBench->stop("ContentObjectExport", "exportPageObject_CollectFileItems"); $a_xml_writer->xmlEndTag("PageObject"); //unset($page_obj); $ilBench->stop("ContentObjectExport", "exportPageObject"); } }
ilObjTest::from_xml | ( | $ | xml_text | ) |
Imports the test properties from XML into the test object.
Imports the test properties from XML into the test object
Definition at line 4455 of file class.ilObjTest.php.
References $result, $score_reporting, domxml_open_mem(), setAuthor(), ilObject::setDescription(), setEndingTime(), setIntroduction(), setNrOfTries(), setProcessingTime(), setRandomQuestionCount(), setRandomTest(), setReportingDate(), setScoreReporting(), setSequenceSettings(), setStartingTime(), setTestType(), and ilObject::setTitle().
Referenced by importObject().
{ $result = false; $this->mark_schema->flush(); $xml_text = preg_replace("/>\s*?</", "><", $xml_text); $domxml = domxml_open_mem($xml_text); if (!empty($domxml)) { $root = $domxml->document_element(); $this->setTitle($root->get_attribute("title")); $item = $root; $itemnodes = $item->child_nodes(); foreach ($itemnodes as $index => $node) { switch ($node->node_name()) { case "qticomment": $comment = $node->get_content(); if (strpos($comment, "Author=") !== false) { $comment = str_replace("Author=", "", $comment); $this->setAuthor($comment); } elseif (strpos($comment, "ILIAS Version=") !== false) { } else { $this->setDescription($comment); } break; case "duration": $iso8601period = $node->get_content(); if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches)) { $this->enable_processing_time = 1; $this->setProcessingTime(sprintf("%02d:%02d:%02d", $matches[4], $matches[5], $matches[6])); } break; case "assessmentcontrol": $score_reporting = $node->get_attribute("solutionswitch"); switch (strtolower($score_reporting)) { case "1": case "yes": $score_reporting = 1; break; default: $score_reporting = 0; break; } $this->setScoreReporting($score_reporting); break; case "objectives": $material = $node->first_child(); if (strcmp($material->get_attribute("label"), "introduction") == 0) { $mattext = $material->first_child(); $this->setIntroduction($mattext->get_content()); } break; case "qtimetadata": $metadata_fields = $node->child_nodes(); foreach ($metadata_fields as $index => $metadata_field) { $fieldlabel = $metadata_field->first_child(); $fieldentry = $fieldlabel->next_sibling(); switch ($fieldlabel->get_content()) { case "sequence_settings": $this->setSequenceSettings($fieldentry->get_content()); break; case "author": $this->setAuthor($fieldentry->get_content()); break; case "test_type": $this->setTestType($fieldentry->get_content()); break; case "reporting_date": $iso8601period = $fieldentry->get_content(); if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches)) { $this->setReportingDate(sprintf("%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6])); } break; case "nr_of_tries": $this->setNrOfTries($fieldentry->get_content()); break; case "random_test": $this->setRandomTest($fieldentry->get_content()); break; case "random_question_count": $this->setRandomQuestionCount($fieldentry->get_content()); break; case "starting_time": $iso8601period = $fieldentry->get_content(); if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches)) { $this->setStartingTime(sprintf("%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6])); } break; case "ending_time": $iso8601period = $fieldentry->get_content(); if (preg_match("/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M(\d+)S/", $iso8601period, $matches)) { $this->setEndingTime(sprintf("%02d%02d%02d%02d%02d%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6])); } break; } if (preg_match("/mark_step_\d+/", $fieldlabel->get_content())) { $xmlmark = $fieldentry->get_content(); preg_match("/<short>(.*?)<\/short>/", $xmlmark, $matches); $mark_short = $matches[1]; preg_match("/<official>(.*?)<\/official>/", $xmlmark, $matches); $mark_official = $matches[1]; preg_match("/<percentage>(.*?)<\/percentage>/", $xmlmark, $matches); $mark_percentage = $matches[1]; preg_match("/<passed>(.*?)<\/passed>/", $xmlmark, $matches); $mark_passed = $matches[1]; $this->mark_schema->add_mark_step($mark_short, $mark_official, $mark_percentage, $mark_passed); } } break; } } $result = true; } return $result; }
& ilObjTest::get_qpl_titles | ( | ) |
Get the titles of all available questionpools for the current user.
Get the titles of all available questionpools for the current user
Definition at line 2192 of file class.ilObjTest.php.
References $query, $rbacsystem, $result, $row, and ilObject::_hasUntrashedReference().
{ global $rbacsystem; $qpl_titles = array(); // get all available questionpools and remove the trashed questionspools $query = "SELECT object_data.*, object_data.obj_id, object_reference.ref_id FROM object_data, object_reference WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'qpl' ORDER BY object_data.title"; $result = $this->ilias->db->query($query); while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)) { if ($rbacsystem->checkAccess("write", $row->ref_id) && ($this->_hasUntrashedReference($row->obj_id))) { $qpl_titles["$row->obj_id"] = $row->title; } } return $qpl_titles; }
ilObjTest::getActiveTestUser | ( | $ | user_id = "" |
) |
Gets the database row of the tst_active table for the active user.
Gets the database row of the tst_active table for the active user
integer | $user_id The database id of the user |
Definition at line 2522 of file class.ilObjTest.php.
References $ilUser, $query, $result, and $user_id.
Referenced by createRandomSolutionsForAllUsers(), getAllQuestionsForActiveUser(), getQuestionIdFromActiveUserSequence(), getQuestionTitle(), setActiveTestUser(), and startWorkingTime().
{ global $ilDB; global $ilUser; $db =& $ilDB->db; if (!$user_id) { $user_id = $ilUser->id; } $query = sprintf("SELECT * FROM tst_active WHERE user_fi = %s AND test_fi = %s", $db->quote($user_id), $db->quote($this->test_id) ); $result = $db->query($query); if ($result->numRows()) { return $result->fetchRow(DB_FETCHMODE_OBJECT); } else { return ""; } }
& ilObjTest::getAllQuestions | ( | ) |
Returns all questions of a test in test order.
Returns all questions of a test in test order
Definition at line 2490 of file class.ilObjTest.php.
References $ilUser, $query, $result, $row, and isRandomTest().
Referenced by getAllQuestionsForActiveUser().
{ global $ilUser; if ($this->isRandomTest()) { $query = sprintf("SELECT qpl_questions.* FROM qpl_questions, tst_test_random_question WHERE tst_test_random_question.question_fi = qpl_questions.question_id AND tst_test_random_question.user_fi = %s AND qpl_questions.question_id IN (" . join($this->questions, ",") . ")", $this->ilias->db->quote($ilUser->id . "") ); } else { $query = "SELECT qpl_questions.* FROM qpl_questions, tst_test_question WHERE tst_test_question.question_fi = qpl_questions.question_id AND qpl_questions.question_id IN (" . join($this->questions, ",") . ")"; } $result = $this->ilias->db->query($query); $result_array = array(); while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { $result_array[$row["question_id"]] = $row; } return $result_array; }
& ilObjTest::getAllQuestionsForActiveUser | ( | ) |
Returns all questions of a test in users order.
Returns all questions of a test in users order
Definition at line 2335 of file class.ilObjTest.php.
References getActiveTestUser(), getAllQuestions(), and getWorkedQuestions().
Referenced by getWrongAnsweredQuestions().
{ $result_array = array(); $active = $this->getActiveTestUser(); $sequence_array = split(",", $active->sequence); $all_questions = &$this->getAllQuestions(); $worked_questions = &$this->getWorkedQuestions(); foreach ($sequence_array as $sequence) { if (in_array($this->questions[$sequence], $worked_questions)) { $all_questions[$this->questions[$sequence]]["worked"] = 1; } else { $all_questions[$this->questions[$sequence]]["worked"] = 0; } array_push($result_array, $all_questions[$this->questions[$sequence]]); } return $result_array; }
ilObjTest::getAuthor | ( | ) |
Gets the authors name.
Gets the authors name of the ilObjTest object
Definition at line 1417 of file class.ilObjTest.php.
Referenced by to_xml().
{
return $this->author;
}
& ilObjTest::getAvailableQuestionpoolIDs | ( | ) |
Returns the object id's of the available question pools for the active user.
Returns the object id's of the available question pools for the active user
Definition at line 3399 of file class.ilObjTest.php.
References $query, $rbacsystem, $result, $row, and ilObject::_hasUntrashedReference().
Referenced by getQuestionsTable(), and randomSelectQuestions().
{ global $rbacsystem; $result_array = array(); $query = "SELECT object_data.*, object_data.obj_id, object_reference.ref_id FROM object_data, object_reference WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'qpl'"; $result = $this->ilias->db->query($query); while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)) { if ($rbacsystem->checkAccess("write", $row->ref_id) && ($this->_hasUntrashedReference($row->obj_id))) { array_push($result_array, $row->obj_id); } } return $result_array; }
& ilObjTest::getAvailableQuestionpools | ( | $ | use_object_id = false |
) |
Returns the available question pools for the active user.
Returns the available question pools for the active user
Definition at line 3424 of file class.ilObjTest.php.
References $query, $rbacsystem, $result, $row, and ilObject::_hasUntrashedReference().
{ global $rbacsystem; $result_array = array(); $query = "SELECT object_data.*, object_data.obj_id, object_reference.ref_id FROM object_data, object_reference WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'qpl' ORDER BY object_data.title"; $result = $this->ilias->db->query($query); while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)) { if ($rbacsystem->checkAccess("write", $row->ref_id) && ($this->_hasUntrashedReference($row->obj_id))) { if ($use_object_id) { $result_array[$row->obj_id] = $row->title; } else { $result_array[$row->ref_id] = $row->title; } } } return $result_array; }
ilObjTest::getCallingScript | ( | ) |
Returns the calling script of the class.
public
Definition at line 376 of file class.ilObjTest.php.
Referenced by getTestResult().
{ return "test.php"; }
ilObjTest::getCompleteWorkingTime | ( | $ | user_id | ) |
Returns the complete working time in seconds a user worked on the test.
Returns the complete working time in seconds a user worked on the test
Definition at line 3036 of file class.ilObjTest.php.
References $q, $result, $row, and $user_id.
{ $q = sprintf("SELECT tst_times.* FROM tst_active, tst_times WHERE tst_active.test_fi = %s AND tst_active.active_id = tst_times.active_fi AND tst_active.user_fi = %s", $this->ilias->db->quote($this->getTestId()), $this->ilias->db->quote($user_id) ); $result = $this->ilias->db->query($q); $time = 0; while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)) { preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row->started, $matches); $epoch_1 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row->finished, $matches); $epoch_2 = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); $time += ($epoch_2 - $epoch_1); } return $time; }
ilObjTest::getECTSGrade | ( | $ | reached_points, | |
$ | max_points | |||
) |
Definition at line 4768 of file class.ilObjTest.php.
References getTotalPointsPassedArray().
{ require_once "./classes/class.ilStatistics.php"; // calculate the median $passed_statistics = new ilStatistics(); $passed_array =& $this->getTotalPointsPassedArray(); $passed_statistics->setData($passed_array); $ects_percentiles = array ( "A" => $passed_statistics->quantile($this->ects_grades["A"]), "B" => $passed_statistics->quantile($this->ects_grades["B"]), "C" => $passed_statistics->quantile($this->ects_grades["C"]), "D" => $passed_statistics->quantile($this->ects_grades["D"]), "E" => $passed_statistics->quantile($this->ects_grades["E"]) ); if (count($passed_array) && ($reached_points >= $ects_percentiles["A"])) { return "A"; } else if (count($passed_array) && ($reached_points >= $ects_percentiles["B"])) { return "B"; } else if (count($passed_array) && ($reached_points >= $ects_percentiles["C"])) { return "C"; } else if (count($passed_array) && ($reached_points >= $ects_percentiles["D"])) { return "D"; } else if (count($passed_array) && ($reached_points >= $ects_percentiles["E"])) { return "E"; } else if (strcmp($this->ects_fx, "") != 0) { if ($max_points > 0) { $percentage = ($reached_points / $max_points) * 100.0; } else { $percentage = 0.0; } if ($percentage >= $this->ects_fx) { return "FX"; } else { return "F"; } } else { return "F"; } }
ilObjTest::getEnableProcessingTime | ( | ) |
Returns the state of the processing time (enabled/disabled).
Returns the state of the processing time (enabled/disabled)
Definition at line 1685 of file class.ilObjTest.php.
{
return $this->enable_processing_time;
}
ilObjTest::getEndingTime | ( | ) |
Returns the ending time of the test.
Returns the ending time of the test
Definition at line 1713 of file class.ilObjTest.php.
Referenced by endingTimeReached(), and to_xml().
{
return $this->ending_time;
}
ilObjTest::getEstimatedWorkingTime | ( | ) |
Returns the estimated working time for the test calculated from the working time of the contained questions.
Returns the estimated working time for the test calculated from the working time of the contained questions
Definition at line 3456 of file class.ilObjTest.php.
References $result, and _instanciateQuestion().
{ $time_in_seconds = 0; foreach ($this->questions as $question_id) { $question =& ilObjTest::_instanciateQuestion($question_id); $est_time = $question->getEstimatedWorkingTime(); $time_in_seconds += $est_time["h"] * 3600 + $est_time["m"] * 60 + $est_time["s"]; } $hours = (int)($time_in_seconds / 3600) ; $time_in_seconds = $time_in_seconds - ($hours * 3600); $minutes = (int)($time_in_seconds / 60); $time_in_seconds = $time_in_seconds - ($minutes * 60); $result = array("h" => $hours, "m" => $minutes, "s" => $time_in_seconds); return $result; }
& ilObjTest::getEvaluationGroups | ( | $ | user_id | ) |
Returns an array of groups who are selected for a test evaluation of a given user.
Returns an array of groups who are selected for a test evaluation of a given user
public
Definition at line 5105 of file class.ilObjTest.php.
References $query, $result, $row, and $user_id.
{ $groups = array(); $query = sprintf("SELECT group_fi FROM tst_eval_groups WHERE test_fi = %s AND evaluator_fi = %s", $this->ilias->db->quote($this->getTestId() . ""), $this->ilias->db->quote($user_id . "") ); $result = $this->ilias->db->query($query); if ($result->numRows()) { while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { $groups[$row["group_fi"]] = $row["group_fi"]; } } return $groups; }
& ilObjTest::getEvaluationUsers | ( | $ | user_id | ) |
Returns an array of users who are selected for a test evaluation of a given user.
Returns an array of users who are selected for a test evaluation of a given user
public
Definition at line 5080 of file class.ilObjTest.php.
References $query, $result, $row, $user_id, and $users.
{ $users = array(); $query = sprintf("SELECT tst_eval_users.user_fi, usr_data.firstname, usr_data.lastname FROM tst_eval_users, usr_data WHERE tst_eval_users.test_fi = %s AND tst_eval_users.evaluator_fi = %s AND tst_eval_users.user_fi = usr_data.usr_id", $this->ilias->db->quote($this->getTestId() . ""), $this->ilias->db->quote($user_id . "") ); $result = $this->ilias->db->query($query); if ($result->numRows()) { while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { $users[$row["user_fi"]] = trim($row["firstname"] ." " . $row["lastname"]); } } return $users; }
& ilObjTest::getExistingQuestions | ( | ) |
Get the id's of the questions which are already part of the test.
Get the id's of the questions which are already part of the test
Definition at line 2218 of file class.ilObjTest.php.
References $data, $ilUser, $query, $result, and isRandomTest().
{ global $ilUser; $existing_questions = array(); if ($this->isRandomTest()) { $query = sprintf("SELECT qpl_questions.original_id FROM qpl_questions, tst_test_random_question WHERE tst_test_random_question.test_fi = %s AND tst_test_random_question.user_fi = %s AND tst_test_random_question.question_fi = qpl_questions.question_id", $this->ilias->db->quote($this->getTestId() . ""), $this->ilias->db->quote($ilUser->id . "") ); } else { $query = sprintf("SELECT qpl_questions.original_id FROM qpl_questions, tst_test_question WHERE tst_test_question.test_fi = %s AND tst_test_question.question_fi = qpl_questions.question_id", $this->ilias->db->quote($this->getTestId()) ); } $result = $this->ilias->db->query($query); while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT)) { array_push($existing_questions, $data->original_id); } return $existing_questions; }
ilObjTest::getExportDirectory | ( | ) |
Get the location of the export directory for the test.
Get the location of the export directory for the test
public
Definition at line 654 of file class.ilObjTest.php.
References ilUtil::getDataDir().
{ $export_dir = ilUtil::getDataDir()."/tst_data"."/tst_".$this->getId()."/export"; return $export_dir; }
ilObjTest::getExportFiles | ( | $ | dir | ) |
Get a list of the already exported files in the export directory.
Get a list of the already exported files in the export directory
Definition at line 669 of file class.ilObjTest.php.
References $file.
{ // quit if import dir not available if (!@is_dir($dir) or !is_writeable($dir)) { return array(); } // open directory $dir = dir($dir); // initialize array $file = array(); // get files and save the in the array while ($entry = $dir->read()) { if ($entry != "." and $entry != ".." and substr($entry, -4) == ".zip" and ereg("^[0-9]{10}_{2}[0-9]+_{2}(test__)*[0-9]+\.zip\$", $entry)) { $file[] = $entry; } } // close import directory $dir->close(); // sort files sort ($file); reset ($file); return $file; }
ilObjTest::getFirstSequence | ( | ) |
Definition at line 2433 of file class.ilObjTest.php.
References $ilUser, $result, getQuestionCount(), getQuestionIdFromActiveUserSequence(), and getTestResult().
{ global $ilUser; $results = $this->getTestResult($ilUser->getId()); for($i = 1; $i <= $this->getQuestionCount(); $i++) { $qid = $this->getQuestionIdFromActiveUserSequence($i); foreach($results as $result) { if($qid == $result['qid']) { if(!$result['max'] or $result['max'] != $result['reached']) { return $i; } } } } return 0; }
& ilObjTest::getForbiddenQuestionpools | ( | ) |
Gets a list of all inaccessable question pools for the active user.
Gets a list of all inaccessable question pools for the active user
Definition at line 3374 of file class.ilObjTest.php.
References $query, $rbacsystem, $result, $row, and ilObject::_hasUntrashedReference().
{ global $rbacsystem; $forbidden_pools = array(); $query = "SELECT object_data.*, object_data.obj_id, object_reference.ref_id FROM object_data, object_reference WHERE object_data.obj_id = object_reference.obj_id AND object_data.type = 'qpl'"; $result = $this->ilias->db->query($query); while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)) { if (!$rbacsystem->checkAccess("write", $row->ref_id) || (!$this->_hasUntrashedReference($row->obj_id))) { array_push($forbidden_pools, $row->obj_id); } } return $forbidden_pools; }
ilObjTest::getImagePath | ( | ) |
Returns the image path for web accessable images of a test.
Returns the image path for web accessable images of a test The image path is under the CLIENT_WEB_DIR in assessment/REFERENCE_ID_OF_TEST/images
public
Definition at line 3623 of file class.ilObjTest.php.
References ilObject::getId().
Referenced by getQuestionsTable().
{ return CLIENT_WEB_DIR . "/assessment/" . $this->getId() . "/images/"; }
ilObjTest::getImagePathWeb | ( | ) |
Returns the web image path for web accessable images of a test.
Returns the web image path for web accessable images of a test The image path is under the web accessable data dir in assessment/REFERENCE_ID_OF_TEST/images
public
Definition at line 3636 of file class.ilObjTest.php.
References ilObject::getId(), and ilUtil::removeTrailingPathSeparators().
{ $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/" . $this->getId() . "/images/"; return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir); }
ilObjTest::getImportDirectory | ( | ) |
Get the import directory location of the test.
Get the import directory location of the test
Definition at line 747 of file class.ilObjTest.php.
References ilUtil::getDataDir().
{ $import_dir = ilUtil::getDataDir()."/tst_data". "/tst_".$this->getId()."/import"; if(@is_dir($import_dir)) { return $import_dir; } else { return false; } }
ilObjTest::getImportMapping | ( | ) |
get array of (two) new created questions for import id
Definition at line 4756 of file class.ilObjTest.php.
{ if (!is_array($this->import_mapping)) { return array(); } else { return $this->import_mapping; } }
ilObjTest::getIntroduction | ( | ) |
Gets the introduction.
Gets the introduction text of the ilObjTest object
Definition at line 1459 of file class.ilObjTest.php.
Referenced by to_xml().
{
return $this->introduction;
}
& ilObjTest::getMetaData | ( | ) |
get meta data object of glossary object
Definition at line 2866 of file class.ilObjTest.php.
{
return $this->meta_data;
}
ilObjTest::getNrOfTries | ( | ) |
Returns the nr of tries for the test.
Returns the nr of tries for the test
Definition at line 1636 of file class.ilObjTest.php.
Referenced by to_xml().
{
return $this->nr_of_tries;
}
ilObjTest::getProcessingTime | ( | ) |
Returns the processing time for the test.
Returns the processing time for the test
Definition at line 1650 of file class.ilObjTest.php.
Referenced by getProcessingTimeInSeconds().
{
return $this->processing_time;
}
ilObjTest::getProcessingTimeInSeconds | ( | ) |
Returns the processing time for the test in seconds.
Returns the processing time for the test in seconds
Definition at line 1664 of file class.ilObjTest.php.
References getProcessingTime().
{ if (preg_match("/(\d{2}):(\d{2}):(\d{2})/", $this->getProcessingTime(), $matches)) { return ($matches[1] * 3600) + ($matches[2] * 60) + $matches[3]; } else { return 0; } }
ilObjTest::getQuestionCount | ( | ) |
Returns the number of questions in the test.
Returns the number of questions in the test
Definition at line 5221 of file class.ilObjTest.php.
References $data, $num, getRandomQuestionCount(), getRandomQuestionpools(), and isRandomTest().
Referenced by getFirstSequence(), and incrementSequenceByResult().
{ $num = 0; if ($this->isRandomTest()) { if ($this->getRandomQuestionCount()) { $num = $this->getRandomQuestionCount(); } else { $qpls =& $this->getRandomQuestionpools(); foreach ($qpls as $data) { $num += $data["count"]; } } } else { $num = count($this->questions); } return $num; }
ilObjTest::getQuestionDataset | ( | $ | question_id | ) |
Returns the dataset for a given question id.
Returns the dataset for a given question id
integer | $question_id The database id of the question |
Definition at line 2174 of file class.ilObjTest.php.
References $query, $result, and $row.
{ $query = sprintf("SELECT qpl_questions.*, qpl_question_type.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", $this->ilias->db->quote("$question_id") ); $result = $this->ilias->db->query($query); $row = $result->fetchRow(DB_FETCHMODE_OBJECT); return $row; }
ilObjTest::getQuestionIdFromActiveUserSequence | ( | $ | sequence | ) |
Calculate the question id from a test sequence number.
Calculate the question id from a test sequence number
integer | $sequence The sequence number of the question |
Definition at line 2317 of file class.ilObjTest.php.
References $ilUser, and getActiveTestUser().
Referenced by decrementSequenceByResult(), getFirstSequence(), and incrementSequenceByResult().
{ global $ilUser; $active = $this->getActiveTestUser(); $sequence_array = split(",", $active->sequence); return $this->questions[$sequence_array[$sequence-1]]; }
ilObjTest::getQuestionsTable | ( | $ | sortoptions, | |
$ | filter_text, | |||
$ | sel_filter_type, | |||
$ | startrow = 0 , |
|||
$ | completeonly = 0 , |
|||
$ | filter_question_type = "" , |
|||
$ | filter_questionpool = "" | |||
) |
Calculates the data for the output of the questionpool.
Calculates the data for the output of the questionpool
public
Definition at line 3855 of file class.ilObjTest.php.
References $ilUser, $query, $result, $row, getAvailableQuestionpoolIDs(), and getImagePath().
{ global $ilUser; $where = ""; if (strlen($filter_text) > 0) { switch($sel_filter_type) { case "title": $where = " AND qpl_questions.title LIKE " . $this->ilias->db->quote("%" . $filter_text . "%"); break; case "comment": $where = " AND qpl_questions.comment LIKE " . $this->ilias->db->quote("%" . $filter_text . "%"); break; case "author": $where = " AND qpl_questions.author LIKE " . $this->ilias->db->quote("%" . $filter_text . "%"); break; } } if ($filter_question_type && (strcmp($filter_question_type, "all") != 0)) { $where .= " AND qpl_question_type.type_tag = " . $this->ilias->db->quote($filter_question_type); } if ($filter_questionpool && (strcmp($filter_questionpool, "all") != 0)) { $where .= " AND qpl_questions.obj_fi = $filter_questionpool"; } // build sort order for sql query $order = ""; $images = array(); if (count($sortoptions)) { foreach ($sortoptions as $key => $value) { switch($key) { case "title": $order = " ORDER BY title $value"; $images["title"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />"; break; case "comment": $order = " ORDER BY comment $value"; $images["comment"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />"; break; case "type": $order = " ORDER BY question_type_id $value"; $images["type"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />"; break; case "author": $order = " ORDER BY author $value"; $images["author"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />"; break; case "created": $order = " ORDER BY created $value"; $images["created"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />"; break; case "updated": $order = " ORDER BY TIMESTAMP14 $value"; $images["updated"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />"; break; case "qpl": $order = " ORDER BY obj_fi $value"; $images["qpl"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />"; break; } } } $maxentries = $ilUser->prefs["hits_per_page"]; if ($maxentries < 1) { $maxentries = 9999; } $available_pools =& $this->getAvailableQuestionpoolIDs(); $available = ""; if (count($available_pools)) { $available = " AND qpl_questions.obj_fi IN (" . join($available_pools, ",") . ")"; } else { return array(); } if ($completeonly) { $available .= " AND qpl_questions.complete = " . $this->ilias->db->quote("1"); } // get all questions in the test $query = sprintf("SELECT qpl_questions.original_id, qpl_questions.TIMESTAMP + 0 AS TIMESTAMP14 FROM qpl_questions, tst_test_question WHERE qpl_questions.question_id = tst_test_question.question_fi AND tst_test_question.test_fi = %s", $this->ilias->db->quote($this->getTestId() . "") ); $result = $this->ilias->db->query($query); $original_ids = array(); while ($row = $result->fetchRow(DB_FETCHMODE_ARRAY)) { if (strcmp($row[0], "") != 0) { array_push($original_ids, $row[0]); } } $original_clause = " ISNULL(qpl_questions.original_id)"; if (count($original_ids)) { $original_clause = " ISNULL(qpl_questions.original_id) AND qpl_questions.question_id NOT IN (" . join($original_ids, ",") . ")"; } $query = "SELECT qpl_questions.question_id, qpl_questions.TIMESTAMP + 0 AS TIMESTAMP14 FROM qpl_questions, qpl_question_type WHERE $original_clause$available AND qpl_questions.question_type_fi = qpl_question_type.question_type_id $where$order$limit"; $query_result = $this->ilias->db->query($query); $max = $query_result->numRows(); if ($startrow > $max -1) { $startrow = $max - ($max % $maxentries); } else if ($startrow < 0) { $startrow = 0; } $limit = " LIMIT $startrow, $maxentries"; $query = "SELECT qpl_questions.*, qpl_questions.TIMESTAMP + 0 AS TIMESTAMP14, qpl_question_type.type_tag FROM qpl_questions, qpl_question_type WHERE $original_clause $available AND qpl_questions.question_type_fi = qpl_question_type.question_type_id $where$order$limit"; $query_result = $this->ilias->db->query($query); $rows = array(); if ($query_result->numRows()) { while ($row = $query_result->fetchRow(DB_FETCHMODE_ASSOC)) { array_push($rows, $row); } } $nextrow = $startrow + $maxentries; if ($nextrow > $max - 1) { $nextrow = $startrow; } $prevrow = $startrow - $maxentries; if ($prevrow < 0) { $prevrow = 0; } return array( "rows" => $rows, "images" => $images, "startrow" => $startrow, "nextrow" => $nextrow, "prevrow" => $prevrow, "step" => $maxentries, "rowcount" => $max ); }
ilObjTest::getQuestiontext | ( | $ | question_id | ) |
Returns the question text for a given question.
Returns the question text for a given question
integer | $question_id The question id |
Definition at line 5441 of file class.ilObjTest.php.
References $query, $res, $result, and $row.
{ $res = ""; if ($question_id) { $query = sprintf("SELECT question_text FROM qpl_questions WHERE question_id = %s", $this->ilias->db->quote($question_id . "") ); $result = $this->ilias->db->query($query); if ($result->numRows() == 1) { $row = $result->fetchRow(DB_FETCHMODE_ASSOC); $res = $row["question_text"]; } } return $res; }
ilObjTest::getQuestionTitle | ( | $ | sequence | ) |
Returns the title of a question with a given sequence number.
Returns the title of a question with a given sequence number
integer | $sequence The sequence number of the question public |
Definition at line 2142 of file class.ilObjTest.php.
References $ilUser, $query, $result, $row, and getActiveTestUser().
{ global $ilUser; if ($ilUser->id > 0) { $active = $this->getActiveTestUser($ilUser->id); $seq = split(",", $active->sequence); $query = sprintf("SELECT title from qpl_questions WHERE question_id = %s", $this->ilias->db->quote($this->questions[$seq[$sequence-1]]) ); } else { $query = sprintf("SELECT title from qpl_questions WHERE question_id = %s", $this->ilias->db->quote($this->questions[$sequence]) ); } $result = $this->ilias->db->query($query); $row = $result->fetchRow(DB_FETCHMODE_OBJECT); return $row->title; }
& ilObjTest::getQuestionTitles | ( | ) |
Returns the titles of the test questions in question sequence.
Returns the titles of the test questions in question sequence
Definition at line 2115 of file class.ilObjTest.php.
References $query, $result, $row, and isRandomTest().
{ $titles = array(); if (!$this->isRandomTest()) { global $ilDB; $query = sprintf("SELECT qpl_questions.title FROM tst_test_question, qpl_questions WHERE tst_test_question.test_fi = %s AND tst_test_question.question_fi = qpl_questions.question_id ORDER BY tst_test_question.sequence", $ilDB->quote($this->getTestId() . "") ); $result = $ilDB->query($query); while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { array_push($titles, $row["title"]); } } return $titles; }
ilObjTest::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 2251 of file class.ilObjTest.php.
References $data, $query, and $result.
Referenced by createQuestionGUI().
{ if ($question_id < 1) return -1; $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", $this->ilias->db->quote($question_id) ); $result = $this->ilias->db->query($query); if ($result->numRows() == 1) { $data = $result->fetchRow(DB_FETCHMODE_OBJECT); return $data->type_tag; } else { return ""; } }
ilObjTest::getRandomQuestionCount | ( | ) |
Gets the number of random questions used for a random test.
Gets the number of random questions used for a random test
Definition at line 1445 of file class.ilObjTest.php.
Referenced by getQuestionCount(), isComplete(), and to_xml().
{
return $this->random_question_count;
}
& ilObjTest::getRandomQuestionpools | ( | ) |
Returns an array containing the random questionpools saved to the database.
Returns an array containing the random questionpools saved to the database
public
Definition at line 1267 of file class.ilObjTest.php.
References $counter, $query, $result, and $row.
Referenced by getQuestionCount(), and isComplete().
{ $qpls = array(); $counter = 0; $query = sprintf("SELECT * FROM tst_test_random WHERE test_fi = %s ORDER BY test_random_id", $this->ilias->db->quote($this->getTestId() . "") ); $result = $this->ilias->db->query($query); if ($result->numRows()) { while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { $qpls[$counter] = array( "index" => $counter, "count" => $row["num_of_q"], "qpl" => $row["questionpool_fi"] ); $counter++; } } return $qpls; }
ilObjTest::getReportingDate | ( | ) |
Gets the reporting date.
Gets the reporting date of the ilObjTest object
Definition at line 1622 of file class.ilObjTest.php.
Referenced by canViewResults(), and to_xml().
{
return $this->reporting_date;
}
ilObjTest::getScoreReporting | ( | ) |
Gets the score reporting.
Gets the score reporting of the ilObjTest object
Definition at line 1594 of file class.ilObjTest.php.
Referenced by to_xml().
{
return $this->score_reporting;
}
ilObjTest::getSequenceSettings | ( | ) |
Gets the sequence settings.
Gets the sequence settings of the ilObjTest object
Definition at line 1580 of file class.ilObjTest.php.
Referenced by to_xml().
{
return $this->sequence_settings;
}
ilObjTest::getStartingTime | ( | ) |
Returns the starting time of the test.
Returns the starting time of the test
Definition at line 1699 of file class.ilObjTest.php.
Referenced by startingTimeReached(), and to_xml().
{
return $this->starting_time;
}
ilObjTest::getTestId | ( | ) |
Gets the database id of the additional test data.
Gets the database id of the additional test data
Definition at line 1473 of file class.ilObjTest.php.
Referenced by createRandomSolutionsForAllUsers(), deleteResults(), evalStatistical(), getTestResult(), getTextAnswer(), getWorkedQuestions(), and saveECTSStatus().
{
return $this->test_id;
}
& ilObjTest::getTestResult | ( | $ | user_id | ) |
Calculates the results of a test for a given user.
Calculates the results of a test for a given user and returns an array with all test results
Definition at line 2647 of file class.ilObjTest.php.
References $row, $user_id, ASS_Question::_getInternalLinkHref(), _instanciateQuestion(), getCallingScript(), getTestId(), isRandomTest(), and loadQuestions().
Referenced by decrementSequenceByResult(), evalStatistical(), evalTotalFinishedPassed(), getFirstSequence(), getTotalPointsArray(), getTotalPointsPassedArray(), getWrongAnsweredQuestions(), and incrementSequenceByResult().
{ // global $ilBench; if ($this->isRandomTest()) { $this->loadQuestions($user_id); } $add_parameter = "?ref_id=$this->ref_id&cmd=run"; $total_max_points = 0; $total_reached_points = 0; // retrieve the active test dataset for the user containing // questions sequence and other information //$active = $this->getActiveTestUser($user_id); //$sequence_array = array(); //if (strlen($active->sequence)) //{ // $sequence_array = split(",", $active->sequence); // sort($sequence_array, SORT_NUMERIC); //} $key = 1; $result_array = array(); foreach ($this->questions as $value) { //$value = $this->questions[$seq]; // $ilBench->start("getTestResult","instanciate question"); $question =& ilObjTest::_instanciateQuestion($value); // $ilBench->stop("getTestResult","instanciate question"); if (is_object($question)) { $max_points = $question->getMaximumPoints(); $total_max_points += $max_points; $reached_points = $question->getReachedPoints($user_id, $this->getTestId()); $total_reached_points += $reached_points; if ($max_points > 0) { $percentvalue = $reached_points / $max_points; } else { $percentvalue = 0; } if (count($question->suggested_solutions) == 1) { $solution_array = $question->getSuggestedSolution(0); $href = ASS_Question::_getInternalLinkHref($solution_array["internal_link"]); } elseif (count($question->suggested_solutions) > 1) { $href = "see_details_for_further_information"; } else { $href = ""; } $row = array( "nr" => "$key", "title" => "<a href=\"" . $this->getCallingScript() . "$add_parameter&evaluation=" . $question->getId() . "\">" . $question->getTitle() . "</a>", "max" => sprintf("%d", $max_points), "reached" => sprintf("%d", $reached_points), "percent" => sprintf("%2.2f ", ($percentvalue) * 100) . "%", "solution" => $href, "type" => $question->getQuestionType(), "qid" => $question->getId() ); array_push($result_array, $row); $key++; } } $result_array["test"]["total_max_points"] = $total_max_points; $result_array["test"]["total_reached_points"] = $total_reached_points; if ((!$total_reached_points) or (!$total_max_points)) { $percentage = 0.0; } else { $percentage = ($total_reached_points / $total_max_points) * 100.0; } $mark_obj = $this->mark_schema->get_matching_mark($percentage); $passed = ""; if ($mark_obj) { if ($mark_obj->get_passed()) { $passed = 1; } else { $passed = 0; } } $result_array["test"]["passed"] = $passed; return $result_array; }
ilObjTest::getTestType | ( | ) |
Gets the test type.
Gets the test type
Definition at line 1608 of file class.ilObjTest.php.
Referenced by canViewResults(), endingTimeReached(), startingTimeReached(), and to_xml().
{
return $this->test_type;
}
ilObjTest::getTextAnswer | ( | $ | user_id, | |
$ | question_id | |||
) |
Returns the text answer of a given user for a given question.
Returns the text answer of a given user for a given question
integer | $user_id The user id | |
integer | $question_id The question id |
Definition at line 5412 of file class.ilObjTest.php.
References $query, $res, $result, $row, $user_id, and getTestId().
{ $res = ""; if (($user_id) && ($question_id)) { $query = sprintf("SELECT value1 FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND question_fi = %s", $this->ilias->db->quote($user_id . ""), $this->ilias->db->quote($this->getTestId() . ""), $this->ilias->db->quote($question_id . "") ); $result = $this->ilias->db->query($query); if ($result->numRows() == 1) { $row = $result->fetchRow(DB_FETCHMODE_ASSOC); $res = $row["value1"]; } } return $res; }
& ilObjTest::getTotalPointsArray | ( | ) |
Returns an array with the total points of all users who participated the test.
Returns an array with the total points of all users who participated the test This array could be used for statistics
Definition at line 3168 of file class.ilObjTest.php.
References $user_id, evalTotalPersonsArray(), and getTestResult().
{ $totalpoints_array = array(); $all_users =& $this->evalTotalPersonsArray(); foreach ($all_users as $user_id => $user_name) { $test_result =& $this->getTestResult($user_id); array_push($totalpoints_array, $test_result["test"]["total_reached_points"]); } return $totalpoints_array; }
& ilObjTest::getTotalPointsPassedArray | ( | ) |
Returns an array with the total points of all users who passed the test.
Returns an array with the total points of all users who passed the test This array could be used for statistics
Definition at line 3189 of file class.ilObjTest.php.
References $user_id, evalTotalPersonsArray(), and getTestResult().
Referenced by getECTSGrade().
{ $totalpoints_array = array(); $all_users =& $this->evalTotalPersonsArray(); foreach ($all_users as $user_id => $user_name) { $test_result =& $this->getTestResult($user_id); $reached = $test_result["test"]["total_reached_points"]; $total = $test_result["test"]["total_max_points"]; $percentage = $reached/$total; $mark = $this->mark_schema->get_matching_mark($percentage*100.0); if ($mark) { if ($mark->get_passed()) { array_push($totalpoints_array, $test_result["test"]["total_reached_points"]); } } } return $totalpoints_array; }
& ilObjTest::getWorkedQuestions | ( | ) |
Gets the id's of all questions a user already worked through.
Gets the id's of all questions a user already worked through
Definition at line 2466 of file class.ilObjTest.php.
References $ilUser, $query, $result, $row, and getTestId().
Referenced by getAllQuestionsForActiveUser().
{ global $ilUser; $query = sprintf("SELECT * FROM tst_solutions WHERE user_fi = %s AND test_fi = %s GROUP BY question_fi", $this->ilias->db->quote($ilUser->id), $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); $result_array = array(); while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)) { array_push($result_array, $row->question_fi); } return $result_array; }
ilObjTest::getWrongAnsweredQuestions | ( | ) |
Definition at line 2357 of file class.ilObjTest.php.
References $ilUser, $result, getAllQuestionsForActiveUser(), and getTestResult().
{ global $ilUser; foreach($all_questions =& $this->getAllQuestionsForActiveUser() as $question) { foreach($this->getTestResult($ilUser->getId()) as $result) { if($result['qid'] == $question['question_id']) { if($result['max'] != $result['reached']) { $wrong[] = $question; } } } } return $wrong ? $wrong : array(); }
ilObjTest::ilClone | ( | $ | a_parent_ref | ) |
copy all entries of your object.
public
integer | ref_id of parent object |
Reimplemented from ilObject.
Definition at line 400 of file class.ilObjTest.php.
References $rbacadmin.
{ global $rbacadmin; // always call parent ilClone function first!! $new_ref_id = parent::ilClone($a_parent_ref); // get object instance of ilCloned object //$newObj =& $this->ilias->obj_factory->getInstanceByRefId($new_ref_id); // create a local role folder & default roles //$roles = $newObj->initDefaultRoles(); // ...finally assign role to creator of object //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "n"); // always destroy objects in ilClone method because ilClone() is recursive and creates instances for each object in subtree! //unset($newObj); // ... and finally always return new reference ID!! return $new_ref_id; }
ilObjTest::ilObjTest | ( | $ | a_id = 0 , |
|
$ | a_call_by_reference = true | |||
) |
Constructor public.
integer | reference_id or object_id | |
boolean | treat the id as reference_id (true) or object_id (false) |
Definition at line 280 of file class.ilObjTest.php.
References $ilUser, ilObject::$lng, assignMetaData(), ilObject::ilObject(), and retrieveTestTypes().
Referenced by _clone(), _getMark(), _getTestResult(), _hasFinished(), and _isComplete().
{ global $ilUser; $this->type = "tst"; $this->mark_schema = new ASS_MarkSchema(); //$this->ilObject($a_id, $a_call_by_reference); $this->retrieveTestTypes(); $this->test_id = -1; $this->author = $ilUser->fullname; $this->introduction = ""; $this->questions = array(); $this->sequence_settings = TEST_FIXED_SEQUENCE; $this->score_reporting = REPORT_AFTER_TEST; $this->reporting_date = ""; $this->nr_of_tries = 0; $this->starting_time = ""; $this->ending_time = ""; $this->processing_time = "00:00:00"; $this->enable_processing_time = "0"; $this->test_type = TYPE_ASSESSMENT; $this->ects_output = 0; $this->ects_fx = ""; $this->random_test = 0; $this->random_question_count = ""; global $lng; $lng->loadLanguageModule("assessment"); $this->mark_schema->create_simple_schema($lng->txt("failed_short"), $lng->txt("failed_official"), 0, 0, $lng->txt("passed_short"), $lng->txt("passed_official"), 50, 1); $this->ects_grades = array( "A" => 90, "B" => 65, "C" => 35, "D" => 10, "E" => 0 ); if ($a_id == 0) { $new_meta =& new ilMetaData(); $this->assignMetaData($new_meta); } $this->ilObject($a_id, $a_call_by_reference); }
ilObjTest::importObject | ( | $ | source, | |
$ | questionpool_id | |||
) |
Imports a test from XML into the ILIAS database.
Imports a test from XML into the ILIAS database
Definition at line 4594 of file class.ilObjTest.php.
References ilObject::$lng, $result, $xml, from_xml(), setTestType(), ilObject::setTitle(), and to_xml().
{ $ilias_version = ""; $error = 0; if (($source == 'none') || (!$source) || $file_info["error"] > UPLOAD_ERR_OK) { $this->ilias->raiseError("No file selected!",$this->ilias->error_obj->FATAL); $error = 1; } if (!$error) { // import file as a test $fh = fopen($source, "r"); if (!$fh) { $this->ilias->raiseError("Error opening the file!",$this->ilias->error_obj->FATAL); $error = 1; return $error; } $xml = fread($fh, filesize($source)); $result = fclose($fh); if (!$result) { $this->ilias->raiseError("Error closing the file!",$this->ilias->error_obj->FATAL); $error = 1; return $error; } $assessment_part = ""; if (preg_match("/ILIAS Version\=(\d+)\.(\d+)\.?(\d?)/", $xml, $matches)) { $major_version = $matches[1]; unset($matches[0]); $ilias_version = join($matches, "."); if ($major_version == 2) { $this->setTestType(TYPE_SELF_ASSESSMENT); global $lng; $lng->loadLanguageModule("assessment"); $this->setTitle($lng->txt("imported_test")); $assessment_part = $this->to_xml(); if (preg_match("/(<assessment[^>]*>.*?<\/assessment>)/si", $assessment_part, $matches)) { $assessment_part = $matches[1]; } } } $found_assessment = preg_match("/(<assessment[^>]*>.*?<\/assessment>)/si", $xml, $matches); if ($found_assessment or $assessment_part) { if ((!$found_assessment) and ($assessment_part)) { $matches[1] = $assessment_part; } // read test properties $succeeded = $this->from_xml($matches[1]); if (!$succeeded) { // $this->ilias->raiseError("The test properties do not contain proper values!",$this->ilias->error_obj->MESSAGE); $error = 1; return $error; } } else { // $this->ilias->raiseError("No test properties found. Cannot import test!",$this->ilias->error_obj->MESSAGE); $error = 1; return $error; } $question_counter = 1; $this->import_mapping = array(); if (preg_match_all("/(<item[^>]*>.*?<\/item>)/si", $xml, $matches)) { foreach ($matches[1] as $index => $item) { // get identifier if (preg_match("/(<item[^>]*>)/is", $item, $start_tag)) { if (preg_match("/(ident=\"([^\"]*)\")/is", $start_tag[1], $ident)) { $ident = $ident[2]; } } $question = ""; $qt = ""; if (preg_match("/<fieldlabel>QUESTIONTYPE<\/fieldlabel>\s*<fieldentry>(.*?)<\/fieldentry>/is", $item, $questiontype)) { $qt = $questiontype[1]; } if (preg_match("/<qticomment>Questiontype\=(.*?)<\/qticomment>/is", $item, $questiontype)) { $qt = $questiontype[1]; } if (strlen($qt)) { switch ($qt) { case CLOZE_TEST_IDENTIFIER: $question = new ASS_ClozeTest(); break; case IMAGEMAP_QUESTION_IDENTIFIER: $question = new ASS_ImagemapQuestion(); break; case MATCHING_QUESTION_IDENTIFIER: $question = new ASS_MatchingQuestion(); break; case MULTIPLE_CHOICE_QUESTION_IDENTIFIER: $question = new ASS_MultipleChoice(); break; case ORDERING_QUESTION_IDENTIFIER: $question = new ASS_OrderingQuestion(); break; case JAVAAPPLET_QUESTION_IDENTIFIER: $question = new ASS_JavaApplet(); break; case TEXT_QUESTION_IDENTIFIER: $question = new ASS_TextQuestion(); break; } if ($question) { $question->setObjId($questionpool_id); if ($question->from_xml("<questestinterop>$item</questestinterop>")) { $question->saveToDb(); $q_1_id = $question->getId(); $question_id = $question->duplicate(true); $this->questions[$question_counter++] = $question_id; $this->import_mapping[$ident] = array( "pool" => $q_1_id, "test" => $question_id); } else { $this->ilias->raiseError($this->lng->txt("error_importing_question"), $this->ilias->error_obj->MESSAGE); } } } } } } //echo "<br>"; var_dump($this->import_mapping); $result = array( "error" => $error, "version" => $ilias_version ); return $result; }
ilObjTest::incrementSequenceByResult | ( | $ | a_sequence | ) |
increments sequence to the next wrong answered question
int | sequence |
Definition at line 2383 of file class.ilObjTest.php.
References $ilUser, $result, getQuestionCount(), getQuestionIdFromActiveUserSequence(), and getTestResult().
{ global $ilUser; for($i = $a_sequence+1; $i <= $this->getQuestionCount(); $i++) { $qid = $this->getQuestionIdFromActiveUserSequence($i); foreach($this->getTestResult($ilUser->getId()) as $result) { if($qid == $result['qid']) { if($result['max'] != $result['reached']) { return $i; } } } } return ($this->getQuestionCount()+1); }
ilObjTest::initDefaultRoles | ( | ) |
init default roles settings
If your module does not require any default roles, delete this method (For an example how this method is used, look at ilObjForum)
public
Reimplemented from ilObject.
Definition at line 533 of file class.ilObjTest.php.
References $rbacadmin, and $roles.
{ global $rbacadmin; // create a local role folder //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId()); // create moderator role and assign role to rolefolder... //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId()); //$roles[] = $roleObj->getId(); //unset($rfoldObj); //unset($roleObj); return $roles ? $roles : array(); }
ilObjTest::initMeta | ( | ) |
init meta data object if needed
Definition at line 2874 of file class.ilObjTest.php.
References assignMetaData(), ilObject::getId(), and ilObject::getType().
Referenced by updateMetaData(), and updateTitleAndDescription().
{ if (!is_object($this->meta_data)) { if ($this->getId()) { $new_meta =& new ilMetaData($this->getType(), $this->getId()); } else { $new_meta =& new ilMetaData(); } $this->assignMetaData($new_meta); } }
ilObjTest::insertQuestion | ( | $ | question_id | ) |
Insert a question in the list of questions.
Insert a question in the list of questions
integer | $question_id The database id of the inserted question public |
Definition at line 2063 of file class.ilObjTest.php.
References $data, $query, $result, ilObjAssessmentFolder::_enabledAssessmentLogging(), duplicateQuestionForTest(), loadQuestions(), logAction(), and saveCompleteStatus().
{ $duplicate_id = $this->duplicateQuestionForTest($question_id); // get maximum sequence index in test $query = sprintf("SELECT MAX(sequence) AS seq FROM tst_test_question WHERE test_fi=%s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); $sequence = 1; if ($result->numRows() == 1) { $data = $result->fetchRow(DB_FETCHMODE_OBJECT); $sequence = $data->seq + 1; } $query = sprintf("INSERT INTO tst_test_question (test_question_id, test_fi, question_fi, sequence, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)", $this->ilias->db->quote($this->getTestId()), $this->ilias->db->quote($duplicate_id), $this->ilias->db->quote($sequence) ); $result = $this->ilias->db->query($query); if ($result != DB_OK) { // Error } else { if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $this->logAction($this->lng->txt("log_question_added") . ": " . $sequence, $duplicate_id); } } // remove test_active entries, because test has changed $query = sprintf("DELETE FROM tst_active WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); $this->loadQuestions(); $this->saveCompleteStatus(); }
ilObjTest::isComplete | ( | ) |
Returns true, if a test is complete for use.
Returns true, if a test is complete for use
Definition at line 850 of file class.ilObjTest.php.
References $count, getRandomQuestionCount(), getRandomQuestionpools(), ilObject::getTitle(), and isRandomTest().
Referenced by saveCompleteStatus(), and saveToDb().
{ if (($this->getTitle()) and ($this->author) and (count($this->mark_schema->mark_steps)) and (count($this->questions))) { return true; } else { if ($this->isRandomTest()) { $arr = $this->getRandomQuestionpools(); if (count($arr) && ($this->getRandomQuestionCount() > 0)) { return true; } $count = 0; foreach ($arr as $array) { $count += $array["count"]; } if ($count) { return true; } } return false; } }
ilObjTest::isRandomTest | ( | ) |
Gets the status of the $random_test attribute.
Gets the status of the $random_test attribute
Definition at line 1431 of file class.ilObjTest.php.
Referenced by getAllQuestions(), getExistingQuestions(), getQuestionCount(), getQuestionTitles(), getTestResult(), isComplete(), loadQuestions(), removeAllTestEditings(), saveToDb(), and to_xml().
{
return $this->random_test;
}
ilObjTest::loadFromDb | ( | ) |
Loads a ilObjTest object from a database.
Loads a ilObjTest object from a database
object | $db A pear DB object | |
integer | $test_id A unique key which defines the test in the database public |
Definition at line 1299 of file class.ilObjTest.php.
References $data, $query, $result, and loadQuestions().
Referenced by read().
{ $db = $this->ilias->db; $query = sprintf("SELECT * FROM tst_tests WHERE obj_fi = %s", $db->quote($this->getId()) ); $result = $db->query($query); if (strcmp(strtolower(get_class($result)), db_result) == 0) { if ($result->numRows() == 1) { $data = $result->fetchRow(DB_FETCHMODE_OBJECT); $this->test_id = $data->test_id; $this->author = $data->author; $this->test_type = $data->test_type_fi; $this->introduction = $data->introduction; $this->sequence_settings = $data->sequence_settings; $this->score_reporting = $data->score_reporting; $this->nr_of_tries = $data->nr_of_tries; $this->processing_time = $data->processing_time; $this->enable_processing_time = $data->enable_processing_time; $this->reporting_date = $data->reporting_date; $this->starting_time = $data->starting_time; $this->ending_time = $data->ending_time; $this->ects_output = $data->ects_output; $this->ects_grades = array( "A" => $data->ects_a, "B" => $data->ects_b, "C" => $data->ects_c, "D" => $data->ects_d, "E" => $data->ects_e ); $this->ects_fx = $data->ects_fx; $this->random_test = $data->random_test; $this->random_question_count = $data->random_question_count; $this->mark_schema->flush(); $this->mark_schema->loadFromDb($this->test_id); $this->loadQuestions(); } } }
ilObjTest::loadQuestions | ( | $ | user_id = "" |
) |
Load the test question id's from the database.
Load the test question id's from the database
integer | $user_id The user id of the test user (necessary for random tests) public |
Definition at line 1350 of file class.ilObjTest.php.
References $data, $ilUser, $query, $result, $user_id, and isRandomTest().
Referenced by getTestResult(), insertQuestion(), loadFromDb(), questionMoveDown(), questionMoveUp(), and removeQuestion().
{ global $ilUser; $db = $this->ilias->db; $this->questions = array(); if (strcmp($user_id, "") == 0) { $user_id = $ilUser->id; } if ($this->isRandomTest()) { $query = sprintf("SELECT tst_test_random_question.* FROM tst_test_random_question, qpl_questions WHERE tst_test_random_question.test_fi = %s AND tst_test_random_question.user_fi = %s AND qpl_questions.question_id = tst_test_random_question.question_fi ORDER BY sequence", $db->quote($this->test_id . ""), $db->quote($user_id . "") ); } else { $query = sprintf("SELECT tst_test_question.* FROM tst_test_question, qpl_questions WHERE tst_test_question.test_fi = %s AND qpl_questions.question_id = tst_test_question.question_fi ORDER BY sequence", $db->quote($this->test_id . "") ); } $result = $db->query($query); $index = 1; while ($data = $result->fetchRow(DB_FETCHMODE_OBJECT)) { $this->questions[$index++] = $data->question_fi; } }
ilObjTest::logAction | ( | $ | logtext = "" , |
|
$ | 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 5320 of file class.ilObjTest.php.
References $ilUser, $query, $result, ASS_Question::_getOriginalId(), and ilObject::getId().
Referenced by insertQuestion(), questionMoveDown(), questionMoveUp(), removeAllTestEditings(), removeQuestion(), saveQuestionsToDb(), and saveToDb().
{ global $ilUser; $original_id = ""; if (strcmp($question_id, "") == 0) { $question_id = "NULL"; } else { $original_id = ASS_Question::_getOriginalId($question_id); $question_id = $this->ilias->db->quote($question_id . ""); } if (strcmp($original_id, "") == 0) { $original_id = "NULL"; } else { $original_id = $this->ilias->db->quote($original_id . ""); } $query = sprintf("INSERT INTO ass_log (ass_log_id, user_fi, obj_fi, logtext, question_fi, original_fi, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, NULL)", $this->ilias->db->quote($ilUser->id . ""), $this->ilias->db->quote($this->getId() . ""), $this->ilias->db->quote($logtext . ""), $question_id, $original_id ); $result = $this->ilias->db->query($query); }
ilObjTest::modifyExportIdentifier | ( | $ | a_tag, | |
$ | a_param, | |||
$ | a_value | |||
) |
Returns the installation id for a given identifier.
Returns the installation id for a given identifier
private
Definition at line 4336 of file class.ilObjTest.php.
References ilUtil::insertInstIntoID().
{ if ($a_tag == "Identifier" && $a_param == "Entry") { $a_value = ilUtil::insertInstIntoID($a_value); } return $a_value; }
ilObjTest::moveQuestions | ( | $ | move_questions, | |
$ | target_index, | |||
$ | insert_mode | |||
) |
Move questions to another position.
Move questions to another position
array | $move_questions An array with the question id's of the questions to move | |
integer | $target_index The question id of the target position | |
integer | $insert_mode 0, if insert before the target position, 1 if insert after the target position public |
Definition at line 3753 of file class.ilObjTest.php.
References $counter, and saveQuestionsToDb().
{ $this->questions = array_values($this->questions); $array_pos = array_search($target_index, $this->questions); if ($insert_mode == 0) { $part1 = array_slice($this->questions, 0, $array_pos); $part2 = array_slice($this->questions, $array_pos); } else if ($insert_mode == 1) { $part1 = array_slice($this->questions, 0, $array_pos + 1); $part2 = array_slice($this->questions, $array_pos + 1); } foreach ($move_questions as $question_id) { if (!(array_search($question_id, $part1) === FALSE)) { unset($part1[array_search($question_id, $part1)]); } if (!(array_search($question_id, $part2) === FALSE)) { unset($part2[array_search($question_id, $part2)]); } } $part1 = array_values($part1); $part2 = array_values($part2); $new_array = array_values(array_merge($part1, $move_questions, $part2)); $this->questions = array(); $counter = 1; foreach ($new_array as $question_id) { $this->questions[$counter] = $question_id; $counter++; } $this->saveQuestionsToDb(); }
ilObjTest::notify | ( | $ | a_event, | |
$ | a_ref_id, | |||
$ | a_parent_non_rbac_id, | |||
$ | a_node_id, | |||
$ | a_params = 0 | |||
) |
notifys an object about an event occured Based on the event happend, each object may decide how it reacts.
If you are not required to handle any events related to your module, just delete this method. (For an example how this method is used, look at ilObjGroup)
public
string | event | |
integer | reference id of object where the event occured | |
array | passes optional parameters if required |
Reimplemented from ilObject.
Definition at line 563 of file class.ilObjTest.php.
References $_GET, $tree, and ilObject::getType().
{ global $tree; switch ($a_event) { case "link": //var_dump("<pre>",$a_params,"</pre>"); //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id; //exit; break; case "cut": //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id; //exit; break; case "copy": //var_dump("<pre>",$a_params,"</pre>"); //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id; //exit; break; case "paste": //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id; //exit; break; case "new": //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id; //exit; break; } // At the beginning of the recursive process it avoids second call of the notify function with the same parameter if ($a_node_id==$_GET["ref_id"]) { $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id); $parent_type = $parent_obj->getType(); if($parent_type == $this->getType()) { $a_node_id = (int) $tree->getParentId($a_node_id); } } parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params); }
& ilObjTest::processCSVRow | ( | $ | row, | |
$ | quoteAll = FALSE , |
|||
$ | separator = ";" | |||
) |
Convertes an array for CSV usage.
Processes an array as a CSV row and converts the array values to correct CSV values. The "converted" array is returned
array | $row The array containing the values for a CSV row | |
string | $quoteAll Indicates to quote every value (=TRUE) or only values containing quotes and separators (=FALSE, default) | |
string | $separator The value separator in the CSV row (used for quoting) (; = default) |
Definition at line 5471 of file class.ilObjTest.php.
References $row, and $separator.
{ $resultarray = array(); foreach ($row as $rowindex => $entry) { $surround = FALSE; if ($quoteAll) { $surround = TRUE; } if (strpos($entry, "\"") !== FALSE) { $entry = str_replace("\"", "\"\"", $entry); $surround = TRUE; } if (strpos($entry, $separator) !== FALSE) { $surround = TRUE; } // replace all CR LF with LF (for Excel for Windows compatibility $entry = str_replace(chr(13).chr(10), chr(10), $entry); if ($surround) { $resultarray[$rowindex] = utf8_decode("\"" . $entry . "\""); } else { $resultarray[$rowindex] = utf8_decode($entry); } } return $resultarray; }
ilObjTest::questionMoveDown | ( | $ | question_id | ) |
Moves a question down in order.
Moves a question down in order
integer | $question_id The database id of the question to be moved down public |
Definition at line 1998 of file class.ilObjTest.php.
References $data, $query, $result, ilObjAssessmentFolder::_enabledAssessmentLogging(), loadQuestions(), and logAction().
{ // Move a question down in sequence $query = sprintf("SELECT * FROM tst_test_question WHERE test_fi=%s AND question_fi=%s", $this->ilias->db->quote($this->getTestId()), $this->ilias->db->quote($question_id) ); $result = $this->ilias->db->query($query); $data = $result->fetchRow(DB_FETCHMODE_OBJECT); $query = sprintf("SELECT * FROM tst_test_question WHERE test_fi=%s AND sequence=%s", $this->ilias->db->quote($this->getTestId()), $this->ilias->db->quote($data->sequence + 1) ); $result = $this->ilias->db->query($query); if ($result->numRows() == 1) { // OK, it's not the last question, so move it down $data_next = $result->fetchRow(DB_FETCHMODE_OBJECT); // change next dataset $query = sprintf("UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s", $this->ilias->db->quote($data->sequence), $this->ilias->db->quote($data_next->test_question_id) ); $result = $this->ilias->db->query($query); // move actual dataset down $query = sprintf("UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s", $this->ilias->db->quote($data->sequence + 1), $this->ilias->db->quote($data->test_question_id) ); $result = $this->ilias->db->query($query); if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $this->logAction($this->lng->txt("log_question_position_changed") . ": " . ($data->sequence) . " => " . ($data->sequence+1), $question_id); } } $this->loadQuestions(); }
ilObjTest::questionMoveUp | ( | $ | question_id | ) |
Moves a question up in order.
Moves a question up in order
integer | $question_id The database id of the question to be moved up public |
Definition at line 1952 of file class.ilObjTest.php.
References $data, $query, $result, ilObjAssessmentFolder::_enabledAssessmentLogging(), loadQuestions(), and logAction().
{ // Move a question up in sequence $query = sprintf("SELECT * FROM tst_test_question WHERE test_fi=%s AND question_fi=%s", $this->ilias->db->quote($this->getTestId()), $this->ilias->db->quote($question_id) ); $result = $this->ilias->db->query($query); $data = $result->fetchRow(DB_FETCHMODE_OBJECT); if ($data->sequence > 1) { // OK, it's not the top question, so move it up $query = sprintf("SELECT * FROM tst_test_question WHERE test_fi=%s AND sequence=%s", $this->ilias->db->quote($this->getTestId()), $this->ilias->db->quote($data->sequence - 1) ); $result = $this->ilias->db->query($query); $data_previous = $result->fetchRow(DB_FETCHMODE_OBJECT); // change previous dataset $query = sprintf("UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s", $this->ilias->db->quote($data->sequence), $this->ilias->db->quote($data_previous->test_question_id) ); $result = $this->ilias->db->query($query); // move actual dataset up $query = sprintf("UPDATE tst_test_question SET sequence=%s WHERE test_question_id=%s", $this->ilias->db->quote($data->sequence - 1), $this->ilias->db->quote($data->test_question_id) ); $result = $this->ilias->db->query($query); if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $this->logAction($this->lng->txt("log_question_position_changed") . ": " . ($data->sequence) . " => " . ($data->sequence-1), $question_id); } } $this->loadQuestions(); }
ilObjTest::randomSelectQuestions | ( | $ | nr_of_questions, | |
$ | questionpool, | |||
$ | use_obj_id = 0 , |
|||
$ | qpls = "" | |||
) |
Returns a random selection of questions.
Returns a random selection of questions
integer | $nr_of_questions Number of questions to return | |
integer | $questionpool ID of questionpool to choose the questions from (0 = all available questionpools) | |
boolean | $user_obj_id Use the object id instead of the reference id when set to true | |
array | $qpls An array of questionpool id's if the random questions should only be chose from the contained questionpools |
Definition at line 3484 of file class.ilObjTest.php.
References $query, $rbacsystem, $result, $row, and getAvailableQuestionpoolIDs().
{ global $rbacsystem; // get the questionpool id if a questionpool ref id was entered if ($questionpool != 0) { // retrieve object id if (!$use_obj_id) { $query = sprintf("SELECT obj_id FROM object_reference WHERE ref_id = %s", $this->ilias->db->quote("$questionpool") ); $result = $this->ilias->db->query($query); $row = $result->fetchRow(DB_FETCHMODE_ARRAY); $questionpool = $row[0]; } } // get all existing questions in the test $query = sprintf("SELECT qpl_questions.original_id FROM qpl_questions, tst_test_question WHERE qpl_questions.question_id = tst_test_question.question_fi AND tst_test_question.test_fi = %s", $this->ilias->db->quote($this->getTestId() . "") ); $result = $this->ilias->db->query($query); $original_ids = array(); while ($row = $result->fetchRow(DB_FETCHMODE_ARRAY)) { if (strcmp($row[0], "") != 0) { array_push($original_ids, $row[0]); } } $original_clause = ""; if (count($original_ids)) { $original_clause = " AND ISNULL(qpl_questions.original_id) AND qpl_questions.question_id NOT IN (" . join($original_ids, ",") . ")"; } // get a list of questionpools which are allowed for the test (only for random selection of questions in test questions editor) if (($questionpool == 0) && (!is_array($qpls))) { $available_pools =& $this->getAvailableQuestionpoolIDs(); $available = ""; $constraint_qpls = ""; if (count($available_pools)) { $available = " AND qpl_questions.obj_fi IN (" . join($available_pools, ",") . ")"; } else { return array(); } } $result_array = array(); if ($questionpool == 0) { if (is_array($qpls)) { if (count($qpls) > 0) { $qplidx = array(); foreach ($qpls as $idx => $arr) { array_push($qplidx, $arr["qpl"]); } $constraint_qpls = " AND qpl_questions.obj_fi IN (" . join($qplidx, ",") . ")"; } } $query = "SELECT COUNT(question_id) FROM qpl_questions, object_data WHERE ISNULL(qpl_questions.original_id) AND object_data.type = 'qpl' AND object_data.obj_id = qpl_questions.obj_fi$available$constraint_qpls AND qpl_questions.complete = '1'$original_clause"; } else { $query = sprintf("SELECT COUNT(question_id) FROM qpl_questions WHERE ISNULL(qpl_questions.original_id) AND obj_fi = %s$original_clause", $this->ilias->db->quote("$questionpool") ); } $result = $this->ilias->db->query($query); $row = $result->fetchRow(DB_FETCHMODE_ARRAY); if (($row[0]) <= $nr_of_questions) { // take all available questions if ($questionpool == 0) { $query = "SELECT question_id FROM qpl_questions, object_data WHERE ISNULL(qpl_questions.original_id) AND object_data.type = 'qpl' AND object_data.obj_id = qpl_questions.obj_fi$available$constraint_qpls AND qpl_questions.complete = '1'$original_clause"; } else { $query = sprintf("SELECT question_id FROM qpl_questions WHERE ISNULL(qpl_questions.original_id) AND obj_fi = %s AND qpl_questions.complete = '1'$original_clause", $this->ilias->db->quote("$questionpool") ); } $result = $this->ilias->db->query($query); while ($row = $result->fetchRow(DB_FETCHMODE_ARRAY)) { if ((!in_array($row[0], $this->questions)) && (strcmp($row[0], "") != 0)) { $result_array[$row[0]] = $row[0]; } } } else { // select a random number out of the maximum number of questions mt_srand((double)microtime()*1000000); $random_number = mt_rand(0, $row[0] - 1); $securitycounter = 500; while ((count($result_array) < $nr_of_questions) && ($securitycounter > 0)) { if ($questionpool == 0) { $query = "SELECT question_id FROM qpl_questions, object_data WHERE ISNULL(qpl_questions.original_id) AND object_data.type = 'qpl' AND object_data.obj_id = qpl_questions.obj_fi$available$constraint_qpls AND qpl_questions.complete = '1'$original_clause LIMIT $random_number, 1"; } else { $query = sprintf("SELECT question_id FROM qpl_questions WHERE ISNULL(qpl_questions.original_id) AND obj_fi = %s AND qpl_questions.complete = '1'$original_clause LIMIT $random_number, 1", $this->ilias->db->quote("$questionpool") ); } $result = $this->ilias->db->query($query); $result_row = $result->fetchRow(DB_FETCHMODE_ARRAY); if ((!in_array($result_row[0], $this->questions)) && (strcmp($result_row[0], "") != 0)) { $result_array[$result_row[0]] = $result_row[0]; } $random_number = mt_rand(0, $row[0] - 1); $securitycounter--; } } return $result_array; }
ilObjTest::read | ( | $ | a_force_db = false |
) |
read object data from db into object
boolean | public |
Reimplemented from ilObject.
Definition at line 386 of file class.ilObjTest.php.
References ilObject::getId(), ilObject::getType(), and loadFromDb().
{ parent::read($a_force_db); $this->loadFromDb(); $this->meta_data =& new ilMetaData($this->getType(), $this->getId()); }
ilObjTest::removeAllTestEditings | ( | $ | question_id = "" |
) |
Removes all references to the question in executed tests in case the question has been changed.
Removes all references to the question in executed tests in case the question has been changed. If a question was changed it cannot be guaranteed that the content and the meaning of the question is the same as before. So we have to delete all already started or completed tests using that question. Therefore we have to delete all references to that question in tst_solutions and the tst_active entries which were created for the user and test in the tst_solutions entry.
public
Definition at line 1855 of file class.ilObjTest.php.
References $query, $result, ilObjAssessmentFolder::_enabledAssessmentLogging(), clearEvalSelectedGroups(), clearEvalSelectedUsers(), deleteActiveTests(), isRandomTest(), and logAction().
Referenced by deleteTest(), removeNonRandomTestData(), removeQuestion(), and removeRandomTestData().
{ // remove test_active entries, because test has changed $this->deleteActiveTests(); // remove selected users/groups $this->clearEvalSelectedUsers(); $this->clearEvalSelectedGroups(); // remove the question from tst_solutions if ($question_id) { $query = sprintf("DELETE FROM tst_solutions WHERE test_fi = %s AND question_fi = %s", $this->ilias->db->quote($this->getTestId()), $this->ilias->db->quote($question_id) ); } else { $query = sprintf("DELETE FROM tst_solutions WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); } $result = $this->ilias->db->query($query); if ($this->isRandomTest()) { $query = sprintf("DELETE FROM tst_test_random_question WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); } if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $this->logAction($this->lng->txt("log_user_data_removed")); } }
ilObjTest::removeNonRandomTestData | ( | ) |
Removes all test data of a non random test when a test was set to random test.
Removes all test data of a non random test when a test was set to random test
private
Definition at line 5280 of file class.ilObjTest.php.
References $query, $result, removeAllTestEditings(), and saveCompleteStatus().
{ // delete eventually set questions of a previous non-random test $this->removeAllTestEditings(); $query = sprintf("DELETE FROM tst_test_question WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); $this->questions = array(); $this->saveCompleteStatus(); }
ilObjTest::removeQuestion | ( | $ | question_id | ) |
Removes a question from the test object.
Removes a question from the test object
integer | $question_id The database id of the question to be removed public |
Definition at line 1801 of file class.ilObjTest.php.
References ilObjAssessmentFolder::_enabledAssessmentLogging(), loadQuestions(), logAction(), removeAllTestEditings(), and saveQuestionsToDb().
Referenced by deleteTest().
{ $question = new ASS_Question(); if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $this->logAction($this->lng->txt("log_question_removed"), $question_id); } $question->delete($question_id); $this->removeAllTestEditings($question_id); $this->loadQuestions(); $this->saveQuestionsToDb(); }
ilObjTest::removeRandomTestData | ( | ) |
Removes all test data of a random test when a test was set to non random test.
Removes all test data of a random test when a test was set to non random test
private
Definition at line 5299 of file class.ilObjTest.php.
References $query, $result, removeAllTestEditings(), and saveCompleteStatus().
{ // delete eventually set random question pools of a previous random test $this->removeAllTestEditings(); $query = sprintf("DELETE FROM tst_test_random WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); $this->questions = array(); $this->saveCompleteStatus(); }
ilObjTest::removeSelectedGroup | ( | $ | group_id, | |
$ | evaluator_id | |||
) |
Disinvites a group from a survey.
Disinvites a group from a survey
integer | $group_id The database id of the disinvited group public |
Definition at line 5176 of file class.ilObjTest.php.
ilObjTest::removeSelectedUser | ( | $ | user_id, | |
$ | evaluator_id | |||
) |
Disinvites a user from a survey.
Disinvites a user from a survey
integer | $user_id The database id of the disinvited user public |
Definition at line 5131 of file class.ilObjTest.php.
ilObjTest::retrieveTestTypes | ( | ) |
Retrieves the test types from the database.
Retrieves the test types from the database and sets the test_types array to the corresponding values.
private
Definition at line 771 of file class.ilObjTest.php.
References $query, $result, and $row.
Referenced by ilObjTest().
{ global $ilDB; $this->test_types = array(); $query = "SELECT * FROM tst_test_type ORDER BY test_type_id"; $result = $ilDB->query($query); while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT)) { $this->test_types[$row->test_type_id] = $row->type_tag; } }
ilObjTest::saveCompleteStatus | ( | ) |
Checks if the test is complete and saves the status in the database.
Checks if the test is complete and saves the status in the database
public
Definition at line 937 of file class.ilObjTest.php.
References ilObject::$ilias, $query, $result, and isComplete().
Referenced by insertQuestion(), removeNonRandomTestData(), and removeRandomTestData().
{ global $ilias; $db =& $ilias->db; $complete = 0; if ($this->isComplete()) { $complete = 1; } if ($this->test_id > 0) { $query = sprintf("UPDATE tst_tests SET complete = %s WHERE test_id = %s", $db->quote("$complete"), $db->quote($this->test_id) ); $result = $db->query($query); } }
ilObjTest::saveECTSStatus | ( | $ | ects_output = 0 , |
|
$ | fx_support = "" , |
|||
$ | ects_a = 90 , |
|||
$ | ects_b = 65 , |
|||
$ | ects_c = 35 , |
|||
$ | ects_d = 10 , |
|||
$ | ects_e = 0 | |||
) |
Saves the ECTS status (output of ECTS grades in a test) to the database.
Saves the ECTS status (output of ECTS grades in a test) to the database
public
Definition at line 901 of file class.ilObjTest.php.
References $ects_output, $query, $result, and getTestId().
{ global $ilDB; if ($this->test_id > 0) { $fx_support = preg_replace("/,/", ".", $fx_support); if (preg_match("/\d+/", $fx_support)) { $fx_support = $fx_support; } else { $fx_support = "NULL"; } $query = sprintf("UPDATE tst_tests SET ects_output = %s, ects_a = %s, ects_b = %s, ects_c = %s, ects_d = %s, ects_e = %s, ects_fx = %s WHERE test_id = %s", $ilDB->quote("$ects_output"), $ilDB->quote($ects_a . ""), $ilDB->quote($ects_b . ""), $ilDB->quote($ects_c . ""), $ilDB->quote($ects_d . ""), $ilDB->quote($ects_e . ""), $fx_support, $this->getTestId() ); $result = $ilDB->query($query); $this->ects_output = $ects_output; $this->ects_fx = $fx_support; } }
ilObjTest::saveQuestionsToDb | ( | ) |
Saves the test questions to the database.
Saves the test questions to the database
public
Definition at line 1103 of file class.ilObjTest.php.
References $pos, $query, $result, $row, ilObjAssessmentFolder::_enabledAssessmentLogging(), and logAction().
Referenced by moveQuestions(), removeQuestion(), and saveToDb().
{ $oldquestions = array(); if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $query = sprintf("SELECT question_fi FROM tst_test_question WHERE test_fi = %s ORDER BY sequence", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); if ($result->numRows() > 0) { while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { array_push($oldquestions, $row["question_fi"]); } } } // delete existing category relations $query = sprintf("DELETE FROM tst_test_question WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); // create new category relations foreach ($this->questions as $key => $value) { $query = sprintf("INSERT INTO tst_test_question (test_question_id, test_fi, question_fi, sequence, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)", $this->ilias->db->quote($this->getTestId() . ""), $this->ilias->db->quote($value . ""), $this->ilias->db->quote($key . "") ); $result = $this->ilias->db->query($query); } if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $query = sprintf("SELECT question_fi FROM tst_test_question WHERE test_fi = %s ORDER BY sequence", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); $newquestions = array(); if ($result->numRows() > 0) { while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { array_push($newquestions, $row["question_fi"]); } } foreach ($oldquestions as $index => $question_id) { if (strcmp($newquestions[$index], $question_id) != 0) { $pos = array_search($question_id, $newquestions); if ($pos === FALSE) { $this->logAction($this->lng->txt("log_question_removed"), $question_id); } else { $this->logAction($this->lng->txt("log_question_position_changed") . ": " . ($index+1) . " => " . ($pos+1), $question_id); } } } foreach ($newquestions as $index => $question_id) { if (array_search($question_id, $oldquestions) === FALSE) { $this->logAction($this->lng->txt("log_question_added") . ": " . ($index+1), $question_id); } } } }
ilObjTest::saveRandomQuestion | ( | $ | question_id | ) |
Saves a random question to the database.
Saves a random question to the database
public
Definition at line 1182 of file class.ilObjTest.php.
References $ilUser, $query, and $result.
{ global $ilUser; $query = sprintf("SELECT test_random_question_id FROM tst_test_random_question WHERE test_fi = %s AND user_fi = %s", $this->ilias->db->quote($this->getTestId() . ""), $this->ilias->db->quote($ilUser->id . "") ); $result = $this->ilias->db->query($query); $query = sprintf("INSERT INTO tst_test_random_question (test_random_question_id, test_fi, user_fi, question_fi, sequence, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, NULL)", $this->ilias->db->quote($this->getTestId() . ""), $this->ilias->db->quote($ilUser->id . ""), $this->ilias->db->quote($question_id . ""), $this->ilias->db->quote(($result->numRows()+1) . "") ); $result = $this->ilias->db->query($query); }
ilObjTest::saveRandomQuestionCount | ( | $ | total_questions = "NULL" |
) |
Saves the total amount of a tests random questions to the database.
Saves the total amount of a tests random questions to the database
integer | $total_questions The amount of random questions public |
Definition at line 1209 of file class.ilObjTest.php.
References $query, $result, and setRandomQuestionCount().
{ if (strcmp($total_questions, "NULL") != 0) { $this->setRandomQuestionCount($total_questions); $total_questions = $this->ilias->db->quote($total_questions); } $query = sprintf("UPDATE tst_tests SET random_question_count = %s WHERE test_id = %s", $total_questions, $this->ilias->db->quote($this->getTestId() . "") ); $result = $this->ilias->db->query($query); }
ilObjTest::saveRandomQuestionpools | ( | $ | qpl_array | ) |
Saves the question pools used for a random test.
Saves the question pools used for a random test
array | $qpl_array An array containing the questionpool id's public |
Definition at line 1232 of file class.ilObjTest.php.
References $count, $query, $result, and ilObjQuestionPool::_getQuestionCount().
{ // delete existing random questionpools $query = sprintf("DELETE FROM tst_test_random WHERE test_fi = %s", $this->ilias->db->quote($this->getTestId()) ); $result = $this->ilias->db->query($query); // create new random questionpools foreach ($qpl_array as $key => $value) { if ($value["qpl"] > -1) { $count = ilObjQuestionPool::_getQuestionCount($value["qpl"]); if ($value["count"] > $count) { $value["count"] = $count; } $query = sprintf("INSERT INTO tst_test_random (test_random_id, test_fi, questionpool_fi, num_of_q, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)", $this->ilias->db->quote($this->getTestId() . ""), $this->ilias->db->quote($value["qpl"] . ""), $this->ilias->db->quote(sprintf("%d", $value["count"]) . "") ); $result = $this->ilias->db->query($query); } } }
ilObjTest::saveToDb | ( | $ | properties_only = FALSE |
) |
Saves a ilObjTest object to a database.
Saves a ilObjTest object to a database (experimental)
object | $db A pear DB object public |
Definition at line 963 of file class.ilObjTest.php.
References $ects_fx, ilObject::$ilias, $query, $random_question_count, $result, ilObjAssessmentFolder::_enabledAssessmentLogging(), isComplete(), isRandomTest(), logAction(), and saveQuestionsToDb().
Referenced by createReference().
{ global $ilias; $db =& $ilias->db; $complete = 0; if ($this->isComplete()) { $complete = 1; } $ects_fx = "NULL"; if (preg_match("/\d+/", $this->ects_fx)) { $ects_fx = $this->ects_fx; } $random_question_count = "NULL"; if ($this->random_question_count > 0) { $random_question_count = $this->ilias->db->quote($this->random_question_count . ""); } if ($this->test_id == -1) { // Create new dataset $now = getdate(); $created = sprintf("%04d%02d%02d%02d%02d%02d", $now['year'], $now['mon'], $now['mday'], $now['hours'], $now['minutes'], $now['seconds']); $query = sprintf("INSERT INTO tst_tests (test_id, obj_fi, author, test_type_fi, introduction, sequence_settings, score_reporting, nr_of_tries, processing_time, enable_processing_time, reporting_date, starting_time, ending_time, complete, ects_output, ects_a, ects_b, ects_c, ects_d, ects_e, ects_fx, random_test, random_question_count, created, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, NULL)", $db->quote($this->getId() . ""), $db->quote($this->author . ""), $db->quote($this->test_type . ""), $db->quote($this->introduction . ""), $db->quote($this->sequence_settings . ""), $db->quote($this->score_reporting . ""), $db->quote(sprintf("%d", $this->nr_of_tries) . ""), $db->quote($this->processing_time . ""), $db->quote("$this->enable_processing_time"), $db->quote($this->reporting_date . ""), $db->quote($this->starting_time . ""), $db->quote($this->ending_time . ""), $db->quote("$complete"), $db->quote($this->ects_output . ""), $db->quote($this->ects_grades["A"] . ""), $db->quote($this->ects_grades["B"] . ""), $db->quote($this->ects_grades["C"] . ""), $db->quote($this->ects_grades["D"] . ""), $db->quote($this->ects_grades["E"] . ""), $ects_fx, $db->quote(sprintf("%d", $this->random_test) . ""), $random_question_count, $db->quote($created) ); if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $this->logAction($this->lng->txt("log_create_new_test")); } $result = $db->query($query); if ($result == DB_OK) { $this->test_id = $this->ilias->db->getLastInsertId(); } } else { // Modify existing dataset $oldrow = array(); if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $query = sprintf("SELECT * FROM tst_tests WHERE test_id = %s", $db->quote($this->test_id) ); $result = $db->query($query); if ($result->numRows() == 1) { $oldrow = $result->fetchRow(DB_FETCHMODE_ASSOC); } } $query = sprintf("UPDATE tst_tests SET author = %s, test_type_fi = %s, introduction = %s, sequence_settings = %s, score_reporting = %s, nr_of_tries = %s, processing_time = %s, enable_processing_time = %s, reporting_date = %s, starting_time = %s, ending_time = %s, ects_output = %s, ects_a = %s, ects_b = %s, ects_c = %s, ects_d = %s, ects_e = %s, ects_fx = %s, random_test = %s, complete = %s WHERE test_id = %s", $db->quote($this->author . ""), $db->quote($this->test_type . ""), $db->quote($this->introduction . ""), $db->quote($this->sequence_settings . ""), $db->quote($this->score_reporting . ""), $db->quote(sprintf("%d", $this->nr_of_tries) . ""), $db->quote($this->processing_time . ""), $db->quote("$this->enable_processing_time"), $db->quote($this->reporting_date . ""), $db->quote($this->starting_time . ""), $db->quote($this->ending_time . ""), $db->quote($this->ects_output . ""), $db->quote($this->ects_grades["A"] . ""), $db->quote($this->ects_grades["B"] . ""), $db->quote($this->ects_grades["C"] . ""), $db->quote($this->ects_grades["D"] . ""), $db->quote($this->ects_grades["E"] . ""), $ects_fx, $db->quote(sprintf("%d", $this->random_test) . ""), $db->quote("$complete"), $db->quote($this->test_id) ); $result = $db->query($query); if (ilObjAssessmentFolder::_enabledAssessmentLogging()) { $query = sprintf("SELECT * FROM tst_tests WHERE test_id = %s", $db->quote($this->test_id) ); $logresult = $db->query($query); $newrow = array(); if ($logresult->numRows() == 1) { $newrow = $logresult->fetchRow(DB_FETCHMODE_ASSOC); } $changed_fields = array(); foreach ($oldrow as $key => $value) { if (strcmp($oldrow[$key], $newrow[$key]) != 0) { array_push($changed_fields, "$key: " . $oldrow[$key] . " => " . $newrow[$key]); } } $changes = join($changed_fields, ", "); if (count($changed_fields) == 0) { $changes = $this->lng->txt("log_no_test_fields_changed"); } $this->logAction($this->lng->txt("log_modified_test") . " [".$changes."]"); } } if (!$properties_only) { if ($result == DB_OK) { if (!$this->isRandomTest()) { $this->saveQuestionsToDb(); } $this->mark_schema->saveToDb($this->test_id); } } }
ilObjTest::setActiveTestUser | ( | $ | lastindex = 1 , |
|
$ | postpone = "" , |
|||
$ | addTries = false | |||
) |
Update the data of the tst_active table for the current user.
Update the data of the tst_active table for the current user The table saves the state of the active user in the test (sequence position, postponed questions etc.)
integer | $lastindex The sequence position of the question the user last visited | |
integer | $postpone The sequence position of a question which should be postponed | |
boolean | $addTries Adds 1 to the number of test completions if set to true public |
Definition at line 2591 of file class.ilObjTest.php.
References $ilUser, $query, and getActiveTestUser().
Referenced by startWorkingTime().
{ global $ilDB; global $ilUser; $db =& $ilDB->db; $old_active = $this->getActiveTestUser(); if ($old_active) { $sequence = $old_active->sequence; $postponed = $old_active->postponed; if ($postpone) { $sequence_array = split(",", $sequence); $postpone_sequence = $sequence_array[$postpone-1]; $question_id = $this->questions[$postpone_sequence]; unset($sequence_array[$postpone-1]); array_push($sequence_array, $postpone_sequence); $sequence = join(",", $sequence_array); $postponed .= ",$question_id"; $postponed = preg_replace("/^,/", "", $postponed); } $tries = $old_active->tries; if ($addTries) { $tries++; } $query = sprintf("UPDATE tst_active SET lastindex = %s, sequence = %s, postponed = %s, tries = %s WHERE user_fi = %s AND test_fi = %s", $db->quote($lastindex), $db->quote($sequence), $db->quote($postponed), $db->quote($tries), $db->quote($ilUser->id), $db->quote($this->test_id) ); } else { $sequence_arr = array_flip($this->questions); $sequence = join($sequence_arr, ","); $query = sprintf("INSERT INTO tst_active (active_id, user_fi, test_fi, sequence, postponed, lastindex, tries, TIMESTAMP) VALUES (NULL, %s, %s, %s, %s, %s, %s, NULL)", $db->quote($ilUser->id), $db->quote($this->test_id), $db->quote($sequence), $db->quote(""), $db->quote($lastindex), $db->quote(0) ); } $db->query($query); }
ilObjTest::setAuthor | ( | $ | author = "" |
) |
Sets the authors name.
Sets the authors name of the ilObjTest object
string | $author A string containing the name of the test author public |
Definition at line 1389 of file class.ilObjTest.php.
References $author.
Referenced by from_xml().
{ $this->author = $author; }
ilObjTest::setEnableProcessingTime | ( | $ | enable = 0 |
) |
Sets the processing time enabled or disabled.
Sets the processing time enabled or disabled
integer | $enable 0 to disable the processing time, 1 to enable the processing time public |
Definition at line 1755 of file class.ilObjTest.php.
{ if ($enable) { $this->enable_processing_time = "1"; } else { $this->enable_processing_time = "0"; } }
ilObjTest::setEndingTime | ( | $ | ending_time = "" |
) |
Sets the ending time for the test.
Sets the ending time in database timestamp format for the test
string | $ending_time The ending time for the test. Empty string for no ending time. public |
Definition at line 1787 of file class.ilObjTest.php.
References $ending_time.
Referenced by from_xml().
{ $this->ending_time = $ending_time; }
ilObjTest::setIntroduction | ( | $ | introduction = "" |
) |
Sets the introduction.
Sets the introduction text of the ilObjTest object
string | $introduction An introduction string for the test public |
Definition at line 1403 of file class.ilObjTest.php.
References $introduction.
Referenced by from_xml().
{ $this->introduction = $introduction; }
ilObjTest::setNrOfTries | ( | $ | nr_of_tries = 0 |
) |
Sets the nr of tries for the test.
Sets the nr of tries for the test
integer | $nr_of_tries The maximum number of tries for the test. 0 for infinite tries. public |
Definition at line 1727 of file class.ilObjTest.php.
References $nr_of_tries.
Referenced by from_xml().
{ $this->nr_of_tries = $nr_of_tries; }
ilObjTest::setProcessingTime | ( | $ | processing_time = "00:00:00" |
) |
Sets the processing time for the test.
Sets the processing time for the test
string | $processing_time The maximum processing time for the test given in hh:mm:ss public |
Definition at line 1741 of file class.ilObjTest.php.
References $processing_time.
Referenced by from_xml().
:00:00") { $this->processing_time = $processing_time; }
ilObjTest::setRandomQuestionCount | ( | $ | a_random_question_count = "" |
) |
Sets the random question count.
Sets the random question count
integer | $a_random_question_count The random question count public |
Definition at line 1543 of file class.ilObjTest.php.
Referenced by from_xml(), and saveRandomQuestionCount().
{ $this->random_question_count = $a_random_question_count; }
ilObjTest::setRandomTest | ( | $ | a_random_test = 0 |
) |
Sets the random test indicator.
Sets the random test indicator
integer | $a_random_test The random test indicator (0 = no random test, 1 = random test) public |
Definition at line 1529 of file class.ilObjTest.php.
Referenced by from_xml().
{ $this->random_test = $a_random_test; }
ilObjTest::setReportingDate | ( | $ | reporting_date | ) |
Sets the reporting date.
Sets the reporting date of the ilObjTest object
timestamp | $reporting_date The date and time the score reporting is available public |
Definition at line 1557 of file class.ilObjTest.php.
References $reporting_date.
Referenced by from_xml().
{ if (!$reporting_date) { $this->reporting_date = ""; $this->ects_output = 0; } else { $this->reporting_date = $reporting_date; $this->score_reporting = REPORT_AFTER_TEST; } }
ilObjTest::setScoreReporting | ( | $ | score_reporting = 0 |
) |
Sets the score reporting.
Sets the score reporting of the ilObjTest object
integer | $score_reporting The score reporting public |
Definition at line 1515 of file class.ilObjTest.php.
References $score_reporting.
Referenced by from_xml().
{ $this->score_reporting = $score_reporting; }
ilObjTest::setSequenceSettings | ( | $ | sequence_settings = 0 |
) |
Sets the sequence settings.
Sets the sequence settings of the ilObjTest object
integer | $sequence_settings The sequence settings public |
Definition at line 1487 of file class.ilObjTest.php.
References $sequence_settings.
Referenced by from_xml().
{ $this->sequence_settings = $sequence_settings; }
ilObjTest::setStartingTime | ( | $ | starting_time = "" |
) |
Sets the starting time for the test.
Sets the starting time in database timestamp format for the test
string | $starting_time The starting time for the test. Empty string for no starting time. public |
Definition at line 1773 of file class.ilObjTest.php.
References $starting_time.
Referenced by from_xml().
{ $this->starting_time = $starting_time; }
ilObjTest::setTestType | ( | $ | type = TYPE_ASSESSMENT |
) |
Sets the test type.
Sets the type of the ilObjTest object
integer | $type The test type value public |
Definition at line 1501 of file class.ilObjTest.php.
References ilObject::$type.
Referenced by from_xml(), and importObject().
{ $this->test_type = $type; }
ilObjTest::startingTimeReached | ( | ) |
Returns true if the starting time of a test is reached.
Returns true if the starting time of a test is reached A starting time is not available for self assessment tests
Definition at line 3801 of file class.ilObjTest.php.
References getStartingTime(), and getTestType().
{ if ($this->getTestType() == TYPE_ASSESSMENT) { if ($this->getStartingTime()) { preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->getStartingTime(), $matches); $epoch_time = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); $now = mktime(); if ($now < $epoch_time) { // starting time not reached return false; } } } return true; }
ilObjTest::startWorkingTime | ( | $ | user_id | ) |
Write the initial entry for the tests working time to the database.
Write the initial entry for the tests working time to the database
integer | $user_id The database id of the user working with the test public |
Definition at line 2275 of file class.ilObjTest.php.
References $q, $result, $user_id, getActiveTestUser(), and setActiveTestUser().
{ $result = ""; if (!($result = $this->getActiveTestUser($user_id))) { $this->setActiveTestUser(); $result = $this->getActiveTestUser($user_id); } $q = sprintf("INSERT INTO tst_times (times_id, active_fi, started, finished, TIMESTAMP) VALUES (NULL, %s, %s, %s, NULL)", $this->ilias->db->quote($result->active_id), $this->ilias->db->quote(strftime("%Y-%m-%d %H:%M:%S")), $this->ilias->db->quote(strftime("%Y-%m-%d %H:%M:%S")) ); $result = $this->ilias->db->query($q); return $this->ilias->db->getLastInsertId(); }
ilObjTest::testTitleExists | ( | $ | title | ) |
Returns TRUE if the test title exists in the database.
Returns TRUE if the test title exists in the database
string | $title The title of the test |
Definition at line 793 of file class.ilObjTest.php.
References $query, $result, and ilObject::$title.
Referenced by duplicate().
{ $query = sprintf("SELECT * FROM object_data WHERE title = %s AND type = %s", $this->ilias->db->quote($title), $this->ilias->db->quote("tst") ); $result = $this->ilias->db->query($query); if (strcmp(strtolower(get_class($result)), db_result) == 0) { if ($result->numRows() == 1) { return TRUE; } } return FALSE; }
ilObjTest::to_xml | ( | ) |
Returns a QTI xml representation of the test.
Returns a QTI xml representation of the test
Definition at line 4058 of file class.ilObjTest.php.
References $score_reporting, $xml, _instanciateQuestion(), domxml_open_mem(), getAuthor(), ilObject::getDescription(), getEndingTime(), getIntroduction(), getNrOfTries(), getRandomQuestionCount(), getReportingDate(), getScoreReporting(), getSequenceSettings(), getStartingTime(), getTestType(), ilObject::getTitle(), and isRandomTest().
Referenced by importObject().
{ $xml_header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<questestinterop></questestinterop>\n"; $domxml = domxml_open_mem($xml_header); $root = $domxml->document_element(); // qti assessment $qtiAssessment = $domxml->create_element("assessment"); $qtiAssessment->set_attribute("ident", "il_".IL_INST_ID."_tst_".$this->getTestId()); $qtiAssessment->set_attribute("title", $this->getTitle()); // add qti comment $qtiComment = $domxml->create_element("qticomment"); $qtiCommentText = $domxml->create_text_node($this->getDescription()); $qtiComment->append_child($qtiCommentText); $qtiAssessment->append_child($qtiComment); // add qti duration if ($this->enable_processing_time) { $qtiDuration = $domxml->create_element("duration"); preg_match("/(\d+):(\d+):(\d+)/", $this->processing_time, $matches); $qtiDurationText = $domxml->create_text_node(sprintf("P0Y0M0DT%dH%dM%dS", $matches[1], $matches[2], $matches[3])); $qtiDuration->append_child($qtiDurationText); $qtiAssessment->append_child($qtiDuration); } // add the rest of the preferences in qtimetadata tags, because there is no correspondent definition in QTI $qtiMetadata = $domxml->create_element("qtimetadata"); // ILIAS version $qtiMetadatafield = $domxml->create_element("qtimetadatafield"); $qtiFieldLabel = $domxml->create_element("fieldlabel"); $qtiFieldLabelText = $domxml->create_text_node("ILIAS_VERSION"); $qtiFieldLabel->append_child($qtiFieldLabelText); $qtiFieldEntry = $domxml->create_element("fieldentry"); $qtiFieldEntryText = $domxml->create_text_node($this->ilias->getSetting("ilias_version")); $qtiFieldEntry->append_child($qtiFieldEntryText); $qtiMetadatafield->append_child($qtiFieldLabel); $qtiMetadatafield->append_child($qtiFieldEntry); $qtiMetadata->append_child($qtiMetadatafield); // test type $qtiMetadatafield = $domxml->create_element("qtimetadatafield"); $qtiFieldLabel = $domxml->create_element("fieldlabel"); $qtiFieldLabelText = $domxml->create_text_node("test_type"); $qtiFieldLabel->append_child($qtiFieldLabelText); $qtiFieldEntry = $domxml->create_element("fieldentry"); $qtiFieldEntryText = $domxml->create_text_node(sprintf("%d", $this->getTestType())); $qtiFieldEntry->append_child($qtiFieldEntryText); $qtiMetadatafield->append_child($qtiFieldLabel); $qtiMetadatafield->append_child($qtiFieldEntry); $qtiMetadata->append_child($qtiMetadatafield); // sequence settings $qtiMetadatafield = $domxml->create_element("qtimetadatafield"); $qtiFieldLabel = $domxml->create_element("fieldlabel"); $qtiFieldLabelText = $domxml->create_text_node("sequence_settings"); $qtiFieldLabel->append_child($qtiFieldLabelText); $qtiFieldEntry = $domxml->create_element("fieldentry"); $qtiFieldEntryText = $domxml->create_text_node(sprintf("%d", $this->getSequenceSettings())); $qtiFieldEntry->append_child($qtiFieldEntryText); $qtiMetadatafield->append_child($qtiFieldLabel); $qtiMetadatafield->append_child($qtiFieldEntry); $qtiMetadata->append_child($qtiMetadatafield); // author $qtiMetadatafield = $domxml->create_element("qtimetadatafield"); $qtiFieldLabel = $domxml->create_element("fieldlabel"); $qtiFieldLabelText = $domxml->create_text_node("author"); $qtiFieldLabel->append_child($qtiFieldLabelText); $qtiFieldEntry = $domxml->create_element("fieldentry"); $qtiFieldEntryText = $domxml->create_text_node($this->getAuthor()); $qtiFieldEntry->append_child($qtiFieldEntryText); $qtiMetadatafield->append_child($qtiFieldLabel); $qtiMetadatafield->append_child($qtiFieldEntry); $qtiMetadata->append_child($qtiMetadatafield); // score reporting date if ($this->getReportingDate()) { $qtiMetadatafield = $domxml->create_element("qtimetadatafield"); $qtiFieldLabel = $domxml->create_element("fieldlabel"); $qtiFieldLabelText = $domxml->create_text_node("reporting_date"); $qtiFieldLabel->append_child($qtiFieldLabelText); $qtiFieldEntry = $domxml->create_element("fieldentry"); preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->reporting_date, $matches); $qtiFieldEntryText = $domxml->create_text_node(sprintf("P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6])); $qtiFieldEntry->append_child($qtiFieldEntryText); $qtiMetadatafield->append_child($qtiFieldLabel); $qtiMetadatafield->append_child($qtiFieldEntry); $qtiMetadata->append_child($qtiMetadatafield); } // number of tries $qtiMetadatafield = $domxml->create_element("qtimetadatafield"); $qtiFieldLabel = $domxml->create_element("fieldlabel"); $qtiFieldLabelText = $domxml->create_text_node("nr_of_tries"); $qtiFieldLabel->append_child($qtiFieldLabelText); $qtiFieldEntry = $domxml->create_element("fieldentry"); $qtiFieldEntryText = $domxml->create_text_node(sprintf("%d", $this->getNrOfTries())); $qtiFieldEntry->append_child($qtiFieldEntryText); $qtiMetadatafield->append_child($qtiFieldLabel); $qtiMetadatafield->append_child($qtiFieldEntry); $qtiMetadata->append_child($qtiMetadatafield); // random test $qtiMetadatafield = $domxml->create_element("qtimetadatafield"); $qtiFieldLabel = $domxml->create_element("fieldlabel"); $qtiFieldLabelText = $domxml->create_text_node("random_test"); $qtiFieldLabel->append_child($qtiFieldLabelText); $qtiFieldEntry = $domxml->create_element("fieldentry"); $qtiFieldEntryText = $domxml->create_text_node(sprintf("%d", $this->isRandomTest())); $qtiFieldEntry->append_child($qtiFieldEntryText); $qtiMetadatafield->append_child($qtiFieldLabel); $qtiMetadatafield->append_child($qtiFieldEntry); $qtiMetadata->append_child($qtiMetadatafield); // random question count $qtiMetadatafield = $domxml->create_element("qtimetadatafield"); $qtiFieldLabel = $domxml->create_element("fieldlabel"); $qtiFieldLabelText = $domxml->create_text_node("random_question_count"); $qtiFieldLabel->append_child($qtiFieldLabelText); $qtiFieldEntry = $domxml->create_element("fieldentry"); $qtiFieldEntryText = $domxml->create_text_node(sprintf("%d", $this->getRandomQuestionCount())); $qtiFieldEntry->append_child($qtiFieldEntryText); $qtiMetadatafield->append_child($qtiFieldLabel); $qtiMetadatafield->append_child($qtiFieldEntry); $qtiMetadata->append_child($qtiMetadatafield); // starting time if ($this->getStartingTime()) { $qtiMetadatafield = $domxml->create_element("qtimetadatafield"); $qtiFieldLabel = $domxml->create_element("fieldlabel"); $qtiFieldLabelText = $domxml->create_text_node("starting_time"); $qtiFieldLabel->append_child($qtiFieldLabelText); $qtiFieldEntry = $domxml->create_element("fieldentry"); preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->starting_time, $matches); $qtiFieldEntryText = $domxml->create_text_node(sprintf("P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6])); $qtiFieldEntry->append_child($qtiFieldEntryText); $qtiMetadatafield->append_child($qtiFieldLabel); $qtiMetadatafield->append_child($qtiFieldEntry); $qtiMetadata->append_child($qtiMetadatafield); } // ending time if ($this->getEndingTime()) { $qtiMetadatafield = $domxml->create_element("qtimetadatafield"); $qtiFieldLabel = $domxml->create_element("fieldlabel"); $qtiFieldLabelText = $domxml->create_text_node("ending_time"); $qtiFieldLabel->append_child($qtiFieldLabelText); $qtiFieldEntry = $domxml->create_element("fieldentry"); preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->ending_time, $matches); $qtiFieldEntryText = $domxml->create_text_node(sprintf("P%dY%dM%dDT%dH%dM%dS", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6])); $qtiFieldEntry->append_child($qtiFieldEntryText); $qtiMetadatafield->append_child($qtiFieldLabel); $qtiMetadatafield->append_child($qtiFieldEntry); $qtiMetadata->append_child($qtiMetadatafield); } foreach ($this->mark_schema->mark_steps as $index => $mark) { // mark steps $qtiMetadatafield = $domxml->create_element("qtimetadatafield"); $qtiFieldLabel = $domxml->create_element("fieldlabel"); $qtiFieldLabelText = $domxml->create_text_node("mark_step_$index"); $qtiFieldLabel->append_child($qtiFieldLabelText); $qtiFieldEntry = $domxml->create_element("fieldentry"); $qtiFieldEntryText = $domxml->create_text_node(sprintf("<short>%s</short><official>%s</official><percentage>%.2f</percentage><passed>%d</passed>", $mark->get_short_name(), $mark->get_official_name(), $mark->get_minimum_level(), $mark->get_passed())); $qtiFieldEntry->append_child($qtiFieldEntryText); $qtiMetadatafield->append_child($qtiFieldLabel); $qtiMetadatafield->append_child($qtiFieldEntry); $qtiMetadata->append_child($qtiMetadatafield); } $qtiAssessment->append_child($qtiMetadata); // add qti objectives $qtiObjectives = $domxml->create_element("objectives"); $qtiMaterial = $domxml->create_element("material"); $qtiMaterial->set_attribute("label", "introduction"); $qtiMatText = $domxml->create_element("mattext"); $qtiMatTextText = $domxml->create_text_node($this->getIntroduction()); $qtiMatText->append_child($qtiMatTextText); $qtiMaterial->append_child($qtiMatText); $qtiObjectives->append_child($qtiMaterial); $qtiAssessment->append_child($qtiObjectives); // add qti assessmentcontrol $qtiAssessmentcontrol = $domxml->create_element("assessmentcontrol"); $score_reporting = "No"; switch ($this->getScoreReporting()) { case "1": $score_reporting = "Yes"; break; } $qtiAssessmentcontrol->set_attribute("solutionswitch", $score_reporting); $qtiAssessment->append_child($qtiAssessmentcontrol); $qtiSection = $domxml->create_element("section"); $qtiSection->set_attribute("ident", "1"); $qtiAssessment->append_child($qtiSection); $root->append_child($qtiAssessment); $xml = $domxml->dump_mem(true); $domxml->free(); foreach ($this->questions as $question_id) { $question =& ilObjTest::_instanciateQuestion($question_id); $qti_question = $question->to_xml(false); $qti_question = preg_replace("/<questestinterop>/", "", $qti_question); $qti_question = preg_replace("/<\/questestinterop>/", "", $qti_question); if (strpos($xml, "</section>") !== false) { $xml = str_replace("</section>", "$qti_question</section>", $xml); } else { $xml = str_replace("<section ident=\"1\"/>", "<section ident=\"1\">\n$qti_question</section>", $xml); } } return $xml; }
ilObjTest::update | ( | ) |
update object data
public
Reimplemented from ilObject.
Definition at line 345 of file class.ilObjTest.php.
Referenced by updateMetaData().
{ if (!parent::update()) { return false; } // put here object specific stuff return true; }
ilObjTest::updateMetaData | ( | ) |
update meta data only
Definition at line 4845 of file class.ilObjTest.php.
References initMeta(), ilObject::setDescription(), ilObject::setTitle(), and update().
{ $this->initMeta(); $this->meta_data->update(); if ($this->meta_data->section != "General") { $meta = $this->meta_data->getElement("Title", "General"); $this->meta_data->setTitle($meta[0]["value"]); $meta = $this->meta_data->getElement("Description", "General"); $this->meta_data->setDescription($meta[0]["value"]); } else { $this->setTitle($this->meta_data->getTitle()); $this->setDescription($this->meta_data->getDescription()); } parent::update(); }
ilObjTest::updateTitleAndDescription | ( | ) |
Set the title and the description for the meta data.
Definition at line 4836 of file class.ilObjTest.php.
References ilObject::getDescription(), ilObject::getTitle(), and initMeta().
{ $this->initMeta(); $this->meta_data->updateTitleAndDescription($this->getTitle(), $this->getDescription()); }
ilObjTest::updateWorkingTime | ( | $ | times_id | ) |
Update the working time of a test when a question is answered.
Update the working time of a test when a question is answered
integer | $times_id The database id of a working time entry public |
Definition at line 2299 of file class.ilObjTest.php.
ilObjTest::$author |
Definition at line 76 of file class.ilObjTest.php.
Referenced by setAuthor().
ilObjTest::$ects_fx |
Definition at line 231 of file class.ilObjTest.php.
Referenced by saveToDb().
ilObjTest::$ects_grades |
Definition at line 252 of file class.ilObjTest.php.
ilObjTest::$ects_output |
Definition at line 222 of file class.ilObjTest.php.
Referenced by saveECTSStatus().
ilObjTest::$enable_processing_time |
Definition at line 195 of file class.ilObjTest.php.
ilObjTest::$ending_time |
Definition at line 213 of file class.ilObjTest.php.
Referenced by setEndingTime().
ilObjTest::$evaluation_data |
Definition at line 158 of file class.ilObjTest.php.
ilObjTest::$introduction |
Definition at line 104 of file class.ilObjTest.php.
Referenced by setIntroduction().
ilObjTest::$mark_schema |
Definition at line 113 of file class.ilObjTest.php.
ilObjTest::$metadata |
Definition at line 85 of file class.ilObjTest.php.
ilObjTest::$nr_of_tries |
Definition at line 177 of file class.ilObjTest.php.
Referenced by setNrOfTries().
ilObjTest::$processing_time |
Definition at line 186 of file class.ilObjTest.php.
Referenced by setProcessingTime().
ilObjTest::$questions |
Definition at line 94 of file class.ilObjTest.php.
ilObjTest::$random_question_count |
Definition at line 272 of file class.ilObjTest.php.
Referenced by saveToDb().
ilObjTest::$random_test |
Definition at line 263 of file class.ilObjTest.php.
ilObjTest::$reporting_date |
Definition at line 149 of file class.ilObjTest.php.
Referenced by setReportingDate().
ilObjTest::$score_reporting |
Definition at line 137 of file class.ilObjTest.php.
Referenced by from_xml(), setScoreReporting(), and to_xml().
ilObjTest::$sequence_settings |
Definition at line 124 of file class.ilObjTest.php.
Referenced by setSequenceSettings().
ilObjTest::$starting_time |
Definition at line 204 of file class.ilObjTest.php.
Referenced by setStartingTime().
ilObjTest::$test_id |
Definition at line 66 of file class.ilObjTest.php.
Referenced by _getActiveTestUser(), _getObjectIDFromTestID(), _getTestIDFromObjectID(), and _getTestType().
ilObjTest::$test_type |
Definition at line 167 of file class.ilObjTest.php.
ilObjTest::$test_types |
Definition at line 243 of file class.ilObjTest.php.