ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilLOTestQuestionAdapter Class Reference

Test question filter. More...

+ Collaboration diagram for ilLOTestQuestionAdapter:

Public Member Functions

 __construct ($a_user_id, $a_course_id)
 
 getTestRefId ()
 
 setTestRefId ($testRefId)
 
 notifyTestStart (ilTestSession $a_test_session, $a_test_obj_id)
 Called from learning objective test on actual test start. More...
 
 prepareTestPass (ilTestSession $a_test_session, ilTestSequence $a_test_sequence)
 Called from learning objective test. More...
 
 buildQuestionRelatedObjectiveList (ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
 
 updateQuestionResult (ilTestSession $session, assQuestion $qst)
 update question result of run More...
 

Static Public Member Functions

static getInstance (ilTestSession $a_test_session)
 

Protected Member Functions

 lookupRelevantObjectiveIdsForTest ($a_container_id, $a_tst_ref_id, $a_user_id)
 Lookup all relevant objective ids for a specific test. More...
 
 buildQuestionRelatedObjectiveListByTest (ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
 
 buildQuestionRelatedObjectiveListByQuestions (ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
 
 lookupObjectiveIdByRandomQuestionSelectionDefinitionId ($a_id)
 
 lookupObjectiveIdByFixedQuestionId ($a_question_id)
 
 getRelatedObjectivesForSeparatedTest ($testRefId)
 
 getUserId ()
 
 getContainerId ()
 
 getSettings ()
 Get loc settings. More...
 
 getAssignments ()
 
 initUserResult (ilTestSession $session)
 init user result More...
 
 isQualifiedStartRun (ilTestSession $session)
 Check if current run is a start object run. More...
 
 setQuestionsOptional (ilTestSequence $seq)
 set questions optional More...
 
 hideQuestions (ilTestSequence $seq)
 Hide questions. More...
 
 initTestRun (ilTestSession $session)
 
 storeTestRun ()
 Store test run in DB. More...
 
 updateQuestions (ilTestSession $session, ilTestSequence $seq)
 
 updateSeparateTestQuestions (ilTestSession $session, ilTestSequence $seq)
 Update questions for separate tests. More...
 
 updateFixedQuestions (ilTestSession $session, ilTestSequence $seq)
 
 updateRandomQuestions (ilTestSession $session, ilTestSequenceRandomQuestionSet $seq)
 
 isInRun ($a_qid)
 

Protected Attributes

 $settings = NULL
 
 $assignments = null
 
 $user_id = 0
 
 $container_id = 0
 
 $testRefId = null
 

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 13 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 28 of file class.ilLOTestQuestionAdapter.php.

29 {
30 $this->user_id = $a_user_id;
31 $this->container_id = $a_course_id;
32
33 $this->settings = ilLOSettings::getInstanceByObjId($this->container_id);
34 $this->assignments = ilLOTestAssignments::getInstance($this->container_id);
35 }
static getInstanceByObjId($a_obj_id)
get singleton instance
static getInstance($a_container_id)
Get instance by container id.

References ilLOTestAssignments\getInstance(), and ilLOSettings\getInstanceByObjId().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildQuestionRelatedObjectiveList()

ilLOTestQuestionAdapter::buildQuestionRelatedObjectiveList ( ilTestQuestionSequence  $a_test_sequence,
ilTestQuestionRelatedObjectivesList  $a_objectives_list 
)
Parameters
ilTestSequence$a_test_sequence
ilTestQuestionRelatedObjectivesList$a_objectives_list

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

201 {
202 $testType = $this->assignments->getTypeByTest($this->getTestRefId());
203
204 if($testType == ilLOSettings::TYPE_TEST_INITIAL && $this->getSettings()->hasSeparateInitialTests())
205 {
206 $this->buildQuestionRelatedObjectiveListByTest($a_test_sequence, $a_objectives_list);
207 }
208 elseif($testType == ilLOSettings::TYPE_TEST_QUALIFIED && $this->getSettings()->hasSeparateQualifiedTests())
209 {
210 $this->buildQuestionRelatedObjectiveListByTest($a_test_sequence, $a_objectives_list);
211 }
212 else
213 {
214 $this->buildQuestionRelatedObjectiveListByQuestions($a_test_sequence, $a_objectives_list);
215 }
216 }
buildQuestionRelatedObjectiveListByQuestions(ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
buildQuestionRelatedObjectiveListByTest(ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)

References buildQuestionRelatedObjectiveListByQuestions(), buildQuestionRelatedObjectiveListByTest(), getSettings(), getTestRefId(), ilLOSettings\TYPE_TEST_INITIAL, and ilLOSettings\TYPE_TEST_QUALIFIED.

Referenced by ilTestServiceGUI\buildQuestionRelatedObjectivesList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuestionRelatedObjectiveListByQuestions()

ilLOTestQuestionAdapter::buildQuestionRelatedObjectiveListByQuestions ( ilTestQuestionSequence  $a_test_sequence,
ilTestQuestionRelatedObjectivesList  $a_objectives_list 
)
protected

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

229 {
230 foreach( $a_test_sequence->getQuestionIds() as $questionId )
231 {
232 if( $a_test_sequence instanceof ilTestRandomQuestionSequence )
233 {
234 $definitionId = $a_test_sequence->getResponsibleSourcePoolDefinitionId($questionId);
235 $objectiveIds = $this->lookupObjectiveIdByRandomQuestionSelectionDefinitionId($definitionId);
236 }
237 else
238 {
239 $objectiveIds = $this->lookupObjectiveIdByFixedQuestionId($questionId);
240 }
241
242 if( count($objectiveIds) )
243 {
244 $a_objectives_list->addQuestionRelatedObjectives($questionId, $objectiveIds);
245 }
246 }
247 }

References ilTestQuestionRelatedObjectivesList\addQuestionRelatedObjectives(), ilTestQuestionSequence\getQuestionIds(), lookupObjectiveIdByFixedQuestionId(), and lookupObjectiveIdByRandomQuestionSelectionDefinitionId().

Referenced by buildQuestionRelatedObjectiveList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuestionRelatedObjectiveListByTest()

ilLOTestQuestionAdapter::buildQuestionRelatedObjectiveListByTest ( ilTestQuestionSequence  $a_test_sequence,
ilTestQuestionRelatedObjectivesList  $a_objectives_list 
)
protected

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

219 {
220 $objectiveIds = array($this->getRelatedObjectivesForSeparatedTest($this->getTestRefId()));
221
222 foreach( $a_test_sequence->getQuestionIds() as $questionId )
223 {
224 $a_objectives_list->addQuestionRelatedObjectives($questionId, $objectiveIds);
225 }
226 }

References ilTestQuestionRelatedObjectivesList\addQuestionRelatedObjectives(), ilTestQuestionSequence\getQuestionIds(), getRelatedObjectivesForSeparatedTest(), and getTestRefId().

Referenced by buildQuestionRelatedObjectiveList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssignments()

ilLOTestQuestionAdapter::getAssignments ( )
protected
Returns
ilLOTestAssignments

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

References $assignments.

Referenced by getRelatedObjectivesForSeparatedTest(), isQualifiedStartRun(), and updateQuestions().

+ Here is the caller graph for this function:

◆ getContainerId()

ilLOTestQuestionAdapter::getContainerId ( )
protected

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

References $container_id.

Referenced by isQualifiedStartRun(), and lookupObjectiveIdByRandomQuestionSelectionDefinitionId().

+ Here is the caller graph for this function:

◆ getInstance()

◆ getQuestionData()

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

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

624 {
625 global $ilDB, $lng, $ilPluginAdmin;
626
627 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
628 $questionList = new ilAssQuestionList($ilDB, $lng, $ilPluginAdmin);
629 $questionList->setParentObjId($testObjId);
630
631 $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES);
632 $questionList->setQuestionIdsFilter($questionIds);
633
634 $questionList->load();
635
636 return $questionList->getQuestionDataArray();
637 }
global $lng
Definition: privfeed.php:40
global $ilDB

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

◆ getRelatedObjectivesForSeparatedTest()

ilLOTestQuestionAdapter::getRelatedObjectivesForSeparatedTest (   $testRefId)
protected

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

262 {
263 foreach( $this->getAssignments()->getAssignments() as $assignment )
264 {
265 if($assignment->getTestRefId() == $testRefId)
266 {
267 return $assignment->getObjectiveId();
268 }
269 }
270
271 return null;
272 }

References $testRefId, and getAssignments().

Referenced by buildQuestionRelatedObjectiveListByTest().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSettings()

ilLOTestQuestionAdapter::getSettings ( )
protected

Get loc settings.

Returns
ilLOSettings

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

References $settings.

Referenced by buildQuestionRelatedObjectiveList(), lookupRelevantObjectiveIdsForTest(), and prepareTestPass().

+ Here is the caller graph for this function:

◆ getTestRefId()

ilLOTestQuestionAdapter::getTestRefId ( )
Returns
null

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

41 {
42 return $this->testRefId;
43 }

References $testRefId.

Referenced by buildQuestionRelatedObjectiveList(), and buildQuestionRelatedObjectiveListByTest().

+ Here is the caller graph for this function:

◆ getUserId()

ilLOTestQuestionAdapter::getUserId ( )
protected

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

References $user_id.

◆ hideQuestions()

ilLOTestQuestionAdapter::hideQuestions ( ilTestSequence  $seq)
protected

Hide questions.

Parameters
ilTestSequence$seq

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

484 {
485 // first unhide all questions
486 $seq->clearHiddenQuestions();
487 foreach($seq->getQuestionIds() as $qid)
488 {
489 if(!$this->isInRun($qid))
490 {
491 $seq->hideQuestion($qid);
492 }
493 }
494 }
hideQuestion($question_id)

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

Referenced by prepareTestPass().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initTestRun()

ilLOTestQuestionAdapter::initTestRun ( ilTestSession  $session)
protected

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

497 {
498 include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php';
499 $this->run = ilLOTestRun::getRun(
500 $this->container_id,
501 $this->user_id,
503 );
504 }
static getRun($a_container_id, $a_user_id, $a_test_id)
static _lookupObjId($a_id)

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

Referenced by notifyTestStart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initUserResult()

ilLOTestQuestionAdapter::initUserResult ( ilTestSession  $session)
protected

init user result

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

306 {
307 // check if current test is start object and fullfilled
308 // if yes => do not increase tries.
309 $is_qualified_run = false;
310 if($this->isQualifiedStartRun($session))
311 {
312 $is_qualified_run = true;
313 }
314
315 foreach($this->run as $run)
316 {
317 include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
318 include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
319
320 $old_result = ilLOUserResults::lookupResult(
321 $this->container_id,
322 $this->user_id,
323 $run->getObjectiveId(),
324 $this->getAssignments()->getTypeByTest($session->getRefId())
325 );
326
327 include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
328
330 $this->container_id,
331 $run->getObjectiveId(),
332 $session->getRefId(),
333 $run->getMaxPoints()
334 );
335
336 $max_attempts = ilLOUtils::lookupMaxAttempts($this->container_id, $run->getObjectiveId());
337 if($max_attempts)
338 {
339 // check if current test is start object and fullfilled
340 // if yes => do not increase tries.
341 $GLOBALS['ilLog']->write(__METHOD__.': check for qualified...');
342 if(!$is_qualified_run)
343 {
344 $GLOBALS['ilLog']->write(__METHOD__.': and increase attempts');
345 ++$old_result['tries'];
346 }
347 $old_result['is_final'] = ($old_result['tries'] >= $max_attempts);
348 }
349
350 $ur = new ilLOUserResults($this->container_id,$this->user_id);
351 $ur->saveObjectiveResult(
352 $run->getObjectiveId(),
353 $this->getAssignments()->getTypeByTest($session->getRefId()),
354 $old_result['status'],
355 $old_result['result_perc'],
356 $limit,
357 $old_result['tries'],
358 $old_result['is_final']
359 );
360 }
361 }
isQualifiedStartRun(ilTestSession $session)
Check if current run is a start object run.
static lookupResult($a_course_obj_id, $a_user_id, $a_objective_id, $a_tst_type)
Lookup user result.
static lookupObjectiveRequiredPercentage($a_container_id, $a_objective_id, $a_test_ref_id, $a_max_points)
static lookupMaxAttempts($a_container_id, $a_objective_id)
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276

References $GLOBALS, ilTestSession\getRefId(), isQualifiedStartRun(), ilLOUtils\lookupMaxAttempts(), ilLOUtils\lookupObjectiveRequiredPercentage(), and ilLOUserResults\lookupResult().

Referenced by prepareTestPass().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isInRun()

ilLOTestQuestionAdapter::isInRun (   $a_qid)
protected

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

611 {
612 foreach($this->run as $run)
613 {
614 if($run->questionExists($a_qid))
615 {
616 return true;
617 }
618 }
619 return false;
620 }

Referenced by hideQuestions(), and setQuestionsOptional().

+ 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 368 of file class.ilLOTestQuestionAdapter.php.

369 {
370 if($this->getAssignments()->getTypeByTest($session->getRefId()) == ilLOSettings::TYPE_TEST_INITIAL)
371 {
372 $GLOBALS['ilLog']->write(__METHOD__.': is initial');
373 return false;
374 }
375
376 if($session->getRefId() != $this->getSettings()->getQualifiedTest())
377 {
378 $GLOBALS['ilLog']->write(__METHOD__.': is not qualified');
379 return false;
380 }
381 include_once './Services/Container/classes/class.ilContainerStartObjects.php';
383 {
384 $GLOBALS['ilLog']->write(__METHOD__.': no start object');
385 return false;
386 }
387 // Check if start object is fullfilled
388
389 $container_ref_ids = ilObject::_getAllReferences($this->getContainerId());
390 $container_ref_id = end($container_ref_ids);
391
392 $start = new ilContainerStartObjects(
393 $container_ref_id,
394 $this->getContainerId()
395 );
396 if($start->isFullfilled($this->getUserId(),$session->getRefId()))
397 {
398 $GLOBALS['ilLog']->write(__METHOD__.': is fullfilled');
399
400 return false;
401 }
402 $GLOBALS['ilLog']->write(__METHOD__.': is not fullfilled');
403 return true;
404 }
static isStartObject($a_container_id, $a_item_ref_id)
Check if object is start object @global type $ilDB.
static _getAllReferences($a_id)
get all reference ids of object

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

Referenced by initUserResult().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupObjectiveIdByFixedQuestionId()

ilLOTestQuestionAdapter::lookupObjectiveIdByFixedQuestionId (   $a_question_id)
protected

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

256 {
257 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
259 }
static lookupObjectivesOfQuestion($a_qid)
Lookup objective for test question @global type $ilDB.

References ilCourseObjectiveQuestion\lookupObjectivesOfQuestion().

Referenced by buildQuestionRelatedObjectiveListByQuestions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupObjectiveIdByRandomQuestionSelectionDefinitionId()

ilLOTestQuestionAdapter::lookupObjectiveIdByRandomQuestionSelectionDefinitionId (   $a_id)
protected

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

250 {
251 include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
253 }
static lookupObjectiveIdsBySequence($a_container_id, $a_seq_id)
Lookup objective id by sequence.

References getContainerId(), and ilLORandomTestQuestionPools\lookupObjectiveIdsBySequence().

Referenced by buildQuestionRelatedObjectiveListByQuestions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupRelevantObjectiveIdsForTest()

ilLOTestQuestionAdapter::lookupRelevantObjectiveIdsForTest (   $a_container_id,
  $a_tst_ref_id,
  $a_user_id 
)
protected

Lookup all relevant objective ids for a specific test.

Returns
array

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

58 {
59 include_once './Modules/Course/classes/Objectives/class.ilLOTestAssignments.php';
61
62 include_once './Modules/Course/classes/class.ilCourseObjective.php';
63 $objective_ids = ilCourseObjective::_getObjectiveIds($a_container_id);
64
65 $relevant_objective_ids = array();
66 if(!$this->getSettings()->hasSeparateInitialTests())
67 {
68 if($a_tst_ref_id == $this->getSettings()->getInitialTest())
69 {
70 $relevant_objective_ids = $objective_ids;
71 }
72 }
73 elseif(!$this->getSettings()->hasSeparateQualifiedTests())
74 {
75 if($a_tst_ref_id == $this->getSettings()->getQualifiedTest())
76 {
77 $relevant_objective_ids = $objective_ids;
78 }
79 }
80
81 foreach((array) $objective_ids as $objective_id)
82 {
83 $assigned_itest = $assignments->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL);
84 if($assigned_itest == $a_tst_ref_id)
85 {
86 $relevant_objective_ids[] = $objective_id;
87 }
88 $assigned_qtest = $assignments->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED);
89 if($assigned_qtest == $a_tst_ref_id)
90 {
91 $relevant_objective_ids[] = $objective_id;
92 }
93 }
94
95 $relevant_objective_ids = array_unique($relevant_objective_ids);
96
97 if(count($relevant_objective_ids) <= 1)
98 {
99 return $relevant_objective_ids;
100 }
101
102 // filter passed objectives
103 $test_type = $assignments->getTypeByTest($a_tst_ref_id);
104
105 $passed_objectives = array();
106 include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
107 $results = new ilLOUserResults($a_container_id,$a_user_id);
108
109 $passed = $results->getCompletedObjectiveIds();
110 $GLOBALS['ilLog']->write(__METHOD__.': Passed objectives are '.print_r($passed,TRUE).' test_type = '.$test_type);
111
112
113 // all completed => show all objectives
114 if(count($passed) >= count($relevant_objective_ids))
115 {
116 return $relevant_objective_ids;
117 }
118
119 $unpassed = array();
120 foreach($relevant_objective_ids as $objective_id)
121 {
122 if(!in_array($objective_id, $passed))
123 {
124 $unpassed[] = $objective_id;
125 }
126 }
127 return $unpassed;
128 }
static _getObjectiveIds($course_id, $a_activated_only=false)
$results

References $assignments, $GLOBALS, $results, ilCourseObjective\_getObjectiveIds(), ilLOTestAssignments\getInstance(), getSettings(), ilLOSettings\TYPE_TEST_INITIAL, and ilLOSettings\TYPE_TEST_QUALIFIED.

Referenced by notifyTestStart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notifyTestStart()

ilLOTestQuestionAdapter::notifyTestStart ( ilTestSession  $a_test_session,
  $a_test_obj_id 
)

Called from learning objective test on actual test start.

Parameters
ilTestSession$a_test_session
integer$a_test_obj_id

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

137 {
138 $relevant_objectives = $this->lookupRelevantObjectiveIdsForTest(
139 $a_test_session->getObjectiveOrientedContainerId(),
140 $a_test_session->getRefId(),
141 $a_test_session->getUserId()
142 );
143 $GLOBALS['ilLog']->write(__METHOD__.': Notify test start ' . print_r($relevant_objectives,TRUE));
144
145 // delete test runs
146 include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php';
148 $a_test_session->getObjectiveOrientedContainerId(),
149 $a_test_session->getUserId(),
150 $a_test_obj_id
151 );
152
153 foreach((array) $relevant_objectives as $oid)
154 {
155 $GLOBALS['ilLog']->write(__METHOD__.': Adding new run for objective with id '.$oid);
156 $run = new ilLOTestRun(
157 $a_test_session->getObjectiveOrientedContainerId(),
158 $a_test_session->getUserId(),
159 $a_test_obj_id,
160 $oid
161 );
162 $run->create();
163 }
164
165 // finally reinitialize test runs
166 $this->initTestRun($a_test_session);
167 }
lookupRelevantObjectiveIdsForTest($a_container_id, $a_tst_ref_id, $a_user_id)
Lookup all relevant objective ids for a specific test.
Stores current objective, questions and max points.
static deleteRun($a_container_id, $a_user_id, $a_test_id)

References $GLOBALS, ilLOTestRun\deleteRun(), ilTestSession\getObjectiveOrientedContainerId(), ilTestSession\getRefId(), ilTestSession\getUserId(), initTestRun(), and lookupRelevantObjectiveIdsForTest().

+ Here is the call graph for this function:

◆ prepareTestPass()

ilLOTestQuestionAdapter::prepareTestPass ( ilTestSession  $a_test_session,
ilTestSequence  $a_test_sequence 
)

Called from learning objective test.

Parameters
ilTestSession$a_test_session
ilTestSequence$a_test_sequence

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

175 {
176 $this->updateQuestions($a_test_session, $a_test_sequence);
177
178 if($this->getSettings()->getPassedObjectiveMode() == ilLOSettings::MARK_PASSED_OBJECTIVE_QST)
179 {
180 $this->setQuestionsOptional($a_test_sequence);
181 }
182 elseif($this->getSettings()->getPassedObjectiveMode() == ilLOSettings::HIDE_PASSED_OBJECTIVE_QST)
183 {
184 $this->hideQuestions($a_test_sequence);
185 }
186
187 $this->storeTestRun();
188 $this->initUserResult($a_test_session);
189
190 // Save test sequence
191 $a_test_sequence->saveToDb();
192
193 return true;
194 }
const HIDE_PASSED_OBJECTIVE_QST
const MARK_PASSED_OBJECTIVE_QST
setQuestionsOptional(ilTestSequence $seq)
set questions optional
hideQuestions(ilTestSequence $seq)
Hide questions.
updateQuestions(ilTestSession $session, ilTestSequence $seq)
initUserResult(ilTestSession $session)
init user result
saveToDb()
Saves the sequence data for a given pass to the database.

References getSettings(), ilLOSettings\HIDE_PASSED_OBJECTIVE_QST, hideQuestions(), initUserResult(), ilLOSettings\MARK_PASSED_OBJECTIVE_QST, ilTestSequence\saveToDb(), setQuestionsOptional(), storeTestRun(), and updateQuestions().

+ Here is the call graph for this function:

◆ setQuestionsOptional()

ilLOTestQuestionAdapter::setQuestionsOptional ( ilTestSequence  $seq)
protected

set questions optional

Parameters
ilTestSequence$seq

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

467 {
468 // first unset optional on all questions
470 foreach($seq->getQuestionIds() as $qid)
471 {
472 if(!$this->isInRun($qid)) // but is assigned to any LO
473 {
474 $seq->setQuestionOptional($qid);
475 }
476 }
477 }
setQuestionOptional($questionId)

References ilTestSequence\clearOptionalQuestions(), ilTestSequence\getQuestionIds(), isInRun(), and ilTestSequence\setQuestionOptional().

Referenced by prepareTestPass().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTestRefId()

ilLOTestQuestionAdapter::setTestRefId (   $testRefId)
Parameters
null$testRefId

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

49 {
50 $this->testRefId = $testRefId;
51 }

References $testRefId.

◆ storeTestRun()

ilLOTestQuestionAdapter::storeTestRun ( )
protected

Store test run in DB.

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

510 {
511 foreach ($this->run as $tst_run)
512 {
513 $tst_run->update();
514 }
515 }

Referenced by prepareTestPass().

+ Here is the caller graph for this function:

◆ updateFixedQuestions()

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

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

561 {
562 foreach ($this->run as $tst_run)
563 {
564 $tst_run->clearQuestions();
565 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
567 ilObject::_lookupObjId($session->getRefId()),
568 $tst_run->getObjectiveId()
569 );
570 $points = 0;
571 foreach($qst as $id)
572 {
573 $tst_run->addQuestion($id);
575 }
576 $tst_run->setMaxPoints($points);
577 }
578 }
static lookupQuestionsByObjective($a_test_id, $a_objective)
static _lookupMaximumPointsOfQuestion($a_question_id)
lookup maximimum point

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

Referenced by updateQuestions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateQuestionResult()

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

update question result of run

Parameters
ilTestSession$session
assQuestion$qst

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

412 {
413 foreach($this->run as $run)
414 {
415 if($run->questionExists($qst->getId()))
416 {
417 $GLOBALS['ilLog']->write(__METHOD__.': reached points are '.$qst->getReachedPoints($session->getActiveId(),$session->getPass()));
418 $run->setQuestionResult(
419 $qst->getId(),
420 $qst->getReachedPoints($session->getActiveId(),$session->getPass())
421 );
422 $run->update();
423
424 $res = $run->getResult();
425
426 include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
427 include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
428
429 $old_result = ilLOUserResults::lookupResult(
430 $this->container_id,
431 $this->user_id,
432 $run->getObjectiveId(),
433 $this->getAssignments()->getTypeByTest($session->getRefId())
434 );
435
436 $ur = new ilLOUserResults($this->container_id,$this->user_id);
437 $ur->saveObjectiveResult(
438 $run->getObjectiveId(),
439 $this->getAssignments()->getTypeByTest($session->getRefId()),
441 $this->container_id,
442 $session->getRefId(),
443 $run->getObjectiveId(),
444 $res['max'],$res['reached'],$old_result['limit_perc']) ?
447 (int) $res['percentage'],
448 $old_result['limit_perc'],
449 $old_result['tries'],
450 $old_result['is_final']
451 );
452 $GLOBALS['ilLog']->write(__METHOD__.': '.print_r($run->getResult(),true));
453 $GLOBALS['ilLog']->write(__METHOD__.'!!!!!!!!!!!!!!!!!!!!: '.print_r($comp,TRUE));
454
455 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
456 ilLPStatusWrapper::_updateStatus($this->container_id,$this->user_id);
457 }
458 }
459 return false;
460 }
getId()
Gets the id of the assQuestion object.
getReachedPoints($active_id, $pass=NULL)
Returns the points, a learner has reached answering the question This is the fast way to get the poin...
static isCompleted($a_cont_oid, $a_test_rid, $a_objective_id, $max_points, $reached, $limit_perc)
Check if objective is completed.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.

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

+ Here is the call graph for this function:

◆ updateQuestions()

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

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

519 {
520 if($this->getAssignments()->isSeparateTest($session->getRefId()))
521 {
522 $GLOBALS['ilLog']->write(__METHOD__.': separate run');
523 return $this->updateSeparateTestQuestions($session, $seq);
524 }
525 if($seq instanceof ilTestSequenceFixedQuestionSet)
526 {
527 $GLOBALS['ilLog']->write(__METHOD__.': fixed run');
528 return $this->updateFixedQuestions($session, $seq);
529 }
530 if($seq instanceof ilTestSequenceRandomQuestionSet)
531 {
532 $GLOBALS['ilLog']->write(__METHOD__.': random run');
533 return $this->updateRandomQuestions($session, $seq);
534 }
535
536 }
updateSeparateTestQuestions(ilTestSession $session, ilTestSequence $seq)
Update questions for separate tests.
updateRandomQuestions(ilTestSession $session, ilTestSequenceRandomQuestionSet $seq)
updateFixedQuestions(ilTestSession $session, ilTestSequence $seq)

References $GLOBALS, getAssignments(), ilTestSession\getRefId(), updateFixedQuestions(), updateRandomQuestions(), and updateSeparateTestQuestions().

Referenced by prepareTestPass().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateRandomQuestions()

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

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

581 {
582 include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
583 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
584
585 foreach($this->run as $tst_run)
586 {
587 // Clear questions of previous run
588 $tst_run->clearQuestions();
590 $this->container_id,
591 $tst_run->getObjectiveId(),
592 ($this->getSettings()->getQualifiedTest() == $session->getRefId() ?
595 );
596 $stored_sequence_id = $rnd->getQplSequence();
597 $points = 0;
598 foreach($seq->getQuestionIds() as $qst)
599 {
600 if($stored_sequence_id == $seq->getResponsibleSourcePoolDefinitionId($qst))
601 {
602 $tst_run->addQuestion($qst);
604 }
605 }
606 $tst_run->setMaxPoints($points);
607 }
608 }

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

Referenced by updateQuestions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateSeparateTestQuestions()

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

Update questions for separate tests.

Parameters
ilTestSession$session
ilTestSequence$seq

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

544 {
545 foreach($this->run as $tst_run)
546 {
547 $tst_run->clearQuestions();
548 $points = 0;
549 foreach($seq->getQuestionIds() as $idx => $qst_id)
550 {
551 $tst_run->addQuestion($qst_id);
552 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
554 }
555 $tst_run->setMaxPoints($points);
556 }
557 }

References ilCourseObjectiveQuestion\_lookupMaximumPointsOfQuestion(), and ilTestSequence\getQuestionIds().

Referenced by updateQuestions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $assignments

ilLOTestQuestionAdapter::$assignments = null
protected

◆ $container_id

ilLOTestQuestionAdapter::$container_id = 0
protected

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

Referenced by getContainerId().

◆ $settings

ilLOTestQuestionAdapter::$settings = NULL
protected

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

Referenced by getSettings().

◆ $testRefId

ilLOTestQuestionAdapter::$testRefId = null
protected

◆ $user_id

ilLOTestQuestionAdapter::$user_id = 0
protected

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

Referenced by getUserId().


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