Public Member Functions | Data Fields

ilObjTest Class Reference

Inheritance diagram for ilObjTest:
Collaboration diagram for ilObjTest:

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.
 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.
 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, $pass=NULL)
 Saves a random question to the database.
 getNrOfResultsForPass ($user_id, $pass)
 Calculates the number of user results for a specific test pass.
 generateRandomQuestions ($pass=NULL)
 Generates new random questions for the active user.
 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="", $pass=NULL)
 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.
 getCountSystem ()
 Gets the count system for the calculation of points.
 _getCountSystem ($test_id)
 Gets the count system for the calculation of points.
 getMCScoring ()
 Gets the scoring type for multiple choice questions.
 getPassScoring ()
 Gets the pass scoring type.
 _getPassScoring ($test_id)
 Gets the pass scoring type.
 _getMCScoring ($test_id)
 Gets the scoring type for multiple choice questions.
 getTestType ()
 Gets the test type.
 getReportingDate ()
 Gets the reporting date.
 getNrOfTries ()
 Returns the nr of tries for the test.
 getHidePreviousResults ()
 Returns if the previous results should be hidden for a learner.
 getHideTitlePoints ()
 Returns true if the maximum points of a question should be hidden in the question title.
 _getHideTitlePoints ($test_id)
 Returns true if the maximum points of a question should be hidden in the question title.
 _getHidePreviousResults ($test_id, $user_active_user_setting=false)
 Returns if the previous results should be hidden for a learner.
 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.
 setHidePreviousResults ($hide_previous_results=0)
 Sets the status of the visibility of previous learner results.
 setHideTitlePoints ($hide_title_points=0)
 Sets the status of the visibility of the maximum points in the question title.
 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.
 setCountSystem ($a_count_system=COUNT_PARTIAL_SOLUTIONS)
 Sets the count system for the calculation of points.
 setMCScoring ($a_mc_scoring=SCORE_ZERO_POINTS_WHEN_UNANSWERED)
 Sets the multiple choice scoring.
 setPassScoring ($a_pass_scoring=SCORE_LAST_PASS)
 Sets the pass scoring.
 removeQuestion ($question_id)
 Removes a question from the test object.
 clearEvalSelectedUsers ()
 Removes all selected users for the test evaluation.
 removeAllTestEditings ($question_id="")
 Removes all references to the question in executed tests in case the question has been changed.
 removeSelectedTestResults ($user_ids)
 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="")
 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.
 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 ($pass=NULL)
 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 ()
 getFirstSequence ()
getWorkedQuestions ($pass=NULL)
 Gets the id's of all questions a user already worked through.
getAllQuestions ($pass=NULL)
 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, $pass=NULL)
 Calculates the results of a test for a given user.
getTestSummary ($user_id, $pass=NULL)
 Calculates the overview of a test for a given user.
_getTestResult ($user_id, $test_obj_id, $pass=NULL)
 Calculates the results of a test for a given user.
 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 ($name_sort_order="asc")
 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.
 evalTotalStartedAverageTime ()
 Returns the average processing time for all started tests.
 evalTotalPassedAverageTime ()
 Returns the average processing time for all passed tests.
getAvailableQuestionpoolIDs ()
 Returns the object id's of the available question pools for the active user.
getAvailableQuestionpools ($use_object_id=false, $equal_points=false, $could_be_offline=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="", $pass=NULL)
 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
 getImportMapping ()
 get array of (two) new created questions for import id
 getECTSGrade ($reached_points, $max_points)
 Returns the ECTS grade for a number of reached points.
 checkMarks ()
 updateMetaData ()
 update meta data entry
_getAvailableTests ($use_object_id=false)
 Returns the available tests 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, $sort_name_option="asc")
 Returns an array of users who are selected for a test evaluation of a given user.
 removeSelectedUser ($user_id, $evaluator_id)
 Disinvites a user from a evaluation.
 addSelectedUser ($user_id, $evaluator_id)
 Invites a user to a evaluation.
 addSelectedGroup ($group_id, $evaluator_id)
 Invites a group to a evaluation.
 addSelectedRole ($role_id, $evaluator_id)
 Adds a role to a evaluation.
 getQuestionCount ()
 Returns the number of questions in the test.
 _getQuestionCount ($test_id, $user_id)
 Returns the number of questions in the test for a given user.
 _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, $pass=NULL)
 Returns the text answer of a given user for a given question.
 getQuestiontext ($question_id)
 Returns the question text for a given question.
getInvitedUsers ($user_id="", $order="login, lastname, firstname")
 Returns a list of all invited users in a test.
getUserData ($ids)
 Returns a data of all users specified by id list.
getArrayData ($query, $id_field)
 Returns a data as id key list.
_getArrayData ($query, $id_field)
getGroupData ($ids)
getRoleData ($ids)
 inviteGroup ($group_id)
 Invites all users of a group to a test.
 inviteRole ($role_id)
 Invites all users of a role to a test.
 disinviteUser ($user_id)
 Disinvites a user from a test.
 inviteUser ($user_id, $client_ip="")
 Invites a user to a test.
 setClientIP ($user_id, $client_ip)
 isOnlineTest ()
 gets TestType equals Online Test
 _getSolvedQuestions ($test_fi, $user_fi, $question_fi=null)
 get solved questions
 setQuestionSetSolved ($value, $question_id, $user_id)
 sets question solved state to value for given user_id
 setActiveTestSubmitted ($user_id)
 submits active test for user user_id
 isActiveTestSubmitted ($user_id=null)
 returns if the active for user_id has been submitted
 hasNrOfTriesRestriction ()
 returns if the numbers of tries have to be checked
 isNrOfTriesReached ($tries)
 returns if number of tries are reached
 getAllTestResults ()
 returns all test results for all participants
processCSVRow ($row, $quoteAll=FALSE, $separator=";")
 Convertes an array for CSV usage.
 _getPass ($user_id, $test_id)
 Retrieves the actual pass of a given user for a given test.
 _getBestPass ($user_id, $test_id)
 Retrieves the best pass of a given user for a given test.
 _getResultPass ($user_id, $test_id)
 Retrieves the pass number that should be counted for a given user.
 getAnsweredQuestionCount ($user_id, $test_id, $pass=NULL)
 Retrieves the number of answered questions for a given user in a given test.
 getPassFinishDate ($user_id, $test_id, $pass)
 Retrieves the number of answered questions for a given user in a given test.
 isExecutable ($user_id)
 Checks if the test is executable by the given user.
 canShowTestResults ($user_id)
 canEditMarks ()
 getStartingTimeOfUser ($user_id)
 Returns the unix timestamp of the time a user started a test.
 isMaxProcessingTimeReached ($starting_time)
 Returns wheather the maximum processing time for a test is reached or not.
_getPassedUsers ($a_obj_id)
 Returns an array containing the user ids of all users who passed the test.

Data Fields

 $test_id
 $invitation = INVITATION_OFF
 $author
 $metadata
 $questions
 $introduction
 $mark_schema
 $sequence_settings
 $score_reporting
 $reporting_date
 $evaluation_data
 $test_type
 $nr_of_tries
 $hide_previous_results
 $hide_title_points
 $processing_time
 $enable_processing_time
 $starting_time
 $ending_time
 $ects_output
 $ects_fx
 $test_types
 $ects_grades
 $random_test
 $random_question_count
 $count_system
 $mc_scoring
 $pass_scoring

Detailed Description

Definition at line 38 of file class.ilObjTest.php.


Member Function Documentation

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 5235 of file class.ilObjTest.php.

References $_GET, $counter, $key, $obj_id, ASS_Question::_getOriginalId(), _instanciateQuestion(), 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->setAuthor($original->getAuthor());
                $newObj->setHideTitlePoints($original->getHideTitlePoints());
                $newObj->setPassScoring($original->getPassScoring());
                $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->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->setHidePreviousResults($original->getHidePreviousResults());
                $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->setCountSystem($original->getCountSystem());
                $newObj->setMCScoring($original->getMCScoring());
                $newObj->saveToDb();            
                if ($original->isRandomTest())
                {
                        $newObj->saveRandomQuestionCount($newObj->random_question_count);
                        $original->cloneRandomQuestions($newObj->getTestId());
                }
                else
                {
                        // clone the questions
                        include_once "./assessment/classes/class.assQuestion.php";
                        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
                include_once "./Services/MetaData/classes/class.ilMD.php";
                $md = new ilMD($original->getId(),0,$original->getType());
                $new_md =& $md->cloneMD($newObj->getId(),0,$newObj->getType());
                return $newObj->getRefId();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

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 738 of file class.ilObjTest.php.

References ilObject::$ilias, ilUtil::getDataDir(), and ilUtil::makeDir().

Referenced by ilObjTestGUI::uploadTstObject().

        {
                global $ilias;
                
                include_once "./classes/class.ilUtil.php";
                $tst_data_dir = ilUtil::getDataDir()."/tst_data";
                ilUtil::makeDir($tst_data_dir);
                
                if(!is_writable($tst_data_dir))
                {
                        $ilias->raiseError("Test data directory (".$tst_data_dir
                                .") not writeable.",$ilias->error_obj->FATAL);
                }

                // create test directory (data_dir/tst_data/tst_import)
                $tst_dir = $tst_data_dir."/tst_import";
                ilUtil::makeDir($tst_dir);
                if(!@is_dir($tst_dir))
                {
                        $ilias->raiseError("Creation of test import directory failed.",$ilias->error_obj->FATAL);
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters:
integer $user_id The database id of the user
integer $test_id The database id of the test
Returns:
object The database row of the tst_active table public

Definition at line 3068 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::_getArrayData ( query,
id_field 
)

Definition at line 5862 of file class.ilObjTest.php.

References $query, $result, and $row.

Referenced by _getSolvedQuestions(), and getArrayData().

        {       
                global $ilDB;
                $result = $ilDB->query($query);
                while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $result_array[$row->$id_field]= $row;
                }
                return ($result_array)?$result_array:array();
        }

Here is the caller graph for this function:

& ilObjTest::_getAvailableTests ( use_object_id = false  ) 

Returns the available tests for the active user.

Returns the available tests for the active user

Returns:
array The available tests public

Definition at line 5170 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);
                include_once "./classes/class.ilObject.php";
                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;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::_getBestPass ( user_id,
test_id 
)

Retrieves the best pass of a given user for a given test.

Retrieves the best pass of a given user for a given test

Parameters:
integer $user_id The user id
integer $test_id The test id
Returns:
integer The best pass of the user for the given test public

Definition at line 6242 of file class.ilObjTest.php.

References $query, $result, $row, $test_id, $user_id, and _getPass().

Referenced by _getResultPass().

        {
                global $ilDB;
                $lastpass = ilObjTest::_getPass($user_id, $test_id);
                $bestpass = 0;
                $maxpoints = 0;
                for ($i = 0; $i <= $lastpass; $i++)
                {
                        $query = sprintf("SELECT SUM(points) AS maxpoints FROM tst_test_result WHERE user_fi = %s AND test_fi = %s AND pass = %s",
                                $ilDB->quote($user_id . ""),
                                $ilDB->quote($test_id . ""),
                                $ilDB->quote($i . "")
                        );
                        $result = $ilDB->query($query);
                        if ($result->numRows())
                        {
                                $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                                if ($row["maxpoints"] > $maxpoints)
                                {
                                        $maxpoints = $row["maxpoints"];
                                        $bestpass = $i;
                                }
                        }
                }
                return $bestpass;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::_getCountSystem ( test_id  ) 

Gets the count system for the calculation of points.

Gets the count system for the calculation of points

Returns:
integer The count system for the calculation of points public
See also:
$count_system

Definition at line 1820 of file class.ilObjTest.php.

References $query, $result, $row, and $test_id.

Referenced by ASS_Question::getSolutionCommentCountSystem().

        {
                global $ilDB;
                $query = sprintf("SELECT count_system FROM tst_tests WHERE test_id = %s",
                        $ilDB->quote($test_id)
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        return $row["count_system"];
                }
    return FALSE;
  }

Here is the caller graph for this function:

ilObjTest::_getHidePreviousResults ( test_id,
user_active_user_setting = false 
)

Returns if the previous results should be hidden for a learner.

Returns if the previous results should be hidden for a learner

Parameters:
integer $test_id The test id
boolean $use_active_user_setting If true, the tst_hide_previous_results of the active user should be used as well
Returns:
integer 1 if the previous results should be hidden, 0 otherwise public
See also:
$hide_previous_results

Definition at line 2018 of file class.ilObjTest.php.

References $ilUser, $query, $result, $row, and $test_id.

Referenced by ilTestOutputGUI::outWorkingForm(), ASS_TextQuestionGUI::outWorkingForm(), ASS_OrderingQuestionGUI::outWorkingForm(), ASS_MultipleChoiceGUI::outWorkingForm(), ASS_MatchingQuestionGUI::outWorkingForm(), ASS_ImagemapQuestionGUI::outWorkingForm(), ASS_ClozeTestGUI::outWorkingForm(), ASS_OrderingQuestion::to_xml(), and ASS_JavaApplet::to_xml().

        {
                global $ilDB;
                global $ilUser;
                
                $user_hide_previous_results = 0;
                if ($user_active_user_setting)
                {
                        if (array_key_exists("tst_hide_previous_results", $ilUser->prefs))
                        {
                                $user_hide_previous_results = $ilUser->prefs["tst_hide_previous_results"];
                        }
                }
                $query = sprintf("SELECT hide_previous_results FROM tst_tests WHERE test_id = %s",
                        $ilDB->quote($test_id . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        if ($row["hide_previous_results"] != 1)
                        {
                                return $row["hide_previous_results"] | $user_hide_previous_results;
                        }
                        else
                        {
                                return $row["hide_previous_results"];
                        }
                }
                return 0;
  }

Here is the caller graph for this function:

ilObjTest::_getHideTitlePoints ( test_id  ) 

Returns true if the maximum points of a question should be hidden in the question title.

Returns true if the maximum points of a question should be hidden in the question title

Parameters:
integer The test id
Returns:
integer 1 if the maximum points in the question title should be hidden public
See also:
$hide_title_points

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

References $query, $result, $row, and $test_id.

Referenced by ASS_QuestionGUI::outQuestionPage().

        {
                global $ilDB;

                $query = sprintf("SELECT hide_title_points FROM tst_tests WHERE test_id = %s",
                        $ilDB->quote($test_id . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        return $row["hide_title_points"];
                }
                return 0;
  }

Here is the caller graph for this function:

ilObjTest::_getImportDirectory (  ) 

Get the import directory location of the test.

Get the import directory location of the test

Returns:
string The location of the import directory or false if the directory doesn't exist public

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

References ilUtil::getDataDir().

Referenced by ilObjTestGUI::importVerifiedFileObject(), and ilObjTestGUI::uploadTstObject().

        {
                include_once "./classes/class.ilUtil.php";
                $import_dir = ilUtil::getDataDir()."/tst_data/tst_import";
                if(@is_dir($import_dir))
                {
                        return $import_dir;
                }
                else
                {
                        return false;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::_getMCScoring ( test_id  ) 

Gets the scoring type for multiple choice questions.

Gets the scoring type for multiple choice questions

Returns:
mixed The scoring type for multiple choice questions public
See also:
$mc_scoring

Definition at line 1896 of file class.ilObjTest.php.

References $query, $result, $row, and $test_id.

Referenced by ASS_Question::getSolutionCommentMCScoring().

        {
                global $ilDB;
                $query = sprintf("SELECT  mc_scoring FROM tst_tests WHERE test_id = %s",
                        $ilDB->quote($test_id)
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        return $row["mc_scoring"];
                }
    return FALSE;
  }

Here is the caller graph for this function:

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

Parameters:
integer $test_id The test id
Returns:
mixed The ILIAS test object id or FALSE if the query was not successful public

Definition at line 5658 of file class.ilObjTest.php.

References $query, $result, $row, and $test_id.

Referenced by ASS_Question::logAction(), and 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;
        }

Here is the caller graph for this function:

ilObjTest::_getPass ( user_id,
test_id 
)

Retrieves the actual pass of a given user for a given test.

Retrieves the actual pass of a given user for a given test

Parameters:
integer $user_id The user id
integer $test_id The test id
Returns:
integer The pass of the user for the given test public

Definition at line 6213 of file class.ilObjTest.php.

References $query, $result, $row, $test_id, and $user_id.

Referenced by _getBestPass(), _getResultPass(), deleteResults(), loadQuestions(), ilTestOutputGUI::outWorkingForm(), ASS_TextQuestionGUI::outWorkingForm(), ASS_OrderingQuestionGUI::outWorkingForm(), ASS_MultipleChoiceGUI::outWorkingForm(), ASS_MatchingQuestionGUI::outWorkingForm(), ASS_ImagemapQuestionGUI::outWorkingForm(), ASS_ClozeTestGUI::outWorkingForm(), ASS_TextQuestion::saveWorkingData(), ASS_Question::saveWorkingData(), ASS_OrderingQuestion::saveWorkingData(), ASS_MultipleChoice::saveWorkingData(), ASS_MatchingQuestion::saveWorkingData(), ASS_ImagemapQuestion::saveWorkingData(), ASS_ClozeTest::saveWorkingData(), ASS_OrderingQuestion::to_xml(), and ASS_JavaApplet::to_xml().

        {
                global $ilDB;
                $query = sprintf("SELECT tries FROM tst_active WHERE user_fi = %s AND test_fi = %s",
                        $ilDB->quote($user_id . ""),
                        $ilDB->quote($test_id . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        return $row["tries"];
                }
                else
                {
                        return 0;
                }
        }

Here is the caller graph for this function:

& ilObjTest::_getPassedUsers ( a_obj_id  ) 

Returns an array containing the user ids of all users who passed the test.

Returns an array containing the user ids of all users who passed the test, regardless if they fnished the test with the finish test button or not. Only the reached points are counted

Parameters:
integer $test_id Test id of the test
Returns:
array An array containing the user ids of the users who passed the test public

Definition at line 6558 of file class.ilObjTest.php.

References $query, $result, $row, $test_id, $user_id, _getResultPass(), and _getTestResult().

Referenced by evalTotalPassedAverageTime().

        {
                global $ilDB;
                
                $passed_users = array();
                $query = sprintf("SELECT tst_active.* FROM tst_active, tst_tests ".
                                                 "WHERE tst_tests.obj_fi = %s ".
                                                 "AND tst_active.test_fi = tst_tests.test_id",
                        $ilDB->quote($a_obj_id . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                $user_id = $row["user_fi"];
                                $test_id = $row["test_fi"];
                                $pass = ilObjTest::_getResultPass($user_id, $test_id);
                                include_once "./assessment/classes/class.ilObjTestAccess.php";
                                $testres =& ilObjTestAccess::_getTestResult($user_id, $a_obj_id, $pass);
                                if ((bool) $testres['passed'])
                                {
                                        array_push($passed_users, $user_id);
                                }
                        }
                }
                return $passed_users;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::_getPassScoring ( test_id  ) 

Gets the pass scoring type.

Gets the pass scoring type

Returns:
integer The pass scoring type public
See also:
$pass_scoring

Definition at line 1872 of file class.ilObjTest.php.

References $query, $result, $row, and $test_id.

Referenced by _getResultPass().

        {
                global $ilDB;
                $query = sprintf("SELECT pass_scoring FROM tst_tests WHERE test_id = %s",
                        $ilDB->quote($test_id . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        return $row["pass_scoring"];
                }
    return 0;
  }

Here is the caller graph for this function:

ilObjTest::_getQuestionCount ( test_id,
user_id 
)

Returns the number of questions in the test for a given user.

Returns the number of questions in the test for a given user

Returns:
integer The number of questions public

Definition at line 5525 of file class.ilObjTest.php.

References $num, $query, $result, $test_id, and $user_id.

Referenced by ilTestOutputGUI::redirectQuestion(), and saveRandomQuestionpools().

        {
                global $ilDB;
                
                $num = 0;
                
                $query = sprintf("SELECT * FROM tst_tests WHERE test_id = %s",
                        $ilDB->quote($test_id . "")
                );
                $result = $ilDB->query($query);
                if (!$result->numRows())
                {
                        return 0;
                }
                $test = $result->fetchRow(DB_FETCHMODE_ASSOC);
                
                if ($test["random_test"] == 1)
                {
                        $query = sprintf("SELECT test_random_question_id FROM tst_test_random_question WHERE test_fi = %s AND user_fi = %s AND pass = 0",
                                $ilDB->quote($test_id . ""),
                                $ilDB->quote($user_id . "")
                        );
                        $result = $ilDB->query($query);
                        $num = $result->numRows();
                }
                else
                {
                        $query = sprintf("SELECT test_question_id FROM tst_test_question WHERE test_fi = %s",
                                $ilDB->quote($test_id . "")
                        );
                        $result = $ilDB->query($query);
                        $num = $result->numRows();
                }
                return $num;
        }

Here is the caller graph for this function:

& ilObjTest::_getQuestiontypes (  ) 

Creates a list of all available question types.

Creates a list of all available question types

Returns:
array An array containing the available questiontypes public

Definition at line 4585 of file class.ilObjTest.php.

References $query, and $row.

        {
                global $ilDB;
                
                $questiontypes = array();
                $query = "SELECT * FROM qpl_question_type ORDER BY type_tag";
                $query_result = $ilDB->query($query);
                while ($row = $query_result->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        array_push($questiontypes, $row["type_tag"]);
                }
                return $questiontypes;
        }

ilObjTest::_getRefIdFromObjId ( obj_id  ) 

Definition at line 5307 of file class.ilObjTest.php.

References $obj_id, $query, $result, and $row.

        {
                global $ilDB;

                $query = sprintf("SELECT ref_id FROM object_reference WHERE obj_id=%s",
                        $ilDB->quote($obj_id)
                        
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        return $row["ref_id"];
                }
                return 0;
        }

ilObjTest::_getResultPass ( user_id,
test_id 
)

Retrieves the pass number that should be counted for a given user.

Retrieves the pass number that should be counted for a given user

Parameters:
integer $user_id The user id
integer $test_id The test id
Returns:
integer The result pass of the user for the given test public

Definition at line 6279 of file class.ilObjTest.php.

References $query, $result, $test_id, $user_id, _getBestPass(), _getPass(), _getPassScoring(), and _getTestType().

Referenced by ilObjTestAccess::_getPassedUsers(), _getPassedUsers(), ilTestEvaluationGUI::evalSelectedUsers(), evalStatistical(), evalTotalFinishedPassed(), ilTestEvaluationGUI::evalUserDetail(), and ilTestOutputGUI::outResultsOverview().

        {
                $counted_pass = NULL;
                if (strcmp(ilObjTest::_getTestType($test_id), "tt_varying_randomtest") == 0)
                {
                        if (ilObjTest::_getPassScoring($test_id) == SCORE_BEST_PASS)
                        {
                                $counted_pass = ilObjTest::_getBestPass($user_id, $test_id);
                        }
                        else
                        {
                                $counted_pass = ilObjTest::_getPass($user_id, $test_id);
                                global $ilDB;
                                $query = sprintf("SELECT test_result_id FROM tst_test_result WHERE user_fi = %s AND test_fi = %s AND pass = %s",
                                        $ilDB->quote($user_id . ""),
                                        $ilDB->quote($test_id . ""),
                                        $ilDB->quote($counted_pass . "")
                                );
                                $result = $ilDB->query($query);
                                if ($result->numRows() == 0)
                                {
                                        // There was no answer answered in the actual pass, so the last pass is
                                        // $counted_pass - 1
                                        $counted_pass -= 1;
                                }
                                if ($counted_pass < 0) $counted_pass = 0;
                        }
                }
                return $counted_pass;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::_getSolvedQuestions ( test_fi,
user_fi,
question_fi = null 
)

get solved questions

Returns:
array of int containing all question ids which have been set solved for the given user and test

Definition at line 6007 of file class.ilObjTest.php.

References $query, and _getArrayData().

Referenced by getTestSummary(), and ilTestOutputGUI::outWorkingForm().

        {
                global $ilDB;
                if (is_numeric($question_fi))
                        $query = sprintf("SELECT question_fi, solved FROM tst_active_qst_sol_settings " .
                                                 "WHERE user_fi = %s AND test_fi = %s AND question_fi=%s",
                                                        $ilDB->quote($user_fi),
                                                        $ilDB->quote($test_fi),
                                                        $question_fi
                        );
                else $query = sprintf("SELECT question_fi, solved FROM tst_active_qst_sol_settings " .
                                                 "WHERE user_fi = %s AND test_fi = %s",
                        $ilDB->quote($user_fi),
                        $ilDB->quote($test_fi)
                );
                return ilObjTest::_getArrayData ($query, "question_fi");                
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::_getTestIDFromObjectID ( object_id  ) 

Returns the ILIAS test id for a given object id.

Returns the ILIAS test id for a given object id

Parameters:
integer $object_id The object id
Returns:
mixed The ILIAS test id or FALSE if the query was not successful public

Definition at line 5683 of file class.ilObjTest.php.

References $query, $result, $row, and $test_id.

        {
                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,
pass = NULL 
)

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

Returns:
array An array containing the test results for the given user public

Definition at line 3324 of file class.ilObjTest.php.

References $result, $user_id, and ilObjTest().

Referenced by _getPassedUsers().

        {
                $test = new ilObjTest($test_obj_id, false);
                $test->loadFromDb();
                $result =& $test->getTestResult($user_id, $pass);
                return $result;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::_getTestType ( test_id  ) 

Returns the test type for a given test id.

Returns the test type for a given test id

Parameters:
integer $test_id The database id of the test
Returns:
integer The test type of the test public

Definition at line 4560 of file class.ilObjTest.php.

References $query, $result, $row, and $test_id.

Referenced by _getResultPass(), and 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;
        }

Here is the caller graph for this function:

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

Parameters:
integer $a_target The reference id of the test public

Definition at line 5569 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))
                {
                        include_once "./classes/class.ilUtil.php";
                        ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=$a_target");
                }
                else
                {
                        $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
                }
        }       

Here is the call graph for this function:

& 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

Parameters:
integer $question_id The question id
Returns:
object The question instance public

Definition at line 4237 of file class.ilObjTest.php.

References ASS_Question::_getQuestionType().

Referenced by ilCourseObjectiveQuestion::__read(), _clone(), ilCourseObjectivesGUI::askDeassignQuestion(), ilCourseObjectivesGUI::assignQuestionSelect(), createRandomSolutionsForAllUsers(), duplicateQuestionForTest(), getAllTestResults(), getEstimatedWorkingTime(), ilCourseObjectiveQuestion::getMaxPointsByObjective(), ilCourseObjectiveQuestion::getMaxPointsByTest(), getTestSummary(), ilCourseObjectivesGUI::listAssignedQuestions(), and to_xml().

        {
                if (strcmp($question_id, "") != 0)
                {
                        include_once "./assessment/classes/class.assQuestion.php";
                        $question_type = ASS_Question::_getQuestionType($question_id);

                        switch ($question_type) {
                                case "qt_cloze":
                                        include_once "./assessment/classes/class.assClozeTest.php";
                                        $question = new ASS_ClozeTest();
                                        break;
                                case "qt_matching":
                                        include_once "./assessment/classes/class.assMatchingQuestion.php";
                                        $question = new ASS_MatchingQuestion();
                                        break;
                                case "qt_ordering":
                                        include_once "./assessment/classes/class.assOrderingQuestion.php";
                                        $question = new ASS_OrderingQuestion();
                                        break;
                                case "qt_imagemap":
                                        include_once "./assessment/classes/class.assImagemapQuestion.php";
                                        $question = new ASS_ImagemapQuestion();
                                        break;
                                case "qt_multiple_choice_sr":
                                case "qt_multiple_choice_mr":
                                        include_once "./assessment/classes/class.assMultipleChoice.php";
                                        $question = new ASS_MultipleChoice();
                                        break;
                                case "qt_javaapplet":
                                        include_once "./assessment/classes/class.assJavaApplet.php";
                                        $question = new ASS_JavaApplet();
                                        break;
                                case "qt_text":
                                        include_once "./assessment/classes/class.assTextQuestion.php";
                                        $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;
                }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::_isComplete ( obj_id  ) 

Returns true, if a test is complete for use.

Returns true, if a test is complete for use

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

Definition at line 957 of file class.ilObjTest.php.

References $obj_id, and ilObjTest().

        {
                $test = new ilObjTest($obj_id, false);
                $test->loadFromDb();
                return $test->isComplete();
        }

Here is the call graph for this function:

ilObjTest::addSelectedGroup ( group_id,
evaluator_id 
)

Invites a group to a evaluation.

Invites a group to a evaluation

Parameters:
integer $group_id The database id of the invited group public

Definition at line 5454 of file class.ilObjTest.php.

References $user_id, and addSelectedUser().

        {
                include_once "./classes/class.ilObjGroup.php";
                $group = new ilObjGroup($group_id);
                $members = $group->getGroupMemberIds();
                foreach ($members as $user_id)
                {
                        $this->addSelectedUser($user_id, $evaluator_id);
                }               
        }

Here is the call graph for this function:

ilObjTest::addSelectedRole ( role_id,
evaluator_id 
)

Adds a role to a evaluation.

Adds a role to a evaluation

Parameters:
integer $role_id The database id of the role to add public

Definition at line 5473 of file class.ilObjTest.php.

References $rbacreview, $role_id, $user_id, and addSelectedUser().

        {
                global $rbacreview;
                $members =  $rbacreview->assignedUsers($role_id,"usr_id");
                foreach ($members as $user_id)
                {
                        $this->addSelectedUser($user_id, $evaluator_id);
                }               
        }

Here is the call graph for this function:

ilObjTest::addSelectedUser ( user_id,
evaluator_id 
)

Invites a user to a evaluation.

Invites a user to a evaluation

Parameters:
integer $user_id The database id of the invited user public

Definition at line 5428 of file class.ilObjTest.php.

References $query, $result, and $user_id.

Referenced by addSelectedGroup(), and addSelectedRole().

        {
                $query = sprintf("SELECT user_fi FROM tst_active 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);
                if ($result->numRows() == 1)
                {
                        $query = sprintf("REPLACE INTO tst_eval_users (test_fi, evaluator_fi, user_fi) VALUES (%s, %s, %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);
                }
        }

Here is the caller graph for this function:

ilObjTest::canEditMarks (  ) 

Definition at line 6454 of file class.ilObjTest.php.

References $total, evalTotalPersons(), and getReportingDate().

        {
                $total = $this->evalTotalPersons();
                if ($total > 0)
                {
                        if ($this->getReportingDate())
                        {
                                if (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) 
                                        {
                                                return true;
                                        }
                                }
                        }
                        return false;
                }
                else
                {
                        return true;
                }
        }

Here is the call graph for this function:

ilObjTest::canShowTestResults ( user_id  ) 

Definition at line 6434 of file class.ilObjTest.php.

References $result, $starting_time, $user_id, canViewResults(), endingTimeReached(), getActiveTestUser(), getStartingTimeOfUser(), getTestType(), isActiveTestSubmitted(), and isMaxProcessingTimeReached().

        {
                $active = $this->getActiveTestUser($user_id);
                $starting_time = $this->getStartingTimeOfUser($user_id);
                $notimeleft = FALSE;
                if ($starting_time !== FALSE)
                {
                        if ($this->isMaxProcessingTimeReached($starting_time))
                        {
                                $notimeleft = TRUE;
                        }
                }
                $result = (($active->tries > 0) || ($this->endingTimeReached()) || $notimeleft) && $this->canViewResults();
                if ($this->getTestType() == TYPE_ONLINE_TEST)
                {
                        return $result && $this->isActiveTestSubmitted();
                }
                return $result;
        }

Here is the call graph for this function:

ilObjTest::canViewResults (  ) 

Returns true, if the test results can be viewed.

Returns true, if the test results can be viewed

Returns:
boolean True, if the test results can be viewed, else false public

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

References $result, getReportingDate(), and getTestType().

Referenced by canShowTestResults().

        {
                $result = true;
                if ($this->getTestType() != TYPE_SELF_ASSESSMENT)
                {
                        if ($this->getReportingDate())
                        {
                                if (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;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::checkMarks (  ) 

Definition at line 5140 of file class.ilObjTest.php.

        {
                return $this->mark_schema->checkMarks();
        }

ilObjTest::clearEvalSelectedUsers (  ) 

Removes all selected users for the test evaluation.

Removes all selected users for the test evaluation

public

Definition at line 2324 of file class.ilObjTest.php.

References $query, and $result.

Referenced by removeAllTestEditings(), and removeSelectedTestResults().

        {
                $query = sprintf("DELETE FROM tst_eval_users WHERE test_fi = %s",
                        $this->ilias->db->quote($this->getTestId())
                );
                $result = $this->ilias->db->query($query);
        }

Here is the caller graph for this function:

ilObjTest::cloneRandomQuestions ( new_id  ) 

Duplicates the source random questionpools for another test.

Duplicates the source random questionpools for another test

Parameters:
integer $new_id Test id of the new test which should take the random questionpools public

Definition at line 5204 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 358 of file class.ilObjTest.php.

References ilObject::create(), and ilObject::createMetaData().

        {
                parent::create();
                
                // meta data will be created by
                // import parser
                if (!$a_upload)
                {
                        $this->createMetaData();
                }
        }

Here is the call graph for this function:

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 646 of file class.ilObjTest.php.

References ilUtil::getDataDir(), ilObject::getId(), and ilUtil::makeDir().

        {
                include_once "./classes/class.ilUtil.php";
                $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);
                }
        }

Here is the call graph for this function:

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 788 of file class.ilObjTest.php.

References ilObject::$ilias, ilUtil::getDataDir(), and ilUtil::makeDir().

        {
                include_once "./classes/class.ilUtil.php";
                $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_import)
                $tst_dir = $tst_data_dir."/tst_import";
                ilUtil::makeDir($tst_dir);
                if(!@is_dir($tst_dir))
                {
                        $ilias->raiseError("Creation of test import directory failed.",$ilias->error_obj->FATAL);
                }
        }

Here is the call graph for this function:

& 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

Parameters:
integer $question_type The question type of the question
integer $question_id The question id of the question, if available
Returns:
object The question GUI instance public

Definition at line 4178 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":
                                include_once "./assessment/classes/class.assMultipleChoiceGUI.php";
        $question =& new ASS_MultipleChoiceGUI();
        $question->object->set_response(RESPONSE_SINGLE);
        break;
      case "qt_multiple_choice_mr":
                                include_once "./assessment/classes/class.assMultipleChoiceGUI.php";
        $question =& new ASS_MultipleChoiceGUI();
        $question->object->set_response(RESPONSE_MULTIPLE);
        break;
      case "qt_cloze":
                                include_once "./assessment/classes/class.assClozeTestGUI.php";
        $question =& new ASS_ClozeTestGUI();
        break;
      case "qt_matching":
                                include_once "./assessment/classes/class.assMatchingQuestionGUI.php";
        $question =& new ASS_MatchingQuestionGUI();
        break;
      case "qt_ordering":
                                include_once "./assessment/classes/class.assOrderingQuestionGUI.php";
        $question =& new ASS_OrderingQuestionGUI();
        break;
      case "qt_imagemap":
                                include_once "./assessment/classes/class.assImagemapQuestionGUI.php";
        $question =& new ASS_ImagemapQuestionGUI();
        break;
                        case "qt_javaapplet":
                                include_once "./assessment/classes/class.assJavaAppletGUI.php";
                                $question =& new ASS_JavaAppletGUI();
                                break;
                        case "qt_text":
                                include_once "./assessment/classes/class.assTextQuestionGUI.php";
                                $question =& new ASS_TextQuestionGUI();
                                break;
    }
                if ($question_id > 0)
                {
                        $question->object->loadFromDb($question_id);
                }
                return $question;
  }

Here is the call graph for this function:

ilObjTest::createRandomSolutionsForAllUsers (  ) 

Definition at line 5324 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, ",");
                include_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"]);
                        }
                }
        }

Here is the call graph for this function:

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 397 of file class.ilObjTest.php.

References $result, and saveToDb().

                                   {
                $result = parent::createReference();
                $this->saveToDb();
                return $result;
        }

Here is the call graph for this function:

ilObjTest::delete (  ) 

delete object and all related data

public

Returns:
boolean true if all object data were removed; false if only a references were removed

Reimplemented from ilObject.

Definition at line 450 of file class.ilObjTest.php.

References ilObject::deleteMetaData(), and deleteTest().

        {
                // always call parent delete function first!!
                if (!parent::delete())
                {
                        return false;
                }

                // delet meta data
                $this->deleteMetaData();

                //put here your module specific stuff
                $this->deleteTest();

                return true;
        }

Here is the call graph for this function:

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 2467 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);
        }

Here is the caller graph for this function:

ilObjTest::deleteResults ( user_id = ""  ) 

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 2485 of file class.ilObjTest.php.

References $query, $result, $user_id, _getPass(), and getTestId().

        {
                if ($user_id) 
                {
                        $pass = $this->_getPass($user_id, $this->getTestId());
                        $query = sprintf("DELETE FROM tst_solutions WHERE test_fi = %s AND user_fi = %s AND pass = %s",
                                $this->ilias->db->quote($this->getTestId() . ""),
                                $this->ilias->db->quote($user_id . ""),
                                $this->ilias->db->quote($pass . "")
                        );
                        $result = $this->ilias->db->query($query);
                        $query = sprintf("DELETE FROM tst_test_result WHERE test_fi = %s AND user_fi = %s AND pass = %s",
                                $this->ilias->db->quote($this->getTestId() . ""),
                                $this->ilias->db->quote($user_id . ""),
                                $this->ilias->db->quote($pass . "")
                        );
                        $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);
                        
                        $query = sprintf("DELETE FROM tst_active_qst_sol_settings 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);
                }
        }

Here is the call graph for this function:

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 474 of file class.ilObjTest.php.

References $query, $result, $row, ilUtil::delDir(), 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
                include_once "./classes/class.ilUtil.php";
                $tst_data_dir = ilUtil::getDataDir()."/tst_data";
                $directory = $tst_data_dir."/tst_".$this->getId();
                if (is_dir($directory))
                {
                        include_once "./classes/class.ilUtil.php";
                        ilUtil::delDir($directory);
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::disinviteUser ( user_id  ) 

Disinvites a user from a test.

Disinvites a user from a test

Parameters:
integer $user_id The database id of the disinvited user public

Definition at line 5951 of file class.ilObjTest.php.

References $query, $result, and $user_id.

        {
                $query = sprintf("DELETE FROM tst_invited_user WHERE test_fi = %s AND user_fi = %s",
                        $this->ilias->db->quote($this->test_id),
                        $this->ilias->db->quote($user_id)
                );
                $result = $this->ilias->db->query($query);      
        }

ilObjTest::duplicate (  ) 

Duplicates the ilObjTest object.

Duplicates the ilObjTest object

public

Definition at line 885 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);
    }
  }

Here is the call graph for this function:

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

Parameters:
integer $question_id The database id of the question
Returns:
integer The database id of the copied question public

Definition at line 2624 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;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Returns:
boolean true if the ending time is reached, otherwise false public

Definition at line 4373 of file class.ilObjTest.php.

References getEndingTime(), and getTestType().

Referenced by canShowTestResults(), and isExecutable().

        {
                if ($this->getTestType() == TYPE_ASSESSMENT || $this->getTestType() == TYPE_ONLINE_TEST || $this->getTestType() == TYPE_VARYING_RANDOMTEST) 
                {
                        if ($this->getEndingTime()) 
                        {
                                if (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;
        }               

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::evalLoadStatisticalSettings ( user_id  ) 

Retrieves the user settings for the statistical evaluation tool.

Retrieves the user settings for the statistical evaluation tool

Returns:
array An array containing the user settings public

Definition at line 3387 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

Parameters:
array $settings_array An array containing the user settings public

Definition at line 3423 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

Returns:
arrary The statistical evaluation array of the test public

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

References $key, $q, $result, $row, $user_id, _getResultPass(), getTestId(), and getTestResult().

        {
//              global $ilBench;
                $pass = ilObjTest::_getResultPass($user_id, $this->getTestId());
                $test_result =& $this->getTestResult($user_id, $pass);
                $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 = 0;
                $last_visit = 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]);
                        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;
                foreach ($test_result as $key => $value)
                {
                        if (preg_match("/\d+/", $key))
                        {
                                $qworkedthrough += $value["workedthrough"];
                        }
                }
                if (!$qworkedthrough)
                {
                        $atimeofwork = 0;
                }
                else
                {
                        $atimeofwork = $max_time / $qworkedthrough;
                }
                $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" => $qworkedthrough,
                        "qmax" => count($this->questions),
                        "pworkedthrough" => $qworkedthrough / 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;
        }

Here is the call graph for this function:

ilObjTest::evalTotalFinished (  ) 

Returns the number of total finished tests.

Returns the number of total finished tests

Returns:
integer The number of total finished tests public

Definition at line 3698 of file class.ilObjTest.php.

References $q, $result, and $row.

        {
                $q = sprintf("SELECT COUNT(*) as total FROM tst_active WHERE test_fi = %s AND tries > 0",
                        $this->ilias->db->quote($this->getTestId())
                );
                $result = $this->ilias->db->query($q);
                $row = $result->fetchRow(DB_FETCHMODE_OBJECT);
                return $row->total;
        }

ilObjTest::evalTotalFinishedAverageTime (  ) 

Returns the average processing time for total finished tests.

Returns the average processing time for total finished tests

Returns:
integer The average processing time for total finished tests public

Definition at line 3784 of file class.ilObjTest.php.

References $counter, $key, $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

Returns:
array The total passed tests and the avarage reached points. array("total_passed" => VALUE, "total_failed" => VALUE, "average_points" => VALUE, "maximum_points" => VALUE) public

Definition at line 3717 of file class.ilObjTest.php.

References $counter, $key, $q, $res, $result, $row, _getResultPass(), and getTestResult().

        {
                $q = sprintf("SELECT * FROM tst_active WHERE test_fi = %s",
                        $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)) 
                {
                        $pass = ilObjTest::_getResultPass($row->user_fi, $this->getTestId());
                        $res =& $this->getTestResult($row->user_fi, $pass);
                        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 = ($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
                );
        }

Here is the call graph for this function:

ilObjTest::evalTotalPassedAverageTime (  ) 

Returns the average processing time for all passed tests.

Returns the average processing time for all passed tests

Returns:
integer The average processing time for all passed tests public

Definition at line 3866 of file class.ilObjTest.php.

References $counter, $key, $q, $result, $row, _getPassedUsers(), and ilObject::getId().

        {
                include_once "./assessment/classes/class.ilObjTestAccess.php";
                $passed_users =& ilObjTest::_getPassedUsers($this->getId());
                $q = sprintf("SELECT tst_times.*, tst_active.user_fi FROM tst_active, tst_times WHERE tst_active.test_fi = %s 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)) 
                {
                        if (in_array($row->user_fi, $passed_users))
                        {
                                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;
        }

Here is the call graph for this function:

ilObjTest::evalTotalPersons (  ) 

Returns the number of persons who started the test.

Returns the number of persons who started the test

Returns:
integer The number of persons who started the test public

Definition at line 3340 of file class.ilObjTest.php.

References $q, $result, and $row.

Referenced by canEditMarks().

        {
                $q = sprintf("SELECT COUNT(*) as total FROM tst_active WHERE test_fi = %s",
                        $this->ilias->db->quote($this->getTestId())
                );
                $result = $this->ilias->db->query($q);
                $row = $result->fetchRow(DB_FETCHMODE_OBJECT);
                return $row->total;
        }

Here is the caller graph for this function:

& ilObjTest::evalTotalPersonsArray ( name_sort_order = "asc"  ) 

Returns all persons who started the test.

Returns all persons who started the test

Returns:
arrary The user id's and names of the persons who started the test public

Definition at line 3665 of file class.ilObjTest.php.

References $q, $result, $row, and getTestType().

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 " . strtoupper($name_sort_order),
                        $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] = array("fullname" => $this->lng->txt("deleted_user"), "firstname" => "", "lastname" => $this->lng->txt("deleted_user"));
                        }
                        else
                        {
                                $persons_array[$row->user_fi] = array("fullname" => trim("$row->lastname, $row->firstname $row->title"), "firstname" => $row->firstname, "lastname" => $row->lastname);
                        }
                        if ($this->getTestType() == TYPE_SELF_ASSESSMENT)
                        {
                                $persons_array[$row->user_fi] = array("fullname" => $this->lng->txt("unknown"), "firstname" => $this->lng->txt("unknown"), "lastname" => $this->lng->txt("unknown"));
                        }
                }
                return $persons_array;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::evalTotalStartedAverageTime (  ) 

Returns the average processing time for all started tests.

Returns the average processing time for all started tests

Returns:
integer The average processing time for all started tests public

Definition at line 3825 of file class.ilObjTest.php.

References $counter, $key, $q, $result, and $row.

        {
                $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",
                        $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::exportFileItems ( a_target_dir,
&$  expLog 
)

export files of file itmes

Definition at line 5041 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);
                }
        }

Here is the caller graph for this function:

ilObjTest::exportPagesXML ( &$  a_xml_writer,
a_inst,
a_target_dir,
&$  expLog 
)

export pages of test to xml (see ilias_co.dtd)

Parameters:
object $a_xml_writer ilXmlWriter object that receives the xml data

Definition at line 4882 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");
        }

Here is the call graph for this function:

ilObjTest::exportXMLMediaObjects ( &$  a_xml_writer,
a_inst,
a_target_dir,
&$  expLog 
)

export media objects to xml (see ilias_co.dtd)

Parameters:
object $a_xml_writer ilXmlWriter object that receives the xml data

Definition at line 5023 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);
                }
        }

Here is the caller graph for this function:

ilObjTest::exportXMLMetaData ( &$  a_xml_writer  ) 

export content objects meta data to xml (see ilias_co.dtd)

Parameters:
object $a_xml_writer ilXmlWriter object that receives the xml data

Definition at line 4926 of file class.ilObjTest.php.

References ilObject::getId(), and ilObject::getType().

Referenced by exportPagesXML().

        {
                include_once "./Services/MetaData/classes/class.ilMD2XML.php";
                $md2xml = new ilMD2XML($this->getId(), 0, $this->getType());
                $md2xml->setExportMode(true);
                $md2xml->startExport();
                $a_xml_writer->appendXML($md2xml->getXML());
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::exportXMLPageObjects ( &$  a_xml_writer,
a_inst,
&$  expLog 
)

export page objects to xml (see ilias_co.dtd)

Parameters:
object $a_xml_writer ilXmlWriter object that receives the xml data

Definition at line 4960 of file class.ilObjTest.php.

References $file_ids, $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("&","&amp;", $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");
                        

                }
        }

Here is the caller graph for this function:

ilObjTest::generateRandomQuestions ( pass = NULL  ) 

Generates new random questions for the active user.

Generates new random questions for the active user

private

See also:
$questions

Definition at line 1318 of file class.ilObjTest.php.

References $ilUser, $key, getNrOfResultsForPass(), getRandomQuestionCount(), getRandomQuestionpools(), loadQuestions(), randomSelectQuestions(), and saveRandomQuestion().

        {
                global $ilUser;
                $this->loadQuestions($ilUser->getId(), $pass);
                if (count($this->questions) > 0)
                {
                        // Something went wrong. Maybe the user pressed the start button twice
                        // Questions already exist so there is no need to create new questions
                        return;
                }
                if ($pass > 0)
                {
                        if ($this->getNrOfResultsForPass($ilUser->getId(), $pass - 1) == 0)
                        {
                                // This means that someone maybe reloaded the test submission page
                                // If there are no existing results for the previous test, it makes
                                // no sense to create a new set of random questions
                                return;
                        }
                }
                if ($this->getRandomQuestionCount() > 0)
                {
                        $qpls =& $this->getRandomQuestionpools();
                        $rndquestions = $this->randomSelectQuestions($this->getRandomQuestionCount(), 0, 1, $qpls, $pass);
                        $allquestions = array();
                        foreach ($rndquestions as $question_id)
                        {
                                array_push($allquestions, $question_id);
                        }
                        srand ((float)microtime()*1000000);
                        shuffle($allquestions);
                        foreach ($allquestions as $question_id)
                        {
                                $this->saveRandomQuestion($question_id, $pass);
                        }
                }
                else
                {
                        $qpls =& $this->getRandomQuestionpools();
                        $allquestions = array();
                        foreach ($qpls as $key => $value)
                        {
                                if ($value["count"] > 0)
                                {
                                        $rndquestions = $this->randomSelectQuestions($value["count"], $value["qpl"], 1, $pass);
                                        foreach ($rndquestions as $question_id)
                                        {
                                                array_push($allquestions, $question_id);
                                        }
                                }
                        }
                        srand ((float)microtime()*1000000);
                        shuffle($allquestions);
                        foreach ($allquestions as $question_id)
                        {
                                $this->saveRandomQuestion($question_id, $pass);
                        }
                }
                return;
        }

Here is the call graph for this function:

& 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

Returns:
array An array containing the questionpool titles as values and the questionpool id's as keys public

Definition at line 2740 of file class.ilObjTest.php.

References $query, $rbacsystem, $result, $row, ilObject::_hasUntrashedReference(), and ilObjQuestionPool::_lookupOnline().

        {
                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)))
                        {
                                include_once("./assessment/classes/class.ilObjQuestionPool.php");
                                if (ilObjQuestionPool::_lookupOnline($row->obj_id))
                                {
                                        $qpl_titles["$row->obj_id"] = $row->title;
                                }
                        }
                }
                return $qpl_titles;
        }

Here is the call graph for this function:

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

Parameters:
integer $user_id The database id of the user
Returns:
object The database row of the tst_active table public

Definition at line 3033 of file class.ilObjTest.php.

References $ilUser, $query, $result, and $user_id.

Referenced by canShowTestResults(), createRandomSolutionsForAllUsers(), getAllQuestionsForActiveUser(), getQuestionIdFromActiveUserSequence(), getTestSummary(), isExecutable(), 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()) {
                        $this->active = $result->fetchRow(DB_FETCHMODE_OBJECT);
                } 
                else 
                {
                        $this->active = null;
                }
                return $this->active;
        }

Here is the caller graph for this function:

& ilObjTest::getAllQuestions ( pass = NULL  ) 

Returns all questions of a test in test order.

Returns all questions of a test in test order

Returns:
array An array containing the id's as keys and the database row objects as values public

Definition at line 2999 of file class.ilObjTest.php.

References $ilUser, $query, $result, $row, and isRandomTest().

Referenced by getAllQuestionsForActiveUser().

        {
                global $ilUser;
                
                if ($this->isRandomTest())
                {
                        if (is_null($pass)) $pass = 0;
                        $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 tst_test_random_question.pass = %s AND qpl_questions.question_id IN (" . join($this->questions, ",") . ")",
                                $this->ilias->db->quote($ilUser->id . ""),
                                $this->ilias->db->quote($pass . "")
                        );
                }
                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;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

& ilObjTest::getAllQuestionsForActiveUser (  ) 

Returns all questions of a test in users order.

Returns all questions of a test in users order

Returns:
array An array containing the id's and the titles of the questions public

Definition at line 2888 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;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::getAllTestResults (  ) 

returns all test results for all participants

Definition at line 6095 of file class.ilObjTest.php.

References $results, $row, $user_id, _instanciateQuestion(), getECTSGrade(), getInvitedUsers(), getTestId(), and processCSVRow().

        {
                $participants = $this->getInvitedUsers("matriculation");
                $results = array();             
                $row = array("matriculation" =>  $this->lng->txt("matriculation"),
                                        "lastname" =>  $this->lng->txt("lastname"),
                                        "firstname" => $this->lng->txt("firstname"),                                    
                                        "reached_points" => $this->lng->txt("tst_reached_points"),
                                        "max_points" => $this->lng->txt("tst_maximum_points"),
                                        "percent_value" => $this->lng->txt("tst_percent_solved"),
                                        "mark" => $this->lng->txt("tst_mark"),
                                        "ects" => $this->lng->txt("ects_grade"));
                
                $results[] = $row;
                foreach ($participants as $user_id => $user_rec) 
                {
                        $row = array();         
                        $reached_points = 0;
                        $max_points = 0;                                        
                        
                        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();
                                        $reached_points += $question->getReachedPoints($user_id, $this->getTestId()); 
                                }
                        }
                        
                        if ($max_points > 0)
                        {
                                $percentvalue = $reached_points / $max_points;
                        }
                        else
                        {
                                $percentvalue = 0;
                        }                       
                        $mark_obj = $this->mark_schema->get_matching_mark($percentvalue * 100);
                        $passed = "";   
                        if ($mark_obj)
                        {
                                $mark = $mark_obj->get_official_name();
                                $ects_mark = $this->getECTSGrade($reached_points, $max_points);
                        }

                        $row = array(
                                        "matriculation" =>  $user_rec->matriculation,
                                        "lastname" =>  $user_rec->lastname,
                                        "firstname" => $user_rec->firstname,
                                        "reached_points" => $reached_points,
                                        "max_points" => $max_points,
                                        "percent_value" => $percentvalue,
                                        "mark" => $mark,
                                        "ects" => $ects_mark);
                        $results[] = $this->processCSVRow ($row, true);
                }                                                               
                return $results;
        }

Here is the call graph for this function:

ilObjTest::getAnsweredQuestionCount ( user_id,
test_id,
pass = NULL 
)

Retrieves the number of answered questions for a given user in a given test.

Retrieves the number of answered questions for a given user in a given test

Parameters:
integer $user_id The user id
integer $test_id The test id
integer $pass The pass of the test (optional)
Returns:
integer The number of answered questions public

Definition at line 6321 of file class.ilObjTest.php.

References $user_id, ASS_Question::_isWorkedThrough(), getTestId(), isRandomTest(), and loadQuestions().

        {
                if ($this->isRandomTest())
                {
                        $this->loadQuestions($user_id, $pass);
                }
                include_once "./assessment/classes/class.assQuestion.php";
                $workedthrough = 0;
                foreach ($this->questions as $value)
                {
                        if (ASS_Question::_isWorkedThrough($user_id, $this->getTestId(), $value, $pass))
                        {
                                $workedthrough += 1;
                        }
                }
                return $workedthrough;
        }

Here is the call graph for this function:

& ilObjTest::getArrayData ( query,
id_field 
)

Returns a data as id key list.

Returns a data as id key list

Parameters:
$query 
$id_field index for array
Returns:
array with data with id as key private

Definition at line 5857 of file class.ilObjTest.php.

References $query, and _getArrayData().

Referenced by getGroupData(), getInvitedUsers(), getRoleData(), and getUserData().

        {       
                return ilObjTest::_getArrayData ($query, $id_field);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::getAuthor (  ) 

Gets the authors name.

Gets the authors name of the ilObjTest object

Returns:
string The string containing the name of the test author public
See also:
$author

Definition at line 1615 of file class.ilObjTest.php.

Referenced by to_xml().

        {
    return $this->author;
  }

Here is the caller graph for this function:

& 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

Returns:
array The available question pool id's public

Definition at line 3912 of file class.ilObjTest.php.

References $query, $rbacsystem, $result, $row, ilObject::_hasUntrashedReference(), and ilObjQuestionPool::_lookupOnline().

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)))
                        {
                                include_once("./assessment/classes/class.ilObjQuestionPool.php");
                                if (ilObjQuestionPool::_lookupOnline($row->obj_id))
                                {
                                        array_push($result_array, $row->obj_id);
                                }
                        }
                }
                return $result_array;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

& ilObjTest::getAvailableQuestionpools ( use_object_id = false,
equal_points = false,
could_be_offline = false 
)

Returns the available question pools for the active user.

Returns the available question pools for the active user

Returns:
array The available question pools public

Definition at line 3941 of file class.ilObjTest.php.

References $query, $rbacsystem, $result, $row, ilObjQuestionPool::_hasEqualPoints(), ilObject::_hasUntrashedReference(), and ilObjQuestionPool::_lookupOnline().

        {
                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)))
                        {
                                include_once("./assessment/classes/class.ilObjQuestionPool.php");
                                if (ilObjQuestionPool::_lookupOnline($row->obj_id) || $could_be_offline)
                                {
                                        if ((!$equal_points) || (($equal_points) && (ilObjQuestionPool::_hasEqualPoints($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;
        }

Here is the call graph for this function:

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

Returns:
integer The working time in seconds public

Definition at line 3480 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::getCountSystem (  ) 

Gets the count system for the calculation of points.

Gets the count system for the calculation of points

Returns:
integer The count system for the calculation of points public
See also:
$count_system

Definition at line 1806 of file class.ilObjTest.php.

Referenced by to_xml().

        {
    return $this->count_system;
  }

Here is the caller graph for this function:

ilObjTest::getECTSGrade ( reached_points,
max_points 
)

Returns the ECTS grade for a number of reached points.

Returns the ECTS grade for a number of reached points

Parameters:
double $reached_points The points reached in the test
double $max_points The maximum number of points for the test
Returns:
string The ECTS grade short description public

Definition at line 5080 of file class.ilObjTest.php.

References getTotalPointsPassedArray().

Referenced by getAllTestResults().

        {
                include_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";
                        }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::getEnableProcessingTime (  ) 

Returns the state of the processing time (enabled/disabled).

Returns the state of the processing time (enabled/disabled)

Returns:
integer The processing time state (0 for disabled, 1 for enabled) public
See also:
$processing_time

Definition at line 2094 of file class.ilObjTest.php.

Referenced by isExecutable(), and isMaxProcessingTimeReached().

        {
    return $this->enable_processing_time;
  }

Here is the caller graph for this function:

ilObjTest::getEndingTime (  ) 

Returns the ending time of the test.

Returns the ending time of the test

Returns:
string The ending time of the test public
See also:
$ending_time

Definition at line 2122 of file class.ilObjTest.php.

Referenced by endingTimeReached(), isExecutable(), and to_xml().

        {
    return $this->ending_time;
  }

Here is the caller graph for this function:

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

Returns:
array An associative array containing the working time. array["h"] = hours, array["m"] = minutes, array["s"] = seconds public

Definition at line 3980 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;
        }

Here is the call graph for this function:

& ilObjTest::getEvaluationUsers ( user_id,
sort_name_option = "asc" 
)

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 5379 of file class.ilObjTest.php.

References $query, $result, $row, $user_id, $users, and getTestType().

        {
                $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 ORDER BY usr_data.lastname " . strtoupper($sort_name_option),
                        $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))
                        {
                                $name = array("fullname" => trim($row["lastname"].", ".$row["firstname"] . " " . $row["title"]), "firstname" => $row["firstname"], "lastname" => $row["lastname"]);
                                if ($this->getTestType() == TYPE_SELF_ASSESSMENT)
                                {
                                        $name = array("fullname" => $this->lng->txt("unknown"), "firstname" => $this->lng->txt("unknown"), "lastname" => $this->lng->txt("unknown"));
                                }
                                $users[$row["user_fi"]] = $name;
                        }
                }
                return $users;
        }

Here is the call graph for this function:

& ilObjTest::getExistingQuestions ( pass = NULL  ) 

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

Returns:
array An array containing the already existing questions public

Definition at line 2770 of file class.ilObjTest.php.

References $data, $ilUser, $query, $result, and isRandomTest().

        {
                global $ilUser;
                $existing_questions = array();
                if ($this->isRandomTest())
                {
                        if (is_null($pass)) $pass = 0;
                        $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 AND tst_test_random_question.pass = %s",
                                $this->ilias->db->quote($this->getTestId() . ""),
                                $this->ilias->db->quote($ilUser->id . ""),
                                $this->ilias->db->quote($pass . "")
                        );
                }
                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;
        }

Here is the call graph for this function:

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 680 of file class.ilObjTest.php.

References ilUtil::getDataDir().

        {
                include_once "./classes/class.ilUtil.php";
                $export_dir = ilUtil::getDataDir()."/tst_data"."/tst_".$this->getId()."/export";
                return $export_dir;
        }

Here is the call graph for this function:

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

Returns:
array A list of file names public

Definition at line 695 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(__results)?__)*[0-9]+\.[a-z]{1,3}\$", $entry))
                        {
                                $file[] = $entry;
                        }
                }

                // close import directory
                $dir->close();

                // sort files
                sort ($file);
                reset ($file);

                return $file;
        }

ilObjTest::getFirstSequence (  ) 

Definition at line 2931 of file class.ilObjTest.php.

References $ilUser, $result, $results, 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;
        }

Here is the call graph for this function:

& ilObjTest::getGroupData ( ids  ) 

Definition at line 5873 of file class.ilObjTest.php.

References $query, and getArrayData().

        {
                if (!is_array($ids) || count($ids) ==0)
                        return array();
                        
                $result_array = array();
                        
                $query = sprintf("SELECT ref_id, title, description FROM `grp_data` g, object_data o, object_reference r WHERE o.obj_id=grp_id AND o.obj_id = r.obj_id AND ref_id IN (%s)",                     
                        join ($ids,",")
                );
                
                return $this->getArrayData ($query, "ref_id");          
        }

Here is the call graph for this function:

ilObjTest::getHidePreviousResults (  ) 

Returns if the previous results should be hidden for a learner.

Returns if the previous results should be hidden for a learner

Returns:
integer 1 if the previous results should be hidden, 0 otherwise public
See also:
$hide_previous_results

Definition at line 1962 of file class.ilObjTest.php.

Referenced by saveToDb(), and to_xml().

        {
    return $this->hide_previous_results;
  }

Here is the caller graph for this function:

ilObjTest::getHideTitlePoints (  ) 

Returns true if the maximum points of a question should be hidden in the question title.

Returns true if the maximum points of a question should be hidden in the question title

Returns:
integer 1 if the maximum points in the question title should be hidden public
See also:
$hide_title_points

Definition at line 1976 of file class.ilObjTest.php.

Referenced by saveToDb(), and to_xml().

        {
    return $this->hide_title_points;
  }

Here is the caller graph for this function:

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 4148 of file class.ilObjTest.php.

References ilObject::getId().

Referenced by getQuestionsTable().

        {
                return CLIENT_WEB_DIR . "/assessment/" . $this->getId() . "/images/";
        }

Here is the call graph for this function:

Here is the caller graph for this function:

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 4161 of file class.ilObjTest.php.

References ilObject::getId(), and ilUtil::removeTrailingPathSeparators().

        {
                include_once "./classes/class.ilUtil.php";
                $webdir = ilUtil::removeTrailingPathSeparators(CLIENT_WEB_DIR) . "/assessment/" . $this->getId() . "/images/";
                return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir);
        }

Here is the call graph for this function:

ilObjTest::getImportDirectory (  ) 

Get the import directory location of the test.

Get the import directory location of the test

Returns:
string The location of the import directory or false if the directory doesn't exist public

Definition at line 817 of file class.ilObjTest.php.

References ilUtil::getDataDir().

        {
                include_once "./classes/class.ilUtil.php";
                $import_dir = ilUtil::getDataDir()."/tst_data/tst_import";
                if(@is_dir($import_dir))
                {
                        return $import_dir;
                }
                else
                {
                        return false;
                }
        }

Here is the call graph for this function:

ilObjTest::getImportMapping (  ) 

get array of (two) new created questions for import id

Definition at line 5058 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

Returns:
string The introduction text of the test public
See also:
$introduction

Definition at line 1657 of file class.ilObjTest.php.

Referenced by to_xml().

        {
    return $this->introduction;
  }

Here is the caller graph for this function:

& ilObjTest::getInvitedUsers ( user_id = "",
order = "login, lastname, firstname" 
)

Returns a list of all invited users in a test.

Returns a list of all invited users in a test

Returns:
array The user id's of the invited users public

Definition at line 5770 of file class.ilObjTest.php.

References $query, $user_id, and getArrayData().

Referenced by getAllTestResults().

        {
                global $ilDB;
                
                $result_array = array();

                if (is_numeric($user_id))
                {
                        $query = sprintf("SELECT usr_id, login, lastname, firstname, tst_invited_user.clientip, " .
                                "tst_active.submitted as test_finished, matriculation, IF(tst_active.active_id IS NULL,0,1) as test_started " .
                                "FROM usr_data, tst_invited_user " . 
                                "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
                                "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id AND usr_data.usr_id=%s " .
                                "ORDER BY %s",
                                $ilDB->quote($this->test_id),
                                $user_id,
                                $order
                        );
/*              CREATED NEW VERSION FOR MYSQL 5 COMPATIBILITY (Helmut Schottmüller, 2006-09-18)
                                $query = sprintf("SELECT usr_id, login, lastname, firstname, t.clientip, test.submitted as test_finished, matriculation, IF(test.active_id IS NULL,0,1) as test_started " .
                                                         "FROM tst_invited_user t, usr_data ".
                                                         "LEFT JOIN tst_active test ON test.user_fi=usr_id AND test.test_fi=t.test_fi ".
                                                         "WHERE t.test_fi = %s and t.user_fi=usr_id AND usr_id=%s ".
                                                         "ORDER BY %s",
                                $ilDB->quote($this->test_id),
                                $user_id,
                                $order
                        );*/
                }
                else 
                {
                        $query = sprintf("SELECT usr_id, login, lastname, firstname, tst_invited_user.clientip, " .
                                "tst_active.submitted as test_finished, matriculation, IF(tst_active.active_id IS NULL,0,1) as test_started " .
                                "FROM usr_data, tst_invited_user " . 
                                "LEFT JOIN tst_active ON tst_active.user_fi = tst_invited_user.user_fi AND tst_active.test_fi = tst_invited_user.test_fi " .
                                "WHERE tst_invited_user.test_fi = %s and tst_invited_user.user_fi=usr_data.usr_id " .
                                "ORDER BY %s",
                                $ilDB->quote($this->test_id),
                                $order
                        );
/*              CREATED NEW VERSION FOR MYSQL 5 COMPATIBILITY (Helmut Schottmüller, 2006-09-18)
                                $query = sprintf("SELECT usr_id, login, lastname, firstname, t.clientip, test.submitted as test_finished, matriculation, IF(test.active_id IS NULL,0,1) as test_started " .                                                                                     
                                                         "FROM tst_invited_user t, usr_data ".
                                                         "LEFT JOIN tst_active test ON test.user_fi=usr_id AND test.test_fi=t.test_fi ".
                                                         "WHERE t.test_fi = %s and t.user_fi=usr_id ".
                                                         "ORDER BY %s",
                                $ilDB->quote($this->test_id),
                                $order
                        );*/
                }
                
                return $this->getArrayData($query, "usr_id");
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::getMCScoring (  ) 

Gets the scoring type for multiple choice questions.

Gets the scoring type for multiple choice questions

Returns:
integer The scoring type for multiple choice questions public
See also:
$mc_scoring

Definition at line 1844 of file class.ilObjTest.php.

Referenced by to_xml().

        {
    return $this->mc_scoring;
  }

Here is the caller graph for this function:

ilObjTest::getNrOfResultsForPass ( user_id,
pass 
)

Calculates the number of user results for a specific test pass.

Calculates the number of user results for a specific test pass

private

Definition at line 1299 of file class.ilObjTest.php.

References $query, $result, and $user_id.

Referenced by generateRandomQuestions(), and setActiveTestUser().

        {
                $query = sprintf("SELECT test_result_id FROM tst_test_result WHERE test_fi = %s AND user_fi = %s AND pass = %s",
                        $this->ilias->db->quote($this->getTestId() . ""),
                        $this->ilias->db->quote($user_id . ""),
                        $this->ilias->db->quote($pass . "")
                );
                $result = $this->ilias->db->query($query);
                return $result->numRows();
        }

Here is the caller graph for this function:

ilObjTest::getNrOfTries (  ) 

Returns the nr of tries for the test.

Returns the nr of tries for the test

Returns:
integer The maximum number of tries public
See also:
$nr_of_tries

Definition at line 1948 of file class.ilObjTest.php.

Referenced by hasNrOfTriesRestriction(), isNrOfTriesReached(), and to_xml().

        {
    return $this->nr_of_tries;
  }

Here is the caller graph for this function:

ilObjTest::getPassFinishDate ( user_id,
test_id,
pass 
)

Retrieves the number of answered questions for a given user in a given test.

Retrieves the number of answered questions for a given user in a given test

Parameters:
integer $user_id The user id
integer $test_id The test id
integer $pass The pass of the test
Returns:
timestamp The SQL timestamp of the finished pass public

Definition at line 6350 of file class.ilObjTest.php.

References $query, $result, $row, $test_id, and $user_id.

        {
                global $ilDB;
                if (is_null($pass)) $pass = 0;
                $query = sprintf("SELECT tst_test_result.TIMESTAMP + 0 AS TIMESTAMP14 FROM tst_test_result WHERE user_fi = %s AND test_fi = %s AND pass = %s ORDER BY tst_test_result.TIMESTAMP DESC",
                        $ilDB->quote($user_id . ""),
                        $ilDB->quote($test_id . ""),
                        $ilDB->quote($pass . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        return $row["TIMESTAMP14"];
                }
                else
                {
                        return 0;
                }
        }

ilObjTest::getPassScoring (  ) 

Gets the pass scoring type.

Gets the pass scoring type

Returns:
integer The pass scoring type public
See also:
$pass_scoring

Definition at line 1858 of file class.ilObjTest.php.

Referenced by saveToDb(), and to_xml().

        {
    return $this->pass_scoring;
  }

Here is the caller graph for this function:

ilObjTest::getProcessingTime (  ) 

Returns the processing time for the test.

Returns the processing time for the test

Returns:
integer The processing time for the test public
See also:
$processing_time

Definition at line 2059 of file class.ilObjTest.php.

Referenced by getProcessingTimeInSeconds().

        {
    return $this->processing_time;
  }

Here is the caller graph for this function:

ilObjTest::getProcessingTimeInSeconds (  ) 

Returns the processing time for the test in seconds.

Returns the processing time for the test in seconds

Returns:
integer The processing time for the test in seconds public
See also:
$processing_time

Definition at line 2073 of file class.ilObjTest.php.

References getProcessingTime().

Referenced by isMaxProcessingTimeReached().

        {
                if (preg_match("/(\d{2}):(\d{2}):(\d{2})/", $this->getProcessingTime(), $matches))
                {
                        return ($matches[1] * 3600) + ($matches[2] * 60) + $matches[3];
                }
                        else
                {
                        return 0;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::getQuestionCount (  ) 

Returns the number of questions in the test.

Returns the number of questions in the test

Returns:
integer The number of questions public

Definition at line 5491 of file class.ilObjTest.php.

References $data, $num, getRandomQuestionCount(), getRandomQuestionpools(), and isRandomTest().

Referenced by getFirstSequence().

        {
                $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;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::getQuestionDataset ( question_id  ) 

Returns the dataset for a given question id.

Returns the dataset for a given question id

Parameters:
integer $question_id The database id of the question
Returns:
object Question dataset public
See also:
$questions

Definition at line 2722 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

Parameters:
integer $sequence The sequence number of the question
Returns:
integer The question id of the question with the given sequence number public

Definition at line 2871 of file class.ilObjTest.php.

References $ilUser, and getActiveTestUser().

Referenced by getFirstSequence().

        {
                global $ilUser;

                $active = $this->getActiveTestUser();
                $sequence_array = split(",", $active->sequence);
                return $this->questions[$sequence_array[$sequence-1]];
        }

Here is the call graph for this function:

Here is the caller graph for this function:

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 4401 of file class.ilObjTest.php.

References $ilUser, $key, $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)) 
                {
                        include_once "./classes/class.ilUtil.php";
      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=\"" . $this->lng->txt(strtolower($value) . "ending_order")."\" />";
            break;
          case "comment":
            $order = " ORDER BY comment $value";
            $images["comment"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . $this->lng->txt(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=\"" . $this->lng->txt(strtolower($value) . "ending_order")."\" />";
            break;
          case "author":
            $order = " ORDER BY author $value";
            $images["author"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . $this->lng->txt(strtolower($value) . "ending_order")."\" />";
            break;
          case "created":
            $order = " ORDER BY created $value";
            $images["created"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . $this->lng->txt(strtolower($value) . "ending_order")."\" />";
            break;
          case "updated":
            $order = " ORDER BY TIMESTAMP14 $value";
            $images["updated"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . $this->lng->txt(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=\"" . $this->lng->txt(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
                );
        }

Here is the call graph for this function:

ilObjTest::getQuestiontext ( question_id  ) 

Returns the question text for a given question.

Returns the question text for a given question

Parameters:
integer $question_id The question id
Returns:
string The question text public

Definition at line 5744 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::getQuestionTitles (  ) 

Returns the titles of the test questions in question sequence.

Returns the titles of the test questions in question sequence

Returns:
array The question titles public
See also:
$questions

Definition at line 2694 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;
        }

Here is the call graph for this function:

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

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

Definition at line 2805 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 "";
    }
  }

Here is the caller graph for this function:

ilObjTest::getRandomQuestionCount (  ) 

Gets the number of random questions used for a random test.

Gets the number of random questions used for a random test

Returns:
integer The number of random questions public
See also:
$random_question_count

Definition at line 1643 of file class.ilObjTest.php.

Referenced by generateRandomQuestions(), getQuestionCount(), isComplete(), and to_xml().

        {
    return $this->random_question_count;
  }

Here is the caller graph for this function:

& 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

Returns:
array All saved random questionpools
See also:
$questions

Definition at line 1446 of file class.ilObjTest.php.

References $counter, $query, $result, and $row.

Referenced by generateRandomQuestions(), 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;
        }

Here is the caller graph for this function:

ilObjTest::getReportingDate (  ) 

Gets the reporting date.

Gets the reporting date of the ilObjTest object

Returns:
string The reporting date of the test of an empty string (=FALSE) if no reporting date is set public
See also:
$reporting_date

Definition at line 1934 of file class.ilObjTest.php.

Referenced by canEditMarks(), canViewResults(), and to_xml().

        {
    return $this->reporting_date;
  }

Here is the caller graph for this function:

& ilObjTest::getRoleData ( ids  ) 

Definition at line 5887 of file class.ilObjTest.php.

References $query, and getArrayData().

        {
                if (!is_array($ids) || count($ids) ==0)
                        return array();
                        
                $result_array = array();
                        
                $query = sprintf("SELECT obj_id, description, title FROM role_data, object_data o WHERE o.obj_id=role_id AND role_id IN (%s)",                  
                        join ($ids,",")
                );
                
                return $this->getArrayData ($query, "obj_id");          
        }

Here is the call graph for this function:

ilObjTest::getScoreReporting (  ) 

Gets the score reporting.

Gets the score reporting of the ilObjTest object

Returns:
integer The score reporting of the test public
See also:
$score_reporting

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

Referenced by to_xml().

        {
    return $this->score_reporting;
  }

Here is the caller graph for this function:

ilObjTest::getSequenceSettings (  ) 

Gets the sequence settings.

Gets the sequence settings of the ilObjTest object

Returns:
integer The sequence settings of the test public
See also:
$sequence_settings

Definition at line 1778 of file class.ilObjTest.php.

Referenced by to_xml().

        {
    return $this->sequence_settings;
  }

Here is the caller graph for this function:

ilObjTest::getStartingTime (  ) 

Returns the starting time of the test.

Returns the starting time of the test

Returns:
string The starting time of the test public
See also:
$starting_time

Definition at line 2108 of file class.ilObjTest.php.

Referenced by isExecutable(), startingTimeReached(), and to_xml().

        {
    return $this->starting_time;
  }

Here is the caller graph for this function:

ilObjTest::getStartingTimeOfUser ( user_id  ) 

Returns the unix timestamp of the time a user started a test.

Returns the unix timestamp of the time a user started a test

Parameters:
integer $user_id The user id
Returns:
mixed The unix timestamp if the user started the test, FALSE otherwise public

Definition at line 6488 of file class.ilObjTest.php.

References $query, $result, $row, $user_id, and getTestId().

Referenced by canShowTestResults(), and isExecutable().

        {
                global $ilDB;
                
                if ($user_id < 1) return FALSE;
                $query = sprintf("SELECT tst_times.started FROM tst_times, tst_active WHERE tst_active.user_fi = %s AND tst_active.test_fi = %s AND tst_active.active_id = tst_times.active_fi ORDER BY tst_times.started",
                        $ilDB->quote($user_id . ""),
                        $ilDB->quote($this->getTestId() . "")
                );
                $result = $ilDB->query($query);
                if ($result->numRows())
                {
                        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                        if (preg_match("/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})/", $row["started"], $matches))
                        {
                                return mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
                        }
                        else
                        {
                                return FALSE;
                        }
                }
                else
                {
                        return FALSE;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::getTestId (  ) 

Gets the database id of the additional test data.

Gets the database id of the additional test data

Returns:
integer The database id of the additional test data public
See also:
$test_id

Definition at line 1671 of file class.ilObjTest.php.

Referenced by createRandomSolutionsForAllUsers(), deleteResults(), evalStatistical(), getAllTestResults(), getAnsweredQuestionCount(), getStartingTimeOfUser(), getTestResult(), getTextAnswer(), getWorkedQuestions(), removeSelectedTestResults(), and saveECTSStatus().

        {
    return $this->test_id;
  }

Here is the caller graph for this function:

& ilObjTest::getTestResult ( user_id,
pass = NULL 
)

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

Returns:
array An array containing the test results for the given user public

Definition at line 3169 of file class.ilObjTest.php.

References $key, $row, $user_id, ASS_Question::_getInternalLinkHref(), ASS_Question::_getMaximumPoints(), ASS_Question::_getQuestionInfo(), ASS_Question::_getReachedPoints(), ASS_Question::_getSuggestedSolution(), ASS_Question::_getSuggestedSolutionCount(), ASS_Question::_isWorkedThrough(), getTestId(), isRandomTest(), loadQuestions(), and ilUtil::prepareFormOutput().

Referenced by evalStatistical(), evalTotalFinishedPassed(), getFirstSequence(), getTotalPointsArray(), getTotalPointsPassedArray(), and getWrongAnsweredQuestions().

        {
                //              global $ilBench;
                if ($this->isRandomTest())
                {
                        $this->loadQuestions($user_id, $pass);
                }
                $total_max_points = 0;
                $total_reached_points = 0;
                
                $key = 1;
                $result_array = array();
                include_once "./assessment/classes/class.assQuestion.php";
                $workedthrough = 0;
                foreach ($this->questions as $value)
                {
                        $max_points = ASS_Question::_getMaximumPoints($value);
                        $total_max_points += $max_points;
                        $reached_points = ASS_Question::_getReachedPoints($user_id, $this->getTestId(), $value, $pass);
                        if (ASS_Question::_isWorkedThrough($user_id, $this->getTestId(), $value, $pass))
                        {
                                $workedthrough = 1;
                        }
                        else
                        {
                                $workedthrough = 0;
                        }
                        $total_reached_points += $reached_points;
                        if ($max_points > 0)
                        {
                                $percentvalue = $reached_points / $max_points;
                        }
                        else
                        {
                                $percentvalue = 0;
                        }
                        if (ASS_Question::_getSuggestedSolutionCount($value) == 1)
                        {
                                $solution_array =& ASS_Question::_getSuggestedSolution($value, 0);
                                $href = ASS_Question::_getInternalLinkHref($solution_array["internal_link"]);
                        }
                        elseif (ASS_Question::_getSuggestedSolutionCount($value) > 1)
                        {
                                $href = "see_details_for_further_information";
                        }
                        else
                        {
                                $href = "";
                        }
                        $info =& ASS_Question::_getQuestionInfo($value);
                        include_once "./classes/class.ilUtil.php";
                        $row = array(
                                "nr" => "$key",
                                "title" => ilUtil::prepareFormOutput($info["title"]),
                                "max" => sprintf("%d", $max_points),
                                "reached" => sprintf("%d", $reached_points),
                                "percent" => sprintf("%2.2f ", ($percentvalue) * 100) . "%",
                                "solution" => $href,
                                "type" => $info["type_tag"],
                                "qid" => $value,
                                "workedthrough" => $workedthrough
                        );
                        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;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

& ilObjTest::getTestSummary ( user_id,
pass = NULL 
)

Calculates the overview of a test for a given user.

and returns an array with all test questions

Returns:
array An array containing the test overview for the given user public

Definition at line 3270 of file class.ilObjTest.php.

References $key, $row, $user, $user_id, _getSolvedQuestions(), _instanciateQuestion(), getActiveTestUser(), isRandomTest(), and loadQuestions().

        {
                global $ilDB;
                if ($this->isRandomTest())
                {
                        $this->loadQuestions($user_id, $pass);
                }
                
                $key = 1;
                $result_array = array();

                $active = $this->getActiveTestUser();
                $solved_questions = ilObjTest::_getSolvedQuestions($this->test_id, $user_id);
                include_once "./classes/class.ilObjUser.php";
                $user = new ilObjUser($user_id);
                foreach ($this->questions as $val) 
                {
                        $question =& ilObjTest::_instanciateQuestion($val);
                        if (is_object($question))
                        {                       
                                $answers = $question->getSolutionValues($this->test_id, $user);
                                $visited = count($answers);
                                $solved  = 0;
                                if (array_key_exists($question->getId(),$solved_questions)) {
                                        $solved =  $solved_questions[$question->getId()]->solved; 
                                }
                                
                                $row = array(
                                        "nr" => "$key",                                 
                                        "title" => $question->getTitle(),
                                        "qid" => $question->getId(),
                                        "visited" => $visited,
                                        "solved" => (($solved)?"1":"0"),
                                        "description" => $question->getComment(),
                                        "points" => $question->getMaximumPoints()
                                );
                                array_push($result_array, $row);
                                $key++;
                        }                       
                }
                
                return $result_array;
        }

Here is the call graph for this function:

ilObjTest::getTestType (  ) 

Gets the test type.

Gets the test type

Returns:
integer The test type public
See also:
$type

Definition at line 1920 of file class.ilObjTest.php.

Referenced by canShowTestResults(), canViewResults(), endingTimeReached(), evalTotalPersonsArray(), getEvaluationUsers(), isOnlineTest(), loadQuestions(), startingTimeReached(), and to_xml().

        {
    return $this->test_type;
  }

Here is the caller graph for this function:

ilObjTest::getTextAnswer ( user_id,
question_id,
pass = NULL 
)

Returns the text answer of a given user for a given question.

Returns the text answer of a given user for a given question

Parameters:
integer $user_id The user id
integer $question_id The question id
Returns:
string The answer text public

Definition at line 5709 of file class.ilObjTest.php.

References $query, $res, $result, $row, $user_id, ASS_Question::_getSolutionMaxPass(), and getTestId().

        {
                $res = "";
                if (($user_id) && ($question_id))
                {
                        if (is_null($pass))
                        {
                                include_once "./assessment/classes/class.assQuestion.php";
                                $pass = ASS_Question::_getSolutionMaxPass($question_id, $user_id, $this->getTestId());
                        }
                        $query = sprintf("SELECT value1 FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND question_fi = %s AND pass = %s",
                                $this->ilias->db->quote($user_id . ""),
                                $this->ilias->db->quote($this->getTestId() . ""),
                                $this->ilias->db->quote($question_id . ""),
                                $this->ilias->db->quote($pass . "")
                        );
                        $result = $this->ilias->db->query($query);
                        if ($result->numRows() == 1)
                        {
                                $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
                                $res = $row["value1"];
                        }
                }
                return $res;
        }

Here is the call graph for this function:

& 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

Returns:
array The total point values public

Definition at line 3614 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;
        }

Here is the call graph for this function:

& 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

Returns:
array The total point values public

Definition at line 3635 of file class.ilObjTest.php.

References $total, $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;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

& ilObjTest::getUserData ( ids  ) 

Returns a data of all users specified by id list.

Returns a data of all users specified by id list

Parameters:
$usr_ids kommaseparated list of ids
Returns:
array The user data "usr_id, login, lastname, firstname, clientip" of the users with id as key public

Definition at line 5833 of file class.ilObjTest.php.

References $query, and getArrayData().

        {
                if (!is_array($ids) || count($ids) ==0)
                        return array();
                        
                $result_array = array();
                        
                $query = sprintf("SELECT usr_id, login, lastname, firstname, client_ip as clientip FROM usr_data WHERE usr_id IN (%s) ORDER BY login",                  
                        join ($ids,",")
                );
                                
                return $this->getArrayData ($query, "usr_id");          
        }

Here is the call graph for this function:

& ilObjTest::getWorkedQuestions ( pass = NULL  ) 

Gets the id's of all questions a user already worked through.

Gets the id's of all questions a user already worked through

Returns:
array The question id's of the questions already worked through public

Definition at line 2964 of file class.ilObjTest.php.

References $ilUser, $query, $result, $row, and getTestId().

Referenced by getAllQuestionsForActiveUser().

        {
                global $ilUser;
                if (is_null($pass))
                {
                        $query = sprintf("SELECT * FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND pass = 0 GROUP BY question_fi",
                                $this->ilias->db->quote($ilUser->id),
                                $this->ilias->db->quote($this->getTestId())
                        );
                }
                else
                {
                        $query = sprintf("SELECT * FROM tst_solutions WHERE user_fi = %s AND test_fi = %s AND pass = %s GROUP BY question_fi",
                                $this->ilias->db->quote($ilUser->id . ""),
                                $this->ilias->db->quote($this->getTestId() . ""),
                                $this->ilias->db->quote($pass . "")
                        );
                }
                $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;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::getWrongAnsweredQuestions (  ) 

Definition at line 2910 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();
        }

Here is the call graph for this function:

ilObjTest::hasNrOfTriesRestriction (  ) 

returns if the numbers of tries have to be checked

Definition at line 6076 of file class.ilObjTest.php.

References getNrOfTries().

Referenced by isExecutable().

        {
                return $this->getNrOfTries() != 0;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::ilClone ( a_parent_ref  ) 

copy all entries of your object.

public

Parameters:
integer ref_id of parent object
Returns:
integer new ref id

Reimplemented from ilObject.

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

Parameters:
integer reference_id or object_id
boolean treat the id as reference_id (true) or object_id (false)

Definition at line 312 of file class.ilObjTest.php.

References $ilUser, ilObject::$lng, ilObject::ilObject(), and retrieveTestTypes().

Referenced by _clone(), _getTestResult(), and _isComplete().

        {
                global $ilUser;
                $this->type = "tst";
                include_once "./assessment/classes/class.assMarkSchema.php";
                $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->hide_previous_results = 0;
                $this->hide_title_points = 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 = "";
                $this->count_system = COUNT_PARTIAL_SOLUTIONS;
                $this->mc_scoring = SCORE_ZERO_POINTS_WHEN_UNANSWERED;
                $this->pass_scoring = SCORE_LAST_PASS;
                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
                );
                $this->ilObject($a_id, $a_call_by_reference);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Returns:
array object IDs of created local roles.

Reimplemented from ilObject.

Definition at line 558 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::insertQuestion ( question_id  ) 

Insert a question in the list of questions.

Insert a question in the list of questions

Parameters:
integer $question_id The database id of the inserted question public

Definition at line 2641 of file class.ilObjTest.php.

References $data, $query, $result, ilObjAssessmentFolder::_enabledAssessmentLogging(), ilObjAssessmentFolder::_getLogLanguage(), 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
                {
                        include_once ("./classes/class.ilObjAssessmentFolder.php");
                        if (ilObjAssessmentFolder::_enabledAssessmentLogging())
                        {
                                $this->logAction($this->lng->txtlng("assessment", "log_question_added", ilObjAssessmentFolder::_getLogLanguage()) . ": " . $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();
        }

Here is the call graph for this function:

ilObjTest::inviteGroup ( group_id  ) 

Invites all users of a group to a test.

Invites all users of a group to a test

Parameters:
integer $group_id The database id of the invited group public

Definition at line 5910 of file class.ilObjTest.php.

References $user_id, ilObjUser::_lookupClientIP(), and inviteUser().

        {                       
                include_once "./classes/class.ilObjGroup.php";
                $group = new ilObjGroup($group_id);
                $members = $group->getGroupMemberIds();
                include_once "./classes/class.ilObjUser.php";
                foreach ($members as $user_id)
                {
                        $this->inviteUser($user_id, ilObjUser::_lookupClientIP($user_id));
                }               
        }

Here is the call graph for this function:

ilObjTest::inviteRole ( role_id  ) 

Invites all users of a role to a test.

Invites all users of a role to a test

Parameters:
integer $group_id The database id of the invited group public

Definition at line 5930 of file class.ilObjTest.php.

References $rbacreview, $role_id, $user_id, ilObjUser::_lookupClientIP(), and inviteUser().

        {                       
                global $rbacreview;
                $members =  $rbacreview->assignedUsers($role_id,"usr_id");
                include_once "./classes/class.ilObjUser.php";
                foreach ($members as $user_id)
                {
                        $this->inviteUser($user_id, ilObjUser::_lookupClientIP($user_id));
                }               
        }

Here is the call graph for this function:

ilObjTest::inviteUser ( user_id,
client_ip = "" 
)

Invites a user to a test.

Invites a user to a test

Parameters:
integer $user_id The database id of the invited user public

Definition at line 5968 of file class.ilObjTest.php.

References $query, $result, and $user_id.

Referenced by inviteGroup(), and inviteRole().

        {
                $query = sprintf("INSERT IGNORE INTO tst_invited_user (test_fi, user_fi, clientip) VALUES (%s, %s, %s)",
                        $this->ilias->db->quote($this->test_id),
                        $this->ilias->db->quote($user_id),
                        $this->ilias->db->quote($client_ip)
                );
                
                $result = $this->ilias->db->query($query);
        }

Here is the caller graph for this function:

ilObjTest::isActiveTestSubmitted ( user_id = null  ) 

returns if the active for user_id has been submitted

Definition at line 6058 of file class.ilObjTest.php.

References $ilUser, $query, $result, and $user_id.

Referenced by canShowTestResults().

        {
                global $ilUser;
                if (!is_numeric($user_id))
                        $user_id = $ilUser->getId();
                        
                $query = sprintf("SELECT submitted FROM tst_active WHERE test_fi=%s AND user_fi=%s AND submitted=1",
                        $this->ilias->db->quote($this->test_id),
                        $this->ilias->db->quote($user_id)
                );              
                $result = $this->ilias->db->query($query);              
                
                return  $result->numRows() == 1;
                
        }

Here is the caller graph for this function:

ilObjTest::isComplete (  ) 

Returns true, if a test is complete for use.

Returns true, if a test is complete for use

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

Definition at line 920 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;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::isExecutable ( user_id  ) 

Checks if the test is executable by the given user.

Checks if the test is executable by the given user

Parameters:
integer $user_id The user id
Returns:
array Result array public

Definition at line 6380 of file class.ilObjTest.php.

References $result, $starting_time, $user_id, endingTimeReached(), ilFormat::ftimestamp2datetimeDB(), getActiveTestUser(), getEnableProcessingTime(), getEndingTime(), getStartingTime(), getStartingTimeOfUser(), hasNrOfTriesRestriction(), isMaxProcessingTimeReached(), isNrOfTriesReached(), isOnlineTest(), and startingTimeReached().

        {
                $result = array(
                        "executable" => true,
                        "errormessage" => ""
                );
                if (!$this->startingTimeReached())
                {
                        $result["executable"] = false;
                        $result["errormessage"] = sprintf($this->lng->txt("detail_starting_time_not_reached"), ilFormat::ftimestamp2datetimeDB($this->getStartingTime()));
                        return $result;
                }
                if ($this->endingTimeReached())
                {
                        $result["executable"] = false;
                        $result["errormessage"] = sprintf($this->lng->txt("detail_ending_time_reached"), ilFormat::ftimestamp2datetimeDB($this->getEndingTime()));
                        return $result;
                }
                if ($this->getEnableProcessingTime())
                {
                        $starting_time = $this->getStartingTimeOfUser($user_id);
                        if ($starting_time !== FALSE)
                        {
                                if ($this->isMaxProcessingTimeReached($starting_time))
                                {
                                        $result["executable"] = false;
                                        $result["errormessage"] = $this->lng->txt("detail_max_processing_time_reached");
                                        return $result;
                                }
                        }
                }

                $active = $this->getActiveTestUser($user_id);
                if ($this->hasNrOfTriesRestriction() && is_object($active) && $this->isNrOfTriesReached($active->tries))
                {
                        $result["executable"] = false;
                        if ($this->isOnlineTest())
                        {
                                // don't display an errormessage for online exams. It could confuse users
                                // because they will get either a finish test button or a print test button
                                $result["errormessage"] = "";
                        }
                        else
                        {
                                $result["errormessage"] = $this->lng->txt("maximum_nr_of_tries_reached");
                        }
                        return $result;
                }
                
                // TODO: max. processing time
                
                return $result;
        }

Here is the call graph for this function:

ilObjTest::isMaxProcessingTimeReached ( starting_time  ) 

Returns wheather the maximum processing time for a test is reached or not.

Returns wheather the maximum processing time for a test is reached or not

Parameters:
long $starting_time The unix timestamp of the starting time of the test
Returns:
boolean TRUE if the maxium processing time is reached, FALSE if the maximum processing time is not reached or no maximum processing time is given public

Definition at line 6526 of file class.ilObjTest.php.

References $processing_time, $starting_time, getEnableProcessingTime(), and getProcessingTimeInSeconds().

Referenced by canShowTestResults(), and isExecutable().

        {
                if ($this->getEnableProcessingTime())
                {
                        $processing_time = $this->getProcessingTimeInSeconds();
                        $now = mktime();
                        if ($now > ($starting_time + $processing_time))
                        {
                                return TRUE;
                        }
                        else
                        {
                                return FALSE;
                        }
                }
                else
                {
                        return FALSE;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::isNrOfTriesReached ( tries  ) 

returns if number of tries are reached

Definition at line 6086 of file class.ilObjTest.php.

References getNrOfTries().

Referenced by isExecutable().

        {
                return $tries >= (int) $this->getNrOfTries();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::isOnlineTest (  ) 

gets TestType equals Online Test

Returns:
boolean true, if test type equals Online Test otherwise false

Definition at line 5995 of file class.ilObjTest.php.

References getTestType().

Referenced by isExecutable().

        {
                return $this->getTestType()==TYPE_ONLINE_TEST;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::isRandomTest (  ) 

Gets the status of the $random_test attribute.

Gets the status of the $random_test attribute

Returns:
integer The random test status. 0 = normal, 1 = questions are generated with random generator public
See also:
$random_test

Definition at line 1629 of file class.ilObjTest.php.

Referenced by getAllQuestions(), getAnsweredQuestionCount(), getExistingQuestions(), getQuestionCount(), getQuestionTitles(), getTestResult(), getTestSummary(), isComplete(), loadQuestions(), removeAllTestEditings(), removeSelectedTestResults(), saveToDb(), and to_xml().

        {
    return $this->random_test;
  }

Here is the caller graph for this function:

ilObjTest::loadFromDb (  ) 

Loads a ilObjTest object from a database.

Loads a ilObjTest object from a database

Parameters:
object $db A pear DB object
integer $test_id A unique key which defines the test in the database public

Definition at line 1478 of file class.ilObjTest.php.

References $data, $query, $result, loadQuestions(), setHidePreviousResults(), setHideTitlePoints(), and setPassScoring().

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->setHidePreviousResults($data->hide_previous_results);
                                $this->setHideTitlePoints($data->hide_title_points);
                                $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->count_system = $data->count_system;
                                $this->mc_scoring = $data->mc_scoring;
                                $this->setPassScoring($data->pass_scoring);
                                $this->loadQuestions();
                        }
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::loadQuestions ( user_id = "",
pass = NULL 
)

Load the test question id's from the database.

Load the test question id's from the database

Parameters:
integer $user_id The user id of the test user (necessary for random tests) public

Definition at line 1534 of file class.ilObjTest.php.

References $data, $ilUser, $query, $result, $user_id, _getPass(), getTestType(), and isRandomTest().

Referenced by generateRandomQuestions(), getAnsweredQuestionCount(), getTestResult(), getTestSummary(), 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())
                {
                        if (is_null($pass))
                        {
                                if ($this->getTestType() == TYPE_VARYING_RANDOMTEST)
                                {
                                        $pass = $this->_getPass($ilUser->id, $this->getTestId());
                                }
                                else
                                {
                                        // normal random questions are created only once, for pass 0
                                        $pass = 0;
                                }
                        }
                        $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 AND tst_test_random_question.pass = %s ORDER BY sequence",
                                $db->quote($this->test_id . ""),
                                $db->quote($user_id . ""),
                                $db->quote($pass . "")
                        );
                }
                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;
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::logAction ( logtext = "",
question_id = "" 
)

Logs an action into the Test&Assessment log.

Logs an action into the Test&Assessment log

Parameters:
string $logtext The log text
integer $question_id If given, saves the question id to the database public

Definition at line 5635 of file class.ilObjTest.php.

References $ilUser, ilObjAssessmentFolder::_addLog(), and ASS_Question::_getOriginalId().

Referenced by insertQuestion(), questionMoveDown(), questionMoveUp(), removeAllTestEditings(), removeQuestion(), removeSelectedTestResults(), saveQuestionsToDb(), and saveToDb().

        {
                global $ilUser;

                $original_id = "";
                if (strcmp($question_id, "") != 0)
                {
                        include_once "./assessment/classes/class.assQuestion.php";
                        $original_id = ASS_Question::_getOriginalId($question_id);
                }
                include_once "./classes/class.ilObjAssessmentFolder.php";
                ilObjAssessmentFolder::_addLog($ilUser->id, $this->getId(), $logtext, $question_id, $original_id);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

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 4942 of file class.ilObjTest.php.

References ilUtil::insertInstIntoID().

        {
                if ($a_tag == "Identifier" && $a_param == "Entry")
                {
                        include_once "./classes/class.ilUtil.php";
                        $a_value = ilUtil::insertInstIntoID($a_value);
                }

                return $a_value;
        }

Here is the call graph for this function:

ilObjTest::moveQuestions ( move_questions,
target_index,
insert_mode 
)

Move questions to another position.

Move questions to another position

Parameters:
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 4295 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();
        }

Here is the call graph for this function:

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

Parameters:
string event
integer reference id of object where the event occured
array passes optional parameters if required
Returns:
boolean

Reimplemented from ilObject.

Definition at line 588 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);
        }

Here is the call graph for this function:

& 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

Parameters:
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)
Returns:
array The converted array ready for CSV use public

Definition at line 6170 of file class.ilObjTest.php.

References $row, and $separator.

Referenced by getAllTestResults().

        {
                $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;
        }

Here is the caller graph for this function:

ilObjTest::questionMoveDown ( question_id  ) 

Moves a question down in order.

Moves a question down in order

Parameters:
integer $question_id The database id of the question to be moved down public
See also:
$test_id

Definition at line 2576 of file class.ilObjTest.php.

References $data, $query, $result, ilObjAssessmentFolder::_enabledAssessmentLogging(), ilObjAssessmentFolder::_getLogLanguage(), 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);
                        include_once ("./classes/class.ilObjAssessmentFolder.php");
                        if (ilObjAssessmentFolder::_enabledAssessmentLogging())
                        {
                                $this->logAction($this->lng->txtlng("assessment", "log_question_position_changed", ilObjAssessmentFolder::_getLogLanguage()) . ": " . ($data->sequence) . " => " . ($data->sequence+1), $question_id);
                        }
                }
                $this->loadQuestions();
        }

Here is the call graph for this function:

ilObjTest::questionMoveUp ( question_id  ) 

Moves a question up in order.

Moves a question up in order

Parameters:
integer $question_id The database id of the question to be moved up public
See also:
$test_id

Definition at line 2529 of file class.ilObjTest.php.

References $data, $query, $result, ilObjAssessmentFolder::_enabledAssessmentLogging(), ilObjAssessmentFolder::_getLogLanguage(), 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);
                        include_once ("./classes/class.ilObjAssessmentFolder.php");
                        if (ilObjAssessmentFolder::_enabledAssessmentLogging())
                        {
                                $this->logAction($this->lng->txtlng("assessment", "log_question_position_changed", ilObjAssessmentFolder::_getLogLanguage()) . ": " . ($data->sequence) . " => " . ($data->sequence-1), $question_id);
                        }
                }
                $this->loadQuestions();
        }

Here is the call graph for this function:

ilObjTest::randomSelectQuestions ( nr_of_questions,
questionpool,
use_obj_id = 0,
qpls = "",
pass = NULL 
)

Returns a random selection of questions.

Returns a random selection of questions

Parameters:
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
Returns:
array A random selection of questions public

Definition at line 4009 of file class.ilObjTest.php.

References $idx, $query, $rbacsystem, $result, $row, and getAvailableQuestionpoolIDs().

Referenced by generateRandomQuestions().

        {
                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 not 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;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::read ( a_force_db = false  ) 

read object data from db into object

Parameters:
boolean public

Reimplemented from ilObject.

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

References loadFromDb().

        {
                parent::read($a_force_db);
                $this->loadFromDb();
        }

Here is the call graph for this function:

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 2343 of file class.ilObjTest.php.

References $query, $query2, $query3, $result, ilObjAssessmentFolder::_enabledAssessmentLogging(), ilObjAssessmentFolder::_getLogLanguage(), 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();
                
                // 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)
                        );
                        $query2 = sprintf("DELETE FROM tst_active_qst_sol_settings WHERE test_fi = %s AND question_fi=%s",
                                $this->ilias->db->quote($this->getTestId()),                            
                                $this->ilias->db->quote($question_id)
                        );
                        $query3 = sprintf("DELETE FROM tst_test_result 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())
                        );
                        $query2 = sprintf("DELETE FROM tst_active_qst_sol_settings WHERE test_fi = %s",
                                $this->ilias->db->quote($this->getTestId())                                                     
                        );                      
                        $query3 = sprintf("DELETE FROM tst_test_result WHERE test_fi = %s",
                                $this->ilias->db->quote($this->getTestId())
                        );
                }
                $result = $this->ilias->db->query($query);
                $result = $this->ilias->db->query($query2);
                $result = $this->ilias->db->query($query3);

                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);
                }
                include_once ("./classes/class.ilObjAssessmentFolder.php");
                if (ilObjAssessmentFolder::_enabledAssessmentLogging())
                {
                        $this->logAction($this->lng->txtlng("assessment", "log_user_data_removed", ilObjAssessmentFolder::_getLogLanguage()));
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

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 5595 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();
        }

Here is the call graph for this function:

ilObjTest::removeQuestion ( question_id  ) 

Removes a question from the test object.

Removes a question from the test object

Parameters:
integer $question_id The database id of the question to be removed public
See also:
$test_id

Definition at line 2302 of file class.ilObjTest.php.

References ilObjAssessmentFolder::_enabledAssessmentLogging(), ilObjAssessmentFolder::_getLogLanguage(), loadQuestions(), logAction(), removeAllTestEditings(), and saveQuestionsToDb().

Referenced by deleteTest().

        {
                include_once "./assessment/classes/class.assQuestion.php";
                $question = new ASS_Question();
                include_once ("./classes/class.ilObjAssessmentFolder.php");
                if (ilObjAssessmentFolder::_enabledAssessmentLogging())
                {
                        $this->logAction($this->lng->txtlng("assessment", "log_question_removed", ilObjAssessmentFolder::_getLogLanguage()), $question_id);
                }
                $question->delete($question_id);
                $this->removeAllTestEditings($question_id);
                $this->loadQuestions();
                $this->saveQuestionsToDb();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

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 5614 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();
        }

Here is the call graph for this function:

ilObjTest::removeSelectedTestResults ( user_ids  ) 

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 2405 of file class.ilObjTest.php.

References $query, $query2, $query3, $result, $user_id, ilObjAssessmentFolder::_enabledAssessmentLogging(), ilObjAssessmentFolder::_getLogLanguage(), ilObjUser::_lookupName(), clearEvalSelectedUsers(), getTestId(), isRandomTest(), and logAction().

        {
                global $ilDB;
                
                // remove test_active entries of selected users
                foreach ($user_ids as $user_id)
                {
                        $query = sprintf("DELETE FROM tst_active WHERE user_fi = %s AND test_fi = %s",
                                $ilDB->quote($user_id . ""),
                                $ilDB->quote($this->getTestId() . "")
                        );
                        $result = $ilDB->query($query);
                }
                
                // remove selected users/groups
                $this->clearEvalSelectedUsers();
                
                // remove the question from tst_solutions
                foreach ($user_ids as $user_id)
                {
                        $query = sprintf("DELETE FROM tst_solutions WHERE test_fi = %s AND user_fi = %s",
                                $ilDB->quote($this->getTestId() . ""),
                                $ilDB->quote($user_id . "")
                        );
                        $query2 = sprintf("DELETE FROM tst_active_qst_sol_settings WHERE test_fi = %s AND user_fi = %s",
                                $ilDB->quote($this->getTestId() . ""),
                                $ilDB->quote($user_id . "")
                        );                      
                        $query3 = sprintf("DELETE FROM tst_test_result WHERE test_fi = %s AND user_fi = %s",
                                $ilDB->quote($this->getTestId() . ""),
                                $ilDB->quote($user_id . "")
                        );
                        $result = $ilDB->query($query);
                        $result = $ilDB->query($query2);
                        $result = $ilDB->query($query3);
        
                        if ($this->isRandomTest())
                        {
                                $query = sprintf("DELETE FROM tst_test_random_question WHERE test_fi = %s AND user_fi = %s",
                                        $ilDB->quote($this->getTestId() . ""),
                                        $ilDB->quote($user_id . "")
                                );
                                $result = $ilDB->query($query);
                        }
                        include_once ("./classes/class.ilObjAssessmentFolder.php");
                        if (ilObjAssessmentFolder::_enabledAssessmentLogging())
                        {
                                include_once ("./classes/class.ilObjUser.php");
                                $uname = ilObjUser::_lookupName($user_id);
                                $this->logAction(sprintf($this->lng->txtlng("assessment", "log_selected_user_data_removed", ilObjAssessmentFolder::_getLogLanguage()), trim($uname["title"] . " " . $uname["firstname"] . " " . $uname["lastname"] . " (" . $uname["user_id"] . ")")));
                        }
                }
        }

Here is the call graph for this function:

ilObjTest::removeSelectedUser ( user_id,
evaluator_id 
)

Disinvites a user from a evaluation.

Disinvites a user from a evaluation

Parameters:
integer $user_id The database id of the disinvited user public

Definition at line 5410 of file class.ilObjTest.php.

References $query, $result, and $user_id.

        {
                $query = sprintf("DELETE FROM tst_eval_users WHERE test_fi = %s AND user_fi = %s AND evaluator_fi = %s",
                        $this->ilias->db->quote($this->getTestId() . ""),
                        $this->ilias->db->quote($user_id . ""),
                        $this->ilias->db->quote($evaluator_id . "")
                );
                $result = $this->ilias->db->query($query);
        }

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

See also:
$test_types

Definition at line 841 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;
                }
        }

Here is the caller graph for this function:

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 1007 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);
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

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 971 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;
                }
        }

Here is the call graph for this function:

ilObjTest::saveQuestionsToDb (  ) 

Saves the test questions to the database.

Saves the test questions to the database

public

See also:
$questions

Definition at line 1189 of file class.ilObjTest.php.

References $key, $pos, $query, $result, $row, ilObjAssessmentFolder::_enabledAssessmentLogging(), ilObjAssessmentFolder::_getLogLanguage(), and logAction().

Referenced by moveQuestions(), removeQuestion(), and saveToDb().

        {
                $oldquestions = array();
                include_once "./classes/class.ilObjAssessmentFolder.php";
                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);
                }
                include_once ("./classes/class.ilObjAssessmentFolder.php");
                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->txtlng("assessment", "log_question_removed", ilObjAssessmentFolder::_getLogLanguage()), $question_id);                                                     
                                        }
                                        else
                                        {
                                                $this->logAction($this->lng->txtlng("assessment", "log_question_position_changed", ilObjAssessmentFolder::_getLogLanguage()) . ": " . ($index+1) . " => " . ($pos+1), $question_id);
                                        }
                                }
                        }
                        foreach ($newquestions as $index => $question_id)
                        {
                                if (array_search($question_id, $oldquestions) === FALSE)
                                {
                                        $this->logAction($this->lng->txtlng("assessment", "log_question_added", ilObjAssessmentFolder::_getLogLanguage()) . ": " . ($index+1), $question_id);
                                }
                        }
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::saveRandomQuestion ( question_id,
pass = NULL 
)

Saves a random question to the database.

Saves a random question to the database

public

See also:
$questions

Definition at line 1270 of file class.ilObjTest.php.

References $ilUser, $query, and $result.

Referenced by generateRandomQuestions().

        {
                global $ilUser;
                
                if (is_null($pass)) $pass = 0;
                $query = sprintf("SELECT test_random_question_id FROM tst_test_random_question WHERE test_fi = %s AND user_fi = %s AND pass = %s",
                        $this->ilias->db->quote($this->getTestId() . ""),
                        $this->ilias->db->quote($ilUser->id . ""),
                        $this->ilias->db->quote($pass . "")
                );
                $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, pass, TIMESTAMP) VALUES (NULL, %s, %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) . ""),
                        $this->ilias->db->quote($pass . "")
                );
                $result = $this->ilias->db->query($query);
        }

Here is the caller graph for this function:

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

Parameters:
integer $total_questions The amount of random questions public

Definition at line 1387 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);
        }

Here is the call graph for this function:

ilObjTest::saveRandomQuestionpools ( qpl_array  ) 

Saves the question pools used for a random test.

Saves the question pools used for a random test

Parameters:
array $qpl_array An array containing the questionpool id's public
See also:
$questions

Definition at line 1410 of file class.ilObjTest.php.

References $count, $key, $query, $result, and _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)
                        {
                                include_once "./assessment/classes/class.ilObjQuestionPool.php";
                                $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);
                        }
                }
        }

Here is the call graph for this function:

ilObjTest::saveToDb ( properties_only = FALSE  ) 

Saves a ilObjTest object to a database.

Saves a ilObjTest object to a database (experimental)

Parameters:
object $db A pear DB object public

Definition at line 1033 of file class.ilObjTest.php.

References $ects_fx, ilObject::$ilias, $key, $query, $random_question_count, $result, ilObjAssessmentFolder::_enabledAssessmentLogging(), ilObjAssessmentFolder::_getLogLanguage(), getHidePreviousResults(), getHideTitlePoints(), getPassScoring(), 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 . "");
                }
                include_once ("./classes/class.ilObjAssessmentFolder.php");
    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, hide_previous_results, hide_title_points, 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, count_system, mc_scoring, pass_scoring, 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, %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(sprintf("%d", $this->getHidePreviousResults() . "")),
                                $db->quote(sprintf("%d", $this->getHideTitlePoints() . "")),
                                $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($this->count_system . ""),
                                $db->quote($this->mc_scoring . ""),
                                $db->quote($this->getPassScoring() . ""),
                                $db->quote($created)
      );
      
                        if (ilObjAssessmentFolder::_enabledAssessmentLogging())
                        {
                                $this->logAction($this->lng->txtlng("assessment", "log_create_new_test", ilObjAssessmentFolder::_getLogLanguage()));
                        }
      $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, hide_previous_results = %s, hide_title_points = %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, count_system = %s, mc_scoring = %s, pass_scoring = %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(sprintf("%d", $this->getHidePreviousResults() . "")),
                                $db->quote(sprintf("%d", $this->getHideTitlePoints() . "")),
        $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->count_system . ""),
                                $db->quote($this->mc_scoring . ""),
                                $db->quote($this->getPassScoring() . ""),
        $db->quote($this->test_id)
      );
      $result = $db->query($query);
                        include_once ("./classes/class.ilObjAssessmentFolder.php");
                        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->txtlng("assessment", "log_no_test_fields_changed", ilObjAssessmentFolder::_getLogLanguage());
                                }
                                $this->logAction($this->lng->txtlng("assessment", "log_modified_test", ilObjAssessmentFolder::_getLogLanguage()) . " [".$changes."]");
                        }
    }
                if (!$properties_only)
                {
                        if ($result == DB_OK) {
                                if (!$this->isRandomTest())
                                {
                                        $this->saveQuestionsToDb();
                                }
                                $this->mark_schema->saveToDb($this->test_id);
                        }
                }
  }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::setActiveTestSubmitted ( user_id  ) 

submits active test for user user_id

Definition at line 6045 of file class.ilObjTest.php.

References $query, and $user_id.

        {
                $query = sprintf("UPDATE tst_active SET submitted=1, tries=1, submittimestamp=NOW() WHERE test_fi=%s AND user_fi=%s",
                        $this->ilias->db->quote($this->test_id),
                        $this->ilias->db->quote($user_id)
                );              
                $this->ilias->db->query($query);                                
                
        }

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

Parameters:
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 3105 of file class.ilObjTest.php.

References $ilUser, $query, getActiveTestUser(), and getNrOfResultsForPass().

Referenced by startWorkingTime().

        {
                global $ilDB;
                global $ilUser;
                
                if ($lastindex < 1) $lastindex = 1;
                $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 && ($this->getNrOfResultsForPass($ilUser->getId(), $old_active->tries) > 0)) 
                        {
                                // only add the number of tries if there are ANY results for the current
                                // test pass. Otherwise something must be wrong (doubleclick, reload etc.)
                                $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);
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjTest::setAuthor ( author = ""  ) 

Sets the authors name.

Sets the authors name of the ilObjTest object

Parameters:
string $author A string containing the name of the test author public
See also:
$author

Definition at line 1587 of file class.ilObjTest.php.

References $author.

        {
    $this->author = $author;
  }

ilObjTest::setClientIP ( user_id,
client_ip 
)

Definition at line 5980 of file class.ilObjTest.php.

References $query, and $user_id.

                                                   {            
                $query = sprintf("UPDATE tst_invited_user SET clientip=%s WHERE test_fi=%s and user_fi=%s",
                                $this->ilias->db->quote($client_ip),
                                $this->ilias->db->quote($this->test_id),
                                $this->ilias->db->quote($user_id)
                );
                $insertresult = $this->ilias->db->query($query);
        }

ilObjTest::setCountSystem ( a_count_system = COUNT_PARTIAL_SOLUTIONS  ) 

Sets the count system for the calculation of points.

Sets the count system for the calculation of points

Parameters:
integer $a_count_system The count system for the calculation of points. public
See also:
$count_system

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

        {
    $this->count_system = $a_count_system;
  }

ilObjTest::setEnableProcessingTime ( enable = 0  ) 

Sets the processing time enabled or disabled.

Sets the processing time enabled or disabled

Parameters:
integer $enable 0 to disable the processing time, 1 to enable the processing time public
See also:
$processing_time

Definition at line 2206 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

Parameters:
string $ending_time The ending time for the test. Empty string for no ending time. public
See also:
$ending_time

Definition at line 2238 of file class.ilObjTest.php.

References $ending_time.

        {
    $this->ending_time = $ending_time;
  }

ilObjTest::setHidePreviousResults ( hide_previous_results = 0  ) 

Sets the status of the visibility of previous learner results.

Sets the status of the visibility of previous learner results

Parameters:
integer $hide_previous_results 1 if the previous results should be hidden. public
See also:
$hide_previous_results

Definition at line 2150 of file class.ilObjTest.php.

References $hide_previous_results.

Referenced by loadFromDb().

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

Here is the caller graph for this function:

ilObjTest::setHideTitlePoints ( hide_title_points = 0  ) 

Sets the status of the visibility of the maximum points in the question title.

Sets the status of the visibility of the maximum points in the question title

Parameters:
integer $hide_title_points 1 if the maximum points should be hidden in the question title public
See also:
$hide_title_points

Definition at line 2171 of file class.ilObjTest.php.

References $hide_title_points.

Referenced by loadFromDb().

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

Here is the caller graph for this function:

ilObjTest::setIntroduction ( introduction = ""  ) 

Sets the introduction.

Sets the introduction text of the ilObjTest object

Parameters:
string $introduction An introduction string for the test public
See also:
$introduction

Definition at line 1601 of file class.ilObjTest.php.

References $introduction.

        {
    $this->introduction = $introduction;
  }

ilObjTest::setMCScoring ( a_mc_scoring = SCORE_ZERO_POINTS_WHEN_UNANSWERED  ) 

Sets the multiple choice scoring.

Sets the multiple choice scoring

Parameters:
integer $a_mc_scoring The scoring for multiple choice questions public
See also:
$mc_scoring

Definition at line 2266 of file class.ilObjTest.php.

        {
    $this->mc_scoring = $a_mc_scoring;
  }

ilObjTest::setNrOfTries ( nr_of_tries = 0  ) 

Sets the nr of tries for the test.

Sets the nr of tries for the test

Parameters:
integer $nr_of_tries The maximum number of tries for the test. 0 for infinite tries. public
See also:
$nr_of_tries

Definition at line 2136 of file class.ilObjTest.php.

References $nr_of_tries.

        {
    $this->nr_of_tries = $nr_of_tries;
  }

ilObjTest::setPassScoring ( a_pass_scoring = SCORE_LAST_PASS  ) 

Sets the pass scoring.

Sets the pass scoring

Parameters:
integer $a_pass_scoring The pass scoring type public
See also:
$pass_scoring

Definition at line 2280 of file class.ilObjTest.php.

Referenced by loadFromDb().

        { 
                switch ($a_pass_scoring)
                {
                        case SCORE_BEST_PASS:
                                $this->pass_scoring = SCORE_BEST_PASS;
                                break;
                        default:
                                $this->pass_scoring = SCORE_LAST_PASS;
                                break;
                }
  }

Here is the caller graph for this function:

ilObjTest::setProcessingTime ( processing_time = "00:00:00"  ) 

Sets the processing time for the test.

Sets the processing time for the test

Parameters:
string $processing_time The maximum processing time for the test given in hh:mm:ss public
See also:
$processing_time

Definition at line 2192 of file class.ilObjTest.php.

References $processing_time.

                                                   :00:00") 
        {
    $this->processing_time = $processing_time;
  }

ilObjTest::setQuestionSetSolved ( value,
question_id,
user_id 
)

sets question solved state to value for given user_id

Definition at line 6029 of file class.ilObjTest.php.

References $query, and $user_id.

        {
                $query = sprintf("REPLACE INTO tst_active_qst_sol_settings SET solved=%s, question_fi=%s, test_fi=%s, user_fi=%s",
                        $this->ilias->db->quote($value),
                        $this->ilias->db->quote($question_id),
                        $this->ilias->db->quote($this->test_id),
                        $this->ilias->db->quote($user_id)
                );
                
                $this->ilias->db->query($query);                                
        }

ilObjTest::setRandomQuestionCount ( a_random_question_count = ""  ) 

Sets the random question count.

Sets the random question count

Parameters:
integer $a_random_question_count The random question count public
See also:
$random_question_count

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

Referenced by saveRandomQuestionCount().

        {
    $this->random_question_count = $a_random_question_count;
  }

Here is the caller graph for this function:

ilObjTest::setRandomTest ( a_random_test = 0  ) 

Sets the random test indicator.

Sets the random test indicator

Parameters:
integer $a_random_test The random test indicator (0 = no random test, 1 = random test) public
See also:
$random_test

Definition at line 1727 of file class.ilObjTest.php.

        {
    $this->random_test = $a_random_test;
  }

ilObjTest::setReportingDate ( reporting_date  ) 

Sets the reporting date.

Sets the reporting date of the ilObjTest object

Parameters:
timestamp $reporting_date The date and time the score reporting is available public
See also:
$reporting_date

Definition at line 1755 of file class.ilObjTest.php.

References $reporting_date.

  {
                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

Parameters:
integer $score_reporting The score reporting public
See also:
$score_reporting

Definition at line 1713 of file class.ilObjTest.php.

References $score_reporting.

        {
    $this->score_reporting = $score_reporting;
  }

ilObjTest::setSequenceSettings ( sequence_settings = 0  ) 

Sets the sequence settings.

Sets the sequence settings of the ilObjTest object

Parameters:
integer $sequence_settings The sequence settings public
See also:
$sequence_settings

Definition at line 1685 of file class.ilObjTest.php.

References $sequence_settings.

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

Parameters:
string $starting_time The starting time for the test. Empty string for no starting time. public
See also:
$starting_time

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

References $starting_time.

        {
    $this->starting_time = $starting_time;
  }

ilObjTest::setTestType ( type = TYPE_ASSESSMENT  ) 

Sets the test type.

Sets the type of the ilObjTest object

Parameters:
integer $type The test type value public
See also:
$type

Definition at line 1699 of file class.ilObjTest.php.

References ilObject::$type.

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

Returns:
boolean true if the starting time is reached, otherwise false public

Definition at line 4343 of file class.ilObjTest.php.

References getStartingTime(), and getTestType().

Referenced by isExecutable().

        {
                if ($this->getTestType() == TYPE_ASSESSMENT || $this->getTestType() == TYPE_ONLINE_TEST || $this->getTestType() == TYPE_VARYING_RANDOMTEST) 
                {
                        if ($this->getStartingTime()) 
                        {
                                if (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;
        }               

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters:
integer $user_id The database id of the user working with the test public

Definition at line 2829 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();
        }

Here is the call graph for this function:

ilObjTest::testTitleExists ( title  ) 

Returns TRUE if the test title exists in the database.

Returns TRUE if the test title exists in the database

Parameters:
string $title The title of the test
Returns:
boolean The result of the title check public

Definition at line 863 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;
  }

Here is the caller graph for this function:

ilObjTest::to_xml (  ) 

Returns a QTI xml representation of the test.

Returns a QTI xml representation of the test

Returns:
string The QTI xml representation of the test public

Definition at line 4607 of file class.ilObjTest.php.

References $score_reporting, $xml, _instanciateQuestion(), domxml_open_mem(), getAuthor(), getCountSystem(), ilObject::getDescription(), getEndingTime(), getHidePreviousResults(), getHideTitlePoints(), getIntroduction(), getMCScoring(), getNrOfTries(), getPassScoring(), getRandomQuestionCount(), getReportingDate(), getScoreReporting(), getSequenceSettings(), getStartingTime(), getTestType(), ilObject::getTitle(), and isRandomTest().

        {
                $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);
                // count system
                $qtiMetadatafield = $domxml->create_element("qtimetadatafield");
                $qtiFieldLabel = $domxml->create_element("fieldlabel");
                $qtiFieldLabelText = $domxml->create_text_node("count_system");
                $qtiFieldLabel->append_child($qtiFieldLabelText);
                $qtiFieldEntry = $domxml->create_element("fieldentry");
                $qtiFieldEntryText = $domxml->create_text_node($this->getCountSystem());
                $qtiFieldEntry->append_child($qtiFieldEntryText);
                $qtiMetadatafield->append_child($qtiFieldLabel);
                $qtiMetadatafield->append_child($qtiFieldEntry);
                $qtiMetadata->append_child($qtiMetadatafield);
                // multiple choice scoring
                $qtiMetadatafield = $domxml->create_element("qtimetadatafield");
                $qtiFieldLabel = $domxml->create_element("fieldlabel");
                $qtiFieldLabelText = $domxml->create_text_node("mc_scoring");
                $qtiFieldLabel->append_child($qtiFieldLabelText);
                $qtiFieldEntry = $domxml->create_element("fieldentry");
                $qtiFieldEntryText = $domxml->create_text_node($this->getMCScoring());
                $qtiFieldEntry->append_child($qtiFieldEntryText);
                $qtiMetadatafield->append_child($qtiFieldLabel);
                $qtiMetadatafield->append_child($qtiFieldEntry);
                $qtiMetadata->append_child($qtiMetadatafield);
                // pass scoring
                $qtiMetadatafield = $domxml->create_element("qtimetadatafield");
                $qtiFieldLabel = $domxml->create_element("fieldlabel");
                $qtiFieldLabelText = $domxml->create_text_node("pass_scoring");
                $qtiFieldLabel->append_child($qtiFieldLabelText);
                $qtiFieldEntry = $domxml->create_element("fieldentry");
                $qtiFieldEntryText = $domxml->create_text_node($this->getPassScoring());
                $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);
                // hide previous results
                $qtiMetadatafield = $domxml->create_element("qtimetadatafield");
                $qtiFieldLabel = $domxml->create_element("fieldlabel");
                $qtiFieldLabelText = $domxml->create_text_node("hide_previous_results");
                $qtiFieldLabel->append_child($qtiFieldLabelText);
                $qtiFieldEntry = $domxml->create_element("fieldentry");
                $qtiFieldEntryText = $domxml->create_text_node(sprintf("%d", $this->getHidePreviousResults()));
                $qtiFieldEntry->append_child($qtiFieldEntryText);
                $qtiMetadatafield->append_child($qtiFieldLabel);
                $qtiMetadatafield->append_child($qtiFieldEntry);
                $qtiMetadata->append_child($qtiMetadatafield);
                // hide title points
                $qtiMetadatafield = $domxml->create_element("qtimetadatafield");
                $qtiFieldLabel = $domxml->create_element("fieldlabel");
                $qtiFieldLabelText = $domxml->create_text_node("hide_title_points");
                $qtiFieldLabel->append_child($qtiFieldLabelText);
                $qtiFieldEntry = $domxml->create_element("fieldentry");
                $qtiFieldEntryText = $domxml->create_text_node(sprintf("%d", $this->getHideTitlePoints()));
                $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;
        }

Here is the call graph for this function:

ilObjTest::update (  ) 

update object data

public

Returns:
boolean

Reimplemented from ilObject.

Definition at line 376 of file class.ilObjTest.php.

References updateMetaData().

        {
                $this->updateMetaData();
                if (!parent::update())
                {
                        return false;
                }

                // put here object specific stuff
                
                return true;
        }

Here is the call graph for this function:

ilObjTest::updateMetaData (  ) 

update meta data entry

Reimplemented from ilObject.

Definition at line 5145 of file class.ilObjTest.php.

References $ilUser, ilObject::getId(), ilObject::getTitle(), and ilObject::getType().

Referenced by update().

        {
                global $ilUser;
                include_once "./Services/MetaData/classes/class.ilMD.php";
                $md =& new ilMD($this->getId(), 0, $this->getType());
                $md_gen =& $md->getGeneral();
                if ($md_gen == false)
                {
                        include_once "./Services/MetaData/classes/class.ilMDCreator.php";
                        $md_creator = new ilMDCreator($this->getId(),0,$this->getType());
                        $md_creator->setTitle($this->getTitle());
                        $md_creator->setTitleLanguage($ilUser->getPref('language'));
                        $md_creator->create();
                }
                parent::updateMetaData();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters:
integer $times_id The database id of a working time entry public

Definition at line 2853 of file class.ilObjTest.php.

References $q, and $result.

        {
                $q = sprintf("UPDATE tst_times SET finished = %s WHERE times_id = %s",
                        $this->ilias->db->quote(strftime("%Y-%m-%d %H:%M:%S")),
                        $this->ilias->db->quote($times_id)
                );
                $result = $this->ilias->db->query($q);
        }


Field Documentation

ilObjTest::$author

Definition at line 67 of file class.ilObjTest.php.

Referenced by setAuthor().

ilObjTest::$count_system

Definition at line 290 of file class.ilObjTest.php.

ilObjTest::$ects_fx

Definition at line 241 of file class.ilObjTest.php.

Referenced by saveToDb().

ilObjTest::$ects_grades

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

ilObjTest::$ects_output

Definition at line 232 of file class.ilObjTest.php.

Referenced by saveECTSStatus().

ilObjTest::$enable_processing_time

Definition at line 205 of file class.ilObjTest.php.

ilObjTest::$ending_time

Definition at line 223 of file class.ilObjTest.php.

Referenced by setEndingTime().

ilObjTest::$evaluation_data

Definition at line 149 of file class.ilObjTest.php.

ilObjTest::$hide_previous_results

Definition at line 178 of file class.ilObjTest.php.

Referenced by setHidePreviousResults().

ilObjTest::$hide_title_points

Definition at line 187 of file class.ilObjTest.php.

Referenced by setHideTitlePoints().

ilObjTest::$introduction

Definition at line 95 of file class.ilObjTest.php.

Referenced by setIntroduction().

ilObjTest::$invitation = INVITATION_OFF

Definition at line 56 of file class.ilObjTest.php.

ilObjTest::$mark_schema

Definition at line 104 of file class.ilObjTest.php.

ilObjTest::$mc_scoring

Definition at line 297 of file class.ilObjTest.php.

ilObjTest::$metadata

Definition at line 76 of file class.ilObjTest.php.

ilObjTest::$nr_of_tries

Definition at line 168 of file class.ilObjTest.php.

Referenced by setNrOfTries().

ilObjTest::$pass_scoring

Definition at line 304 of file class.ilObjTest.php.

ilObjTest::$processing_time

Definition at line 196 of file class.ilObjTest.php.

Referenced by isMaxProcessingTimeReached(), and setProcessingTime().

ilObjTest::$questions

Definition at line 85 of file class.ilObjTest.php.

ilObjTest::$random_question_count

Definition at line 282 of file class.ilObjTest.php.

Referenced by saveToDb().

ilObjTest::$random_test

Definition at line 273 of file class.ilObjTest.php.

ilObjTest::$reporting_date

Definition at line 140 of file class.ilObjTest.php.

Referenced by setReportingDate().

ilObjTest::$score_reporting

Definition at line 128 of file class.ilObjTest.php.

Referenced by setScoreReporting(), and to_xml().

ilObjTest::$sequence_settings

Definition at line 115 of file class.ilObjTest.php.

Referenced by setSequenceSettings().

ilObjTest::$starting_time
ilObjTest::$test_id
ilObjTest::$test_type

Definition at line 158 of file class.ilObjTest.php.

ilObjTest::$test_types

Definition at line 253 of file class.ilObjTest.php.


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