ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestSequenceFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29{
31 private array $test_sequences = [];
32
33 public function __construct(
34 private ilObjTest $test_obj,
35 private ilDBInterface $db,
36 private GeneralQuestionPropertiesRepository $questionrepository
37 ) {
38 }
39
47 public function getSequenceByTestSession($testSession)
48 {
49 return $this->getSequenceByActiveIdAndPass($testSession->getActiveId(), $testSession->getPass());
50 }
51
60 public function getSequenceByActiveIdAndPass($activeId, $pass)
61 {
62 if (!isset($this->test_sequences[$activeId][$pass])) {
63 if ($this->test_obj->isFixedTest()) {
64 $this->test_sequences[$activeId][$pass] = new ilTestSequenceFixedQuestionSet(
65 $this->db,
66 $activeId,
67 $pass,
68 $this->questionrepository
69 );
70 }
71
72 if ($this->test_obj->isRandomTest()) {
73 $this->test_sequences[$activeId][$pass] = new ilTestSequenceRandomQuestionSet(
74 $this->db,
75 $activeId,
76 $pass,
77 $this->questionrepository
78 );
79 }
80 }
81
82 return $this->test_sequences[$activeId][$pass];
83 }
84}
getSequenceByActiveIdAndPass($activeId, $pass)
creates and returns an instance of a test sequence that corresponds to the current test mode and give...
getSequenceByTestSession($testSession)
creates and returns an instance of a test sequence that corresponds to the current test mode and the ...
__construct(private ilObjTest $test_obj, private ilDBInterface $db, private GeneralQuestionPropertiesRepository $questionrepository)
Interface ilDBInterface.