ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilLOTestQuestionAdapter Class Reference

Test question filter. More...

+ Collaboration diagram for ilLOTestQuestionAdapter:

Public Member Functions

 __construct (int $a_user_id, int $a_course_id)
 
 getTestRefId ()
 
 setTestRefId (int $testRefId)
 
 notifyTestStart (ilTestSession $a_test_session, int $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 (int $a_container_id, int $a_tst_ref_id, int $a_user_id)
 
 buildQuestionRelatedObjectiveListByTest (ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
 
 buildQuestionRelatedObjectiveListByQuestions (ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
 
 lookupObjectiveIdByRandomQuestionSelectionDefinitionId (int $a_id)
 
 lookupObjectiveIdByFixedQuestionId (int $a_question_id)
 
 getRelatedObjectivesForSeparatedTest (int $testRefId)
 
 getUserId ()
 
 getContainerId ()
 
 getSettings ()
 
 getAssignments ()
 
 initUserResult (ilTestSession $session)
 
 isQualifiedStartRun (ilTestSession $session)
 Check if current run is a start object run. More...
 
 setQuestionsOptional (ilTestSequence $seq)
 
 hideQuestions (ilTestSequence $seq)
 
 initTestRun (ilTestSession $session)
 
 storeTestRun ()
 
 updateQuestions (ilTestSession $session, ilTestSequence $seq)
 
 updateSeparateTestQuestions (ilTestSession $session, ilTestSequence $seq)
 
 updateFixedQuestions (ilTestSession $session, ilTestSequence $seq)
 
 updateRandomQuestions (ilTestSession $session, ilTestSequenceRandomQuestionSet $seq)
 
 isInRun (int $a_qid)
 

Protected Attributes

ilLOSettings $settings
 
ilLOTestAssignments $assignments
 
array $run = []
 
int $user_id = 0
 
int $container_id = 0
 
int $testRefId = null
 
ilLogger $logger
 

Detailed Description

Test question filter.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilLOTestQuestionAdapter::__construct ( int  $a_user_id,
int  $a_course_id 
)

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

References $DIC, ilLOTestAssignments\getInstance(), ilLOSettings\getInstanceByObjId(), ILIAS\Repository\logger(), and ILIAS\Repository\settings().

40  {
41  global $DIC;
42 
43  $this->logger = $DIC->logger()->crs();
44  $this->user_id = $a_user_id;
45  $this->container_id = $a_course_id;
46  $this->settings = ilLOSettings::getInstanceByObjId($this->container_id);
47  $this->assignments = ilLOTestAssignments::getInstance($this->container_id);
48  }
global $DIC
Definition: shib_login.php:22
static getInstanceByObjId(int $a_obj_id)
static getInstance(int $a_container_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ buildQuestionRelatedObjectiveList()

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

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

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

Referenced by ilTestServiceGUI\buildQuestionRelatedObjectivesList().

176  : void {
177  $testType = $this->assignments->getTypeByTest($this->getTestRefId());
178 
179  if ($testType == ilLOSettings::TYPE_TEST_INITIAL && $this->getSettings()->hasSeparateInitialTests()) {
180  $this->buildQuestionRelatedObjectiveListByTest($a_test_sequence, $a_objectives_list);
181  } elseif ($testType == ilLOSettings::TYPE_TEST_QUALIFIED && $this->getSettings()->hasSeparateQualifiedTests()) {
182  $this->buildQuestionRelatedObjectiveListByTest($a_test_sequence, $a_objectives_list);
183  } else {
184  $this->buildQuestionRelatedObjectiveListByQuestions($a_test_sequence, $a_objectives_list);
185  }
186  }
buildQuestionRelatedObjectiveListByQuestions(ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
buildQuestionRelatedObjectiveListByTest(ilTestQuestionSequence $a_test_sequence, ilTestQuestionRelatedObjectivesList $a_objectives_list)
+ 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 199 of file class.ilLOTestQuestionAdapter.php.

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

Referenced by buildQuestionRelatedObjectiveList().

202  : void {
203  foreach ($a_test_sequence->getQuestionIds() as $questionId) {
204  if ($a_test_sequence instanceof ilTestRandomQuestionSequence) {
205  $definitionId = $a_test_sequence->getResponsibleSourcePoolDefinitionId($questionId);
206  $objectiveIds = $this->lookupObjectiveIdByRandomQuestionSelectionDefinitionId($definitionId);
207  } else {
208  $objectiveIds = $this->lookupObjectiveIdByFixedQuestionId($questionId);
209  }
210 
211  if ($objectiveIds !== []) {
212  $a_objectives_list->addQuestionRelatedObjectives($questionId, $objectiveIds);
213  }
214  }
215  }
lookupObjectiveIdByFixedQuestionId(int $a_question_id)
lookupObjectiveIdByRandomQuestionSelectionDefinitionId(int $a_id)
+ 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 188 of file class.ilLOTestQuestionAdapter.php.

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

Referenced by buildQuestionRelatedObjectiveList().

191  : void {
192  $objectiveIds = array($this->getRelatedObjectivesForSeparatedTest($this->getTestRefId()));
193 
194  foreach ($a_test_sequence->getQuestionIds() as $questionId) {
195  $a_objectives_list->addQuestionRelatedObjectives($questionId, $objectiveIds);
196  }
197  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssignments()

ilLOTestQuestionAdapter::getAssignments ( )
protected

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

References $assignments.

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

253  {
254  return $this->assignments;
255  }
Settings for LO courses.
+ Here is the caller graph for this function:

◆ getContainerId()

ilLOTestQuestionAdapter::getContainerId ( )
protected

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

References $container_id.

Referenced by isQualifiedStartRun(), and lookupObjectiveIdByRandomQuestionSelectionDefinitionId().

242  : int
243  {
244  return $this->container_id;
245  }
+ Here is the caller graph for this function:

◆ getInstance()

static ilLOTestQuestionAdapter::getInstance ( ilTestSession  $a_test_session)
static

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

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

Referenced by ilTestSubmissionReviewGUI\buildUserReviewOutput(), ilTestServiceGUI\getPassOverviewTableData(), ilTestServiceGUI\outCorrectSolution(), ilTestEvaluationGUI\outUserListOfAnswerPasses(), ilTestEvaluationGUI\outUserPassDetails(), ilTestPlayerAbstractGUI\save(), ilTestPlayerAbstractGUI\showQuestionCmd(), ilTestEvalObjectiveOrientedGUI\showVirtualPassCmd(), and ilTestPlayerAbstractGUI\startTestCmd().

519  : self
520  {
521  $adapter = new self(
522  $a_test_session->getUserId(),
523  $a_test_session->getObjectiveOrientedContainerId()
524  );
525 
526  $adapter->setTestRefId($a_test_session->getRefId());
527  $adapter->initTestRun($a_test_session);
528  return $adapter;
529  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRelatedObjectivesForSeparatedTest()

ilLOTestQuestionAdapter::getRelatedObjectivesForSeparatedTest ( int  $testRefId)
protected

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

References $testRefId, getAssignments(), and null.

Referenced by buildQuestionRelatedObjectiveListByTest().

227  : ?int
228  {
229  foreach ($this->getAssignments()->getAssignments() as $assignment) {
230  if ($assignment->getTestRefId() === $testRefId) {
231  return $assignment->getObjectiveId();
232  }
233  }
234  return null;
235  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSettings()

ilLOTestQuestionAdapter::getSettings ( )
protected

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

References $settings.

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

247  : ilLOSettings
248  {
249  return $this->settings;
250  }
Settings for LO courses.
+ Here is the caller graph for this function:

◆ getTestRefId()

ilLOTestQuestionAdapter::getTestRefId ( )

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

References $testRefId.

Referenced by buildQuestionRelatedObjectiveList(), and buildQuestionRelatedObjectiveListByTest().

50  : ?int
51  {
52  return $this->testRefId;
53  }
+ Here is the caller graph for this function:

◆ getUserId()

ilLOTestQuestionAdapter::getUserId ( )
protected

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

References $user_id.

237  : int
238  {
239  return $this->user_id;
240  }

◆ hideQuestions()

ilLOTestQuestionAdapter::hideQuestions ( ilTestSequence  $seq)
protected

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

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

Referenced by prepareTestPass().

409  : void
410  {
411  // first unhide all questions
412  $seq->clearHiddenQuestions();
413  foreach ($seq->getQuestionIds() as $qid) {
414  if (!$this->isInRun($qid)) {
415  $seq->hideQuestion($qid);
416  }
417  }
418  }
hideQuestion(int $question_id)
+ 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 420 of file class.ilLOTestQuestionAdapter.php.

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

Referenced by notifyTestStart().

420  : void
421  {
422  $this->run = ilLOTestRun::getRun(
423  $this->container_id,
424  $this->user_id,
425  ilObject::_lookupObjId($session->getRefId())
426  );
427  }
static _lookupObjId(int $ref_id)
static getRun(int $a_container_id, int $a_user_id, int $a_test_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initUserResult()

ilLOTestQuestionAdapter::initUserResult ( ilTestSession  $session)
protected

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

References getAssignments(), ilTestSession\getRefId(), isQualifiedStartRun(), ILIAS\Repository\logger(), ilLOUtils\lookupMaxAttempts(), ilLOUtils\lookupObjectiveRequiredPercentage(), and ilLOUserResults\lookupResult().

Referenced by prepareTestPass().

257  : void
258  {
259  // check if current test is start object and fullfilled
260  // if yes => do not increase tries.
261  $is_qualified_run = false;
262  if ($this->isQualifiedStartRun($session)) {
263  $is_qualified_run = true;
264  }
265 
266  foreach ($this->run as $run) {
267  $old_result = ilLOUserResults::lookupResult(
268  $this->container_id,
269  $this->user_id,
270  $run->getObjectiveId(),
271  $this->getAssignments()->getTypeByTest($session->getRefId())
272  );
273 
275  $this->container_id,
276  $run->getObjectiveId(),
277  $session->getRefId(),
278  $run->getMaxPoints()
279  );
280 
281  $max_attempts = ilLOUtils::lookupMaxAttempts(
282  $this->container_id,
283  $run->getObjectiveId(),
284  $session->getRefId()
285  );
286 
287  $this->logger->debug('Max attempts = ' . $max_attempts);
288 
289  if ($max_attempts) {
290  // check if current test is start object and fullfilled
291  // if yes => do not increase tries.
292  $this->logger->debug('Checking for qualified test...');
293  if (!$is_qualified_run) {
294  $this->logger->debug(' and increasing attempts.');
295  ++$old_result['tries'];
296  }
297  $old_result['is_final'] = ($old_result['tries'] >= $max_attempts);
298  }
299 
300  $ur = new ilLOUserResults($this->container_id, $this->user_id);
301  $ur->saveObjectiveResult(
302  $run->getObjectiveId(),
303  $this->getAssignments()->getTypeByTest($session->getRefId()),
304  $old_result['status'],
305  $old_result['result_perc'],
306  $limit,
307  $old_result['tries'],
308  $old_result['is_final']
309  );
310  }
311  }
static lookupResult(int $a_course_obj_id, int $a_user_id, int $a_objective_id, int $a_tst_type)
static lookupObjectiveRequiredPercentage(int $a_container_id, int $a_objective_id, int $a_test_ref_id, int $a_max_points)
isQualifiedStartRun(ilTestSession $session)
Check if current run is a start object run.
static lookupMaxAttempts(int $a_container_id, int $a_objective_id, int $a_test_ref_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isInRun()

ilLOTestQuestionAdapter::isInRun ( int  $a_qid)
protected

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

Referenced by hideQuestions(), and setQuestionsOptional().

509  : bool
510  {
511  foreach ($this->run as $run) {
512  if ($run->questionExists($a_qid)) {
513  return true;
514  }
515  }
516  return false;
517  }
+ Here is the caller graph for this function:

◆ isQualifiedStartRun()

ilLOTestQuestionAdapter::isQualifiedStartRun ( ilTestSession  $session)
protected

Check if current run is a start object run.

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

References ilObject\_getAllReferences(), getAssignments(), getContainerId(), ilTestSession\getRefId(), getSettings(), ilContainerStartObjects\isStartObject(), ILIAS\Repository\logger(), and ilLOSettings\TYPE_TEST_INITIAL.

Referenced by initUserResult().

316  : bool
317  {
318  if ($this->getAssignments()->getTypeByTest($session->getRefId()) == ilLOSettings::TYPE_TEST_INITIAL) {
319  $this->logger->debug('Initial test');
320  return false;
321  }
322 
323  if ($session->getRefId() !== $this->getSettings()->getQualifiedTest()) {
324  $this->logger->debug('No qualified test run');
325  return false;
326  }
327  if (!ilContainerStartObjects::isStartObject($this->getContainerId(), $session->getRefId())) {
328  $this->logger->debug('No start object');
329  return false;
330  }
331  // Check if start object is fullfilled
332 
333  $container_ref_ids = ilObject::_getAllReferences($this->getContainerId());
334  $container_ref_id = end($container_ref_ids);
335 
336  $start = new ilContainerStartObjects(
337  $container_ref_id,
338  $this->getContainerId()
339  );
340  if ($start->isFullfilled($this->getUserId(), $session->getRefId())) {
341  $this->logger->debug('Is fullfilled');
342  return false;
343  }
344  $this->logger->debug('Is not fullfilled');
345  return true;
346  }
static _getAllReferences(int $id)
get all reference ids for object ID
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static isStartObject(int $a_container_id, int $a_item_ref_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupObjectiveIdByFixedQuestionId()

ilLOTestQuestionAdapter::lookupObjectiveIdByFixedQuestionId ( int  $a_question_id)
protected

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

References ilCourseObjectiveQuestion\lookupObjectivesOfQuestion().

Referenced by buildQuestionRelatedObjectiveListByQuestions().

222  : array
223  {
225  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupObjectiveIdByRandomQuestionSelectionDefinitionId()

ilLOTestQuestionAdapter::lookupObjectiveIdByRandomQuestionSelectionDefinitionId ( int  $a_id)
protected

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

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

Referenced by buildQuestionRelatedObjectiveListByQuestions().

217  : array
218  {
220  }
static lookupObjectiveIdsBySequence(int $a_container_id, int $a_seq_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupRelevantObjectiveIdsForTest()

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

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

References $results, ilCourseObjective\_getObjectiveIds(), ilLOTestAssignments\getInstance(), getSettings(), ilLOTestAssignments\getTestByObjective(), ilLOTestAssignments\getTypeByTest(), ILIAS\Repository\logger(), ilLOSettings\TYPE_TEST_INITIAL, and ilLOSettings\TYPE_TEST_QUALIFIED.

Referenced by notifyTestStart().

60  : array
61  {
63 
64  $objective_ids = ilCourseObjective::_getObjectiveIds($a_container_id);
65 
66  $relevant_objective_ids = array();
67  if (!$this->getSettings()->hasSeparateInitialTests()) {
68  if ($a_tst_ref_id === $this->getSettings()->getInitialTest()) {
69  $relevant_objective_ids = $objective_ids;
70  }
71  } elseif (!$this->getSettings()->hasSeparateQualifiedTests()) {
72  if ($a_tst_ref_id === $this->getSettings()->getQualifiedTest()) {
73  $relevant_objective_ids = $objective_ids;
74  }
75  }
76 
77  foreach ($objective_ids as $objective_id) {
78  $assigned_itest = $assignments->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_INITIAL);
79  if ($assigned_itest === $a_tst_ref_id) {
80  $relevant_objective_ids[] = $objective_id;
81  }
82  $assigned_qtest = $assignments->getTestByObjective($objective_id, ilLOSettings::TYPE_TEST_QUALIFIED);
83  if ($assigned_qtest === $a_tst_ref_id) {
84  $relevant_objective_ids[] = $objective_id;
85  }
86  }
87 
88  $relevant_objective_ids = array_unique($relevant_objective_ids);
89 
90  if (count($relevant_objective_ids) <= 1) {
91  return $relevant_objective_ids;
92  }
93 
94  // filter passed objectives
95  $test_type = $assignments->getTypeByTest($a_tst_ref_id);
96  $results = new ilLOUserResults($a_container_id, $a_user_id);
97 
98  $passed = $results->getCompletedObjectiveIds();
99  $this->logger->debug('Passed objectives are ' . print_r($passed, true) . ' for test type: ' . $test_type);
100 
101  // all completed => show all objectives
102  if (count($passed) >= count($relevant_objective_ids)) {
103  return $relevant_objective_ids;
104  }
105 
106  $unpassed = array();
107  foreach ($relevant_objective_ids as $objective_id) {
108  if (!in_array($objective_id, $passed)) {
109  $unpassed[] = $objective_id;
110  }
111  }
112  return $unpassed;
113  }
static _getObjectiveIds(int $course_id, bool $a_activated_only=false)
getTypeByTest(int $a_test_ref_id)
$results
static getInstance(int $a_container_id)
getTestByObjective(int $a_objective_id, int $a_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ notifyTestStart()

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

Called from learning objective test on actual test start.

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

References ilLOTestRun\create(), ilLOTestRun\deleteRun(), ilTestSession\getObjectiveOrientedContainerId(), ilTestSession\getRefId(), ilTestSession\getUserId(), initTestRun(), ILIAS\Repository\logger(), and lookupRelevantObjectiveIdsForTest().

118  : void
119  {
120  $relevant_objectives = $this->lookupRelevantObjectiveIdsForTest(
121  $a_test_session->getObjectiveOrientedContainerId(),
122  $a_test_session->getRefId(),
123  $a_test_session->getUserId()
124  );
125  $this->logger->debug('Notify test start: ' . print_r($relevant_objectives, true));
126 
127  // delete test runs
129  $a_test_session->getObjectiveOrientedContainerId(),
130  $a_test_session->getUserId(),
131  $a_test_obj_id
132  );
133 
134  foreach ($relevant_objectives as $oid) {
135  $this->logger->debug('Adding new run for objective with id: ' . $oid);
136  $run = new ilLOTestRun(
137  $a_test_session->getObjectiveOrientedContainerId(),
138  $a_test_session->getUserId(),
139  $a_test_obj_id,
140  $oid
141  );
142  $run->create();
143  }
144 
145  // finally reinitialize test runs
146  $this->initTestRun($a_test_session);
147  }
static deleteRun(int $a_container_id, int $a_user_id, int $a_test_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
lookupRelevantObjectiveIdsForTest(int $a_container_id, int $a_tst_ref_id, int $a_user_id)
+ Here is the call graph for this function:

◆ prepareTestPass()

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

Called from learning objective test.

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

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

152  : bool
153  {
154  $this->logger->debug('Prepare test pass called');
155 
156  $this->updateQuestions($a_test_session, $a_test_sequence);
157 
158  if ($this->getSettings()->getPassedObjectiveMode() == ilLOSettings::MARK_PASSED_OBJECTIVE_QST) {
159  $this->setQuestionsOptional($a_test_sequence);
160  } elseif ($this->getSettings()->getPassedObjectiveMode() == ilLOSettings::HIDE_PASSED_OBJECTIVE_QST) {
161  $this->hideQuestions($a_test_sequence);
162  }
163 
164  $this->storeTestRun();
165  $this->initUserResult($a_test_session);
166 
167  // Save test sequence
168  $a_test_sequence->saveToDb();
169 
170  return true;
171  }
const HIDE_PASSED_OBJECTIVE_QST
saveToDb()
Saves the sequence data for a given pass to the database.
updateQuestions(ilTestSession $session, ilTestSequence $seq)
const MARK_PASSED_OBJECTIVE_QST
initUserResult(ilTestSession $session)
+ Here is the call graph for this function:

◆ setQuestionsOptional()

ilLOTestQuestionAdapter::setQuestionsOptional ( ilTestSequence  $seq)
protected

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

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

Referenced by prepareTestPass().

398  : void
399  {
400  // first unset optional on all questions
401  $seq->clearOptionalQuestions();
402  foreach ($seq->getQuestionIds() as $qid) {
403  if (!$this->isInRun($qid)) { // but is assigned to any LO
404  $seq->setQuestionOptional($qid);
405  }
406  }
407  }
setQuestionOptional(int $question_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTestRefId()

ilLOTestQuestionAdapter::setTestRefId ( int  $testRefId)

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

References $testRefId.

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

◆ storeTestRun()

ilLOTestQuestionAdapter::storeTestRun ( )
protected

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

Referenced by prepareTestPass().

429  : void
430  {
431  foreach ($this->run as $tst_run) {
432  $tst_run->update();
433  }
434  }
+ Here is the caller graph for this function:

◆ updateFixedQuestions()

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

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

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

Referenced by updateQuestions().

464  : void
465  {
466  foreach ($this->run as $tst_run) {
467  $tst_run->clearQuestions();
469  ilObject::_lookupObjId($session->getRefId()),
470  $tst_run->getObjectiveId()
471  );
472  $points = 0;
473  foreach ($qst as $id) {
474  $tst_run->addQuestion($id);
476  }
477  $tst_run->setMaxPoints((int) $points);
478  }
479  }
static _lookupMaximumPointsOfQuestion(int $a_question_id)
static lookupQuestionsByObjective(int $a_test_id, int $a_objective)
static _lookupObjId(int $ref_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ 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

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

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

351  : void
352  {
353  foreach ($this->run as $run) {
354  if ($run->questionExists($qst->getId())) {
355  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': reached points are ' . $qst->getReachedPoints(
356  $session->getActiveId(),
357  $session->getPass()
358  ));
359  $run->setQuestionResult(
360  $qst->getId(),
361  $qst->getReachedPoints($session->getActiveId(), $session->getPass())
362  );
363  $run->update();
364 
365  $res = $run->getResult();
366 
367  $old_result = ilLOUserResults::lookupResult(
368  $this->container_id,
369  $this->user_id,
370  $run->getObjectiveId(),
371  $this->getAssignments()->getTypeByTest($session->getRefId())
372  );
373 
374  $ur = new ilLOUserResults($this->container_id, $this->user_id);
375  $ur->saveObjectiveResult(
376  $run->getObjectiveId(),
377  $this->getAssignments()->getTypeByTest($session->getRefId()),
378  $comp = ilLOUtils::isCompleted(
379  $this->container_id,
380  $session->getRefId(),
381  $run->getObjectiveId(),
382  $res['max'],
383  $res['reached'],
384  $old_result['limit_perc']
385  ) ?
388  (float) $res['percentage'],
389  $old_result['limit_perc'],
390  $old_result['tries'],
391  $old_result['is_final']
392  );
393  ilLPStatusWrapper::_updateStatus($this->container_id, $this->user_id);
394  }
395  }
396  }
$res
Definition: ltiservices.php:66
static lookupResult(int $a_course_obj_id, int $a_user_id, int $a_objective_id, int $a_tst_type)
$GLOBALS["DIC"]
Definition: wac.php:53
static isCompleted(int $a_cont_oid, int $a_test_rid, int $a_objective_id, int $max_points, int $reached, int $limit_perc)
Check if objective is completed.
getReachedPoints(int $active_id, int $pass)
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
+ Here is the call graph for this function:

◆ updateQuestions()

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

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

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

Referenced by prepareTestPass().

436  : void
437  {
438  if ($this->getAssignments()->isSeparateTest($session->getRefId())) {
439  $this->updateSeparateTestQuestions($session, $seq);
440  return;
441  }
442  if ($seq instanceof ilTestSequenceFixedQuestionSet) {
443  $this->updateFixedQuestions($session, $seq);
444  return;
445  }
446  if ($seq instanceof ilTestSequenceRandomQuestionSet) {
447  $this->updateRandomQuestions($session, $seq);
448  }
449  }
updateRandomQuestions(ilTestSession $session, ilTestSequenceRandomQuestionSet $seq)
updateSeparateTestQuestions(ilTestSession $session, ilTestSequence $seq)
updateFixedQuestions(ilTestSession $session, ilTestSequence $seq)
+ 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 481 of file class.ilLOTestQuestionAdapter.php.

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

Referenced by updateQuestions().

481  : void
482  {
483  foreach ($this->run as $tst_run) {
484  // Clear questions of previous run
485  $tst_run->clearQuestions();
486 
488  $this->container_id,
489  $tst_run->getObjectiveId(),
490  ilObject::_lookupObjId($session->getRefId()),
491  (
492  ($this->getSettings()->getQualifiedTest() === $session->getRefId()) ?
495  )
496  );
497 
498  $points = 0;
499  foreach ($seq->getQuestionIds() as $qst) {
500  if (in_array($seq->getResponsibleSourcePoolDefinitionId($qst), $sequences)) {
501  $tst_run->addQuestion($qst);
503  }
504  }
505  $tst_run->setMaxPoints((int) $points);
506  }
507  }
static _lookupMaximumPointsOfQuestion(int $a_question_id)
static _lookupObjId(int $ref_id)
static lookupSequencesByType(int $a_container_id, int $a_objective_id, int $a_test_id, int $a_test_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateSeparateTestQuestions()

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

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

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

Referenced by updateQuestions().

451  : void
452  {
453  foreach ($this->run as $tst_run) {
454  $tst_run->clearQuestions();
455  $points = 0;
456  foreach ($seq->getQuestionIds() as $qst_id) {
457  $tst_run->addQuestion($qst_id);
459  }
460  $tst_run->setMaxPoints((int) $points);
461  }
462  }
static _lookupMaximumPointsOfQuestion(int $a_question_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $assignments

ilLOTestAssignments ilLOTestQuestionAdapter::$assignments
protected

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

Referenced by getAssignments().

◆ $container_id

int ilLOTestQuestionAdapter::$container_id = 0
protected

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

Referenced by getContainerId().

◆ $logger

ilLogger ilLOTestQuestionAdapter::$logger
protected

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

◆ $run

array ilLOTestQuestionAdapter::$run = []
protected

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

◆ $settings

ilLOSettings ilLOTestQuestionAdapter::$settings
protected

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

Referenced by getSettings().

◆ $testRefId

int ilLOTestQuestionAdapter::$testRefId = null
protected

◆ $user_id

int ilLOTestQuestionAdapter::$user_id = 0
protected

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

Referenced by getUserId().


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