ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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

 $logger = null
 
 $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 33 of file class.ilLOTestQuestionAdapter.php.

34 {
35 $this->logger = $GLOBALS['DIC']->logger()->crs();
36
37 $this->user_id = $a_user_id;
38 $this->container_id = $a_course_id;
39
40 $this->settings = ilLOSettings::getInstanceByObjId($this->container_id);
41 $this->assignments = ilLOTestAssignments::getInstance($this->container_id);
42 }
static getInstanceByObjId($a_obj_id)
get singleton instance
static getInstance($a_container_id)
Get instance by container id.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
settings()
Definition: settings.php:2

References $GLOBALS, ilLOTestAssignments\getInstance(), ilLOSettings\getInstanceByObjId(), and settings().

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

210 {
211 $testType = $this->assignments->getTypeByTest($this->getTestRefId());
212
213 if($testType == ilLOSettings::TYPE_TEST_INITIAL && $this->getSettings()->hasSeparateInitialTests())
214 {
215 $this->buildQuestionRelatedObjectiveListByTest($a_test_sequence, $a_objectives_list);
216 }
217 elseif($testType == ilLOSettings::TYPE_TEST_QUALIFIED && $this->getSettings()->hasSeparateQualifiedTests())
218 {
219 $this->buildQuestionRelatedObjectiveListByTest($a_test_sequence, $a_objectives_list);
220 }
221 else
222 {
223 $this->buildQuestionRelatedObjectiveListByQuestions($a_test_sequence, $a_objectives_list);
224 }
225 }
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 237 of file class.ilLOTestQuestionAdapter.php.

238 {
239 foreach( $a_test_sequence->getQuestionIds() as $questionId )
240 {
241 if( $a_test_sequence instanceof ilTestRandomQuestionSequence )
242 {
243 $definitionId = $a_test_sequence->getResponsibleSourcePoolDefinitionId($questionId);
244 $objectiveIds = $this->lookupObjectiveIdByRandomQuestionSelectionDefinitionId($definitionId);
245 }
246 else
247 {
248 $objectiveIds = $this->lookupObjectiveIdByFixedQuestionId($questionId);
249 }
250
251 if( count($objectiveIds) )
252 {
253 $a_objectives_list->addQuestionRelatedObjectives($questionId, $objectiveIds);
254 }
255 }
256 }

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

228 {
229 $objectiveIds = array($this->getRelatedObjectivesForSeparatedTest($this->getTestRefId()));
230
231 foreach( $a_test_sequence->getQuestionIds() as $questionId )
232 {
233 $a_objectives_list->addQuestionRelatedObjectives($questionId, $objectiveIds);
234 }
235 }

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 306 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 288 of file class.ilLOTestQuestionAdapter.php.

References $container_id.

Referenced by isQualifiedStartRun(), and lookupObjectiveIdByRandomQuestionSelectionDefinitionId().

+ Here is the caller graph for this function:

◆ getInstance()

static ilLOTestQuestionAdapter::getInstance ( ilTestSession  $a_test_session)
static

◆ getQuestionData()

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

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

639 {
640 global $ilDB, $lng, $ilPluginAdmin;
641
642 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
643 $questionList = new ilAssQuestionList($ilDB, $lng, $ilPluginAdmin);
644 $questionList->setParentObjId($testObjId);
645
646 $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES);
647 $questionList->setQuestionIdsFilter($questionIds);
648
649 $questionList->load();
650
651 return $questionList->getQuestionDataArray();
652 }
global $lng
Definition: privfeed.php:17
global $ilDB

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

◆ getRelatedObjectivesForSeparatedTest()

ilLOTestQuestionAdapter::getRelatedObjectivesForSeparatedTest (   $testRefId)
protected

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

271 {
272 foreach( $this->getAssignments()->getAssignments() as $assignment )
273 {
274 if($assignment->getTestRefId() == $testRefId)
275 {
276 return $assignment->getObjectiveId();
277 }
278 }
279
280 return null;
281 }

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 297 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 47 of file class.ilLOTestQuestionAdapter.php.

48 {
49 return $this->testRefId;
50 }

References $testRefId.

Referenced by buildQuestionRelatedObjectiveList(), and buildQuestionRelatedObjectiveListByTest().

+ Here is the caller graph for this function:

◆ getUserId()

ilLOTestQuestionAdapter::getUserId ( )
protected

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

References $user_id.

◆ hideQuestions()

ilLOTestQuestionAdapter::hideQuestions ( ilTestSequence  $seq)
protected

Hide questions.

Parameters
ilTestSequence$seq

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

499 {
500 // first unhide all questions
501 $seq->clearHiddenQuestions();
502 foreach($seq->getQuestionIds() as $qid)
503 {
504 if(!$this->isInRun($qid))
505 {
506 $seq->hideQuestion($qid);
507 }
508 }
509 }
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 511 of file class.ilLOTestQuestionAdapter.php.

512 {
513 include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php';
514 $this->run = ilLOTestRun::getRun(
515 $this->container_id,
516 $this->user_id,
518 );
519 }
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 314 of file class.ilLOTestQuestionAdapter.php.

315 {
316 // check if current test is start object and fullfilled
317 // if yes => do not increase tries.
318 $is_qualified_run = false;
319 if($this->isQualifiedStartRun($session))
320 {
321 $is_qualified_run = true;
322 }
323
324 foreach($this->run as $run)
325 {
326 include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
327 include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
328
329 $old_result = ilLOUserResults::lookupResult(
330 $this->container_id,
331 $this->user_id,
332 $run->getObjectiveId(),
333 $this->getAssignments()->getTypeByTest($session->getRefId())
334 );
335
336 include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
337
339 $this->container_id,
340 $run->getObjectiveId(),
341 $session->getRefId(),
342 $run->getMaxPoints()
343 );
344
345 $max_attempts = ilLOUtils::lookupMaxAttempts(
346 $this->container_id,
347 $run->getObjectiveId(),
348 $session->getRefId()
349 );
350
351 $this->logger->debug('Max attempts = ' . $max_attempts);
352
353 if($max_attempts)
354 {
355 // check if current test is start object and fullfilled
356 // if yes => do not increase tries.
357 $this->logger->debug('Checking for qualified test...');
358 if(!$is_qualified_run)
359 {
360 $this->logger->debug(' and increasing attempts.');
361 ++$old_result['tries'];
362 }
363 $old_result['is_final'] = ($old_result['tries'] >= $max_attempts);
364 }
365
366 $ur = new ilLOUserResults($this->container_id,$this->user_id);
367 $ur->saveObjectiveResult(
368 $run->getObjectiveId(),
369 $this->getAssignments()->getTypeByTest($session->getRefId()),
370 $old_result['status'],
371 $old_result['result_perc'],
372 $limit,
373 $old_result['tries'],
374 $old_result['is_final']
375 );
376 }
377 }
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)

References ilTestSession\getRefId(), isQualifiedStartRun(), 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 625 of file class.ilLOTestQuestionAdapter.php.

626 {
627 foreach($this->run as $run)
628 {
629 if($run->questionExists($a_qid))
630 {
631 return true;
632 }
633 }
634 return false;
635 }

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

385 {
386 if($this->getAssignments()->getTypeByTest($session->getRefId()) == ilLOSettings::TYPE_TEST_INITIAL)
387 {
388 $this->logger->debug('Initial test');
389 return false;
390 }
391
392 if($session->getRefId() != $this->getSettings()->getQualifiedTest())
393 {
394 $this->logger->debug('No qualified test run');
395 return false;
396 }
397 include_once './Services/Container/classes/class.ilContainerStartObjects.php';
399 {
400 $this->logger->debug('No start object');
401 return false;
402 }
403 // Check if start object is fullfilled
404
405 $container_ref_ids = ilObject::_getAllReferences($this->getContainerId());
406 $container_ref_id = end($container_ref_ids);
407
409 $container_ref_id,
410 $this->getContainerId()
411 );
412 if($start->isFullfilled($this->getUserId(),$session->getRefId()))
413 {
414 $this->logger->debug('Is fullfilled');
415 return false;
416 }
417 $this->logger->debug('Is not fullfilled');
418 return true;
419 }
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 $start, 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 264 of file class.ilLOTestQuestionAdapter.php.

265 {
266 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
268 }
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 258 of file class.ilLOTestQuestionAdapter.php.

259 {
260 include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
262 }
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 64 of file class.ilLOTestQuestionAdapter.php.

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

References $assignments, $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 143 of file class.ilLOTestQuestionAdapter.php.

144 {
145 $relevant_objectives = $this->lookupRelevantObjectiveIdsForTest(
146 $a_test_session->getObjectiveOrientedContainerId(),
147 $a_test_session->getRefId(),
148 $a_test_session->getUserId()
149 );
150 $this->logger->debug('Notify test start: '. print_r($relevant_objectives,true));
151
152 // delete test runs
153 include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php';
155 $a_test_session->getObjectiveOrientedContainerId(),
156 $a_test_session->getUserId(),
157 $a_test_obj_id
158 );
159
160 foreach((array) $relevant_objectives as $oid)
161 {
162 $this->logger->debug('Adding new run for objective with id: ' . $oid);
163 $run = new ilLOTestRun(
164 $a_test_session->getObjectiveOrientedContainerId(),
165 $a_test_session->getUserId(),
166 $a_test_obj_id,
167 $oid
168 );
169 $run->create();
170 }
171
172 // finally reinitialize test runs
173 $this->initTestRun($a_test_session);
174 }
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 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 181 of file class.ilLOTestQuestionAdapter.php.

182 {
183 $this->logger->debug('Prepare test pass called');
184
185 $this->updateQuestions($a_test_session, $a_test_sequence);
186
187 if($this->getSettings()->getPassedObjectiveMode() == ilLOSettings::MARK_PASSED_OBJECTIVE_QST)
188 {
189 $this->setQuestionsOptional($a_test_sequence);
190 }
191 elseif($this->getSettings()->getPassedObjectiveMode() == ilLOSettings::HIDE_PASSED_OBJECTIVE_QST)
192 {
193 $this->hideQuestions($a_test_sequence);
194 }
195
196 $this->storeTestRun();
197 $this->initUserResult($a_test_session);
198
199 // Save test sequence
200 $a_test_sequence->saveToDb();
201
202 return true;
203 }
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 481 of file class.ilLOTestQuestionAdapter.php.

482 {
483 // first unset optional on all questions
485 foreach($seq->getQuestionIds() as $qid)
486 {
487 if(!$this->isInRun($qid)) // but is assigned to any LO
488 {
489 $seq->setQuestionOptional($qid);
490 }
491 }
492 }
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 55 of file class.ilLOTestQuestionAdapter.php.

56 {
57 $this->testRefId = $testRefId;
58 }

References $testRefId.

◆ storeTestRun()

ilLOTestQuestionAdapter::storeTestRun ( )
protected

Store test run in DB.

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

525 {
526 foreach ($this->run as $tst_run)
527 {
528 $tst_run->update();
529 }
530 }

Referenced by prepareTestPass().

+ Here is the caller graph for this function:

◆ updateFixedQuestions()

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

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

576 {
577 foreach ($this->run as $tst_run)
578 {
579 $tst_run->clearQuestions();
580 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
582 ilObject::_lookupObjId($session->getRefId()),
583 $tst_run->getObjectiveId()
584 );
585 $points = 0;
586 foreach($qst as $id)
587 {
588 $tst_run->addQuestion($id);
590 }
591 $tst_run->setMaxPoints($points);
592 }
593 }
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 426 of file class.ilLOTestQuestionAdapter.php.

427 {
428 foreach($this->run as $run)
429 {
430 if($run->questionExists($qst->getId()))
431 {
432 $GLOBALS['ilLog']->write(__METHOD__.': reached points are '.$qst->getReachedPoints($session->getActiveId(),$session->getPass()));
433 $run->setQuestionResult(
434 $qst->getId(),
435 $qst->getReachedPoints($session->getActiveId(),$session->getPass())
436 );
437 $run->update();
438
439 $res = $run->getResult();
440
441 include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
442 include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
443
444 $old_result = ilLOUserResults::lookupResult(
445 $this->container_id,
446 $this->user_id,
447 $run->getObjectiveId(),
448 $this->getAssignments()->getTypeByTest($session->getRefId())
449 );
450
451 $ur = new ilLOUserResults($this->container_id,$this->user_id);
452 $ur->saveObjectiveResult(
453 $run->getObjectiveId(),
454 $this->getAssignments()->getTypeByTest($session->getRefId()),
456 $this->container_id,
457 $session->getRefId(),
458 $run->getObjectiveId(),
459 $res['max'],$res['reached'],$old_result['limit_perc']) ?
462 (int) $res['percentage'],
463 $old_result['limit_perc'],
464 $old_result['tries'],
465 $old_result['is_final']
466 );
467 $GLOBALS['ilLog']->write(__METHOD__.': '.print_r($run->getResult(),true));
468 $GLOBALS['ilLog']->write(__METHOD__.'!!!!!!!!!!!!!!!!!!!!: '.print_r($comp,TRUE));
469
470 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
471 ilLPStatusWrapper::_updateStatus($this->container_id,$this->user_id);
472 }
473 }
474 return false;
475 }
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 533 of file class.ilLOTestQuestionAdapter.php.

534 {
535 if($this->getAssignments()->isSeparateTest($session->getRefId()))
536 {
537 $GLOBALS['ilLog']->write(__METHOD__.': separate run');
538 return $this->updateSeparateTestQuestions($session, $seq);
539 }
540 if($seq instanceof ilTestSequenceFixedQuestionSet)
541 {
542 $GLOBALS['ilLog']->write(__METHOD__.': fixed run');
543 return $this->updateFixedQuestions($session, $seq);
544 }
545 if($seq instanceof ilTestSequenceRandomQuestionSet)
546 {
547 $GLOBALS['ilLog']->write(__METHOD__.': random run');
548 return $this->updateRandomQuestions($session, $seq);
549 }
550
551 }
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 595 of file class.ilLOTestQuestionAdapter.php.

596 {
597 include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
598 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
599
600 foreach($this->run as $tst_run)
601 {
602 // Clear questions of previous run
603 $tst_run->clearQuestions();
605 $this->container_id,
606 $tst_run->getObjectiveId(),
607 ($this->getSettings()->getQualifiedTest() == $session->getRefId() ?
610 );
611 $stored_sequence_id = $rnd->getQplSequence();
612 $points = 0;
613 foreach($seq->getQuestionIds() as $qst)
614 {
615 if($stored_sequence_id == $seq->getResponsibleSourcePoolDefinitionId($qst))
616 {
617 $tst_run->addQuestion($qst);
619 }
620 }
621 $tst_run->setMaxPoints($points);
622 }
623 }

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

559 {
560 foreach($this->run as $tst_run)
561 {
562 $tst_run->clearQuestions();
563 $points = 0;
564 foreach($seq->getQuestionIds() as $idx => $qst_id)
565 {
566 $tst_run->addQuestion($qst_id);
567 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
569 }
570 $tst_run->setMaxPoints($points);
571 }
572 }

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

Referenced by getContainerId().

◆ $logger

ilLOTestQuestionAdapter::$logger = null
protected

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

◆ $settings

ilLOTestQuestionAdapter::$settings = NULL
protected

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

Referenced by getSettings().

◆ $testRefId

ilLOTestQuestionAdapter::$testRefId = null
protected

◆ $user_id

ilLOTestQuestionAdapter::$user_id = 0
protected

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

Referenced by getUserId().


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