ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilCourseObjectiveQuestion Class Reference

class ilcourseobjectiveQuestion More...

+ Inheritance diagram for ilCourseObjectiveQuestion:
+ Collaboration diagram for ilCourseObjectiveQuestion:

Public Member Functions

 __construct ($a_objective_id)
 Constructor type $ilDB. More...
 
 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...
 
 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)
 
 deleteByTestType ($a_type)
 
 deleteAll ()
 
 __read ()
 
 toXml (ilXmlWriter $writer)
 To xml. More...
 

Static Public Member Functions

static lookupObjectivesOfQuestion ($a_qid)
 Lookup objective for test question type $ilDB. More...
 
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 _getTest ($a_test_objective_id)
 
static _lookupMaximumPointsOfQuestion ($a_question_id)
 lookup maximimum point More...
 
static deleteTest ($a_tst_ref_id)
 
static _hasTests ($a_course_id)
 public More...
 
static _isAssigned ($a_objective_id, $a_tst_ref_id, $a_question_id)
 
static lookupQuestionsByObjective ($a_test_id, $a_objective)
 
static loookupTestLimit ($a_test_id, $a_objective_id)
 

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.

Constructor & Destructor Documentation

◆ __construct()

ilCourseObjectiveQuestion::__construct (   $a_objective_id)

Constructor type $ilDB.

Parameters
type$a_objective_id

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

References $ilDB, and __read().

51  {
52  global $ilDB;
53 
54  $this->db = $ilDB;
55 
56  $this->objective_id = $a_objective_id;
57 
58  $this->__read();
59  }
global $ilDB
+ Here is the call graph for this function:

Member Function Documentation

◆ __addTest()

ilCourseObjectiveQuestion::__addTest ( )

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

References $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, getObjectiveId(), getTestObjId(), getTestRefId(), and getTestStatus().

Referenced by add().

208  {
209  global $ilDB;
210 
211  $query = "UPDATE crs_objective_tst ".
212  "SET tst_status = ".$this->db->quote($this->getTestStatus() ,'integer')." ".
213  "WHERE objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ".
214  "AND ref_id = ".$this->db->quote($this->getTestRefId() ,'integer')." ";
215  $res = $ilDB->manipulate($query);
216 
217 
218  // CHECK if entry already exists
219  $query = "SELECT * FROM crs_objective_tst ".
220  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
221  "AND ref_id = ".$ilDB->quote($this->getTestRefId() ,'integer')."";
222 
223  $res = $this->db->query($query);
224  if($res->numRows())
225  {
226  return false;
227  }
228 
229  // Check for existing limit
230  $query = "SELECT tst_limit_p FROM crs_objective_tst ".
231  "WHERE objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ".
232  "AND tst_status = ".$this->db->quote($this->getTestStatus() ,'integer')." ";
233 
234  $res = $this->db->query($query);
235 
236  $limit = 100;
237  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
238  {
239  $limit = $row->tst_limit_p;
240  }
241 
242  $next_id = $ilDB->nextId('crs_objective_tst');
243  $query = "INSERT INTO crs_objective_tst (test_objective_id,objective_id,ref_id,obj_id,tst_status,tst_limit_p) ".
244  "VALUES( ".
245  $ilDB->quote($next_id,'integer').", ".
246  $ilDB->quote($this->getObjectiveId() ,'integer').", ".
247  $ilDB->quote($this->getTestRefId() ,'integer').", ".
248  $ilDB->quote($this->getTestObjId() ,'integer').", ".
249  $ilDB->quote($this->getTestStatus() ,'integer').", ".
250  $this->db->quote($limit ,'integer')." ".
251  ")";
252  $res = $ilDB->manipulate($query);
253 
254  return true;
255  }
global $ilDB
+ 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 257 of file class.ilCourseObjectiveQuestion.php.

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

Referenced by __read(), and delete().

258  {
259  global $ilDB;
260 
261  // Delete questions
262  $query = "DELETE FROM crs_objective_qst ".
263  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
264  "AND ref_id = ".$ilDB->quote($a_test_ref_id ,'integer')." ";
265  $res = $ilDB->manipulate($query);
266 
267  // delete tst entries
268  $query = "DELETE FROM crs_objective_tst ".
269  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
270  "AND ref_id = ".$ilDB->quote($a_test_ref_id ,'integer')." ";
271  $res = $ilDB->manipulate($query);
272 
273  unset($this->tests[$a_test_ref_id]);
274 
275  return true;
276  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __read()

ilCourseObjectiveQuestion::__read ( )

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

References $ilDB, $query, $res, $row, __deleteTest(), ilObject\_getAllReferences(), ilObjTest\_instanciateQuestion(), ilCourseObjective\_lookupContainerIdByObjectiveId(), array, ilDBConstants\FETCHMODE_OBJECT, and getObjectiveId().

Referenced by __construct(), and add().

818  {
819  global $ilDB,$tree;
820 
821  include_once './Modules/Test/classes/class.ilObjTest.php';
822  include_once('Modules/Course/classes/class.ilCourseObjective.php');
823 
824  $container_ref_ids = ilObject::_getAllReferences(ilCourseObjective::_lookupContainerIdByObjectiveId($this->objective_id));
825  $container_ref_id = current($container_ref_ids);
826 
827  // Read test data
828  $query = "SELECT * FROM crs_objective_tst ".
829  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
830  $res = $this->db->query($query);
831  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
832  {
833  $this->tests[$row->ref_id]['test_objective_id'] = $row->test_objective_id;
834  $this->tests[$row->ref_id]['ref_id'] = $row->ref_id;
835  $this->tests[$row->ref_id]['obj_id'] = $row->obj_id;
836  $this->tests[$row->ref_id]['status'] = $row->tst_status;
837  $this->tests[$row->ref_id]['limit'] = $row->tst_limit_p;
838  }
839 
840  $this->questions = array();
841  $query = "SELECT * FROM crs_objective_qst coq ".
842  "JOIN qpl_questions qq ON coq.question_id = qq.question_id ".
843  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
844  "ORDER BY title";
845 
846  $res = $this->db->query($query);
847  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
848  {
849  if(!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id,$row->ref_id))
850  {
851  $this->__deleteTest($row->ref_id);
852  continue;
853  }
854  if(!$question = ilObjTest::_instanciateQuestion($row->question_id))
855  {
856  $this->delete($row->question_id);
857  continue;
858  }
859 
860  $qst['ref_id'] = $row->ref_id;
861  $qst['obj_id'] = $row->obj_id;
862  $qst['question_id'] = $row->question_id;
863  $qst['qst_ass_id'] = $row->qst_ass_id;
864  $qst['title'] = $question->getTitle();
865  $qst['description'] = $question->getComment();
866  $qst['test_type'] = $this->tests[$row->ref_id]['status'];
867  $qst['points'] = $question->getPoints();
868 
869  $this->questions[$row->qst_ass_id] = $qst;
870  }
871 
872  return true;
873  }
static _lookupContainerIdByObjectiveId($a_objective_id)
Get container of object.
static _getAllReferences($a_id)
get all reference ids of object
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
Create styles array
The data for the language used.
global $ilDB
+ 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 183 of file class.ilCourseObjectiveQuestion.php.

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

184  {
185  global $tree;
186 
187  return $tree->getSubTree($tree->getNodeData($a_container_ref_id),true,'tst');
188  }
+ Here is the caller graph for this function:

◆ _getTest()

static ilCourseObjectiveQuestion::_getTest (   $a_test_objective_id)
static

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

References $ilDB, $query, $res, $row, $test, array, and ilDBConstants\FETCHMODE_OBJECT.

377  {
378  global $ilDB;
379 
380  $query = "SELECT * FROM crs_objective_tst ".
381  "WHERE test_objective_id = ".$ilDB->quote($a_test_objective_id ,'integer')." ";
382 
383  $res = $ilDB->query($query);
384  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
385  {
386  $test['test_objective_id'] = $row->test_objective_id;
387  $test['objective_id'] = $row->objective_id;
388  $test['ref_id'] = $row->ref_id;
389  $test['obj_id'] = $row->obj_id;
390  $test['tst_status'] = $row->tst_status;
391  $test['tst_limit'] = $row->tst_limit_p;
392  }
393 
394  return $test ? $test : array();
395  }
Create styles array
The data for the language used.
global $ilDB
$test
Definition: Utf8Test.php:84

◆ _hasTests()

static ilCourseObjectiveQuestion::_hasTests (   $a_course_id)
static

public

Parameters

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

References $ilDB, $query, and $res.

Referenced by ilCourseObjectivesGUI\setSubTabs().

884  {
885  global $ilDB;
886 
887  $query = "SELECT co.objective_id FROM crs_objectives co JOIN ".
888  "crs_objective_tst cot ON co.objective_id = cot.objective_id ".
889  "WHERE crs_id = ".$ilDB->quote($a_course_id ,'integer')." ";
890  $res = $ilDB->query($query);
891  return $res->numRows() ? true : false;
892  }
global $ilDB
+ Here is the caller graph for this function:

◆ _isAssigned()

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

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

References $ilDB, $objective_id, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

896  {
897  global $ilDB;
898 
899  $query = "SELECT crs_qst.objective_id objective_id FROM crs_objective_qst crs_qst, crs_objectives crs_obj ".
900  "WHERE crs_qst.objective_id = crs_obj.objective_id ".
901  "AND crs_qst.objective_id = ".$ilDB->quote($a_objective_id ,'integer') ." ".
902  "AND ref_id = ".$ilDB->quote($a_tst_ref_id ,'integer')." ".
903  "AND question_id = ".$ilDB->quote($a_question_id ,'integer')." ";
904 
905  $res = $ilDB->query($query);
906  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
907  {
908  $objective_id = $row->objective_id;
909  }
910 
911  return $objective_id ? $objective_id : 0;
912  }
global $ilDB

◆ _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 94 of file class.ilCourseObjectiveQuestion.php.

References $ilDB, $query, and $res.

95  {
96  global $ilDB;
97 
98  $query = "SELECT qst_ass_id FROM crs_objective_qst ".
99  "WHERE ref_id = ".$ilDB->quote($a_test_id ,'integer')." ".
100  "AND objective_id = ".$ilDB->quote($a_objective_id ,'integer');
101  $res = $ilDB->query($query);
102  return $res->numRows() ? true : false;
103  }
global $ilDB

◆ _lookupMaximumPointsOfQuestion()

static ilCourseObjectiveQuestion::_lookupMaximumPointsOfQuestion (   $a_question_id)
static

lookup maximimum point

public

Parameters
intquestion id
Returns

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

References assQuestion\_getMaximumPoints().

Referenced by ilLOTestQuestionAdapter\updateFixedQuestions(), ilLOTestQuestionAdapter\updateRandomQuestions(), and ilLOTestQuestionAdapter\updateSeparateTestQuestions().

614  {
615  include_once('Modules/TestQuestionPool/classes/class.assQuestion.php');
616  return assQuestion::_getMaximumPoints($a_question_id);
617  }
static _getMaximumPoints($question_id)
Returns the maximum points, a learner can reach answering the question.
+ Here is the call graph for this function:
+ Here is the caller 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 288 of file class.ilCourseObjectiveQuestion.php.

References $ilDB, $query, and $res.

Referenced by ilCourseObjectivesGUI\saveQuestionOverview().

289  {
290  global $ilDB;
291 
292  $query = "UPDATE crs_objective_tst ".
293  "SET tst_limit_p = ".$ilDB->quote($a_limit ,'integer')." ".
294  "WHERE tst_status = ".$ilDB->quote($a_status ,'integer')." ".
295  "AND objective_id = ".$ilDB->quote($a_objective_id ,'integer');
296  $res = $ilDB->manipulate($query);
297  return true;
298  }
global $ilDB
+ Here is the caller graph for this function:

◆ add()

ilCourseObjectiveQuestion::add ( )

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

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

691  {
692  global $ilDB;
693 
694  $query = "DELETE FROM crs_objective_qst ".
695  "WHERE objective_id = ".$this->db->quote($this->getObjectiveId() ,'integer')." ".
696  "AND question_id = ".$this->db->quote($this->getQuestionId() ,'integer')." ";
697  $res = $ilDB->manipulate($query);
698 
699  $next_id = $ilDB->nextId('crs_objective_qst');
700  $query = "INSERT INTO crs_objective_qst (qst_ass_id, objective_id,ref_id,obj_id,question_id) ".
701  "VALUES( ".
702  $ilDB->quote($next_id,'integer').", ".
703  $ilDB->quote($this->getObjectiveId() ,'integer').", ".
704  $ilDB->quote($this->getTestRefId() ,'integer').", ".
705  $ilDB->quote($this->getTestObjId() ,'integer').", ".
706  $ilDB->quote($this->getQuestionId() ,'integer').
707  ")";
708  $res = $ilDB->manipulate($query);
709 
710  $this->__addTest();
711 
712  $this->__read();
713 
714  return true;
715  }
global $ilDB
+ 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 114 of file class.ilCourseObjectiveQuestion.php.

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

115  {
116  global $ilObjDataCache,$ilLog,$ilDB;
117 
118  include_once('Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
119  $cwo = ilCopyWizardOptions::_getInstance($a_copy_id);
120  $mappings = $cwo->getMappings();
121  foreach($this->getQuestions() as $question)
122  {
123  $mapping_key = $question['ref_id'].'_question_'.$question['question_id'];
124  if(!isset($mappings[$mapping_key]) or !$mappings[$mapping_key])
125  {
126  continue;
127  }
128  $question_ref_id = $question['ref_id'];
129  $question_obj_id = $question['obj_id'];
130  $question_qst_id = $question['question_id'];
131  $new_ref_id = $mappings[$question_ref_id];
132  $new_obj_id = $ilObjDataCache->lookupObjId($new_ref_id);
133 
134  if($new_obj_id == $question_obj_id)
135  {
136  ilLoggerFactory::getLogger('crs')->info('Test has been linked. Keeping question id');
137  // Object has been linked
138  $new_question_id = $question_qst_id;
139  }
140  else
141  {
142  $new_question_info = $mappings[$question_ref_id.'_question_'.$question_qst_id];
143  $new_question_arr = explode('_',$new_question_info);
144  if(!isset($new_question_arr[2]) or !$new_question_arr[2])
145  {
146  ilLoggerFactory::getLogger('crs')->debug('found invalid format of question id mapping: ' . print_r($new_question_arr,TRUE));
147  continue;
148  }
149  $new_question_id = $new_question_arr[2];
150  ilLoggerFactory::getLogger('crs')->info('New question id is: '.$new_question_id);
151  }
152 
153  ilLoggerFactory::getLogger('crs')->debug('Copying question assignments');
154  $new_question = new ilCourseObjectiveQuestion($a_new_objective);
155  $new_question->setTestRefId($new_ref_id);
156  $new_question->setTestObjId($new_obj_id);
157  $new_question->setQuestionId($new_question_id);
158  $new_question->add();
159  }
160 
161  // Copy tests
162  foreach($this->getTests() as $test)
163  {
164  $new_test_id = $mappings["$test[ref_id]"];
165 
166  $query = "UPDATE crs_objective_tst ".
167  "SET tst_status = ".$this->db->quote($test['tst_status'] ,'integer').", ".
168  "tst_limit_p = ".$this->db->quote($test['tst_limit'] ,'integer')." ".
169  "WHERE objective_id = ".$this->db->quote($a_new_objective ,'integer')." ".
170  "AND ref_id = ".$this->db->quote($new_test_id ,'integer');
171  $res = $ilDB->manipulate($query);
172  }
173  }
static _getInstance($a_copy_id)
Get instance of copy wizard options.
global $ilDB
static getLogger($a_component_id)
Get component logger.
class ilcourseobjectiveQuestion
$test
Definition: Utf8Test.php:84
+ Here is the call graph for this function:

◆ delete()

ilCourseObjectiveQuestion::delete (   $qst_id)

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

References $ilDB, $query, $res, $row, __deleteTest(), ilDBConstants\FETCHMODE_OBJECT, and getObjectiveId().

717  {
718  global $ilDB;
719 
720  if(!$qst_id)
721  {
722  return false;
723  }
724 
725  $query = "SELECT * FROM crs_objective_qst ".
726  "WHERE qst_ass_id = ".$ilDB->quote($qst_id ,'integer')." ";
727 
728  $res = $this->db->query($query);
729  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
730  {
731  $test_rid = $row->ref_id;
732  $test_oid = $row->obj_id;
733  }
734 
735  $query = "DELETE FROM crs_objective_qst ".
736  "WHERE qst_ass_id = ".$ilDB->quote($qst_id ,'integer')." ";
737  $res = $ilDB->manipulate($query);
738 
739  // delete test if it was the last question
740  $query = "SELECT * FROM crs_objective_qst ".
741  "WHERE ref_id = ".$ilDB->quote($test_rid ,'integer')." ".
742  "AND obj_id = ".$ilDB->quote($test_oid ,'integer')." ".
743  "AND objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
744 
745  $res = $this->db->query($query);
746  if(!$res->numRows())
747  {
748  $this->__deleteTest($test_rid);
749  }
750 
751  return true;
752  }
global $ilDB
+ Here is the call graph for this function:

◆ deleteAll()

ilCourseObjectiveQuestion::deleteAll ( )

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

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

801  {
802  global $ilDB;
803 
804  $query = "DELETE FROM crs_objective_qst ".
805  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
806  $res = $ilDB->manipulate($query);
807 
808  $query = "DELETE FROM crs_objective_tst ".
809  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ";
810  $res = $ilDB->manipulate($query);
811 
812  return true;
813  }
global $ilDB
+ Here is the call graph for this function:

◆ deleteByTestType()

ilCourseObjectiveQuestion::deleteByTestType (   $a_type)

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

References $a_type, $ilDB, $query, array, and getObjectiveId().

770  {
771  global $ilDB;
772 
773 
774  // Read tests by type
775  $deletable_refs = array();
776  foreach((array) $this->tests as $tst_data)
777  {
778  if($tst_data['status'] == $a_type)
779  {
780  $deletable_refs[] = $tst_data['ref_id'];
781  }
782  }
783 
784  $query = 'DELETE from crs_objective_tst '.
785  'WHERE objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer').' '.
786  'AND tst_status = '.$ilDB->quote($a_type,'integer');
787  $ilDB->manipulate($query);
788 
789 
790  $query = 'DELETE from crs_objective_tst '.
791  'WHERE objective_id = '.$ilDB->quote($this->getObjectiveId(),'integer').' '.
792  'AND '.$ilDB->in('ref_id',$deletable_refs,false,'integer');
793  $ilDB->manipulate($query);
794 
795  return true;
796  }
$a_type
Definition: workflow.php:93
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ deleteTest()

static ilCourseObjectiveQuestion::deleteTest (   $a_tst_ref_id)
static

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

References $ilDB, and $query.

Referenced by ilLOEditorGUI\deleteTest(), and ilLOEditorGUI\deleteTests().

756  {
757  global $ilDB;
758 
759  $query = 'DELETE FROM crs_objective_tst '.
760  'WHERE ref_id = '.$ilDB->quote($a_tst_ref_id,'integer');
761  $ilDB->manipulate($query);
762 
763  $query = 'DELETE FROM crs_objective_qst '.
764  'WHERE ref_id = '.$ilDB->quote($a_tst_ref_id,'integer');
765  $ilDB->manipulate($query);
766  }
global $ilDB
+ Here is the caller graph for this function:

◆ getFinalTestPoints()

ilCourseObjectiveQuestion::getFinalTestPoints ( )

get final test points

public

Returns

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

References getFinalTestQuestions().

Referenced by updateLimits().

443  {
444  foreach($this->getFinalTestQuestions() as $question)
445  {
446  $points += $question['points'];
447  }
448  return $points ? $points : 0;
449  }
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 495 of file class.ilCourseObjectiveQuestion.php.

References array.

Referenced by getFinalTestPoints().

496  {
497  foreach($this->questions as $question)
498  {
499  if($question['test_type'] == self::TYPE_FINAL_TEST)
500  {
501  $final[] = $question;
502  }
503  }
504  return $final ? $final : array();
505  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getFinalTests()

ilCourseObjectiveQuestion::getFinalTests ( )

get final tests

public

Returns

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

References $test, and array.

365  {
366  foreach($this->tests as $test)
367  {
368  if($test['status'] == self::TYPE_FINAL_TEST)
369  {
370  $final[] = $test;
371  }
372  }
373  return $final ? $final : array();
374  }
Create styles array
The data for the language used.
$test
Definition: Utf8Test.php:84

◆ getMaxPointsByObjective()

ilCourseObjectiveQuestion::getMaxPointsByObjective ( )

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

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

565  {
566  include_once './Modules/Test/classes/class.ilObjTest.php';
567 
568  $points = 0;
569  foreach($this->getQuestions() as $question)
570  {
571  $tmp_test =& ilObjectFactory::getInstanceByRefId($question['ref_id']);
572 
573  $tmp_question =& ilObjTest::_instanciateQuestion($question['question_id']);
574 
575  $points += $tmp_question->getMaximumPoints();
576 
577  unset($tmp_question);
578  unset($tmp_test);
579  }
580  return $points;
581  }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ getMaxPointsByTest()

ilCourseObjectiveQuestion::getMaxPointsByTest (   $a_test_ref_id)

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

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

584  {
585  $points = 0;
586 
587  $tmp_test =& ilObjectFactory::getInstanceByRefId($a_test_ref_id);
588 
589  foreach($this->getQuestions() as $question)
590  {
591  if($question['ref_id'] == $a_test_ref_id)
592  {
593  $tmp_question =& ilObjTest::_instanciateQuestion($question['question_id']);
594 
595  $points += $tmp_question->getMaximumPoints();
596 
597  unset($tmp_question);
598  }
599  }
600  unset($tmp_test);
601 
602  return $points;
603  }
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
+ Here is the call graph for this function:

◆ getNumberOfQuestionsByTest()

ilCourseObjectiveQuestion::getNumberOfQuestionsByTest (   $a_test_ref_id)

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

References $counter, and getQuestions().

621  {
622  $counter = 0;
623 
624  foreach($this->getQuestions() as $question)
625  {
626  if($question['ref_id'] == $a_test_ref_id)
627  {
628  ++$counter;
629  }
630  }
631  return $counter;
632  }
$counter
+ Here is the call graph for this function:

◆ getObjectiveId()

ilCourseObjectiveQuestion::getObjectiveId ( )

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

References $objective_id.

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

+ Here is the caller graph for this function:

◆ getQuestion()

ilCourseObjectiveQuestion::getQuestion (   $question_id)

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

References array.

529  {
530  return $this->questions[$question_id] ? $this->questions[$question_id] : array();
531  }
Create styles array
The data for the language used.

◆ getQuestionId()

ilCourseObjectiveQuestion::getQuestionId ( )

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

Referenced by add().

559  {
560  return $this->question_id;
561  }
+ Here is the caller graph for this function:

◆ getQuestions()

ilCourseObjectiveQuestion::getQuestions ( )

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

References array.

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

399  {
400  return $this->questions ? $this->questions : array();
401  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getQuestionsByTest()

ilCourseObjectiveQuestion::getQuestionsByTest (   $a_test_ref_id)

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

References array, and getQuestions().

Referenced by toXml().

635  {
636  foreach($this->getQuestions() as $question)
637  {
638  if($question['ref_id'] == $a_test_ref_id)
639  {
640  $qst[] = $question['question_id'];
641  }
642  }
643  return $qst ? $qst : array();
644  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionsOfTest()

ilCourseObjectiveQuestion::getQuestionsOfTest (   $a_test_id)

Get questions of test.

public

Parameters
inttest id

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

References $questions, array, and getQuestions().

517  {
518  foreach($this->getQuestions() as $qst)
519  {
520  if($a_test_id == $qst['obj_id'])
521  {
522  $questions[] = $qst;
523  }
524  }
525  return $questions ? $questions : array();
526  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getSelfAssessmentPoints()

ilCourseObjectiveQuestion::getSelfAssessmentPoints ( )

get self assessment points

public

Returns

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

References getSelfAssessmentQuestions().

Referenced by updateLimits().

428  {
429  foreach($this->getSelfAssessmentQuestions() as $question)
430  {
431  $points += $question['points'];
432  }
433  return $points ? $points : 0;
434  }
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 409 of file class.ilCourseObjectiveQuestion.php.

References array, and TYPE_SELF_ASSESSMENT.

Referenced by getSelfAssessmentPoints().

410  {
411  foreach($this->questions as $question)
412  {
413  if($question['test_type'] == self::TYPE_SELF_ASSESSMENT)
414  {
415  $self[] = $question;
416  }
417  }
418  return $self ? $self : array();
419  }
Create styles array
The data for the language used.
const TYPE_SELF_ASSESSMENT
+ Here is the caller graph for this function:

◆ getSelfAssessmentTests()

ilCourseObjectiveQuestion::getSelfAssessmentTests ( )

get self assessment tests

public

Parameters

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

References $test, array, and TYPE_SELF_ASSESSMENT.

347  {
348  foreach($this->tests as $test)
349  {
350  if($test['status'] == self::TYPE_SELF_ASSESSMENT)
351  {
352  $self[] = $test;
353  }
354  }
355  return $self ? $self : array();
356  }
Create styles array
The data for the language used.
const TYPE_SELF_ASSESSMENT
$test
Definition: Utf8Test.php:84

◆ getTestObjId()

ilCourseObjectiveQuestion::getTestObjId ( )

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

Referenced by __addTest(), and add().

551  {
552  return $this->tst_obj_id ? $this->tst_obj_id : 0;
553  }
+ Here is the caller graph for this function:

◆ getTestRefId()

ilCourseObjectiveQuestion::getTestRefId ( )

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

Referenced by __addTest(), and add().

543  {
544  return $this->tst_ref_id ? $this->tst_ref_id : 0;
545  }
+ Here is the caller graph for this function:

◆ getTests()

ilCourseObjectiveQuestion::getTests ( )

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

References $ilDB, $query, $res, $row, $test, $tests, array, ilDBConstants\FETCHMODE_OBJECT, and getObjectiveId().

Referenced by cloneDependencies(), and toXml().

314  {
315  global $ilDB;
316 
317  $query = "SELECT * FROM crs_objective_tst cot ".
318  "JOIN object_data obd ON cot.obj_id = obd.obj_id ".
319  "WHERE objective_id = ".$ilDB->quote($this->getObjectiveId() ,'integer')." ".
320  "ORDER BY title ";
321 
322  $res = $this->db->query($query);
323  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
324  {
325  $test['test_objective_id'] = $row->test_objective_id;
326  $test['objective_id'] = $row->objective_id;
327  $test['ref_id'] = $row->ref_id;
328  $test['obj_id'] = $row->obj_id;
329  $test['tst_status'] = $row->tst_status;
330  $test['tst_limit'] = $row->tst_limit_p;
331  $test['title'] = $row->title;
332 
333  $tests[] = $test;
334  }
335 
336  return $tests ? $tests : array();
337  }
Create styles array
The data for the language used.
global $ilDB
$test
Definition: Utf8Test.php:84
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTestStatus()

ilCourseObjectiveQuestion::getTestStatus ( )

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

Referenced by __addTest(), and updateTest().

196  {
197  return (int) $this->tst_status;
198  }
+ Here is the caller graph for this function:

◆ getTestSuggestedLimit()

ilCourseObjectiveQuestion::getTestSuggestedLimit ( )

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

Referenced by updateTest().

204  {
205  return (int) $this->tst_limit;
206  }
+ 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 476 of file class.ilCourseObjectiveQuestion.php.

477  {
478  foreach($this->questions as $question)
479  {
480  if($question['question_id'] == $a_question_id)
481  {
482  return $question['test_type'] == self::TYPE_FINAL_TEST;
483  }
484  }
485  return false;
486 
487  }

◆ isSelfAssessmentQuestion()

ilCourseObjectiveQuestion::isSelfAssessmentQuestion (   $a_question_id)

check if question is self assessment question

Parameters
intquestion id public
Returns

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

References TYPE_SELF_ASSESSMENT.

458  {
459  foreach($this->questions as $question)
460  {
461  if($question['question_id'] == $a_question_id)
462  {
463  return $question['test_type'] == self::TYPE_SELF_ASSESSMENT;
464  }
465  }
466  return false;
467  }
const TYPE_SELF_ASSESSMENT

◆ lookupObjectivesOfQuestion()

static ilCourseObjectiveQuestion::lookupObjectivesOfQuestion (   $a_qid)
static

Lookup objective for test question type $ilDB.

Parameters
type$a_test_ref_id
type$a_qid
Returns
int

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

References $ilDB, $query, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilLOTestQuestionAdapter\lookupObjectiveIdByFixedQuestionId().

70  {
71  global $ilDB;
72 
73  $query = 'SELECT objective_id FROM crs_objective_qst '.
74  'WHERE question_id = '.$ilDB->quote($a_qid,'integer');
75  $res = $ilDB->query($query);
76  $objectiveIds = array();
77  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
78  {
79  $objectiveIds[] = $row->objective_id;
80  }
81  return $objectiveIds;
82  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ lookupQuestionsByObjective()

static ilCourseObjectiveQuestion::lookupQuestionsByObjective (   $a_test_id,
  $a_objective 
)
static

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

References $ilDB, $query, $questions, $res, $row, array, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilLOEditorStatus\lookupQuestionsAssigned(), and ilLOTestQuestionAdapter\updateFixedQuestions().

916  {
917  global $ilDB;
918 
919  $query = 'SELECT question_id FROM crs_objective_qst '.
920  'WHERE objective_id = '.$ilDB->quote($a_objective,'integer').' '.
921  'AND obj_id = '.$ilDB->quote($a_test_id,'integer');
922  $res = $ilDB->query($query);
923 
924  $questions = array();
925  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
926  {
927  $questions[] = $row->question_id;
928  }
929  return (array) $questions;
930  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ loookupTestLimit()

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

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

References $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilLOUtils\lookupObjectiveRequiredPercentage().

933  {
934  global $ilDB;
935 
936  $query = 'SELECT tst_limit_p FROM crs_objective_tst '.
937  'WHERE objective_id = '.$ilDB->quote($a_objective_id,'integer').' '.
938  'AND obj_id = '.$ilDB->quote($a_test_id,'integer');
939  $res = $ilDB->query($query);
940  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
941  {
942  return (int) $row->tst_limit_p;
943  }
944  return 0;
945  }
global $ilDB
+ Here is the caller graph for this function:

◆ setQuestionId()

ilCourseObjectiveQuestion::setQuestionId (   $a_question_id)

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

555  {
556  $this->question_id = $a_question_id;
557  }

◆ setTestObjId()

ilCourseObjectiveQuestion::setTestObjId (   $a_obj_id)

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

547  {
548  $this->tst_obj_id = $a_obj_id;
549  }

◆ setTestRefId()

ilCourseObjectiveQuestion::setTestRefId (   $a_ref_id)

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

539  {
540  $this->tst_ref_id = $a_ref_id;
541  }

◆ setTestStatus()

ilCourseObjectiveQuestion::setTestStatus (   $a_status)

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

192  {
193  $this->tst_status = $a_status;
194  }

◆ setTestSuggestedLimit()

ilCourseObjectiveQuestion::setTestSuggestedLimit (   $a_limit)

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

200  {
201  $this->tst_limit = $a_limit;
202  }

◆ toXml()

ilCourseObjectiveQuestion::toXml ( ilXmlWriter  $writer)

To xml.

Parameters
ilXmlWriter$writer

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

References $test, array, getQuestionsByTest(), getTests(), ilLOXmlWriter\TYPE_TST_ALL, ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

952  {
953  foreach($this->getTests() as $test)
954  {
955  include_once './Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
956  $writer->xmlStartTag(
957  'Test',
958  array(
959  'type' => ilLOXmlWriter::TYPE_TST_ALL,
960  'refId' => $test['ref_id'],
961  'testType' => $test['tst_status'],
962  'limit' => $test['tst_limit']
963  )
964  );
965 
966  // questions
967  foreach($this->getQuestionsByTest($test['ref_id']) as $question_id)
968  {
969  $writer->xmlElement('Question', array('id' => $question_id));
970  }
971  $writer->xmlEndTag('Test');
972  }
973 
974  }
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
xmlEndTag($tag)
Writes an endtag.
Create styles array
The data for the language used.
$test
Definition: Utf8Test.php:84
+ Here is the call graph for this function:

◆ updateLimits()

ilCourseObjectiveQuestion::updateLimits ( )

update limits

public

Parameters

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

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

654  {
655  global $ilDB;
656 
657  foreach($this->tests as $ref_id => $test_data)
658  {
659  switch($test_data['status'])
660  {
662  $points = $this->getSelfAssessmentPoints();
663  break;
664 
665  case self::TYPE_FINAL_TEST:
666  $points = $this->getFinalTestPoints();
667  break;
668  }
669  if($test_data['limit'] == -1 or $test_data['limit'] > $points)
670  {
671  switch($test_data['status'])
672  {
674  $points = $this->getSelfAssessmentPoints();
675  break;
676 
677  case self::TYPE_FINAL_TEST:
678  $points = $this->getFinalTestPoints();
679  break;
680  }
681  $query = "UPDATE crs_objective_tst ".
682  "SET tst_limit = ".$this->db->quote($points ,'integer')." ".
683  "WHERE test_objective_id = ".$this->db->quote($test_data['test_objective_id'] ,'integer')." ";
684  $res = $ilDB->manipulate($query);
685  }
686  }
687  }
getSelfAssessmentPoints()
get self assessment points
$ref_id
Definition: sahs_server.php:39
global $ilDB
const TYPE_SELF_ASSESSMENT
+ Here is the call graph for this function:

◆ updateTest()

ilCourseObjectiveQuestion::updateTest (   $a_objective_id)

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

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

301  {
302  global $ilDB;
303 
304  $query = "UPDATE crs_objective_tst ".
305  "SET tst_status = ".$ilDB->quote($this->getTestStatus() ,'integer').", ".
306  "tst_limit_p = ".$ilDB->quote($this->getTestSuggestedLimit() ,'integer')." ".
307  "WHERE test_objective_id = ".$ilDB->quote($a_objective_id ,'integer')."";
308  $res = $ilDB->manipulate($query);
309 
310  return true;
311  }
global $ilDB
+ 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

◆ $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: