ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 199 of file class.ilCourseObjectiveQuestion.php.

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

Referenced by add().

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

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

Referenced by __read(), and delete().

248  {
249  global $ilDB;
250 
251  // Delete questions
252  $query = "DELETE FROM crs_objective_qst " .
253  "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " .
254  "AND ref_id = " . $ilDB->quote($a_test_ref_id, 'integer') . " ";
255  $res = $ilDB->manipulate($query);
256 
257  // delete tst entries
258  $query = "DELETE FROM crs_objective_tst " .
259  "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " .
260  "AND ref_id = " . $ilDB->quote($a_test_ref_id, 'integer') . " ";
261  $res = $ilDB->manipulate($query);
262 
263  unset($this->tests[$a_test_ref_id]);
264 
265  return true;
266  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __read()

ilCourseObjectiveQuestion::__read ( )

Definition at line 772 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().

773  {
774  global $ilDB,$tree;
775 
776  include_once './Modules/Test/classes/class.ilObjTest.php';
777  include_once('Modules/Course/classes/class.ilCourseObjective.php');
778 
779  $container_ref_ids = ilObject::_getAllReferences(ilCourseObjective::_lookupContainerIdByObjectiveId($this->objective_id));
780  $container_ref_id = current($container_ref_ids);
781 
782  // Read test data
783  $query = "SELECT * FROM crs_objective_tst " .
784  "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " ";
785  $res = $this->db->query($query);
786  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
787  $this->tests[$row->ref_id]['test_objective_id'] = $row->test_objective_id;
788  $this->tests[$row->ref_id]['ref_id'] = $row->ref_id;
789  $this->tests[$row->ref_id]['obj_id'] = $row->obj_id;
790  $this->tests[$row->ref_id]['status'] = $row->tst_status;
791  $this->tests[$row->ref_id]['limit'] = $row->tst_limit_p;
792  }
793 
794  $this->questions = array();
795  $query = "SELECT * FROM crs_objective_qst coq " .
796  "JOIN qpl_questions qq ON coq.question_id = qq.question_id " .
797  "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " .
798  "ORDER BY title";
799 
800  $res = $this->db->query($query);
801  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
802  if (!$tree->isInTree($row->ref_id) or !$tree->isGrandChild($container_ref_id, $row->ref_id)) {
803  $this->__deleteTest($row->ref_id);
804  continue;
805  }
806  if (!$question = ilObjTest::_instanciateQuestion($row->question_id)) {
807  $this->delete($row->question_id);
808  continue;
809  }
810 
811  $qst['ref_id'] = $row->ref_id;
812  $qst['obj_id'] = $row->obj_id;
813  $qst['question_id'] = $row->question_id;
814  $qst['qst_ass_id'] = $row->qst_ass_id;
815  $qst['title'] = $question->getTitle();
816  $qst['description'] = $question->getComment();
817  $qst['test_type'] = $this->tests[$row->ref_id]['status'];
818  $qst['points'] = $question->getPoints();
819 
820  $this->questions[$row->qst_ass_id] = $qst;
821  }
822 
823  return true;
824  }
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.
foreach($_POST as $key=> $value) $res
$query
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 175 of file class.ilCourseObjectiveQuestion.php.

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

176  {
177  global $tree;
178 
179  return $tree->getSubTree($tree->getNodeData($a_container_ref_id), true, 'tst');
180  }
+ Here is the caller graph for this function:

◆ _getTest()

static ilCourseObjectiveQuestion::_getTest (   $a_test_objective_id)
static

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

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

362  {
363  global $ilDB;
364 
365  $query = "SELECT * FROM crs_objective_tst " .
366  "WHERE test_objective_id = " . $ilDB->quote($a_test_objective_id, 'integer') . " ";
367 
368  $res = $ilDB->query($query);
369  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
370  $test['test_objective_id'] = $row->test_objective_id;
371  $test['objective_id'] = $row->objective_id;
372  $test['ref_id'] = $row->ref_id;
373  $test['obj_id'] = $row->obj_id;
374  $test['tst_status'] = $row->tst_status;
375  $test['tst_limit'] = $row->tst_limit_p;
376  }
377 
378  return $test ? $test : array();
379  }
foreach($_POST as $key=> $value) $res
$query
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 834 of file class.ilCourseObjectiveQuestion.php.

References $ilDB, $query, and $res.

Referenced by ilCourseObjectivesGUI\setSubTabs().

835  {
836  global $ilDB;
837 
838  $query = "SELECT co.objective_id FROM crs_objectives co JOIN " .
839  "crs_objective_tst cot ON co.objective_id = cot.objective_id " .
840  "WHERE crs_id = " . $ilDB->quote($a_course_id, 'integer') . " ";
841  $res = $ilDB->query($query);
842  return $res->numRows() ? true : false;
843  }
foreach($_POST as $key=> $value) $res
$query
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 846 of file class.ilCourseObjectiveQuestion.php.

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

847  {
848  global $ilDB;
849 
850  $query = "SELECT crs_qst.objective_id objective_id FROM crs_objective_qst crs_qst, crs_objectives crs_obj " .
851  "WHERE crs_qst.objective_id = crs_obj.objective_id " .
852  "AND crs_qst.objective_id = " . $ilDB->quote($a_objective_id, 'integer') . " " .
853  "AND ref_id = " . $ilDB->quote($a_tst_ref_id, 'integer') . " " .
854  "AND question_id = " . $ilDB->quote($a_question_id, 'integer') . " ";
855 
856  $res = $ilDB->query($query);
857  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
858  $objective_id = $row->objective_id;
859  }
860 
861  return $objective_id ? $objective_id : 0;
862  }
foreach($_POST as $key=> $value) $res
$query
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 93 of file class.ilCourseObjectiveQuestion.php.

References $ilDB, $query, and $res.

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

◆ _lookupMaximumPointsOfQuestion()

static ilCourseObjectiveQuestion::_lookupMaximumPointsOfQuestion (   $a_question_id)
static

lookup maximimum point

public

Parameters
intquestion id
Returns

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

References assQuestion\_getMaximumPoints().

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

582  {
583  include_once('Modules/TestQuestionPool/classes/class.assQuestion.php');
584  return assQuestion::_getMaximumPoints($a_question_id);
585  }
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 278 of file class.ilCourseObjectiveQuestion.php.

References $ilDB, $query, and $res.

Referenced by ilCourseObjectivesGUI\saveQuestionOverview().

279  {
280  global $ilDB;
281 
282  $query = "UPDATE crs_objective_tst " .
283  "SET tst_limit_p = " . $ilDB->quote($a_limit, 'integer') . " " .
284  "WHERE tst_status = " . $ilDB->quote($a_status, 'integer') . " " .
285  "AND objective_id = " . $ilDB->quote($a_objective_id, 'integer');
286  $res = $ilDB->manipulate($query);
287  return true;
288  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ add()

ilCourseObjectiveQuestion::add ( )

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

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

651  {
652  global $ilDB;
653 
654  $query = "DELETE FROM crs_objective_qst " .
655  "WHERE objective_id = " . $this->db->quote($this->getObjectiveId(), 'integer') . " " .
656  "AND question_id = " . $this->db->quote($this->getQuestionId(), 'integer') . " ";
657  $res = $ilDB->manipulate($query);
658 
659  $next_id = $ilDB->nextId('crs_objective_qst');
660  $query = "INSERT INTO crs_objective_qst (qst_ass_id, objective_id,ref_id,obj_id,question_id) " .
661  "VALUES( " .
662  $ilDB->quote($next_id, 'integer') . ", " .
663  $ilDB->quote($this->getObjectiveId(), 'integer') . ", " .
664  $ilDB->quote($this->getTestRefId(), 'integer') . ", " .
665  $ilDB->quote($this->getTestObjId(), 'integer') . ", " .
666  $ilDB->quote($this->getQuestionId(), 'integer') .
667  ")";
668  $res = $ilDB->manipulate($query);
669 
670  $this->__addTest();
671 
672  $this->__read();
673 
674  return true;
675  }
foreach($_POST as $key=> $value) $res
$query
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 113 of file class.ilCourseObjectiveQuestion.php.

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

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

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

677  {
678  global $ilDB;
679 
680  if (!$qst_id) {
681  return false;
682  }
683 
684  $query = "SELECT * FROM crs_objective_qst " .
685  "WHERE qst_ass_id = " . $ilDB->quote($qst_id, 'integer') . " ";
686 
687  $res = $this->db->query($query);
688  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
689  $test_rid = $row->ref_id;
690  $test_oid = $row->obj_id;
691  }
692 
693  $query = "DELETE FROM crs_objective_qst " .
694  "WHERE qst_ass_id = " . $ilDB->quote($qst_id, 'integer') . " ";
695  $res = $ilDB->manipulate($query);
696 
697  // delete test if it was the last question
698  $query = "SELECT * FROM crs_objective_qst " .
699  "WHERE ref_id = " . $ilDB->quote($test_rid, 'integer') . " " .
700  "AND obj_id = " . $ilDB->quote($test_oid, 'integer') . " " .
701  "AND objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " ";
702 
703  $res = $this->db->query($query);
704  if (!$res->numRows()) {
705  $this->__deleteTest($test_rid);
706  }
707 
708  return true;
709  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ deleteAll()

ilCourseObjectiveQuestion::deleteAll ( )

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

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

756  {
757  global $ilDB;
758 
759  $query = "DELETE FROM crs_objective_qst " .
760  "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " ";
761  $res = $ilDB->manipulate($query);
762 
763  $query = "DELETE FROM crs_objective_tst " .
764  "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " ";
765  $res = $ilDB->manipulate($query);
766 
767  return true;
768  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the call graph for this function:

◆ deleteByTestType()

ilCourseObjectiveQuestion::deleteByTestType (   $a_type)

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

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

727  {
728  global $ilDB;
729 
730 
731  // Read tests by type
732  $deletable_refs = array();
733  foreach ((array) $this->tests as $tst_data) {
734  if ($tst_data['status'] == $a_type) {
735  $deletable_refs[] = $tst_data['ref_id'];
736  }
737  }
738 
739  $query = 'DELETE from crs_objective_tst ' .
740  'WHERE objective_id = ' . $ilDB->quote($this->getObjectiveId(), 'integer') . ' ' .
741  'AND tst_status = ' . $ilDB->quote($a_type, 'integer');
742  $ilDB->manipulate($query);
743 
744 
745  $query = 'DELETE from crs_objective_tst ' .
746  'WHERE objective_id = ' . $ilDB->quote($this->getObjectiveId(), 'integer') . ' ' .
747  'AND ' . $ilDB->in('ref_id', $deletable_refs, false, 'integer');
748  $ilDB->manipulate($query);
749 
750  return true;
751  }
$a_type
Definition: workflow.php:92
$query
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 712 of file class.ilCourseObjectiveQuestion.php.

References $ilDB, and $query.

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

713  {
714  global $ilDB;
715 
716  $query = 'DELETE FROM crs_objective_tst ' .
717  'WHERE ref_id = ' . $ilDB->quote($a_tst_ref_id, 'integer');
718  $ilDB->manipulate($query);
719 
720  $query = 'DELETE FROM crs_objective_qst ' .
721  'WHERE ref_id = ' . $ilDB->quote($a_tst_ref_id, 'integer');
722  $ilDB->manipulate($query);
723  }
$query
global $ilDB
+ Here is the caller graph for this function:

◆ getFinalTestPoints()

ilCourseObjectiveQuestion::getFinalTestPoints ( )

get final test points

public

Returns

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

References getFinalTestQuestions().

Referenced by updateLimits().

424  {
425  foreach ($this->getFinalTestQuestions() as $question) {
426  $points += $question['points'];
427  }
428  return $points ? $points : 0;
429  }
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 470 of file class.ilCourseObjectiveQuestion.php.

References array.

Referenced by getFinalTestPoints().

471  {
472  foreach ($this->questions as $question) {
473  if ($question['test_type'] == self::TYPE_FINAL_TEST) {
474  $final[] = $question;
475  }
476  }
477  return $final ? $final : array();
478  }
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 351 of file class.ilCourseObjectiveQuestion.php.

References $test, and array.

352  {
353  foreach ($this->tests as $test) {
354  if ($test['status'] == self::TYPE_FINAL_TEST) {
355  $final[] = $test;
356  }
357  }
358  return $final ? $final : array();
359  }
Create styles array
The data for the language used.
$test
Definition: Utf8Test.php:84

◆ getMaxPointsByObjective()

ilCourseObjectiveQuestion::getMaxPointsByObjective ( )

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

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

536  {
537  include_once './Modules/Test/classes/class.ilObjTest.php';
538 
539  $points = 0;
540  foreach ($this->getQuestions() as $question) {
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  }
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 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  if ($question['ref_id'] == $a_test_ref_id) {
561  $tmp_question =&ilObjTest::_instanciateQuestion($question['question_id']);
562 
563  $points += $tmp_question->getMaximumPoints();
564 
565  unset($tmp_question);
566  }
567  }
568  unset($tmp_test);
569 
570  return $points;
571  }
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 588 of file class.ilCourseObjectiveQuestion.php.

References $counter, and getQuestions().

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

◆ getObjectiveId()

ilCourseObjectiveQuestion::getObjectiveId ( )

Definition at line 504 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 499 of file class.ilCourseObjectiveQuestion.php.

References array.

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

◆ getQuestionId()

ilCourseObjectiveQuestion::getQuestionId ( )

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

Referenced by add().

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

◆ getQuestions()

ilCourseObjectiveQuestion::getQuestions ( )

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

References array.

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

383  {
384  return $this->questions ? $this->questions : array();
385  }
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 600 of file class.ilCourseObjectiveQuestion.php.

References array, and getQuestions().

Referenced by toXml().

601  {
602  foreach ($this->getQuestions() as $question) {
603  if ($question['ref_id'] == $a_test_ref_id) {
604  $qst[] = $question['question_id'];
605  }
606  }
607  return $qst ? $qst : array();
608  }
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 489 of file class.ilCourseObjectiveQuestion.php.

References $questions, array, and getQuestions().

490  {
491  foreach ($this->getQuestions() as $qst) {
492  if ($a_test_id == $qst['obj_id']) {
493  $questions[] = $qst;
494  }
495  }
496  return $questions ? $questions : array();
497  }
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 409 of file class.ilCourseObjectiveQuestion.php.

References getSelfAssessmentQuestions().

Referenced by updateLimits().

410  {
411  foreach ($this->getSelfAssessmentQuestions() as $question) {
412  $points += $question['points'];
413  }
414  return $points ? $points : 0;
415  }
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 393 of file class.ilCourseObjectiveQuestion.php.

References array, and TYPE_SELF_ASSESSMENT.

Referenced by getSelfAssessmentPoints().

394  {
395  foreach ($this->questions as $question) {
396  if ($question['test_type'] == self::TYPE_SELF_ASSESSMENT) {
397  $self[] = $question;
398  }
399  }
400  return $self ? $self : array();
401  }
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 335 of file class.ilCourseObjectiveQuestion.php.

References $test, array, and TYPE_SELF_ASSESSMENT.

336  {
337  foreach ($this->tests as $test) {
338  if ($test['status'] == self::TYPE_SELF_ASSESSMENT) {
339  $self[] = $test;
340  }
341  }
342  return $self ? $self : array();
343  }
Create styles array
The data for the language used.
const TYPE_SELF_ASSESSMENT
$test
Definition: Utf8Test.php:84

◆ getTestObjId()

ilCourseObjectiveQuestion::getTestObjId ( )

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

Referenced by __addTest(), and add().

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

◆ getTestRefId()

ilCourseObjectiveQuestion::getTestRefId ( )

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

Referenced by __addTest(), and add().

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

◆ getTests()

ilCourseObjectiveQuestion::getTests ( )

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

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

Referenced by cloneDependencies(), and toXml().

304  {
305  global $ilDB;
306 
307  $query = "SELECT * FROM crs_objective_tst cot " .
308  "JOIN object_data obd ON cot.obj_id = obd.obj_id " .
309  "WHERE objective_id = " . $ilDB->quote($this->getObjectiveId(), 'integer') . " " .
310  "ORDER BY title ";
311 
312  $res = $this->db->query($query);
313  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
314  $test['test_objective_id'] = $row->test_objective_id;
315  $test['objective_id'] = $row->objective_id;
316  $test['ref_id'] = $row->ref_id;
317  $test['obj_id'] = $row->obj_id;
318  $test['tst_status'] = $row->tst_status;
319  $test['tst_limit'] = $row->tst_limit_p;
320  $test['title'] = $row->title;
321 
322  $tests[] = $test;
323  }
324 
325  return $tests ? $tests : array();
326  }
foreach($_POST as $key=> $value) $res
$query
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 187 of file class.ilCourseObjectiveQuestion.php.

Referenced by __addTest(), and updateTest().

188  {
189  return (int) $this->tst_status;
190  }
+ Here is the caller graph for this function:

◆ getTestSuggestedLimit()

ilCourseObjectiveQuestion::getTestSuggestedLimit ( )

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

Referenced by updateTest().

196  {
197  return (int) $this->tst_limit;
198  }
+ 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 454 of file class.ilCourseObjectiveQuestion.php.

455  {
456  foreach ($this->questions as $question) {
457  if ($question['question_id'] == $a_question_id) {
458  return $question['test_type'] == self::TYPE_FINAL_TEST;
459  }
460  }
461  return false;
462  }

◆ isSelfAssessmentQuestion()

ilCourseObjectiveQuestion::isSelfAssessmentQuestion (   $a_question_id)

check if question is self assessment question

Parameters
intquestion id public
Returns

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

References TYPE_SELF_ASSESSMENT.

438  {
439  foreach ($this->questions as $question) {
440  if ($question['question_id'] == $a_question_id) {
441  return $question['test_type'] == self::TYPE_SELF_ASSESSMENT;
442  }
443  }
444  return false;
445  }
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  $objectiveIds[] = $row->objective_id;
79  }
80  return $objectiveIds;
81  }
foreach($_POST as $key=> $value) $res
$query
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 865 of file class.ilCourseObjectiveQuestion.php.

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

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

866  {
867  global $ilDB;
868 
869  $query = 'SELECT question_id FROM crs_objective_qst ' .
870  'WHERE objective_id = ' . $ilDB->quote($a_objective, 'integer') . ' ' .
871  'AND obj_id = ' . $ilDB->quote($a_test_id, 'integer');
872  $res = $ilDB->query($query);
873 
874  $questions = array();
875  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
876  $questions[] = $row->question_id;
877  }
878  return (array) $questions;
879  }
foreach($_POST as $key=> $value) $res
$query
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 881 of file class.ilCourseObjectiveQuestion.php.

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

Referenced by ilLOUtils\lookupObjectiveRequiredPercentage().

882  {
883  global $ilDB;
884 
885  $query = 'SELECT tst_limit_p FROM crs_objective_tst ' .
886  'WHERE objective_id = ' . $ilDB->quote($a_objective_id, 'integer') . ' ' .
887  'AND obj_id = ' . $ilDB->quote($a_test_id, 'integer');
888  $res = $ilDB->query($query);
889  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
890  return (int) $row->tst_limit_p;
891  }
892  return 0;
893  }
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ Here is the caller graph for this function:

◆ setQuestionId()

ilCourseObjectiveQuestion::setQuestionId (   $a_question_id)

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

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

◆ setTestObjId()

ilCourseObjectiveQuestion::setTestObjId (   $a_obj_id)

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

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

◆ setTestRefId()

ilCourseObjectiveQuestion::setTestRefId (   $a_ref_id)

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

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

◆ setTestStatus()

ilCourseObjectiveQuestion::setTestStatus (   $a_status)

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

184  {
185  $this->tst_status = $a_status;
186  }

◆ setTestSuggestedLimit()

ilCourseObjectiveQuestion::setTestSuggestedLimit (   $a_limit)

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

192  {
193  $this->tst_limit = $a_limit;
194  }

◆ toXml()

ilCourseObjectiveQuestion::toXml ( ilXmlWriter  $writer)

To xml.

Parameters
ilXmlWriter$writer

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

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

900  {
901  foreach ($this->getTests() as $test) {
902  include_once './Modules/Course/classes/Objectives/class.ilLOXmlWriter.php';
903  $writer->xmlStartTag(
904  'Test',
905  array(
906  'type' => ilLOXmlWriter::TYPE_TST_ALL,
907  'refId' => $test['ref_id'],
908  'testType' => $test['tst_status'],
909  'limit' => $test['tst_limit']
910  )
911  );
912 
913  // questions
914  foreach ($this->getQuestionsByTest($test['ref_id']) as $question_id) {
915  $writer->xmlElement('Question', array('id' => $question_id));
916  }
917  $writer->xmlEndTag('Test');
918  }
919  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
xmlEndTag($tag)
Writes an endtag.
Create styles array
The data for the language used.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
$test
Definition: Utf8Test.php:84
+ Here is the call graph for this function:

◆ updateLimits()

ilCourseObjectiveQuestion::updateLimits ( )

update limits

public

Parameters

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

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

618  {
619  global $ilDB;
620 
621  foreach ($this->tests as $ref_id => $test_data) {
622  switch ($test_data['status']) {
624  $points = $this->getSelfAssessmentPoints();
625  break;
626 
627  case self::TYPE_FINAL_TEST:
628  $points = $this->getFinalTestPoints();
629  break;
630  }
631  if ($test_data['limit'] == -1 or $test_data['limit'] > $points) {
632  switch ($test_data['status']) {
634  $points = $this->getSelfAssessmentPoints();
635  break;
636 
637  case self::TYPE_FINAL_TEST:
638  $points = $this->getFinalTestPoints();
639  break;
640  }
641  $query = "UPDATE crs_objective_tst " .
642  "SET tst_limit = " . $this->db->quote($points, 'integer') . " " .
643  "WHERE test_objective_id = " . $this->db->quote($test_data['test_objective_id'], 'integer') . " ";
644  $res = $ilDB->manipulate($query);
645  }
646  }
647  }
getSelfAssessmentPoints()
get self assessment points
foreach($_POST as $key=> $value) $res
$query
global $ilDB
const TYPE_SELF_ASSESSMENT
+ Here is the call graph for this function:

◆ updateTest()

ilCourseObjectiveQuestion::updateTest (   $a_objective_id)

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

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

291  {
292  global $ilDB;
293 
294  $query = "UPDATE crs_objective_tst " .
295  "SET tst_status = " . $ilDB->quote($this->getTestStatus(), 'integer') . ", " .
296  "tst_limit_p = " . $ilDB->quote($this->getTestSuggestedLimit(), 'integer') . " " .
297  "WHERE test_objective_id = " . $ilDB->quote($a_objective_id, 'integer') . "";
298  $res = $ilDB->manipulate($query);
299 
300  return true;
301  }
foreach($_POST as $key=> $value) $res
$query
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: