ILIAS  release_8 Revision v8.23
class.ilTestInfoScreenToolbarFactory.php
Go to the documentation of this file.
1 <?php
2 
26 {
30  private $testRefId;
31 
35  private $testOBJ;
36 
41 
46 
51 
56 
60  public function getTestRefId(): int
61  {
62  return $this->testRefId;
63  }
64 
68  public function setTestRefId($testRefId)
69  {
70  $this->testRefId = $testRefId;
71  }
72 
76  public function getTestOBJ(): ilObjTest
77  {
78  return $this->testOBJ;
79  }
80 
84  public function setTestOBJ($testOBJ)
85  {
86  $this->testOBJ = $testOBJ;
87  }
88 
89  protected function ensureInitialised()
90  {
92 
93  $d = $GLOBALS['DIC'];
94 
95  $this->testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory(
96  $d['tree'],
97  $d['ilDB'],
98  $d['component.repository'],
99  $this->getTestOBJ()
100  );
101 
102  $this->testPlayerFactory = new ilTestPlayerFactory($this->getTestOBJ());
103  $this->testSessionFactory = new ilTestSessionFactory($this->getTestOBJ());
104 
105  $this->testSequenceFactory = new ilTestSequenceFactory(
106  $d['ilDB'],
107  $d['lng'],
108  $d['refinery'],
109  $d['component.repository'],
110  $this->getTestOBJ()
111  );
112  }
113 
114  private function ensureTestObjectInitialised()
115  {
116  if (!($this->testOBJ instanceof ilObjTest)) {
117  $this->testOBJ = ilObjectFactory::getInstanceByRefId($this->testRefId);
118  }
119  }
120 
122  {
123  $this->ensureInitialised();
124 
125  $d = $GLOBALS['DIC'];
126 
127  $toolbar = new ilTestInfoScreenToolbarGUI($d['ilDB'], $d['ilAccess'], $d['ilCtrl'], $d['lng'], $d['component.repository']);
128 
129  $toolbar->setTestOBJ($this->getTestOBJ());
130  $toolbar->setTestPlayerGUI($this->testPlayerFactory->getPlayerGUI());
131 
132  $testQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
133  $testSession = $this->testSessionFactory->getSession();
134  $testSequence = $this->testSequenceFactory->getSequenceByTestSession($testSession);
135  $testSequence->loadFromDb();
136  $testSequence->loadQuestions($testQuestionSetConfig, new ilTestDynamicQuestionSetFilterSelection());
137 
138  $toolbar->setTestQuestionSetConfig($testQuestionSetConfig);
139  $toolbar->setTestSession($testSession);
140  $toolbar->setTestSequence($testSequence);
141 
142  return $toolbar;
143  }
144 }
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296