ILIAS  release_4-4 Revision
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 More...
 
 setTestStatus ($a_status)
 
 getTestStatus ()
 
 setTestSuggestedLimit ($a_limit)
 
 getTestSuggestedLimit ()
 
 __addTest ()
 
 __deleteTest ($a_test_ref_id)
 
 updateTest ($a_objective_id)
 
 getTests ()
 
 getSelfAssessmentTests ()
 get self assessment tests More...
 
 getFinalTests ()
 get final tests More...
 
 _getTest ($a_test_objective_id)
 
 getQuestions ()
 
 getSelfAssessmentQuestions ()
 get self assessment questions More...
 
 getSelfAssessmentPoints ()
 get self assessment points More...
 
 getFinalTestPoints ()
 get final test points More...
 
 isSelfAssessmentQuestion ($a_question_id)
 check if question is self assessment question More...
 
 isFinalTestQuestion ($a_question_id)
 is final test question More...
 
 getFinalTestQuestions ()
 get final test questions More...
 
 getQuestionsOfTest ($a_test_id)
 Get questions of test. More...
 
 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)
 
 updateLimits ()
 update limits More...
 
 add ()
 
 delete ($qst_id)
 
 deleteAll ()
 
 __read ()
 
 _hasTests ($a_course_id)
 public More...
 
 _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. More...
 
static _getAssignableTests ($a_container_ref_id)
 Get assignable tests. More...
 
static _updateTestLimits ($a_objective_id, $a_status, $a_limit)
 update test limits More...
 
static _lookupMaximumPointsOfQuestion ($a_question_id)
 lookup maximimum point More...
 

Data Fields

const TYPE_SELF_ASSESSMENT = 0
 
const TYPE_FINAL_TEST = 1
 
 $db = null
 
 $objective_id = null
 
 $questions
 

Protected Attributes

 $tests = array()
 

Detailed Description

class ilcourseobjectiveQuestion

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

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

Member Function Documentation

◆ __addTest()

ilCourseObjectiveQuestion::__addTest ( )

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

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

Referenced by add().

178  {
179  global $ilDB;
180 
181  $query = "UPDATE crs_objective_tst ".
182  "SET tst_status = ".$this->db->quote($this->getTestStatus() ,'integer')." ".
183  "WHERE objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ".
184  "AND ref_id = ".$this->db->quote($this->getTestRefId() ,'integer')." ";
185  $res = $ilDB->manipulate($query);
186 
187 
188  // CHECK if entry already exists
189  $query = "SELECT * FROM crs_objective_tst ".
190  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
191  "AND ref_id = ".$ilDB->quote($this->getTestRefId() ,'integer')."";
192 
193  $res = $this->db->query($query);
194  if($res->numRows())
195  {
196  return false;
197  }
198 
199  // Check for existing limit
200  $query = "SELECT tst_limit FROM crs_objective_tst ".
201  "WHERE objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ".
202  "AND tst_status = ".$this->db->quote($this->getTestStatus() ,'integer')." ";
203 
204  $res = $this->db->query($query);
205 
206  $limit = -1;
207  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
208  {
209  $limit = $row->tst_limit;
210  }
211 
212  $next_id = $ilDB->nextId('crs_objective_tst');
213  $query = "INSERT INTO crs_objective_tst (test_objective_id,objective_id,ref_id,obj_id,tst_status,tst_limit) ".
214  "VALUES( ".
215  $ilDB->quote($next_id,'integer').", ".
216  $ilDB->quote($this->getObjectiveId() ,'integer').", ".
217  $ilDB->quote($this->getTestRefId() ,'integer').", ".
218  $ilDB->quote($this->getTestObjId() ,'integer').", ".
219  $ilDB->quote($this->getTestStatus() ,'integer').", ".
220  $this->db->quote($limit ,'integer')." ".
221  ")";
222  $res = $ilDB->manipulate($query);
223 
224  return true;
225  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __deleteTest()

ilCourseObjectiveQuestion::__deleteTest (   $a_test_ref_id)

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

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

Referenced by __read(), and delete().

228  {
229  global $ilDB;
230 
231  // Delete questions
232  $query = "DELETE FROM crs_objective_qst ".
233  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
234  "AND ref_id = ".$ilDB->quote($a_test_ref_id ,'integer')." ";
235  $res = $ilDB->manipulate($query);
236 
237  // delete tst entries
238  $query = "DELETE FROM crs_objective_tst ".
239  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
240  "AND ref_id = ".$ilDB->quote($a_test_ref_id ,'integer')." ";
241  $res = $ilDB->manipulate($query);
242 
243  unset($this->tests[$a_test_ref_id]);
244 
245  return true;
246  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __read()

ilCourseObjectiveQuestion::__read ( )

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

References $query, $res, $row, __deleteTest(), ilObject\_getAllReferences(), ilObjTest\_instanciateQuestion(), ilCourseObjective\_lookupContainerIdByObjectiveId(), DB_FETCHMODE_OBJECT, and getObjectiveId().

Referenced by add(), and ilCourseObjectiveQuestion().

742  {
743  global $ilDB,$tree;
744 
745  include_once './Modules/Test/classes/class.ilObjTest.php';
746  include_once('Modules/Course/classes/class.ilCourseObjective.php');
747 
748  $container_ref_ids = ilObject::_getAllReferences(ilCourseObjective::_lookupContainerIdByObjectiveId($this->objective_id));
749  $container_ref_id = current($container_ref_ids);
750 
751  // Read test data
752  $query = "SELECT * FROM crs_objective_tst ".
753  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
754  $res = $this->db->query($query);
755  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
756  {
757  $this->tests[$row->ref_id]['test_objective_id'] = $row->test_objective_id;
758  $this->tests[$row->ref_id]['ref_id'] = $row->ref_id;
759  $this->tests[$row->ref_id]['obj_id'] = $row->obj_id;
760  $this->tests[$row->ref_id]['status'] = $row->tst_status;
761  $this->tests[$row->ref_id]['limit'] = $row->tst_limit;
762  }
763 
764  $this->questions = array();
765  $query = "SELECT * FROM crs_objective_qst coq ".
766  "JOIN qpl_questions qq ON coq.question_id = qq.question_id ".
767  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
768  "ORDER BY title";
769 
770  $res = $this->db->query($query);
771  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
772  {
773  if(!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id,$row->ref_id))
774  {
775  $this->__deleteTest($row->ref_id);
776  continue;
777  }
778  if(!$question = ilObjTest::_instanciateQuestion($row->question_id))
779  {
780  $this->delete($row->question_id);
781  continue;
782  }
783 
784  $qst['ref_id'] = $row->ref_id;
785  $qst['obj_id'] = $row->obj_id;
786  $qst['question_id'] = $row->question_id;
787  $qst['qst_ass_id'] = $row->qst_ass_id;
788  $qst['title'] = $question->getTitle();
789  $qst['description'] = $question->getComment();
790  $qst['test_type'] = $this->tests[$row->ref_id]['status'];
791  $qst['points'] = $question->getPoints();
792 
793  $this->questions[$row->qst_ass_id] = $qst;
794  }
795 
796  return true;
797  }
static _lookupContainerIdByObjectiveId($a_objective_id)
Get container of object.
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _getAllReferences($a_id)
get all reference ids of object
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getAssignableTests()

static ilCourseObjectiveQuestion::_getAssignableTests (   $a_container_ref_id)
static

Get assignable tests.

public

Parameters

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

Referenced by ilCourseObjectivesGUI\finalTestAssignment(), and ilCourseObjectivesGUI\selfAssessmentAssignment().

154  {
155  global $tree;
156 
157  return $tree->getSubTree($tree->getNodeData($a_container_ref_id),true,'tst');
158  }
+ Here is the caller graph for this function:

◆ _getTest()

ilCourseObjectiveQuestion::_getTest (   $a_test_objective_id)

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

References $query, $res, $row, $test, and DB_FETCHMODE_OBJECT.

347  {
348  global $ilDB;
349 
350  $query = "SELECT * FROM crs_objective_tst ".
351  "WHERE test_objective_id = ".$ilDB->quote($a_test_objective_id ,'integer')." ";
352 
353  $res = $ilDB->query($query);
354  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
355  {
356  $test['test_objective_id'] = $row->test_objective_id;
357  $test['objective_id'] = $row->objective_id;
358  $test['ref_id'] = $row->ref_id;
359  $test['obj_id'] = $row->obj_id;
360  $test['tst_status'] = $row->tst_status;
361  $test['tst_limit'] = $row->tst_limit;
362  }
363 
364  return $test ? $test : array();
365  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
$test
Definition: Utf8Test.php:85

◆ _hasTests()

ilCourseObjectiveQuestion::_hasTests (   $a_course_id)

public

Parameters

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

References $query, and $res.

Referenced by ilCourseObjectivesGUI\setSubTabs().

808  {
809  global $ilDB;
810 
811  $query = "SELECT co.objective_id FROM crs_objectives co JOIN ".
812  "crs_objective_tst cot ON co.objective_id = cot.objective_id ".
813  "WHERE crs_id = ".$ilDB->quote($a_course_id ,'integer')." ";
814  $res = $ilDB->query($query);
815  return $res->numRows() ? true : false;
816  }
+ Here is the caller graph for this function:

◆ _isAssigned()

ilCourseObjectiveQuestion::_isAssigned (   $a_objective_id,
  $a_tst_ref_id,
  $a_question_id 
)

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

References $objective_id, $query, $res, $row, and DB_FETCHMODE_OBJECT.

820  {
821  global $ilDB;
822 
823  $query = "SELECT crs_qst.objective_id objective_id FROM crs_objective_qst crs_qst, crs_objectives crs_obj ".
824  "WHERE crs_qst.objective_id = crs_obj.objective_id ".
825  "AND crs_qst.objective_id = ".$ilDB->quote($a_objective_id ,'integer') ." ".
826  "AND ref_id = ".$ilDB->quote($a_tst_ref_id ,'integer')." ".
827  "AND question_id = ".$ilDB->quote($a_question_id ,'integer')." ";
828 
829  $res = $ilDB->query($query);
830  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
831  {
832  $objective_id = $row->objective_id;
833  }
834 
835  return $objective_id ? $objective_id : 0;
836  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11

◆ _isTestAssignedToObjective()

static ilCourseObjectiveQuestion::_isTestAssignedToObjective (   $a_test_id,
  $a_objective_id 
)
static

Check if test is assigned to objective.

public

Parameters
inttest ref_id
intobjective_id
Returns
boolean success

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

References $query, and $res.

Referenced by ilCourseObjectivePresentationGUI\__showTests().

68  {
69  global $ilDB;
70 
71  $query = "SELECT qst_ass_id FROM crs_objective_qst ".
72  "WHERE ref_id = ".$ilDB->quote($a_test_id ,'integer')." ".
73  "AND objective_id = ".$ilDB->quote($a_objective_id ,'integer');
74  $res = $ilDB->query($query);
75  return $res->numRows() ? true : false;
76  }
+ Here is the caller graph for this function:

◆ _lookupMaximumPointsOfQuestion()

static ilCourseObjectiveQuestion::_lookupMaximumPointsOfQuestion (   $a_question_id)
static

lookup maximimum point

public

Parameters
intquestion id
Returns

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

References assQuestion\_getMaximumPoints().

584  {
585  include_once('Modules/TestQuestionPool/classes/class.assQuestion.php');
586  return assQuestion::_getMaximumPoints($a_question_id);
587  }
_getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:

◆ _updateTestLimits()

static ilCourseObjectiveQuestion::_updateTestLimits (   $a_objective_id,
  $a_status,
  $a_limit 
)
static

update test limits

public

Parameters
intobjective_id
intstatus
intlimit
Returns

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

References $query, and $res.

Referenced by ilCourseObjectivesGUI\saveQuestionOverview().

259  {
260  global $ilDB;
261 
262  $query = "UPDATE crs_objective_tst ".
263  "SET tst_limit = ".$ilDB->quote($a_limit ,'integer')." ".
264  "WHERE tst_status = ".$ilDB->quote($a_status ,'integer')." ".
265  "AND objective_id = ".$ilDB->quote($a_objective_id ,'integer');
266  $res = $ilDB->manipulate($query);
267  return true;
268  }
+ Here is the caller graph for this function:

◆ add()

ilCourseObjectiveQuestion::add ( )

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

References $query, $res, __addTest(), __read(), getObjectiveId(), getQuestionId(), getTestObjId(), and getTestRefId().

661  {
662  global $ilDB;
663 
664  $query = "DELETE FROM crs_objective_qst ".
665  "WHERE objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ".
666  "AND question_id = ".$this->db->quote($this->getQuestionId() ,'integer')." ";
667  $res = $ilDB->manipulate($query);
668 
669  $next_id = $ilDB->nextId('crs_objective_qst');
670  $query = "INSERT INTO crs_objective_qst (qst_ass_id, objective_id,ref_id,obj_id,question_id) ".
671  "VALUES( ".
672  $ilDB->quote($next_id,'integer').", ".
673  $ilDB->quote($this->getObjectiveId() ,'integer').", ".
674  $ilDB->quote($this->getTestRefId() ,'integer').", ".
675  $ilDB->quote($this->getTestObjId() ,'integer').", ".
676  $ilDB->quote($this->getQuestionId() ,'integer').
677  ")";
678  $res = $ilDB->manipulate($query);
679 
680  $this->__addTest();
681 
682  $this->__read();
683 
684  return true;
685  }
+ Here is the call graph for this function:

◆ cloneDependencies()

ilCourseObjectiveQuestion::cloneDependencies (   $a_new_objective,
  $a_copy_id 
)

clone objective questions

public

Parameters
intsource objective
inttarget objective
intcopy id

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

References $ilLog, $query, $res, $test, ilCopyWizardOptions\_getInstance(), getQuestions(), getTests(), and ilCourseObjectiveQuestion().

88  {
89  global $ilObjDataCache,$ilLog,$ilDB;
90 
91  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
92  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
93  $mappings = $cwo->getMappings();
94  foreach($this->getQuestions() as $question)
95  {
96  if(!isset($mappings["$question[ref_id]"]) or !$mappings["$question[ref_id]"])
97  {
98  continue;
99  }
100  $question_ref_id = $question['ref_id'];
101  $question_obj_id = $question['obj_id'];
102  $question_qst_id = $question['question_id'];
103  $new_ref_id = $mappings[$question_ref_id];
104  $new_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
105 
106  if($new_obj_id == $question_obj_id)
107  {
108  $ilLog->write(__METHOD__.': Test has been linked. Keeping question id.');
109  // Object has been linked
110  $new_question_id = $question_qst_id;
111  }
112  else
113  {
114  $new_question_info = $mappings[$question_ref_id.'_'.$question_qst_id];
115  $new_question_arr = explode('_',$new_question_info);
116  if(!isset($new_question_arr[1]) or !$new_question_arr[1])
117  {
118  continue;
119  }
120  $new_question_id = $new_question_arr[1];
121  $ilLog->write(__METHOD__.': New question id is: '.$new_question_id);
122  }
123 
124  $new_question = new ilCourseObjectiveQuestion($a_new_objective);
125  $new_question->setTestRefId($new_ref_id);
126  $new_question->setTestObjId($new_obj_id);
127  $new_question->setQuestionId($new_question_id);
128  $new_question->add();
129  }
130 
131  // Copy tests
132  foreach($this->getTests() as $test)
133  {
134  $new_test_id = $mappings["$test[ref_id]"];
135 
136  $query = "UPDATE crs_objective_tst ".
137  "SET tst_status = ".$this->db->quote($test['tst_status'] ,'integer').", ".
138  "tst_limit = ".$this->db->quote($test['tst_limit'] ,'integer')." ".
139  "WHERE objective_id = ".$this->db->quote($a_new_objective ,'integer')." ".
140  "AND ref_id = ".$this->db->quote($new_test_id ,'integer');
141  $res = $ilDB->manipulate($query);
142  }
143  }
static _getInstance($a_copy_id)
Get instance of copy wizard options.
$test
Definition: Utf8Test.php:85
+ Here is the call graph for this function:

◆ delete()

ilCourseObjectiveQuestion::delete (   $qst_id)

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

References $query, $res, $row, __deleteTest(), DB_FETCHMODE_OBJECT, and getObjectiveId().

687  {
688  global $ilDB;
689 
690  if(!$qst_id)
691  {
692  return false;
693  }
694 
695  $query = "SELECT * FROM crs_objective_qst ".
696  "WHERE qst_ass_id = ".$ilDB->quote($qst_id ,'integer')." ";
697 
698  $res = $this->db->query($query);
699  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
700  {
701  $test_rid = $row->ref_id;
702  $test_oid = $row->obj_id;
703  }
704 
705  $query = "DELETE FROM crs_objective_qst ".
706  "WHERE qst_ass_id = ".$ilDB->quote($qst_id ,'integer')." ";
707  $res = $ilDB->manipulate($query);
708 
709  // delete test if it was the last question
710  $query = "SELECT * FROM crs_objective_qst ".
711  "WHERE ref_id = ".$ilDB->quote($test_rid ,'integer')." ".
712  "AND obj_id = ".$ilDB->quote($test_oid ,'integer')." ".
713  "AND objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
714 
715  $res = $this->db->query($query);
716  if(!$res->numRows())
717  {
718  $this->__deleteTest($test_rid);
719  }
720 
721  return true;
722  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the call graph for this function:

◆ deleteAll()

ilCourseObjectiveQuestion::deleteAll ( )

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

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

725  {
726  global $ilDB;
727 
728  $query = "DELETE FROM crs_objective_qst ".
729  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
730  $res = $ilDB->manipulate($query);
731 
732  $query = "DELETE FROM crs_objective_tst ".
733  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
734  $res = $ilDB->manipulate($query);
735 
736  return true;
737  }
+ Here is the call graph for this function:

◆ getFinalTestPoints()

ilCourseObjectiveQuestion::getFinalTestPoints ( )

get final test points

public

Returns

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

References getFinalTestQuestions().

Referenced by updateLimits().

413  {
414  foreach($this->getFinalTestQuestions() as $question)
415  {
416  $points += $question['points'];
417  }
418  return $points ? $points : 0;
419  }
getFinalTestQuestions()
get final test questions
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFinalTestQuestions()

ilCourseObjectiveQuestion::getFinalTestQuestions ( )

get final test questions

public

Returns

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

Referenced by getFinalTestPoints().

466  {
467  foreach($this->questions as $question)
468  {
469  if($question['test_type'] == self::TYPE_FINAL_TEST)
470  {
471  $final[] = $question;
472  }
473  }
474  return $final ? $final : array();
475  }
+ Here is the caller graph for this function:

◆ getFinalTests()

ilCourseObjectiveQuestion::getFinalTests ( )

get final tests

public

Returns

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

References $test.

335  {
336  foreach($this->tests as $test)
337  {
338  if($test['status'] == self::TYPE_FINAL_TEST)
339  {
340  $final[] = $test;
341  }
342  }
343  return $final ? $final : array();
344  }
$test
Definition: Utf8Test.php:85

◆ getMaxPointsByObjective()

ilCourseObjectiveQuestion::getMaxPointsByObjective ( )

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

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

535  {
536  include_once './Modules/Test/classes/class.ilObjTest.php';
537 
538  $points = 0;
539  foreach($this->getQuestions() as $question)
540  {
541  $tmp_test =& ilObjectFactory::getInstanceByRefId($question['ref_id']);
542 
543  $tmp_question =& ilObjTest::_instanciateQuestion($question['question_id']);
544 
545  $points += $tmp_question->getMaximumPoints();
546 
547  unset($tmp_question);
548  unset($tmp_test);
549  }
550  return $points;
551  }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
+ Here is the call graph for this function:

◆ getMaxPointsByTest()

ilCourseObjectiveQuestion::getMaxPointsByTest (   $a_test_ref_id)

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

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

554  {
555  $points = 0;
556 
557  $tmp_test =& ilObjectFactory::getInstanceByRefId($a_test_ref_id);
558 
559  foreach($this->getQuestions() as $question)
560  {
561  if($question['ref_id'] == $a_test_ref_id)
562  {
563  $tmp_question =& ilObjTest::_instanciateQuestion($question['question_id']);
564 
565  $points += $tmp_question->getMaximumPoints();
566 
567  unset($tmp_question);
568  }
569  }
570  unset($tmp_test);
571 
572  return $points;
573  }
getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
+ Here is the call graph for this function:

◆ getNumberOfQuestionsByTest()

ilCourseObjectiveQuestion::getNumberOfQuestionsByTest (   $a_test_ref_id)

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

References getQuestions().

591  {
592  $counter = 0;
593 
594  foreach($this->getQuestions() as $question)
595  {
596  if($question['ref_id'] == $a_test_ref_id)
597  {
598  ++$counter;
599  }
600  }
601  return $counter;
602  }
+ Here is the call graph for this function:

◆ getObjectiveId()

ilCourseObjectiveQuestion::getObjectiveId ( )

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

References $objective_id.

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

+ Here is the caller graph for this function:

◆ getQuestion()

ilCourseObjectiveQuestion::getQuestion (   $question_id)

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

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

◆ getQuestionId()

ilCourseObjectiveQuestion::getQuestionId ( )

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

Referenced by add().

529  {
530  return $this->question_id;
531  }
+ Here is the caller graph for this function:

◆ getQuestions()

ilCourseObjectiveQuestion::getQuestions ( )

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

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

369  {
370  return $this->questions ? $this->questions : array();
371  }
+ Here is the caller graph for this function:

◆ getQuestionsByTest()

ilCourseObjectiveQuestion::getQuestionsByTest (   $a_test_ref_id)

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

References getQuestions().

605  {
606  foreach($this->getQuestions() as $question)
607  {
608  if($question['ref_id'] == $a_test_ref_id)
609  {
610  $qst[] = $question['question_id'];
611  }
612  }
613  return $qst ? $qst : array();
614  }
+ Here is the call graph for this function:

◆ getQuestionsOfTest()

ilCourseObjectiveQuestion::getQuestionsOfTest (   $a_test_id)

Get questions of test.

public

Parameters
inttest id

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

References $questions, and getQuestions().

487  {
488  foreach($this->getQuestions() as $qst)
489  {
490  if($a_test_id == $qst['obj_id'])
491  {
492  $questions[] = $qst;
493  }
494  }
495  return $questions ? $questions : array();
496  }
+ Here is the call graph for this function:

◆ getSelfAssessmentPoints()

ilCourseObjectiveQuestion::getSelfAssessmentPoints ( )

get self assessment points

public

Returns

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

References getSelfAssessmentQuestions().

Referenced by updateLimits().

398  {
399  foreach($this->getSelfAssessmentQuestions() as $question)
400  {
401  $points += $question['points'];
402  }
403  return $points ? $points : 0;
404  }
getSelfAssessmentQuestions()
get self assessment questions
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSelfAssessmentQuestions()

ilCourseObjectiveQuestion::getSelfAssessmentQuestions ( )

get self assessment questions

public

Returns

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

References TYPE_SELF_ASSESSMENT.

Referenced by getSelfAssessmentPoints().

380  {
381  foreach($this->questions as $question)
382  {
383  if($question['test_type'] == self::TYPE_SELF_ASSESSMENT)
384  {
385  $self[] = $question;
386  }
387  }
388  return $self ? $self : array();
389  }
const TYPE_SELF_ASSESSMENT
+ Here is the caller graph for this function:

◆ getSelfAssessmentTests()

ilCourseObjectiveQuestion::getSelfAssessmentTests ( )

get self assessment tests

public

Parameters

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

References $test, and TYPE_SELF_ASSESSMENT.

317  {
318  foreach($this->tests as $test)
319  {
320  if($test['status'] == self::TYPE_SELF_ASSESSMENT)
321  {
322  $self[] = $test;
323  }
324  }
325  return $self ? $self : array();
326  }
const TYPE_SELF_ASSESSMENT
$test
Definition: Utf8Test.php:85

◆ getTestObjId()

ilCourseObjectiveQuestion::getTestObjId ( )

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

Referenced by __addTest(), and add().

521  {
522  return $this->tst_obj_id ? $this->tst_obj_id : 0;
523  }
+ Here is the caller graph for this function:

◆ getTestRefId()

ilCourseObjectiveQuestion::getTestRefId ( )

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

Referenced by __addTest(), and add().

513  {
514  return $this->tst_ref_id ? $this->tst_ref_id : 0;
515  }
+ Here is the caller graph for this function:

◆ getTests()

ilCourseObjectiveQuestion::getTests ( )

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

References $query, $res, $row, $test, $tests, DB_FETCHMODE_OBJECT, and getObjectiveId().

Referenced by cloneDependencies().

284  {
285  global $ilDB;
286 
287  $query = "SELECT * FROM crs_objective_tst cot ".
288  "JOIN object_data obd ON cot.obj_id = obd.obj_id ".
289  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
290  "ORDER BY title ";
291 
292  $res = $this->db->query($query);
293  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
294  {
295  $test['test_objective_id'] = $row->test_objective_id;
296  $test['objective_id'] = $row->objective_id;
297  $test['ref_id'] = $row->ref_id;
298  $test['obj_id'] = $row->obj_id;
299  $test['tst_status'] = $row->tst_status;
300  $test['tst_limit'] = $row->tst_limit;
301  $test['title'] = $row->title;
302 
303  $tests[] = $test;
304  }
305 
306  return $tests ? $tests : array();
307  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
$test
Definition: Utf8Test.php:85
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTestStatus()

ilCourseObjectiveQuestion::getTestStatus ( )

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

Referenced by __addTest(), and updateTest().

166  {
167  return (int) $this->tst_status;
168  }
+ Here is the caller graph for this function:

◆ getTestSuggestedLimit()

ilCourseObjectiveQuestion::getTestSuggestedLimit ( )

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

Referenced by updateTest().

174  {
175  return (int) $this->tst_limit;
176  }
+ Here is the caller graph for this function:

◆ ilCourseObjectiveQuestion()

ilCourseObjectiveQuestion::ilCourseObjectiveQuestion (   $a_objective_id)

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

References __read().

Referenced by cloneDependencies().

46  {
47  global $ilDB;
48 
49  $this->db =& $ilDB;
50 
51  $this->objective_id = $a_objective_id;
52 
53  $this->__read();
54  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFinalTestQuestion()

ilCourseObjectiveQuestion::isFinalTestQuestion (   $a_question_id)

is final test question

public

Parameters
intquestion id
Returns

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

447  {
448  foreach($this->questions as $question)
449  {
450  if($question['question_id'] == $a_question_id)
451  {
452  return $question['test_type'] == self::TYPE_FINAL_TEST;
453  }
454  }
455  return false;
456 
457  }

◆ isSelfAssessmentQuestion()

ilCourseObjectiveQuestion::isSelfAssessmentQuestion (   $a_question_id)

check if question is self assessment question

Parameters
intquestion id public
Returns

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

References TYPE_SELF_ASSESSMENT.

428  {
429  foreach($this->questions as $question)
430  {
431  if($question['question_id'] == $a_question_id)
432  {
433  return $question['test_type'] == self::TYPE_SELF_ASSESSMENT;
434  }
435  }
436  return false;
437  }
const TYPE_SELF_ASSESSMENT

◆ setQuestionId()

ilCourseObjectiveQuestion::setQuestionId (   $a_question_id)

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

525  {
526  $this->question_id = $a_question_id;
527  }

◆ setTestObjId()

ilCourseObjectiveQuestion::setTestObjId (   $a_obj_id)

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

517  {
518  $this->tst_obj_id = $a_obj_id;
519  }

◆ setTestRefId()

ilCourseObjectiveQuestion::setTestRefId (   $a_ref_id)

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

509  {
510  $this->tst_ref_id = $a_ref_id;
511  }

◆ setTestStatus()

ilCourseObjectiveQuestion::setTestStatus (   $a_status)

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

162  {
163  $this->tst_status = $a_status;
164  }

◆ setTestSuggestedLimit()

ilCourseObjectiveQuestion::setTestSuggestedLimit (   $a_limit)

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

170  {
171  $this->tst_limit = $a_limit;
172  }

◆ updateLimits()

ilCourseObjectiveQuestion::updateLimits ( )

update limits

public

Parameters

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

References $query, $ref_id, $res, getFinalTestPoints(), getSelfAssessmentPoints(), and TYPE_SELF_ASSESSMENT.

624  {
625  global $ilDB;
626 
627  foreach($this->tests as $ref_id => $test_data)
628  {
629  switch($test_data['status'])
630  {
632  $points = $this->getSelfAssessmentPoints();
633  break;
634 
635  case self::TYPE_FINAL_TEST:
636  $points = $this->getFinalTestPoints();
637  break;
638  }
639  if($test_data['limit'] == -1 or $test_data['limit'] > $points)
640  {
641  switch($test_data['status'])
642  {
644  $points = $this->getSelfAssessmentPoints();
645  break;
646 
647  case self::TYPE_FINAL_TEST:
648  $points = $this->getFinalTestPoints();
649  break;
650  }
651  $query = "UPDATE crs_objective_tst ".
652  "SET tst_limit = ".$this->db->quote($points ,'integer')." ".
653  "WHERE test_objective_id = ".$this->db->quote($test_data['test_objective_id'] ,'integer')." ";
654  $res = $ilDB->manipulate($query);
655  }
656  }
657  }
getSelfAssessmentPoints()
get self assessment points
$ref_id
Definition: sahs_server.php:39
const TYPE_SELF_ASSESSMENT
+ Here is the call graph for this function:

◆ updateTest()

ilCourseObjectiveQuestion::updateTest (   $a_objective_id)

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

References $query, $res, getTestStatus(), and getTestSuggestedLimit().

271  {
272  global $ilDB;
273 
274  $query = "UPDATE crs_objective_tst ".
275  "SET tst_status = ".$ilDB->quote($this->getTestStatus() ,'integer').", ".
276  "tst_limit = ".$ilDB->quote($this->getTestSuggestedLimit() ,'integer')." ".
277  "WHERE test_objective_id = ".$ilDB->quote($a_objective_id ,'integer')."";
278  $res = $ilDB->manipulate($query);
279 
280  return true;
281  }
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilCourseObjectiveQuestion::$db = null

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

◆ $objective_id

ilCourseObjectiveQuestion::$objective_id = null

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

Referenced by _isAssigned(), and getObjectiveId().

◆ $questions

ilCourseObjectiveQuestion::$questions

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

Referenced by getQuestionsOfTest().

◆ $tests

ilCourseObjectiveQuestion::$tests = array()
protected

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

Referenced by getTests().

◆ TYPE_FINAL_TEST

◆ TYPE_SELF_ASSESSMENT


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