ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAsqFactory.php
Go to the documentation of this file.
1 <?php
2 
25 {
29  public function service(): ilAsqService
30  {
31  return new ilAsqService();
32  }
33 
38  public function getQuestionDataArray($parentObjectId): array
39  {
40  global $DIC; /* @var ILIAS\DI\Container $DIC */
41 
42  /* @var ilComponentRepository $component_repository */
43  $component_repository = $DIC['component.repository'];
44 
45  $list = new ilAssQuestionList($DIC->database(), $DIC->language(), $DIC->refinery(), $component_repository);
46  $list->setParentObjIdsFilter([$parentObjectId]);
47  $list->load();
48 
49  return $list->getQuestionDataArray(); // returns an array of arrays containing the question data
50 
55  }
56 
61  public function getQuestionInstances($parentObjectId): array
62  {
63  global $DIC; /* @var ILIAS\DI\Container $DIC */
64 
65  /* @var ilComponentRepository $component_repository */
66  $component_repository = $DIC['component.repository'];
67 
68  $list = new ilAssQuestionList($DIC->database(), $DIC->language(), $DIC->refinery(), $component_repository);
69  $list->setParentObjIdsFilter(array($parentObjectId));
70  $list->load();
71 
72  $questionInstances = array();
73 
74  foreach ($list->getQuestionDataArray() as $questionId => $questionData) {
75  $questionInstances[] = $this->getQuestionInstance($questionId);
76  }
77 
78  return $questionInstances;
79  }
80 
85  public function getAuthoringCommandInstance($questionInstance): ilAsqQuestionAuthoring
86  {
87  $authoringGUI; /* @var ilAsqQuestionAuthoring $authoringGUI */
88 
94  $authoringGUI->setQuestion($questionInstance);
95 
96  return $authoringGUI;
97  }
98 
102  public const RENDER_PURPOSE_PLAYBACK = 'renderPurposePlayback'; // e.g. Test Player
103  public const RENDER_PURPOSE_DEMOPLAY = 'renderPurposeDemoplay'; // e.g. Page Editing View in Test
104  public const RENDER_PURPOSE_PREVIEW = 'renderPurposePreview'; // e.g. Preview Player
105  public const RENDER_PURPOSE_PRINT_PDF = 'renderPurposePrintPdf'; // When used for PDF rendering
106  public const RENDER_PURPOSE_INPUT_VALUE = 'renderPurposeInputValue'; // When used as RTE Input Content
107 
112  public function getQuestionPresentationInstance($questionInstance, $renderPurpose): ilAsqQuestionPresentation
113  {
114  $presentationGUI; /* @var ilAsqQuestionPresentation $presentationGUI */
115 
122  $presentationGUI->setQuestion($questionInstance);
123 
124  return $presentationGUI;
125  }
126 
131  public function getQuestionInstance($questionId): ilAsqQuestion
132  {
133  $questionInstance; /* @var ilAsqQuestion $questionInstance */
134 
140  $questionInstance->setId($questionId);
141  $questionInstance->load();
142 
143  return $questionInstance;
144  }
145 
150  public function getEmptyQuestionInstance($questionType): ilAsqQuestion
151  {
152  $questionInstance; /* @var ilAsqQuestion $questionInstance */
153 
159  return $questionInstance;
160  }
161 
166  public function getOfflineExportableQuestionInstance($questionId, $a_image_path = null, $a_output_mode = 'presentation'): ilAsqQuestion
167  {
168  $questionInstance; /* @var ilAsqQuestion $questionInstance */
169 
175  $questionInstance->setId($questionId);
176  $questionInstance->load();
177 
178  $questionInstance->setOfflineExportImagePath($a_image_path);
179  $questionInstance->setOfflineExportPagePresentationMode($a_output_mode);
180 
181  return $questionInstance;
182  }
183 
188  public function getQuestionOfflinePresentationExporter(ilAsqQuestion $offlineExportableQuestionInstance)
189  {
190  $qstOffPresentationExporter; /* @var ilAsqQuestionOfflinePresentationExporter $qstOffPresentationExporter */
191 
198  $qstOffPresentationExporter->setQuestion($offlineExportableQuestionInstance);
199 
200  return $qstOffPresentationExporter;
201  }
202 
207  {
213  return new ilAsqQuestionResourcesCollector();
214  }
215 
221  public function getQuestionSolutionInstance($questionId, $solutionId): ilAsqQuestionSolution
222  {
223  $questionSolutionInstance; /* @var ilAsqQuestionSolution $questionSolutionInstance */
224 
229  $questionSolutionInstance->setQuestionId($questionId);
230  $questionSolutionInstance->setSolutionId($solutionId);
231  $questionSolutionInstance->load();
232 
233  return $questionSolutionInstance;
234  }
235 
241  {
242  $emptySolutionInstance; /* @var ilAsqQuestionSolution $questionSolutionInstance */
243 
249  $emptySolutionInstance->setQuestionId($questionId);
250 
251  return $emptySolutionInstance;
252  }
253 
259  public function getResultCalculator(ilAsqQuestion $questionInstance, ilAsqQuestionSolution $solutionInstance): ilAsqResultCalculator
260  {
261  $resultCalculator; /* @var ilAsqResultCalculator $resultCalculator */
262 
268  $resultCalculator->setQuestion($questionInstance);
269  $resultCalculator->setSolution($solutionInstance);
270 
271  return $resultCalculator;
272  }
273 }
getOfflineExportableQuestionInstance($questionId, $a_image_path=null, $a_output_mode='presentation')
getEmptyQuestionInstance($questionType)
setQuestionId($questionId)
getResultCalculator(ilAsqQuestion $questionInstance, ilAsqQuestionSolution $solutionInstance)
getQuestionDataArray($parentObjectId)
getQuestionInstance($questionId)
setQuestion(ilAsqQuestion $question)
getQuestionInstances($parentObjectId)
setQuestion(ilAsqQuestion $question)
setQuestion(ilAsqQuestion $question)
global $DIC
Definition: feed.php:28
getAuthoringCommandInstance($questionInstance)
getQuestionSolutionInstance($questionId, $solutionId)
const RENDER_PURPOSE_PLAYBACK
render purpose constants that are required to get corresponding presentation renderer ...
getQuestionOfflinePresentationExporter(ilAsqQuestion $offlineExportableQuestionInstance)
getQuestionPresentationInstance($questionInstance, $renderPurpose)
getEmptyQuestionSolutionInstance($questionId)
setId($questionId)
setParentObjIdsFilter($parentObjIdsFilter)
const RENDER_PURPOSE_INPUT_VALUE
const RENDER_PURPOSE_PRINT_PDF