ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilTestSequenceFactory.php
Go to the documentation of this file.
1 <?php
2 
20 
27 {
29  private array $testSequences = [];
30  private ilDBInterface $db;
31  private ilLanguage $lng;
35 
36  public function __construct(
37  ilDBInterface $db,
38  ilLanguage $lng,
39  Refinery $refinery,
40  ilComponentRepository $component_repository,
41  ilObjTest $testOBJ
42  ) {
43  $this->db = $db;
44  $this->lng = $lng;
45  $this->refinery = $refinery;
46  $this->component_repository = $component_repository;
47  $this->testOBJ = $testOBJ;
48  }
49 
57  public function getSequenceByTestSession($testSession)
58  {
59  return $this->getSequenceByActiveIdAndPass($testSession->getActiveId(), $testSession->getPass());
60  }
61 
70  public function getSequenceByActiveIdAndPass($activeId, $pass)
71  {
72  if (!isset($this->testSequences[$activeId][$pass])) {
73  if ($this->testOBJ->isFixedTest()) {
74  $this->testSequences[$activeId][$pass] = new ilTestSequenceFixedQuestionSet(
75  $activeId,
76  $pass,
77  $this->testOBJ->isRandomTest()
78  );
79  }
80 
81  if ($this->testOBJ->isRandomTest()) {
82  $this->testSequences[$activeId][$pass] = new ilTestSequenceRandomQuestionSet(
83  $activeId,
84  $pass,
85  $this->testOBJ->isRandomTest()
86  );
87  }
88 
89  if ($this->testOBJ->isDynamicTest()) {
90  $questionSet = new ilTestDynamicQuestionSet(
91  $this->db,
92  $this->lng,
93  $this->refinery,
94  $this->component_repository,
95  $this->testOBJ
96  );
97  $this->testSequences[$activeId][$pass] = new ilTestSequenceDynamicQuestionSet(
98  $this->db,
99  $questionSet,
100  $activeId
101  );
102  }
103  }
104 
105  return $this->testSequences[$activeId][$pass];
106  }
107 }
Readable part of repository interface to ilComponentDataDB.
ilComponentRepository $component_repository
getSequenceByTestSession($testSession)
creates and returns an instance of a test sequence that corresponds to the current test mode and the ...
__construct(ilDBInterface $db, ilLanguage $lng, Refinery $refinery, ilComponentRepository $component_repository, ilObjTest $testOBJ)
getSequenceByActiveIdAndPass($activeId, $pass)
creates and returns an instance of a test sequence that corresponds to the current test mode and give...