ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilLOTestQuestionAdapter Class Reference

Test question filter. More...

+ Collaboration diagram for ilLOTestQuestionAdapter:

Public Member Functions

 __construct ($a_user_id, $a_course_id)
 

Static Public Member Functions

static filterQuestions (ilTestSession $a_test_session, ilTestSequence $a_test_sequence)
 Called from learning objective test. More...
 
static updateObjectiveStatus (ilTestSession $a_test_session, ilTestSequence $a_test_sequence, assQuestion $a_question)
 Store result and update objective status. More...
 

Protected Member Functions

 getUserId ()
 
 getContainerId ()
 
 getSettings ()
 Get loc settings. More...
 
 initUserResult (ilTestSession $session)
 init user result More...
 
 isQualifiedStartRun (ilTestSession $session)
 Check if current run is a start object run. More...
 
 updateQuestionResult (ilTestSession $session, assQuestion $qst)
 update question result of run More...
 
 hideQuestions (ilTestSequence $seq)
 Hide questions. More...
 
 initTestRun (ilTestSession $session)
 
 storeTestRun ()
 Store test run in DB. More...
 
 updateQuestions (ilTestSession $session, ilTestSequence $seq)
 
 updateFixedQuestions (ilTestSession $session, ilTestSequence $seq)
 
 updateRandomQuestions (ilTestSession $session, ilTestSequenceRandomQuestionSet $seq)
 
 isInRun ($a_qid)
 

Protected Attributes

 $settings = NULL
 
 $user_id = 0
 
 $container_id = 0
 

Static Private Member Functions

static getQuestionData ($testObjId, $questionIds)
 

Detailed Description

Test question filter.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilLOTestQuestionAdapter.php.

Constructor & Destructor Documentation

◆ __construct()

ilLOTestQuestionAdapter::__construct (   $a_user_id,
  $a_course_id 
)
Parameters
type$a_user_id
type$a_course_id

Definition at line 26 of file class.ilLOTestQuestionAdapter.php.

References ilLOSettings\getInstanceByObjId().

27  {
28  $this->user_id = $a_user_id;
29  $this->container_id = $a_course_id;
30 
31  $this->settings = ilLOSettings::getInstanceByObjId($this->container_id);
32  }
static getInstanceByObjId($a_obj_id)
get singleton instance
+ Here is the call graph for this function:

Member Function Documentation

◆ filterQuestions()

static ilLOTestQuestionAdapter::filterQuestions ( ilTestSession  $a_test_session,
ilTestSequence  $a_test_sequence 
)
static

Called from learning objective test.

Parameters
ilTestSession$a_test_session
ilTestSequence$a_test_sequence

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

References $GLOBALS, ilTestSession\getObjectiveOrientedContainerId(), ilTestSession\getUserId(), and ilTestSequence\saveToDb().

Referenced by ilTestOutputGUI\filterTestSequenceByObjectives().

43  {
44 
45  $adapter = new self(
46  $a_test_session->getUserId(),
47  $a_test_session->getObjectiveOrientedContainerId()
48  );
49  $adapter->initTestRun($a_test_session);
50  $adapter->updateQuestions($a_test_session, $a_test_sequence);
51  $adapter->hideQuestions($a_test_sequence);
52  $adapter->storeTestRun();
53  $adapter->initUserResult($a_test_session);
54 
55  // Save test sequence
56  $a_test_sequence->saveToDb();
57 
58  $GLOBALS['ilLog']->write(__METHOD__.': '.print_r($a_test_sequence,true));
59  return true;
60  }
saveToDb()
Saves the sequence data for a given pass to the database.
$GLOBALS['ct_recipient']
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContainerId()

ilLOTestQuestionAdapter::getContainerId ( )
protected

Definition at line 105 of file class.ilLOTestQuestionAdapter.php.

References $container_id.

Referenced by isQualifiedStartRun().

+ Here is the caller graph for this function:

◆ getQuestionData()

static ilLOTestQuestionAdapter::getQuestionData (   $testObjId,
  $questionIds 
)
staticprivate

Definition at line 406 of file class.ilLOTestQuestionAdapter.php.

References $ilDB, $lng, and ilAssQuestionList\QUESTION_INSTANCE_TYPE_DUPLICATES.

407  {
408  global $ilDB, $lng, $ilPluginAdmin;
409 
410  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
411  $questionList = new ilAssQuestionList($ilDB, $lng, $ilPluginAdmin, $testObjId);
412 
413  $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES);
414  $questionList->setQuestionIdsFilter($questionIds);
415 
416  $questionList->load();
417 
418  return $questionList->getQuestionDataArray();
419  }
global $lng
Definition: privfeed.php:40
global $ilDB

◆ getSettings()

ilLOTestQuestionAdapter::getSettings ( )
protected

Get loc settings.

Returns
ilLOSettings

Definition at line 114 of file class.ilLOTestQuestionAdapter.php.

References $settings.

Referenced by initUserResult(), isQualifiedStartRun(), updateQuestionResult(), and updateRandomQuestions().

+ Here is the caller graph for this function:

◆ getUserId()

ilLOTestQuestionAdapter::getUserId ( )
protected

Definition at line 100 of file class.ilLOTestQuestionAdapter.php.

References $user_id.

◆ hideQuestions()

ilLOTestQuestionAdapter::hideQuestions ( ilTestSequence  $seq)
protected

Hide questions.

Parameters
ilTestSequence$seq

Definition at line 292 of file class.ilLOTestQuestionAdapter.php.

References ilTestSequence\clearHiddenQuestions(), ilTestSequence\getQuestionIds(), ilTestSequence\hideQuestion(), and isInRun().

293  {
294  // first unhide all questions
295  $seq->clearHiddenQuestions();
296  foreach($seq->getQuestionIds() as $qid)
297  {
298  if(!$this->isInRun($qid))
299  {
300  $seq->hideQuestion($qid);
301  }
302  }
303  }
hideQuestion($question_id)
+ Here is the call graph for this function:

◆ initTestRun()

ilLOTestQuestionAdapter::initTestRun ( ilTestSession  $session)
protected

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

References ilObject\_lookupObjId(), ilTestSession\getRefId(), and ilLOTestRun\getRun().

307  {
308  include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php';
309  $this->run = ilLOTestRun::getRun(
310  $this->container_id,
311  $this->user_id,
312  ilObject::_lookupObjId($session->getRefId())
313  );
314  #$GLOBALS['ilLog']->write(__METHOD__.': '.print_r($this->run,true));
315  }
static getRun($a_container_id, $a_user_id, $a_test_id)
static _lookupObjId($a_id)
getRefId()
Get Ref id.
+ Here is the call graph for this function:

◆ initUserResult()

ilLOTestQuestionAdapter::initUserResult ( ilTestSession  $session)
protected

init user result

Definition at line 122 of file class.ilLOTestQuestionAdapter.php.

References $GLOBALS, ilTestSession\getRefId(), getSettings(), isQualifiedStartRun(), ilLOUtils\lookupMaxAttempts(), ilLOUtils\lookupObjectiveRequiredPercentage(), ilLOUserResults\lookupResult(), ilLOUserResults\TYPE_INITIAL, ilLOUserResults\TYPE_QUALIFIED, ilLOSettings\TYPE_TEST_INITIAL, and ilLOSettings\TYPE_TEST_QUALIFIED.

123  {
124  // check if current test is start object and fullfilled
125  // if yes => do not increase tries.
126  $is_qualified_run = false;
127  if($this->isQualifiedStartRun($session))
128  {
129  $is_qualified_run = true;
130  }
131 
132  foreach($this->run as $run)
133  {
134  include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
135  include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
136 
137  $old_result = ilLOUserResults::lookupResult(
138  $this->container_id,
139  $this->user_id,
140  $run->getObjectiveId(),
141  ($this->getSettings()->getQualifiedTest() == $session->getRefId()) ?
144  );
145 
146  include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
147 
149  $this->container_id,
150  $run->getObjectiveId(),
151  ($this->getSettings()->getQualifiedTest() == $session->getRefId()) ?
154  $run->getMaxPoints()
155  );
156 
157  $max_attempts = ilLOUtils::lookupMaxAttempts($this->container_id, $run->getObjectiveId());
158  if($max_attempts)
159  {
160  // check if current test is start object and fullfilled
161  // if yes => do not increase tries.
162  $GLOBALS['ilLog']->write(__METHOD__.': check for qualified...');
163  if(!$is_qualified_run)
164  {
165  $GLOBALS['ilLog']->write(__METHOD__.': and increase attempts');
166  ++$old_result['tries'];
167  }
168  $old_result['is_final'] = ($old_result['tries'] >= $max_attempts);
169  }
170 
171  $ur = new ilLOUserResults($this->container_id,$this->user_id);
172  $ur->saveObjectiveResult(
173  $run->getObjectiveId(),
174  ($this->getSettings()->getQualifiedTest() == $session->getRefId()) ?
177  $old_result['status'],
178  $old_result['result_perc'],
179  $limit,
180  $old_result['tries'],
181  $old_result['is_final']
182  );
183  }
184  }
static lookupResult($a_course_obj_id, $a_user_id, $a_objective_id, $a_tst_type)
Lookup user result.
$GLOBALS['ct_recipient']
static lookupObjectiveRequiredPercentage($a_container_id, $a_objective_id, $a_test_type, $a_max_points)
getRefId()
Get Ref id.
static lookupMaxAttempts($a_container_id, $a_objective_id)
isQualifiedStartRun(ilTestSession $session)
Check if current run is a start object run.
+ Here is the call graph for this function:

◆ isInRun()

ilLOTestQuestionAdapter::isInRun (   $a_qid)
protected

Definition at line 393 of file class.ilLOTestQuestionAdapter.php.

Referenced by hideQuestions().

394  {
395  foreach($this->run as $run)
396  {
397  if($run->questionExists($a_qid))
398  {
399  return true;
400  }
401  }
402  return false;
403  }
+ Here is the caller graph for this function:

◆ isQualifiedStartRun()

ilLOTestQuestionAdapter::isQualifiedStartRun ( ilTestSession  $session)
protected

Check if current run is a start object run.

Parameters
ilTestSession$session
Returns
boolean

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

References $GLOBALS, ilObject\_getAllReferences(), getContainerId(), ilTestSession\getRefId(), getSettings(), and ilContainerStartObjects\isStartObject().

Referenced by initUserResult().

192  {
193  if($session->getRefId() == $this->getSettings()->getInitialTest())
194  {
195  $GLOBALS['ilLog']->write(__METHOD__.': is intial');
196  return false;
197  }
198  if($session->getRefId() != $this->getSettings()->getQualifiedTest())
199  {
200  $GLOBALS['ilLog']->write(__METHOD__.': is not qualified');
201  return false;
202  }
203  include_once './Services/Container/classes/class.ilContainerStartObjects.php';
205  {
206  $GLOBALS['ilLog']->write(__METHOD__.': no start object');
207  return false;
208  }
209  // Check if start object is fullfilled
210 
211  $container_ref_ids = ilObject::_getAllReferences($this->getContainerId());
212  $container_ref_id = end($container_ref_ids);
213 
214  $start = new ilContainerStartObjects(
215  $container_ref_id,
216  $this->getContainerId()
217  );
218  if($start->isFullfilled($this->getUserId(),$session->getRefId()))
219  {
220  $GLOBALS['ilLog']->write(__METHOD__.': is fullfilled');
221 
222  return false;
223  }
224  $GLOBALS['ilLog']->write(__METHOD__.': is not fullfilled');
225  return true;
226  }
static _getAllReferences($a_id)
get all reference ids of object
$GLOBALS['ct_recipient']
getRefId()
Get Ref id.
static isStartObject($a_container_id, $a_item_ref_id)
Check if object is start object type $ilDB.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeTestRun()

ilLOTestQuestionAdapter::storeTestRun ( )
protected

Store test run in DB.

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

321  {
322  foreach ($this->run as $tst_run)
323  {
324  $tst_run->update();
325  }
326  }

◆ updateFixedQuestions()

ilLOTestQuestionAdapter::updateFixedQuestions ( ilTestSession  $session,
ilTestSequence  $seq 
)
protected

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

References $GLOBALS, ilCourseObjectiveQuestion\_lookupMaximumPointsOfQuestion(), ilObject\_lookupObjId(), ilTestSession\getRefId(), and ilCourseObjectiveQuestion\lookupQuestionsByObjective().

Referenced by updateQuestions().

343  {
344  foreach ($this->run as $tst_run)
345  {
346  $tst_run->clearQuestions();
347  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
349  ilObject::_lookupObjId($session->getRefId()),
350  $tst_run->getObjectiveId()
351  );
352  $GLOBALS['ilLog']->write(__METHOD__.': '.print_r($qst,true));
353  $points = 0;
354  foreach($qst as $id)
355  {
356  $tst_run->addQuestion($id);
358  }
359  $tst_run->setMaxPoints($points);
360  }
361  }
static _lookupMaximumPointsOfQuestion($a_question_id)
lookup maximimum point
$GLOBALS['ct_recipient']
static _lookupObjId($a_id)
getRefId()
Get Ref id.
static lookupQuestionsByObjective($a_test_id, $a_objective)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateObjectiveStatus()

static ilLOTestQuestionAdapter::updateObjectiveStatus ( ilTestSession  $a_test_session,
ilTestSequence  $a_test_sequence,
assQuestion  $a_question 
)
static

Store result and update objective status.

Parameters
ilTestSession$a_test_session
ilTestSequence$a_test_sequence
assQuestion$a_question

Definition at line 68 of file class.ilLOTestQuestionAdapter.php.

References ilTestSession\getObjectiveOrientedContainerId(), and ilTestSession\getUserId().

Referenced by ilTestOutputGUI\updateContainerObjectivesWithAnsweredQuestion().

69  {
70  $adapter = new self(
71  $a_test_session->getUserId(),
72  $a_test_session->getObjectiveOrientedContainerId()
73  );
74  $adapter->initTestRun($a_test_session);
75  $adapter->updateQuestionResult($a_test_session,$a_question);
76  return true;
77 
78  /*
79  $usr_id = $a_test_session->getUserId();
80  $crs_id = $a_test_session->getObjectiveOrientedContainerId();
81 
82  $question_id = $a_question->getId();
83 
84  $points_reached = $a_question->getReachedPoints($a_test_session->getActiveId(), $a_test_session->getPass());
85  //$points_max = $a_question->getMaxPoints();
86 
87  if( $a_test_sequence instanceof ilTestSequenceFixedQuestionSet )
88  {
89  // make some noise (with question id only)
90  }
91  elseif( $a_test_sequence instanceof ilTestSequenceRandomQuestionSet )
92  {
93  $respSrcPoolDefId = $a_test_sequence->getResponsibleSourcePoolDefinitionId($question_id);
94 
95  // make some noise (with question id and responsible source pool definition)
96  }
97  */
98  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateQuestionResult()

ilLOTestQuestionAdapter::updateQuestionResult ( ilTestSession  $session,
assQuestion  $qst 
)
protected

update question result of run

Parameters
ilTestSession$session
assQuestion$qst

Definition at line 233 of file class.ilLOTestQuestionAdapter.php.

References $GLOBALS, $res, ilLPStatusWrapper\_updateStatus(), ilTestSession\getActiveId(), assQuestion\getId(), ilTestSession\getPass(), assQuestion\getReachedPoints(), ilTestSession\getRefId(), getSettings(), ilLOUtils\isCompleted(), ilLOUserResults\lookupResult(), ilLOUserResults\STATUS_COMPLETED, ilLOUserResults\STATUS_FAILED, ilLOUserResults\TYPE_INITIAL, and ilLOUserResults\TYPE_QUALIFIED.

234  {
235  foreach($this->run as $run)
236  {
237  if($run->questionExists($qst->getId()))
238  {
239  $GLOBALS['ilLog']->write(__METHOD__.': reached points are '.$qst->getReachedPoints($session->getActiveId(),$session->getPass()));
240  $run->setQuestionResult(
241  $qst->getId(),
242  $qst->getReachedPoints($session->getActiveId(),$session->getPass())
243  );
244  $run->update();
245 
246  $res = $run->getResult();
247 
248  include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
249  include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
250 
251  $old_result = ilLOUserResults::lookupResult(
252  $this->container_id,
253  $this->user_id,
254  $run->getObjectiveId(),
255  ($this->getSettings()->getQualifiedTest() == $session->getRefId()) ?
258  );
259 
260  $ur = new ilLOUserResults($this->container_id,$this->user_id);
261  $ur->saveObjectiveResult(
262  $run->getObjectiveId(),
263  ($this->getSettings()->getQualifiedTest() == $session->getRefId()) ?
267  $this->container_id,
268  $session->getRefId(),
269  $run->getObjectiveId(),
270  $res['max'],$res['reached'],$old_result['limit_perc']) ?
273  (int) $res['percentage'],
274  $old_result['limit_perc'],
275  $old_result['tries'],
276  $old_result['is_final']
277  );
278  $GLOBALS['ilLog']->write(__METHOD__.': '.print_r($run->getResult(),true));
279 
280  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
281  ilLPStatusWrapper::_updateStatus($this->container_id,$this->user_id);
282  }
283  }
284  return false;
285  }
static isCompleted($a_cont_oid, $a_test_rid, $a_objective_id, $max_points, $reached, $limit_perc)
Check if objective is completed.
getId()
Gets the id of the assQuestion object.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_no_raise=false, $a_force_raise=false)
Update status.
static lookupResult($a_course_obj_id, $a_user_id, $a_objective_id, $a_tst_type)
Lookup user result.
getReachedPoints($active_id, $pass=NULL)
Returns the points, a learner has reached answering the question This is the fast way to get the poin...
$GLOBALS['ct_recipient']
getRefId()
Get Ref id.
+ Here is the call graph for this function:

◆ updateQuestions()

ilLOTestQuestionAdapter::updateQuestions ( ilTestSession  $session,
ilTestSequence  $seq 
)
protected

Definition at line 329 of file class.ilLOTestQuestionAdapter.php.

References updateFixedQuestions(), and updateRandomQuestions().

330  {
331  if($seq instanceof ilTestSequenceFixedQuestionSet)
332  {
333  $this->updateFixedQuestions($session, $seq);
334  }
335  if($seq instanceof ilTestSequenceRandomQuestionSet)
336  {
337  $this->updateRandomQuestions($session, $seq);
338  }
339 
340  }
updateRandomQuestions(ilTestSession $session, ilTestSequenceRandomQuestionSet $seq)
updateFixedQuestions(ilTestSession $session, ilTestSequence $seq)
+ Here is the call graph for this function:

◆ updateRandomQuestions()

ilLOTestQuestionAdapter::updateRandomQuestions ( ilTestSession  $session,
ilTestSequenceRandomQuestionSet  $seq 
)
protected

Definition at line 363 of file class.ilLOTestQuestionAdapter.php.

References ilCourseObjectiveQuestion\_lookupMaximumPointsOfQuestion(), ilTestSequence\getQuestionIds(), ilTestSession\getRefId(), ilTestSequenceRandomQuestionSet\getResponsibleSourcePoolDefinitionId(), getSettings(), ilLOSettings\TYPE_TEST_INITIAL, and ilLOSettings\TYPE_TEST_QUALIFIED.

Referenced by updateQuestions().

364  {
365  include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
366  include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
367 
368  foreach($this->run as $tst_run)
369  {
370  // Clear questions of previous run
371  $tst_run->clearQuestions();
372  $rnd = new ilLORandomTestQuestionPools(
373  $this->container_id,
374  $tst_run->getObjectiveId(),
375  ($this->getSettings()->getQualifiedTest() == $session->getRefId() ?
378  );
379  $stored_sequence_id = $rnd->getQplSequence();
380  $points = 0;
381  foreach($seq->getQuestionIds() as $qst)
382  {
383  if($stored_sequence_id == $seq->getResponsibleSourcePoolDefinitionId($qst))
384  {
385  $tst_run->addQuestion($qst);
387  }
388  }
389  $tst_run->setMaxPoints($points);
390  }
391  }
static _lookupMaximumPointsOfQuestion($a_question_id)
lookup maximimum point
getRefId()
Get Ref id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $container_id

ilLOTestQuestionAdapter::$container_id = 0
protected

Definition at line 17 of file class.ilLOTestQuestionAdapter.php.

Referenced by getContainerId().

◆ $settings

ilLOTestQuestionAdapter::$settings = NULL
protected

Definition at line 14 of file class.ilLOTestQuestionAdapter.php.

Referenced by getSettings().

◆ $user_id

ilLOTestQuestionAdapter::$user_id = 0
protected

Definition at line 16 of file class.ilLOTestQuestionAdapter.php.

Referenced by getUserId().


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