Public Member Functions | Static Public Member Functions | Data Fields

ilCourseObjectiveQuestion Class Reference

class ilcourseobjectiveQuestion More...

Inheritance diagram for ilCourseObjectiveQuestion:
Collaboration diagram for ilCourseObjectiveQuestion:

Public Member Functions

 ilCourseObjectiveQuestion ($a_objective_id)
 cloneDependencies ($a_new_objective, $a_copy_id)
 clone objective questions
 setTestStatus ($a_status)
 getTestStatus ()
 setTestSuggestedLimit ($a_limit)
 getTestSuggestedLimit ()
 __addTest ()
 __deleteTest ($a_test_ref_id)
 updateTest ($a_test_objective_id)
 getTests ()
 _getTest ($a_test_objective_id)
 getQuestions ()
 getQuestionsOfTest ($a_test_id)
 Get questions of test.
 getQuestion ($question_id)
 getObjectiveId ()
 setTestRefId ($a_ref_id)
 getTestRefId ()
 setTestObjId ($a_obj_id)
 getTestObjId ()
 setQuestionId ($a_question_id)
 getQuestionId ()
 getMaxPointsByObjective ()
 getMaxPointsByTest ($a_test_ref_id)
 getNumberOfQuestionsByTest ($a_test_ref_id)
 getQuestionsByTest ($a_test_ref_id)
 add ()
 delete ($qst_id)
 deleteAll ()
 __read ()
 _isAssigned ($a_objective_id, $a_tst_ref_id, $a_question_id)

Static Public Member Functions

static _isTestAssignedToObjective ($a_test_id, $a_objective_id)
 Check if test is assigned to objective.
static _getAssignableTests ($a_container_ref_id)
 Get assignable tests.

Data Fields

 $db = null
 $objective_id = null
 $questions

Detailed Description

class ilcourseobjectiveQuestion

Author:
Stefan Meyer <smeyer@databay.de>
Version:
Id:
class.ilCourseObjectiveQuestion.php 13860 2007-05-11 10:05:02Z smeyer

Definition at line 34 of file class.ilCourseObjectiveQuestion.php.


Member Function Documentation

ilCourseObjectiveQuestion::__addTest (  ) 

Definition at line 173 of file class.ilCourseObjectiveQuestion.php.

References $res, getObjectiveId(), getTestObjId(), getTestRefId(), and getTestStatus().

Referenced by add().

        {
                global $ilDB;
                
                // CHECK if entry already exists
                $query = "SELECT * FROM crs_objective_tst ".
                        "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId())." ".
                        "AND ref_id = ".$ilDB->quote($this->getTestRefId())."";

                $res = $this->db->query($query);
                if($res->numRows())
                {
                        return false;
                }
                $query = "INSERT INTO crs_objective_tst ".
                        "SET objective_id = ".$ilDB->quote($this->getObjectiveId()).", ".
                        "ref_id = ".$ilDB->quote($this->getTestRefId()).", ".
                        "obj_id = ".$ilDB->quote($this->getTestObjId()).", ".
                        "tst_status = ".$ilDB->quote($this->getTestStatus()).", ".
                        "tst_limit = '100'";

                $this->db->query($query);

                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseObjectiveQuestion::__deleteTest ( a_test_ref_id  ) 

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

References getObjectiveId().

Referenced by __read(), and delete().

        {
                global $ilDB;
                
                // Delete questions
                $query = "DELETE FROM crs_objective_qst ".
                        "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId())." ".
                        "AND ref_id = ".$ilDB->quote($a_test_ref_id)." ";

                $this->db->query($query);

                // delete tst entries
                $query = "DELETE FROM crs_objective_tst ".
                        "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId())." ".
                        "AND ref_id = ".$ilDB->quote($a_test_ref_id)." ";

                $this->db->query($query);

                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseObjectiveQuestion::__read (  ) 

Definition at line 485 of file class.ilCourseObjectiveQuestion.php.

References $res, __deleteTest(), ilObject::_getAllReferences(), ilObjTest::_instanciateQuestion(), ilCourseObjective::_lookupContainerIdByObjectiveId(), and getObjectiveId().

Referenced by ilCourseObjectiveQuestion().

        {
                global $ilDB,$tree;
                
                include_once './Modules/Test/classes/class.ilObjTest.php';
                include_once('Modules/Course/classes/class.ilCourseObjective.php');

                $container_ref_ids = ilObject::_getAllReferences(ilCourseObjective::_lookupContainerIdByObjectiveId($this->objective_id));
                $container_ref_id  = current($container_ref_ids);


                $this->questions = array();
                $query = "SELECT * FROM crs_objective_qst as coq ".
                        "JOIN qpl_questions as qq ON coq.question_id = qq.question_id ".
                        "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId())." ".
                        "ORDER BY title";

                $res = $this->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        if(!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id,$row->ref_id))
                        {
                                $this->__deleteTest($row->ref_id);
                                continue;
                        }
                        if(!$question = ilObjTest::_instanciateQuestion($row->question_id))
                        {
                                $this->delete($row->question_id);
                                continue;
                        }
                        $qst['ref_id'] = $row->ref_id;
                        $qst['obj_id'] = $row->obj_id;
                        $qst['question_id'] = $row->question_id;
                        $qst['qst_ass_id'] = $row->qst_ass_id;
                        $qst['title'] = $question->getTitle();

                        $this->questions[$row->qst_ass_id] = $qst;
                }
                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

static ilCourseObjectiveQuestion::_getAssignableTests ( a_container_ref_id  )  [static]

Get assignable tests.

public

Parameters:
 

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

Referenced by ilCourseObjectivesGUI::listQuestionAssignment().

        {
                global $tree;
                
                return $tree->getSubTree($tree->getNodeData($a_container_ref_id),true,'tst');
        }

Here is the caller graph for this function:

ilCourseObjectiveQuestion::_getTest ( a_test_objective_id  ) 

Definition at line 260 of file class.ilCourseObjectiveQuestion.php.

References $res.

Referenced by ilCourseObjectivesGUI::updateQuestionAssignment().

        {
                global $ilDB;

                $query = "SELECT * FROM crs_objective_tst ".
                        "WHERE test_objective_id = ".$ilDB->quote($a_test_objective_id)." ";

                $res = $ilDB->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $test['test_objective_id'] = $row->test_objective_id;
                        $test['objective_id']           = $row->objective_id;
                        $test['ref_id']                 = $row->ref_id;
                        $test['obj_id']                 = $row->obj_id;
                        $test['tst_status']             = $row->tst_status;
                        $test['tst_limit']              = $row->tst_limit;
                }

                return $test ? $test : array();
        }

Here is the caller graph for this function:

ilCourseObjectiveQuestion::_isAssigned ( a_objective_id,
a_tst_ref_id,
a_question_id 
)

Definition at line 527 of file class.ilCourseObjectiveQuestion.php.

References $objective_id, and $res.

Referenced by ilCourseObjectivesGUI::assignQuestions(), and ilCourseObjectivesGUI::listQuestionAssignment().

        {
                global $ilDB;

                $query = "SELECT crs_qst.objective_id as objective_id FROM crs_objective_qst as crs_qst, crs_objectives as crs_obj ".
                        "WHERE crs_qst.objective_id = crs_obj.objective_id ".
                        "AND crs_qst.objective_id = ".$ilDB->quote($a_objective_id) ." ".
                        "AND ref_id = ".$ilDB->quote($a_tst_ref_id)." ".
                        "AND question_id = ".$ilDB->quote($a_question_id)." ";

                $res = $ilDB->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $objective_id = $row->objective_id;
                }
                
                return $objective_id ? $objective_id : 0;
        }

Here is the caller graph for this function:

static ilCourseObjectiveQuestion::_isTestAssignedToObjective ( a_test_id,
a_objective_id 
) [static]

Check if test is assigned to objective.

public

Parameters:
int test ref_id
int objective_id
Returns:
boolean success

Definition at line 63 of file class.ilCourseObjectiveQuestion.php.

References $res.

Referenced by ilCourseObjectivePresentationGUI::__showTests().

        {
                global $ilDB;
                
                $query = "SELECT qst_ass_id FROM crs_objective_qst ".
                        "WHERE ref_id = ".$ilDB->quote($a_test_id)." ".
                        "AND objective_id = ".$ilDB->quote($a_objective_id);
                $res = $ilDB->query($query);
                return $res->numRows() ? true : false;
        }

Here is the caller graph for this function:

ilCourseObjectiveQuestion::add (  ) 

Definition at line 410 of file class.ilCourseObjectiveQuestion.php.

References __addTest(), getObjectiveId(), getQuestionId(), getTestObjId(), and getTestRefId().

        {
                global $ilDB;
                
                $query = "INSERT INTO crs_objective_qst ".
                        "SET objective_id = ".$ilDB->quote($this->getObjectiveId()).", ".
                        "ref_id = ".$ilDB->quote($this->getTestRefId()).", ".
                        "obj_id = ".$ilDB->quote($this->getTestObjId()).", ".
                        "question_id = ".$ilDB->quote($this->getQuestionId())."";

                $this->db->query($query);

                $this->__addTest();

                return true;
        }

Here is the call graph for this function:

ilCourseObjectiveQuestion::cloneDependencies ( a_new_objective,
a_copy_id 
)

clone objective questions

public

Parameters:
int source objective
int target objective
int copy id

Definition at line 83 of file class.ilCourseObjectiveQuestion.php.

References $ilLog, ilCopyWizardOptions::_getInstance(), getQuestions(), getTests(), and ilCourseObjectiveQuestion().

        {
                global $ilObjDataCache,$ilLog;
                
                include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
                $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
                $mappings = $cwo->getMappings();
                foreach($this->getQuestions() as $question)
                {
                        if(!isset($mappings["$question[ref_id]"]) or !$mappings["$question[ref_id]"])
                        {
                                continue;
                        }
                        $question_ref_id = $question['ref_id'];
                        $question_obj_id = $question['obj_id'];
                        $question_qst_id = $question['question_id'];
                        $new_ref_id = $mappings[$question_ref_id];
                        $new_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
                        
                        if($new_obj_id == $question_obj_id)
                        {
                                $ilLog->write(__METHOD__.': Test has been linked. Keeping question id.');
                                // Object has been linked
                                $new_question_id = $question_qst_id;
                        }
                        else
                        {
                                $new_question_info = $mappings[$question_ref_id.'_'.$question_qst_id];
                                $new_question_arr = explode('_',$new_question_info);
                                if(!isset($new_question_arr[1]) or !$new_question_arr[1])
                                {
                                        continue;
                                }
                                $new_question_id = $new_question_arr[1];
                                $ilLog->write(__METHOD__.': New question id is: '.$new_question_id);
                        }
        
                        $new_question = new ilCourseObjectiveQuestion($a_new_objective);
                        $new_question->setTestRefId($new_ref_id);
                        $new_question->setTestObjId($new_obj_id);
                        $new_question->setQuestionId($new_question_id);
                        $new_question->add();
                }
                
                // Copy tests
                foreach($this->getTests() as $test)
                {
                        $new_test_id = $mappings["$test[ref_id]"];
                        
                        $query = "UPDATE crs_objective_tst ".
                                "SET tst_status = ".$this->db->quote($test['tst_status']).", ".
                                "tst_limit = ".$this->db->quote($test['tst_limit'])." ".
                                "WHERE objective_id = ".$this->db->quote($a_new_objective)." ".
                                "AND ref_id = ".$this->db->quote($new_test_id);
                        $this->db->query($query);
                }
        }

Here is the call graph for this function:

ilCourseObjectiveQuestion::delete ( qst_id  ) 

Definition at line 426 of file class.ilCourseObjectiveQuestion.php.

References $res, __deleteTest(), and getObjectiveId().

        {
                global $ilDB;
                
                if(!$qst_id)
                {
                        return false;
                }
                
                $query = "SELECT * FROM crs_objective_qst ".
                        "WHERE qst_ass_id = ".$ilDB->quote($qst_id)." ";

                $res = $this->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $test_rid = $row->ref_id;
                        $test_oid = $row->obj_id;
                }

                $query = "DELETE FROM crs_objective_qst ".
                        "WHERE qst_ass_id = ".$ilDB->quote($qst_id)." ";

                $this->db->query($query);

                // delete test if it was the last question
                $query = "SELECT * FROM crs_objective_qst ".
                        "WHERE ref_id = ".$ilDB->quote($test_rid)." ".
                        "AND obj_id = ".$ilDB->quote($test_oid)." ".
                        "AND objective_id = ".$ilDB->quote($this->getObjectiveId())." ";
                

                $res = $this->db->query($query);
                if(!$res->numRows())
                {
                        $this->__deleteTest($test_rid);
                }

                return true;
        }

Here is the call graph for this function:

ilCourseObjectiveQuestion::deleteAll (  ) 

Definition at line 466 of file class.ilCourseObjectiveQuestion.php.

References getObjectiveId().

        {
                global $ilDB;
                
                $query = "DELETE FROM crs_objective_qst ".
                        "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId())." ";

                $this->db->query($query);

                $query = "DELETE FROM crs_objective_tst ".
                        "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId())." ";

                $this->db->query($query);

                return true;
        }

Here is the call graph for this function:

ilCourseObjectiveQuestion::getMaxPointsByObjective (  ) 

Definition at line 342 of file class.ilCourseObjectiveQuestion.php.

References ilObjTest::_instanciateQuestion(), ilObjectFactory::getInstanceByRefId(), and getQuestions().

        {
                include_once './Modules/Test/classes/class.ilObjTest.php';

                $points = 0;
                foreach($this->getQuestions() as $question)
                {
                        $tmp_test =& ilObjectFactory::getInstanceByRefId($question['ref_id']);

                        $tmp_question =& ilObjTest::_instanciateQuestion($question['question_id']);

                        $points += $tmp_question->getMaximumPoints();

                        unset($tmp_question);
                        unset($tmp_test);
                }
                return $points;
        }

Here is the call graph for this function:

ilCourseObjectiveQuestion::getMaxPointsByTest ( a_test_ref_id  ) 

Definition at line 361 of file class.ilCourseObjectiveQuestion.php.

References ilObjTest::_instanciateQuestion(), ilObjectFactory::getInstanceByRefId(), and getQuestions().

        {
                $points = 0;

                $tmp_test =& ilObjectFactory::getInstanceByRefId($a_test_ref_id);

                foreach($this->getQuestions() as $question)
                {
                        if($question['ref_id'] == $a_test_ref_id)
                        {
                                $tmp_question =& ilObjTest::_instanciateQuestion($question['question_id']);

                                $points += $tmp_question->getMaximumPoints();

                                unset($tmp_question);
                        }
                }
                unset($tmp_test);

                return $points;
        }

Here is the call graph for this function:

ilCourseObjectiveQuestion::getNumberOfQuestionsByTest ( a_test_ref_id  ) 

Definition at line 383 of file class.ilCourseObjectiveQuestion.php.

References getQuestions().

        {
                $counter = 0;

                foreach($this->getQuestions() as $question)
                {
                        if($question['ref_id'] == $a_test_ref_id)
                        {
                                ++$counter;
                        }
                }
                return $counter;
        }

Here is the call graph for this function:

ilCourseObjectiveQuestion::getObjectiveId (  ) 

Definition at line 311 of file class.ilCourseObjectiveQuestion.php.

Referenced by __addTest(), __deleteTest(), __read(), add(), delete(), deleteAll(), and getTests().

        {
                return $this->objective_id;
        }

Here is the caller graph for this function:

ilCourseObjectiveQuestion::getQuestion ( question_id  ) 

Definition at line 306 of file class.ilCourseObjectiveQuestion.php.

        {
                return $this->questions[$question_id] ? $this->questions[$question_id] : array();
        }

ilCourseObjectiveQuestion::getQuestionId (  ) 

Definition at line 336 of file class.ilCourseObjectiveQuestion.php.

Referenced by add().

        {
                return $this->question_id;
        }

Here is the caller graph for this function:

ilCourseObjectiveQuestion::getQuestions (  ) 

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

Referenced by cloneDependencies(), getMaxPointsByObjective(), getMaxPointsByTest(), getNumberOfQuestionsByTest(), getQuestionsByTest(), and getQuestionsOfTest().

        {
                return $this->questions ? $this->questions : array();
        }

Here is the caller graph for this function:

ilCourseObjectiveQuestion::getQuestionsByTest ( a_test_ref_id  ) 

Definition at line 397 of file class.ilCourseObjectiveQuestion.php.

References getQuestions().

        {
                foreach($this->getQuestions() as $question)
                {
                        if($question['ref_id'] == $a_test_ref_id)
                        {
                                $qst[] = $question['question_id'];
                        }
                }
                return $qst ? $qst : array();
        }

Here is the call graph for this function:

ilCourseObjectiveQuestion::getQuestionsOfTest ( a_test_id  ) 

Get questions of test.

public

Parameters:
int test id

Definition at line 294 of file class.ilCourseObjectiveQuestion.php.

References $questions, and getQuestions().

        {
                foreach($this->getQuestions() as $qst)
                {
                        if($a_test_id == $qst['obj_id'])
                        {
                                $questions[] = $qst;
                        }
                }
                return $questions ? $questions : array();
        }

Here is the call graph for this function:

ilCourseObjectiveQuestion::getTestObjId (  ) 

Definition at line 328 of file class.ilCourseObjectiveQuestion.php.

Referenced by __addTest(), and add().

        {
                return $this->tst_obj_id ? $this->tst_obj_id : 0;
        }

Here is the caller graph for this function:

ilCourseObjectiveQuestion::getTestRefId (  ) 

Definition at line 320 of file class.ilCourseObjectiveQuestion.php.

Referenced by __addTest(), and add().

        {
                return $this->tst_ref_id ? $this->tst_ref_id : 0;
        }

Here is the caller graph for this function:

ilCourseObjectiveQuestion::getTests (  ) 

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

References $res, and getObjectiveId().

Referenced by cloneDependencies().

        {
                global $ilDB;
                
                $query = "SELECT * FROM crs_objective_tst as cot ".
                        "JOIN object_data as obd ON cot.obj_id = obd.obj_id ".
                        "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId())." ".
                        "ORDER BY title ";

                $res = $this->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $test['test_objective_id'] = $row->test_objective_id;
                        $test['objective_id']           = $row->objective_id;
                        $test['ref_id']                 = $row->ref_id;
                        $test['obj_id']                 = $row->obj_id;
                        $test['tst_status']             = $row->tst_status;
                        $test['tst_limit']              = $row->tst_limit;
                        $test['title']                  = $row->title;

                        $tests[] = $test;
                }

                return $tests ? $tests : array();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseObjectiveQuestion::getTestStatus (  ) 

Definition at line 161 of file class.ilCourseObjectiveQuestion.php.

Referenced by __addTest(), and updateTest().

        {
                return (int) $this->tst_status;
        }

Here is the caller graph for this function:

ilCourseObjectiveQuestion::getTestSuggestedLimit (  ) 

Definition at line 169 of file class.ilCourseObjectiveQuestion.php.

Referenced by updateTest().

        {
                return (int) $this->tst_limit;
        }

Here is the caller graph for this function:

ilCourseObjectiveQuestion::ilCourseObjectiveQuestion ( a_objective_id  ) 

Definition at line 41 of file class.ilCourseObjectiveQuestion.php.

References __read().

Referenced by cloneDependencies().

        {
                global $ilDB;

                $this->db =& $ilDB;
        
                $this->objective_id = $a_objective_id;

                $this->__read();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilCourseObjectiveQuestion::setQuestionId ( a_question_id  ) 

Definition at line 332 of file class.ilCourseObjectiveQuestion.php.

        {
                $this->question_id = $a_question_id;
        }

ilCourseObjectiveQuestion::setTestObjId ( a_obj_id  ) 

Definition at line 324 of file class.ilCourseObjectiveQuestion.php.

        {
                $this->tst_obj_id = $a_obj_id;
        }

ilCourseObjectiveQuestion::setTestRefId ( a_ref_id  ) 

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

        {
                $this->tst_ref_id = $a_ref_id;
        }

ilCourseObjectiveQuestion::setTestStatus ( a_status  ) 

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

        {
                $this->tst_status = $a_status;
        }

ilCourseObjectiveQuestion::setTestSuggestedLimit ( a_limit  ) 

Definition at line 165 of file class.ilCourseObjectiveQuestion.php.

        {
                $this->tst_limit = $a_limit;
        }

ilCourseObjectiveQuestion::updateTest ( a_test_objective_id  ) 

Definition at line 220 of file class.ilCourseObjectiveQuestion.php.

References getTestStatus(), and getTestSuggestedLimit().

        {
                global $ilDB;
                
                $query = "UPDATE crs_objective_tst ".
                        "SET tst_status = ".$ilDB->quote($this->getTestStatus()).", ".
                        "tst_limit = ".$ilDB->quote($this->getTestSuggestedLimit())." ".
                        "WHERE test_objective_id = ".$ilDB->quote($a_test_objective_id)."";

                $this->db->query($query);

                return true;
        }

Here is the call graph for this function:


Field Documentation

ilCourseObjectiveQuestion::$db = null

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

ilCourseObjectiveQuestion::$objective_id = null

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

Referenced by _isAssigned().

ilCourseObjectiveQuestion::$questions

Definition at line 39 of file class.ilCourseObjectiveQuestion.php.

Referenced by getQuestionsOfTest().


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