ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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)
 update random questions More...
 
 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['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
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 193 of file class.ilLOTestQuestionAdapter.php.

194 {
195 $testType = $this->assignments->getTypeByTest($this->getTestRefId());
196
197 if ($testType == ilLOSettings::TYPE_TEST_INITIAL && $this->getSettings()->hasSeparateInitialTests()) {
198 $this->buildQuestionRelatedObjectiveListByTest($a_test_sequence, $a_objectives_list);
199 } elseif ($testType == ilLOSettings::TYPE_TEST_QUALIFIED && $this->getSettings()->hasSeparateQualifiedTests()) {
200 $this->buildQuestionRelatedObjectiveListByTest($a_test_sequence, $a_objectives_list);
201 } else {
202 $this->buildQuestionRelatedObjectiveListByQuestions($a_test_sequence, $a_objectives_list);
203 }
204 }
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 215 of file class.ilLOTestQuestionAdapter.php.

216 {
217 foreach ($a_test_sequence->getQuestionIds() as $questionId) {
218 if ($a_test_sequence instanceof ilTestRandomQuestionSequence) {
219 $definitionId = $a_test_sequence->getResponsibleSourcePoolDefinitionId($questionId);
220 $objectiveIds = $this->lookupObjectiveIdByRandomQuestionSelectionDefinitionId($definitionId);
221 } else {
222 $objectiveIds = $this->lookupObjectiveIdByFixedQuestionId($questionId);
223 }
224
225 if (count($objectiveIds)) {
226 $a_objectives_list->addQuestionRelatedObjectives($questionId, $objectiveIds);
227 }
228 }
229 }

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

207 {
208 $objectiveIds = array($this->getRelatedObjectivesForSeparatedTest($this->getTestRefId()));
209
210 foreach ($a_test_sequence->getQuestionIds() as $questionId) {
211 $a_objectives_list->addQuestionRelatedObjectives($questionId, $objectiveIds);
212 }
213 }

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 277 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 259 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 593 of file class.ilLOTestQuestionAdapter.php.

594 {
595 global $DIC;
596
597 $ilDB = $DIC['ilDB'];
598 $lng = $DIC['lng'];
599 $ilPluginAdmin = $DIC['ilPluginAdmin'];
600
601 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
602 $questionList = new ilAssQuestionList($ilDB, $lng, $ilPluginAdmin);
603 $questionList->setParentObjId($testObjId);
604
605 $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES);
606 $questionList->setQuestionIdsFilter($questionIds);
607
608 $questionList->load();
609
610 return $questionList->getQuestionDataArray();
611 }
global $DIC
Definition: saml.php:7
$lng
global $ilDB

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

◆ getRelatedObjectivesForSeparatedTest()

ilLOTestQuestionAdapter::getRelatedObjectivesForSeparatedTest (   $testRefId)
protected

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

244 {
245 foreach ($this->getAssignments()->getAssignments() as $assignment) {
246 if ($assignment->getTestRefId() == $testRefId) {
247 return $assignment->getObjectiveId();
248 }
249 }
250
251 return null;
252 }

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

References $user_id.

◆ hideQuestions()

ilLOTestQuestionAdapter::hideQuestions ( ilTestSequence  $seq)
protected

Hide questions.

Parameters
ilTestSequence$seq

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

461 {
462 // first unhide all questions
463 $seq->clearHiddenQuestions();
464 foreach ($seq->getQuestionIds() as $qid) {
465 if (!$this->isInRun($qid)) {
466 $seq->hideQuestion($qid);
467 }
468 }
469 }
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 471 of file class.ilLOTestQuestionAdapter.php.

472 {
473 include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php';
474 $this->run = ilLOTestRun::getRun(
475 $this->container_id,
476 $this->user_id,
478 );
479 }
static getRun($a_container_id, $a_user_id, $a_test_id)
static _lookupObjId($a_id)
run()
Runs the loop.
Definition: functions.php:130
$session

References $session, ilObject\_lookupObjId(), ilLOTestRun\getRun(), and Sabre\Event\Loop\run().

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

286 {
287 // check if current test is start object and fullfilled
288 // if yes => do not increase tries.
289 $is_qualified_run = false;
290 if ($this->isQualifiedStartRun($session)) {
291 $is_qualified_run = true;
292 }
293
294 foreach ($this->run as $run) {
295 include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
296 include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
297
298 $old_result = ilLOUserResults::lookupResult(
299 $this->container_id,
300 $this->user_id,
301 $run->getObjectiveId(),
302 $this->getAssignments()->getTypeByTest($session->getRefId())
303 );
304
305 include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
306
308 $this->container_id,
309 $run->getObjectiveId(),
310 $session->getRefId(),
311 $run->getMaxPoints()
312 );
313
314 $max_attempts = ilLOUtils::lookupMaxAttempts(
315 $this->container_id,
316 $run->getObjectiveId(),
317 $session->getRefId()
318 );
319
320 $this->logger->debug('Max attempts = ' . $max_attempts);
321
322 if ($max_attempts) {
323 // check if current test is start object and fullfilled
324 // if yes => do not increase tries.
325 $this->logger->debug('Checking for qualified test...');
326 if (!$is_qualified_run) {
327 $this->logger->debug(' and increasing attempts.');
328 ++$old_result['tries'];
329 }
330 $old_result['is_final'] = ($old_result['tries'] >= $max_attempts);
331 }
332
333 $ur = new ilLOUserResults($this->container_id, $this->user_id);
334 $ur->saveObjectiveResult(
335 $run->getObjectiveId(),
336 $this->getAssignments()->getTypeByTest($session->getRefId()),
337 $old_result['status'],
338 $old_result['result_perc'],
339 $limit,
340 $old_result['tries'],
341 $old_result['is_final']
342 );
343 }
344 }
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 $session, isQualifiedStartRun(), ilLOUtils\lookupObjectiveRequiredPercentage(), ilLOUserResults\lookupResult(), and Sabre\Event\Loop\run().

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

583 {
584 foreach ($this->run as $run) {
585 if ($run->questionExists($a_qid)) {
586 return true;
587 }
588 }
589 return false;
590 }

References Sabre\Event\Loop\run().

Referenced by hideQuestions(), and setQuestionsOptional().

+ Here is the call graph for this function:
+ 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 351 of file class.ilLOTestQuestionAdapter.php.

352 {
353 if ($this->getAssignments()->getTypeByTest($session->getRefId()) == ilLOSettings::TYPE_TEST_INITIAL) {
354 $this->logger->debug('Initial test');
355 return false;
356 }
357
358 if ($session->getRefId() != $this->getSettings()->getQualifiedTest()) {
359 $this->logger->debug('No qualified test run');
360 return false;
361 }
362 include_once './Services/Container/classes/class.ilContainerStartObjects.php';
364 $this->logger->debug('No start object');
365 return false;
366 }
367 // Check if start object is fullfilled
368
369 $container_ref_ids = ilObject::_getAllReferences($this->getContainerId());
370 $container_ref_id = end($container_ref_ids);
371
373 $container_ref_id,
374 $this->getContainerId()
375 );
376 if ($start->isFullfilled($this->getUserId(), $session->getRefId())) {
377 $this->logger->debug('Is fullfilled');
378 return false;
379 }
380 $this->logger->debug('Is not fullfilled');
381 return true;
382 }
static isStartObject($a_container_id, $a_item_ref_id)
Check if object is start object.
static _getAllReferences($a_id)
get all reference ids of object
$start
Definition: bench.php:8

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

238 {
239 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
241 }
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 231 of file class.ilLOTestQuestionAdapter.php.

232 {
233 include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
235 }
static lookupObjectiveIdsBySequence($a_container_id, $a_seq_id)
Lookup objective ids by sequence_id @global type $ilDB.

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 if ($a_tst_ref_id == $this->getSettings()->getInitialTest()) {
75 $relevant_objective_ids = $objective_ids;
76 }
77 } elseif (!$this->getSettings()->hasSeparateQualifiedTests()) {
78 if ($a_tst_ref_id == $this->getSettings()->getQualifiedTest()) {
79 $relevant_objective_ids = $objective_ids;
80 }
81 }
82
83 foreach ((array) $objective_ids as $objective_id) {
84 $assigned_itest = $assignments->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL);
85 if ($assigned_itest == $a_tst_ref_id) {
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 $relevant_objective_ids[] = $objective_id;
91 }
92 }
93
94 $relevant_objective_ids = array_unique($relevant_objective_ids);
95
96 if (count($relevant_objective_ids) <= 1) {
97 return $relevant_objective_ids;
98 }
99
100 // filter passed objectives
101 $test_type = $assignments->getTypeByTest($a_tst_ref_id);
102
103 $passed_objectives = array();
104 include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
105 $results = new ilLOUserResults($a_container_id, $a_user_id);
106
107 $passed = $results->getCompletedObjectiveIds();
108 $this->logger->debug('Passed objectives are ' . print_r($passed, true) . ' for test type: ' . $test_type);
109
110
111 // all completed => show all objectives
112 if (count($passed) >= count($relevant_objective_ids)) {
113 return $relevant_objective_ids;
114 }
115
116 $unpassed = array();
117 foreach ($relevant_objective_ids as $objective_id) {
118 if (!in_array($objective_id, $passed)) {
119 $unpassed[] = $objective_id;
120 }
121 }
122 return $unpassed;
123 }
static _getObjectiveIds($course_id, $a_activated_only=false)
$results
Definition: svg-scanner.php:47

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

132 {
133 $relevant_objectives = $this->lookupRelevantObjectiveIdsForTest(
134 $a_test_session->getObjectiveOrientedContainerId(),
135 $a_test_session->getRefId(),
136 $a_test_session->getUserId()
137 );
138 $this->logger->debug('Notify test start: ' . print_r($relevant_objectives, true));
139
140 // delete test runs
141 include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php';
143 $a_test_session->getObjectiveOrientedContainerId(),
144 $a_test_session->getUserId(),
145 $a_test_obj_id
146 );
147
148 foreach ((array) $relevant_objectives as $oid) {
149 $this->logger->debug('Adding new run for objective with id: ' . $oid);
150 $run = new ilLOTestRun(
151 $a_test_session->getObjectiveOrientedContainerId(),
152 $a_test_session->getUserId(),
153 $a_test_obj_id,
154 $oid
155 );
156 $run->create();
157 }
158
159 // finally reinitialize test runs
160 $this->initTestRun($a_test_session);
161 }
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 168 of file class.ilLOTestQuestionAdapter.php.

169 {
170 $this->logger->debug('Prepare test pass called');
171
172 $this->updateQuestions($a_test_session, $a_test_sequence);
173
174 if ($this->getSettings()->getPassedObjectiveMode() == ilLOSettings::MARK_PASSED_OBJECTIVE_QST) {
175 $this->setQuestionsOptional($a_test_sequence);
176 } elseif ($this->getSettings()->getPassedObjectiveMode() == ilLOSettings::HIDE_PASSED_OBJECTIVE_QST) {
177 $this->hideQuestions($a_test_sequence);
178 }
179
180 $this->storeTestRun();
181 $this->initUserResult($a_test_session);
182
183 // Save test sequence
184 $a_test_sequence->saveToDb();
185
186 return true;
187 }
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 445 of file class.ilLOTestQuestionAdapter.php.

446 {
447 // first unset optional on all questions
449 foreach ($seq->getQuestionIds() as $qid) {
450 if (!$this->isInRun($qid)) { // but is assigned to any LO
451 $seq->setQuestionOptional($qid);
452 }
453 }
454 }
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 484 of file class.ilLOTestQuestionAdapter.php.

485 {
486 foreach ($this->run as $tst_run) {
487 $tst_run->update();
488 }
489 }

References Sabre\Event\Loop\run().

Referenced by prepareTestPass().

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

◆ updateFixedQuestions()

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

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

529 {
530 foreach ($this->run as $tst_run) {
531 $tst_run->clearQuestions();
532 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
534 ilObject::_lookupObjId($session->getRefId()),
535 $tst_run->getObjectiveId()
536 );
537 $points = 0;
538 foreach ($qst as $id) {
539 $tst_run->addQuestion($id);
541 }
542 $tst_run->setMaxPoints($points);
543 }
544 }
static lookupQuestionsByObjective($a_test_id, $a_objective)
static _lookupMaximumPointsOfQuestion($a_question_id)
lookup maximimum point
if(!array_key_exists('StateId', $_REQUEST)) $id

References $id, $session, ilCourseObjectiveQuestion\_lookupMaximumPointsOfQuestion(), ilObject\_lookupObjId(), ilCourseObjectiveQuestion\lookupQuestionsByObjective(), and Sabre\Event\Loop\run().

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

390 {
391 foreach ($this->run as $run) {
392 if ($run->questionExists($qst->getId())) {
393 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': reached points are ' . $qst->getReachedPoints($session->getActiveId(), $session->getPass()));
394 $run->setQuestionResult(
395 $qst->getId(),
396 $qst->getReachedPoints($session->getActiveId(), $session->getPass())
397 );
398 $run->update();
399
400 $res = $run->getResult();
401
402 include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
403 include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
404
405 $old_result = ilLOUserResults::lookupResult(
406 $this->container_id,
407 $this->user_id,
408 $run->getObjectiveId(),
409 $this->getAssignments()->getTypeByTest($session->getRefId())
410 );
411
412 $ur = new ilLOUserResults($this->container_id, $this->user_id);
413 $ur->saveObjectiveResult(
414 $run->getObjectiveId(),
415 $this->getAssignments()->getTypeByTest($session->getRefId()),
417 $this->container_id,
418 $session->getRefId(),
419 $run->getObjectiveId(),
420 $res['max'],
421 $res['reached'],
422 $old_result['limit_perc']
423 ) ?
426 (int) $res['percentage'],
427 $old_result['limit_perc'],
428 $old_result['tries'],
429 $old_result['is_final']
430 );
431 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': ' . print_r($run->getResult(), true));
432 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . '!!!!!!!!!!!!!!!!!!!!: ' . print_r($comp, true));
433
434 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
435 ilLPStatusWrapper::_updateStatus($this->container_id, $this->user_id);
436 }
437 }
438 return false;
439 }
getReachedPoints($active_id, $pass=null)
Returns the points, a learner has reached answering the question This is the fast way to get the poin...
getId()
Gets the id of the assQuestion object.
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.
foreach($_POST as $key=> $value) $res

References $GLOBALS, $res, $session, ilLPStatusWrapper\_updateStatus(), assQuestion\getId(), assQuestion\getReachedPoints(), ilLOUtils\isCompleted(), ilLOUserResults\lookupResult(), Sabre\Event\Loop\run(), 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 492 of file class.ilLOTestQuestionAdapter.php.

493 {
494 if ($this->getAssignments()->isSeparateTest($session->getRefId())) {
495 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': separate run');
496 return $this->updateSeparateTestQuestions($session, $seq);
497 }
498 if ($seq instanceof ilTestSequenceFixedQuestionSet) {
499 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': fixed run');
500 return $this->updateFixedQuestions($session, $seq);
501 }
502 if ($seq instanceof ilTestSequenceRandomQuestionSet) {
503 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': random run');
504 return $this->updateRandomQuestions($session, $seq);
505 }
506 }
updateSeparateTestQuestions(ilTestSession $session, ilTestSequence $seq)
Update questions for separate tests.
updateRandomQuestions(ilTestSession $session, ilTestSequenceRandomQuestionSet $seq)
update random questions
updateFixedQuestions(ilTestSession $session, ilTestSequence $seq)

References $GLOBALS, $session, getAssignments(), 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

update random questions

Parameters
ilTestSession$session
ilTestSequenceRandomQuestionSet$seq

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

552 {
553 include_once './Modules/Course/classes/Objectives/class.ilLORandomTestQuestionPools.php';
554 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
555
556 foreach ($this->run as $tst_run) {
557 // Clear questions of previous run
558 $tst_run->clearQuestions();
559
561 $this->container_id,
562 $tst_run->getObjectiveId(),
563 ilObject::_lookupObjId($session->getRefId()),
564 (
565 ($this->getSettings()->getQualifiedTest() == $session->getRefId()) ?
568 )
569 );
570
571 $points = 0;
572 foreach ($seq->getQuestionIds() as $qst) {
573 if (in_array($seq->getResponsibleSourcePoolDefinitionId($qst), $sequences)) {
574 $tst_run->addQuestion($qst);
576 }
577 }
578 $tst_run->setMaxPoints($points);
579 }
580 }
static lookupSequencesByType($a_container_id, $a_objective_id, $a_test_id, $a_test_type)
Lookup sequence ids @global type $ilDB.

References $session, ilCourseObjectiveQuestion\_lookupMaximumPointsOfQuestion(), ilObject\_lookupObjId(), ilTestSequence\getQuestionIds(), ilTestSequenceRandomQuestionSet\getResponsibleSourcePoolDefinitionId(), ilLORandomTestQuestionPools\lookupSequencesByType(), Sabre\Event\Loop\run(), 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 513 of file class.ilLOTestQuestionAdapter.php.

514 {
515 foreach ($this->run as $tst_run) {
516 $tst_run->clearQuestions();
517 $points = 0;
518 foreach ($seq->getQuestionIds() as $idx => $qst_id) {
519 $tst_run->addQuestion($qst_id);
520 include_once './Modules/Course/classes/class.ilCourseObjectiveQuestion.php';
522 }
523 $tst_run->setMaxPoints($points);
524 }
525 }

References ilCourseObjectiveQuestion\_lookupMaximumPointsOfQuestion(), ilTestSequence\getQuestionIds(), and Sabre\Event\Loop\run().

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: