ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTestDynamicQuestionSet Class Reference
+ Collaboration diagram for ilTestDynamicQuestionSet:

Public Member Functions

 __construct (ilDBInterface $db, ilLanguage $lng, ilPluginAdmin $pluginAdmin, ilObjTest $testOBJ)
 Constructor. More...
 
 load (ilObjTestDynamicQuestionSetConfig $dynamicQuestionSetConfig, ilTestDynamicQuestionSetFilterSelection $filterSelection)
 
 initSelectionQuestionList (ilObjTestDynamicQuestionSetConfig $dynamicQuestionSetConfig, ilTestDynamicQuestionSetFilterSelection $filterSelection)
 
 getActualQuestionSequence ()
 
 questionExists ($questionId)
 
 getQuestionData ($questionId)
 
 getAllQuestionsData ()
 
 getCompleteQuestionList ()
 
 getSelectionQuestionList ()
 
 getFilteredQuestionList ()
 

Private Member Functions

 initCompleteQuestionList (ilObjTestDynamicQuestionSetConfig $dynamicQuestionSetConfig, $answerStatusActiveId)
 
 initFilteredQuestionList (ilObjTestDynamicQuestionSetConfig $dynamicQuestionSetConfig, ilTestDynamicQuestionSetFilterSelection $filterSelection)
 
 initActualQuestionSequence (ilObjTestDynamicQuestionSetConfig $dynamicQuestionSetConfig, ilAssQuestionList $questionList)
 
 getQuestionSequenceStructuredByTaxonomy (ilAssQuestionList $questionList, $orderingTaxId)
 
 getQuestionSequenceStructuredByUpdateDate (ilAssQuestionList $questionList)
 
 buildQuestionList ($sourceQuestionPoolId, $answerStatusActiveId)
 

Private Attributes

 $db = null
 
 $lng = null
 
 $pluginAdmin = null
 
 $testOBJ = null
 
 $completeQuestionList = null
 
 $selectionQuestionList = null
 
 $filteredQuestionList = null
 
 $actualQuestionSequence = array()
 

Detailed Description

Definition at line 15 of file class.ilTestDynamicQuestionSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestDynamicQuestionSet::__construct ( ilDBInterface  $db,
ilLanguage  $lng,
ilPluginAdmin  $pluginAdmin,
ilObjTest  $testOBJ 
)

Constructor.

Parameters
ilObjTest$testOBJ

Definition at line 62 of file class.ilTestDynamicQuestionSet.php.

References $db, $lng, $pluginAdmin, and $testOBJ.

Member Function Documentation

◆ buildQuestionList()

ilTestDynamicQuestionSet::buildQuestionList (   $sourceQuestionPoolId,
  $answerStatusActiveId 
)
private
Parameters
integer$sourceQuestionPoolId
string$answerStatusActiveId
Returns
ilAssQuestionList

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

Referenced by initCompleteQuestionList(), initFilteredQuestionList(), and initSelectionQuestionList().

317  {
318  $questionList = new ilAssQuestionList($this->db, $this->lng, $this->pluginAdmin);
319  $questionList->setParentObjId($sourceQuestionPoolId);
320  $questionList->setAnswerStatusActiveId($answerStatusActiveId);
321  return $questionList;
322  }
+ Here is the caller graph for this function:

◆ getActualQuestionSequence()

ilTestDynamicQuestionSet::getActualQuestionSequence ( )

◆ getAllQuestionsData()

ilTestDynamicQuestionSet::getAllQuestionsData ( )

Definition at line 280 of file class.ilTestDynamicQuestionSet.php.

281  {
282  return $this->completeQuestionList->getQuestionDataArray();
283  }

◆ getCompleteQuestionList()

ilTestDynamicQuestionSet::getCompleteQuestionList ( )

◆ getFilteredQuestionList()

ilTestDynamicQuestionSet::getFilteredQuestionList ( )

◆ getQuestionData()

ilTestDynamicQuestionSet::getQuestionData (   $questionId)

Definition at line 274 of file class.ilTestDynamicQuestionSet.php.

275  {
276  $questionData = $this->completeQuestionList->getQuestionDataArray();
277  return $questionData[$questionId];
278  }

◆ getQuestionSequenceStructuredByTaxonomy()

ilTestDynamicQuestionSet::getQuestionSequenceStructuredByTaxonomy ( ilAssQuestionList  $questionList,
  $orderingTaxId 
)
private

Definition at line 196 of file class.ilTestDynamicQuestionSet.php.

References $path, $tree, ilAssQuestionList\getQuestionDataArray(), and ilObjTaxonomy\SORT_MANUAL.

Referenced by initActualQuestionSequence().

197  {
198  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
199  $tax = new ilObjTaxonomy($orderingTaxId);
200 
201  require_once 'Modules/Test/classes/class.ilTestTaxonomyTree.php';
202  $tree = new ilTestTaxonomyTree($orderingTaxId);
203  $tree->initOrderedTreeIndex($tax);
204 
205  $questionsByNode = array();
206  $nodelessQuestions = array();
207 
208  foreach ($questionList->getQuestionDataArray() as $qId => $qData) {
209  if (isset($qData['taxonomies'][$orderingTaxId]) && count($qData['taxonomies'][$orderingTaxId])) {
210  foreach ($qData['taxonomies'][$orderingTaxId] as $nodeId => $itemData) {
211  $nodeOrderingPath = $tree->getNodeOrderingPathString($itemData['node_id']);
212 
213  if (!isset($questionsByNode[ $nodeOrderingPath ])) {
214  $questionsByNode[ $nodeOrderingPath ] = array();
215  }
216 
217  if ($tax->getItemSorting() == ilObjTaxonomy::SORT_MANUAL) {
218  $questionsByNode[ $nodeOrderingPath ][$itemData['order_nr']] = $qId;
219  } else {
220  $questionsByNode[ $nodeOrderingPath ][$qData['title'] . '::' . $qId] = $qId;
221  }
222  }
223  } else {
224  $nodelessQuestions[$qData['tstamp'] . '::' . $qId] = $qId;
225  }
226  }
227 
228  foreach ($questionsByNode as $path => $questions) {
229  if ($tax->getItemSorting() == ilObjTaxonomy::SORT_MANUAL) {
230  ksort($questions, SORT_NUMERIC);
231  } else {
232  ksort($questions, SORT_STRING);
233  }
234 
235  $questionsByNode[$path] = array_values($questions);
236  }
237 
238  ksort($questionsByNode, SORT_STRING);
239  $sequence = array_values($questionsByNode);
240 
241  ksort($nodelessQuestions);
242  $sequence[] = array_values($nodelessQuestions);
243 
244  return $sequence;
245  }
$path
Definition: aliased.php:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionSequenceStructuredByUpdateDate()

ilTestDynamicQuestionSet::getQuestionSequenceStructuredByUpdateDate ( ilAssQuestionList  $questionList)
private

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

References ilAssQuestionList\getQuestionDataArray().

Referenced by initActualQuestionSequence().

248  {
249  $sequence = array();
250 
251  foreach ($questionList->getQuestionDataArray() as $qId => $qData) {
252  $sequence[ $qData['tstamp'] . '::' . $qId ] = $qId;
253  }
254 
255  ksort($sequence);
256  $sequence = array_values($sequence);
257 
258  return array($sequence);
259  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSelectionQuestionList()

ilTestDynamicQuestionSet::getSelectionQuestionList ( )

◆ initActualQuestionSequence()

ilTestDynamicQuestionSet::initActualQuestionSequence ( ilObjTestDynamicQuestionSetConfig  $dynamicQuestionSetConfig,
ilAssQuestionList  $questionList 
)
private

Definition at line 182 of file class.ilTestDynamicQuestionSet.php.

References ilObjTestDynamicQuestionSetConfig\getOrderingTaxonomyId(), getQuestionSequenceStructuredByTaxonomy(), and getQuestionSequenceStructuredByUpdateDate().

Referenced by load().

183  {
184  if ($dynamicQuestionSetConfig->getOrderingTaxonomyId()) {
186  $questionList,
187  $dynamicQuestionSetConfig->getOrderingTaxonomyId()
188  );
189  }
190 
191  return $this->getQuestionSequenceStructuredByUpdateDate($questionList);
192  }
getQuestionSequenceStructuredByUpdateDate(ilAssQuestionList $questionList)
getQuestionSequenceStructuredByTaxonomy(ilAssQuestionList $questionList, $orderingTaxId)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initCompleteQuestionList()

ilTestDynamicQuestionSet::initCompleteQuestionList ( ilObjTestDynamicQuestionSetConfig  $dynamicQuestionSetConfig,
  $answerStatusActiveId 
)
private

Definition at line 97 of file class.ilTestDynamicQuestionSet.php.

References buildQuestionList(), and ilObjTestDynamicQuestionSetConfig\getSourceQuestionPoolId().

Referenced by load().

98  {
99  $questionList = $this->buildQuestionList(
100  $dynamicQuestionSetConfig->getSourceQuestionPoolId(),
101  $answerStatusActiveId
102  );
103 
104  $questionList->load();
105 
106  return $questionList;
107  }
buildQuestionList($sourceQuestionPoolId, $answerStatusActiveId)
getSourceQuestionPoolId()
getter for source question pool id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFilteredQuestionList()

ilTestDynamicQuestionSet::initFilteredQuestionList ( ilObjTestDynamicQuestionSetConfig  $dynamicQuestionSetConfig,
ilTestDynamicQuestionSetFilterSelection  $filterSelection 
)
private

Definition at line 109 of file class.ilTestDynamicQuestionSet.php.

References buildQuestionList(), ilTestDynamicQuestionSetFilterSelection\getAnswerStatusActiveId(), ilTestDynamicQuestionSetFilterSelection\getAnswerStatusSelection(), ilTestDynamicQuestionSetFilterSelection\getForcedQuestionIds(), ilObjTestDynamicQuestionSetConfig\getOrderingTaxonomyId(), ilObjTestDynamicQuestionSetConfig\getSourceQuestionPoolId(), ilTestDynamicQuestionSetFilterSelection\getTaxonomySelection(), ilObjTaxonomy\getUsageOfObject(), ilObjTestDynamicQuestionSetConfig\isAnswerStatusFilterEnabled(), and ilObjTestDynamicQuestionSetConfig\isTaxonomyFilterEnabled().

Referenced by load().

110  {
111  $questionList = $this->buildQuestionList(
112  $dynamicQuestionSetConfig->getSourceQuestionPoolId(),
113  $filterSelection->getAnswerStatusActiveId()
114  );
115 
116  if ($dynamicQuestionSetConfig->isAnswerStatusFilterEnabled()) {
117  $questionList->setAnswerStatusFilter($filterSelection->getAnswerStatusSelection());
118  }
119 
120  if ($dynamicQuestionSetConfig->isTaxonomyFilterEnabled()) {
121  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
122 
123  $questionList->setAvailableTaxonomyIds(ilObjTaxonomy::getUsageOfObject(
124  $dynamicQuestionSetConfig->getSourceQuestionPoolId()
125  ));
126 
127  foreach ($filterSelection->getTaxonomySelection() as $taxId => $taxNodes) {
128  $questionList->addTaxonomyFilter(
129  $taxId,
130  $taxNodes,
131  $this->testOBJ->getId(),
132  $this->testOBJ->getType()
133  );
134  }
135  } elseif ($dynamicQuestionSetConfig->getOrderingTaxonomyId()) {
136  $questionList->setAvailableTaxonomyIds(array(
137  $dynamicQuestionSetConfig->getOrderingTaxonomyId()
138  ));
139  }
140 
141  $questionList->setForcedQuestionIds($filterSelection->getForcedQuestionIds());
142 
143  $questionList->load();
144 
145  return $questionList;
146  }
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
isTaxonomyFilterEnabled()
isser for taxonomie filter enabled
buildQuestionList($sourceQuestionPoolId, $answerStatusActiveId)
getSourceQuestionPoolId()
getter for source question pool id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSelectionQuestionList()

ilTestDynamicQuestionSet::initSelectionQuestionList ( ilObjTestDynamicQuestionSetConfig  $dynamicQuestionSetConfig,
ilTestDynamicQuestionSetFilterSelection  $filterSelection 
)
Parameters
ilObjTestDynamicQuestionSetConfig$dynamicQuestionSetConfig
ilTestDynamicQuestionSetFilterSelection$filterSelection
Returns
ilAssQuestionList

Definition at line 153 of file class.ilTestDynamicQuestionSet.php.

References buildQuestionList(), ilTestDynamicQuestionSetFilterSelection\getAnswerStatusActiveId(), ilObjTestDynamicQuestionSetConfig\getSourceQuestionPoolId(), ilTestDynamicQuestionSetFilterSelection\getTaxonomySelection(), ilObjTaxonomy\getUsageOfObject(), and ilObjTestDynamicQuestionSetConfig\isTaxonomyFilterEnabled().

Referenced by load().

154  {
155  $questionList = $this->buildQuestionList(
156  $dynamicQuestionSetConfig->getSourceQuestionPoolId(),
157  $filterSelection->getAnswerStatusActiveId()
158  );
159 
160  if ($dynamicQuestionSetConfig->isTaxonomyFilterEnabled()) {
161  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
162 
163  $questionList->setAvailableTaxonomyIds(ilObjTaxonomy::getUsageOfObject(
164  $dynamicQuestionSetConfig->getSourceQuestionPoolId()
165  ));
166 
167  foreach ($filterSelection->getTaxonomySelection() as $taxId => $taxNodes) {
168  $questionList->addTaxonomyFilter(
169  $taxId,
170  $taxNodes,
171  $this->testOBJ->getId(),
172  $this->testOBJ->getType()
173  );
174  }
175  }
176 
177  $questionList->load();
178 
179  return $questionList;
180  }
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
isTaxonomyFilterEnabled()
isser for taxonomie filter enabled
buildQuestionList($sourceQuestionPoolId, $answerStatusActiveId)
getSourceQuestionPoolId()
getter for source question pool id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load()

ilTestDynamicQuestionSet::load ( ilObjTestDynamicQuestionSetConfig  $dynamicQuestionSetConfig,
ilTestDynamicQuestionSetFilterSelection  $filterSelection 
)

Definition at line 72 of file class.ilTestDynamicQuestionSet.php.

References ilTestDynamicQuestionSetFilterSelection\getAnswerStatusActiveId(), initActualQuestionSequence(), initCompleteQuestionList(), initFilteredQuestionList(), and initSelectionQuestionList().

73  {
74  $this->completeQuestionList = $this->initCompleteQuestionList(
75  $dynamicQuestionSetConfig,
76  $filterSelection->getAnswerStatusActiveId()
77  );
78 
79  $this->selectionQuestionList = $this->initSelectionQuestionList(
80  $dynamicQuestionSetConfig,
81  $filterSelection
82  );
83 
84  $this->filteredQuestionList = $this->initFilteredQuestionList(
85  $dynamicQuestionSetConfig,
86  $filterSelection
87  );
88 
89  $this->actualQuestionSequence = $this->initActualQuestionSequence(
90  $dynamicQuestionSetConfig,
91  $this->filteredQuestionList
92  );
93  }
initFilteredQuestionList(ilObjTestDynamicQuestionSetConfig $dynamicQuestionSetConfig, ilTestDynamicQuestionSetFilterSelection $filterSelection)
initActualQuestionSequence(ilObjTestDynamicQuestionSetConfig $dynamicQuestionSetConfig, ilAssQuestionList $questionList)
initSelectionQuestionList(ilObjTestDynamicQuestionSetConfig $dynamicQuestionSetConfig, ilTestDynamicQuestionSetFilterSelection $filterSelection)
initCompleteQuestionList(ilObjTestDynamicQuestionSetConfig $dynamicQuestionSetConfig, $answerStatusActiveId)
+ Here is the call graph for this function:

◆ questionExists()

ilTestDynamicQuestionSet::questionExists (   $questionId)

Definition at line 268 of file class.ilTestDynamicQuestionSet.php.

269  {
270  $questionData = $this->completeQuestionList->getQuestionDataArray();
271  return isset($questionData[$questionId]);
272  }

Field Documentation

◆ $actualQuestionSequence

ilTestDynamicQuestionSet::$actualQuestionSequence = array()
private

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

Referenced by getActualQuestionSequence().

◆ $completeQuestionList

ilTestDynamicQuestionSet::$completeQuestionList = null
private

Definition at line 40 of file class.ilTestDynamicQuestionSet.php.

Referenced by getCompleteQuestionList().

◆ $db

ilTestDynamicQuestionSet::$db = null
private

Definition at line 20 of file class.ilTestDynamicQuestionSet.php.

Referenced by __construct().

◆ $filteredQuestionList

ilTestDynamicQuestionSet::$filteredQuestionList = null
private

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

Referenced by getFilteredQuestionList().

◆ $lng

ilTestDynamicQuestionSet::$lng = null
private

Definition at line 25 of file class.ilTestDynamicQuestionSet.php.

Referenced by __construct().

◆ $pluginAdmin

ilTestDynamicQuestionSet::$pluginAdmin = null
private

Definition at line 30 of file class.ilTestDynamicQuestionSet.php.

Referenced by __construct().

◆ $selectionQuestionList

ilTestDynamicQuestionSet::$selectionQuestionList = null
private

Definition at line 45 of file class.ilTestDynamicQuestionSet.php.

Referenced by getSelectionQuestionList().

◆ $testOBJ

ilTestDynamicQuestionSet::$testOBJ = null
private

Definition at line 35 of file class.ilTestDynamicQuestionSet.php.

Referenced by __construct().


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