ILIAS  release_4-4 Revision
ilAssQuestionList Class Reference
+ Inheritance diagram for ilAssQuestionList:
+ Collaboration diagram for ilAssQuestionList:

Public Member Functions

 __construct (ilDB $db, ilLanguage $lng, ilPluginAdmin $pluginAdmin, $parentObjId)
 Constructor. More...
 
 addFieldFilter ($fieldName, $fieldValue)
 
 addTaxonomyFilter ($taxId, $taxNodes)
 
 setAvailableTaxonomyIds ($availableTaxonomyIds)
 
 getAvailableTaxonomyIds ()
 
 setAnswerStatusActiveId ($answerStatusActiveId)
 
 getAnswerStatusActiveId ()
 
 setAnswerStatusFilter ($answerStatusFilter)
 
 getAnswerStatusFilter ()
 
 setForcedQuestionIds ($forcedQuestionIds)
 
 getForcedQuestionIds ()
 
 load ()
 
 getQuestionDataArray ()
 
 getTitle ($a_comp_id, $a_item_type, $a_item_id)
 Get title of an assigned item. More...
 

Data Fields

const QUESTION_ANSWER_STATUS_NON_ANSWERED = 'nonAnswered'
 answer status domain for single questions More...
 
const QUESTION_ANSWER_STATUS_WRONG_ANSWERED = 'wrongAnswered'
 
const QUESTION_ANSWER_STATUS_CORRECT_ANSWERED = 'correctAnswered'
 
const ANSWER_STATUS_FILTER_ALL_NON_CORRECT = 'allNonCorrect'
 answer status filter value domain More...
 
const ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY = 'nonAnswered'
 
const ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY = 'wrongAnswered'
 

Private Member Functions

 getFieldFilterExpressions ()
 
 getTaxonomyFilterExpressions ()
 
 getAnswerStatusFilterExpressions ()
 
 getTableJoinExpression ()
 
 getConditionalFilterExpression ()
 
 getSelectFieldsExpression ()
 
 buildBasicQuery ()
 
 buildQuery ()
 
 loadTaxonomyAssignmentData ($questionId)
 
 isActiveQuestionType ($questionData)
 
 checkFilters ()
 

Private Attributes

 $db = null
 
 $lng = null
 
 $pluginAdmin = null
 
 $parentObjId = null
 
 $availableTaxonomyIds = array()
 
 $fieldFilters = array()
 
 $taxFilters = array()
 
 $answerStatusActiveId = null
 
 $forcedQuestionIds = array()
 
 $answerStatusFilter = null
 
 $questions = array()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionList::__construct ( ilDB  $db,
ilLanguage  $lng,
ilPluginAdmin  $pluginAdmin,
  $parentObjId 
)

Constructor.

Parameters
ilDB$db
integer$parentObjId

Definition at line 112 of file class.ilAssQuestionList.php.

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

113  {
114  $this->db = $db;
115  $this->lng = $lng;
116  $this->pluginAdmin = $pluginAdmin;
117  $this->parentObjId = $parentObjId;
118  }

Member Function Documentation

◆ addFieldFilter()

ilAssQuestionList::addFieldFilter (   $fieldName,
  $fieldValue 
)

Definition at line 120 of file class.ilAssQuestionList.php.

121  {
122  $this->fieldFilters[$fieldName] = $fieldValue;
123  }

◆ addTaxonomyFilter()

ilAssQuestionList::addTaxonomyFilter (   $taxId,
  $taxNodes 
)

Definition at line 125 of file class.ilAssQuestionList.php.

Referenced by ilObjQuestionPoolGUI\buildQuestionBrowserTableGUI().

126  {
127  $this->taxFilters[$taxId] = $taxNodes;
128  }
+ Here is the caller graph for this function:

◆ buildBasicQuery()

ilAssQuestionList::buildBasicQuery ( )
private

Definition at line 329 of file class.ilAssQuestionList.php.

Referenced by buildQuery().

330  {
331  return "
332  {$this->getSelectFieldsExpression()}
333 
334  FROM qpl_questions
335 
336  {$this->getTableJoinExpression()}
337 
338  WHERE qpl_questions.original_id IS NULL
339  AND qpl_questions.obj_fi = {$this->db->quote($this->parentObjId, 'integer')}
340  AND qpl_questions.tstamp > 0
341  ";
342  }
+ Here is the caller graph for this function:

◆ buildQuery()

ilAssQuestionList::buildQuery ( )
private

Definition at line 344 of file class.ilAssQuestionList.php.

References $query, buildBasicQuery(), and getForcedQuestionIds().

Referenced by load().

345  {
346  $query = $this->buildBasicQuery()."
347  {$this->getConditionalFilterExpression()}
348  ";
349 
350  if( count($this->getForcedQuestionIds()) )
351  {
352  $query .= "
353  UNION {$this->buildBasicQuery()}
354  AND {$this->db->in('qpl_questions.question_id', $this->getForcedQuestionIds(), false, 'integer')}
355  ";
356  }
357 
358  return $query;
359  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkFilters()

ilAssQuestionList::checkFilters ( )
private

Definition at line 465 of file class.ilAssQuestionList.php.

References getAnswerStatusActiveId(), and getAnswerStatusFilter().

Referenced by load().

466  {
467  if( strlen($this->getAnswerStatusFilter()) && !$this->getAnswerStatusActiveId() )
468  {
469  require_once 'Modules/TestQuestionPool/exceptions/class.ilTestQuestionPoolException.php';
470 
471  throw new ilTestQuestionPoolException(
472  'No active id given! You cannot use the answer status filter without giving an active id.'
473  );
474  }
475 
476  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAnswerStatusActiveId()

ilAssQuestionList::getAnswerStatusActiveId ( )

Definition at line 145 of file class.ilAssQuestionList.php.

References $answerStatusActiveId.

Referenced by checkFilters(), getSelectFieldsExpression(), and getTableJoinExpression().

146  {
148  }
+ Here is the caller graph for this function:

◆ getAnswerStatusFilter()

ilAssQuestionList::getAnswerStatusFilter ( )

Definition at line 155 of file class.ilAssQuestionList.php.

References $answerStatusFilter.

Referenced by checkFilters(), and getAnswerStatusFilterExpressions().

156  {
158  }
+ Here is the caller graph for this function:

◆ getAnswerStatusFilterExpressions()

ilAssQuestionList::getAnswerStatusFilterExpressions ( )
private

Definition at line 242 of file class.ilAssQuestionList.php.

References getAnswerStatusFilter().

Referenced by getConditionalFilterExpression().

243  {
244  $expressions = array();
245 
246  switch( $this->getAnswerStatusFilter() )
247  {
248  case self::ANSWER_STATUS_FILTER_ALL_NON_CORRECT:
249 
250  $expressions[] = '
251  (tst_test_result.question_fi IS NULL OR tst_test_result.points < qpl_questions.points)
252  ';
253  break;
254 
255  case self::ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY:
256 
257  $expressions[] = 'tst_test_result.question_fi IS NULL';
258  break;
259 
260  case self::ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY:
261 
262  $expressions[] = 'tst_test_result.question_fi IS NOT NULL';
263  $expressions[] = 'tst_test_result.points < qpl_questions.points';
264  break;
265  }
266 
267  return $expressions;
268  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAvailableTaxonomyIds()

ilAssQuestionList::getAvailableTaxonomyIds ( )

Definition at line 135 of file class.ilAssQuestionList.php.

References $availableTaxonomyIds.

Referenced by loadTaxonomyAssignmentData().

136  {
138  }
+ Here is the caller graph for this function:

◆ getConditionalFilterExpression()

ilAssQuestionList::getConditionalFilterExpression ( )
private

Definition at line 289 of file class.ilAssQuestionList.php.

References getAnswerStatusFilterExpressions(), getFieldFilterExpressions(), and getTaxonomyFilterExpressions().

290  {
291  $CONDITIONS = array_merge(
292  $this->getFieldFilterExpressions(),
295  );
296 
297  $CONDITIONS = implode(' AND ', $CONDITIONS);
298 
299  return strlen($CONDITIONS) ? 'AND '.$CONDITIONS : '';
300  }
+ Here is the call graph for this function:

◆ getFieldFilterExpressions()

ilAssQuestionList::getFieldFilterExpressions ( )
private

Definition at line 176 of file class.ilAssQuestionList.php.

Referenced by getConditionalFilterExpression().

177  {
178  $expressions = array();
179 
180  foreach($this->fieldFilters as $fieldName => $fieldValue)
181  {
182  switch($fieldName)
183  {
184  case 'title':
185  case 'description':
186  case 'author':
187 
188  $expressions[] = $this->db->like('qpl_questions.' . $fieldName, 'text', "%%$fieldValue%%");
189  break;
190 
191  case 'type':
192 
193  $expressions[] = "qpl_qst_type.type_tag = {$this->db->quote($fieldValue, 'text')}";
194  break;
195  }
196  }
197 
198  return $expressions;
199  }
+ Here is the caller graph for this function:

◆ getForcedQuestionIds()

ilAssQuestionList::getForcedQuestionIds ( )
Returns
array

Definition at line 171 of file class.ilAssQuestionList.php.

References $forcedQuestionIds.

Referenced by buildQuery().

172  {
174  }
+ Here is the caller graph for this function:

◆ getQuestionDataArray()

ilAssQuestionList::getQuestionDataArray ( )

◆ getSelectFieldsExpression()

ilAssQuestionList::getSelectFieldsExpression ( )
private

Definition at line 302 of file class.ilAssQuestionList.php.

References getAnswerStatusActiveId().

303  {
304  $selectFields = array(
305  'qpl_questions.*',
306  'qpl_qst_type.type_tag',
307  'qpl_qst_type.plugin',
308  'qpl_questions.points max_points'
309  );
310 
311  if( $this->getAnswerStatusActiveId() )
312  {
313  $selectFields[] = 'tst_test_result.points reached_points';
314  $selectFields[] = "CASE
315  WHEN tst_test_result.points IS NULL THEN '".self::QUESTION_ANSWER_STATUS_NON_ANSWERED."'
316  WHEN tst_test_result.points < qpl_questions.points THEN '".self::QUESTION_ANSWER_STATUS_WRONG_ANSWERED."'
317  ELSE '".self::QUESTION_ANSWER_STATUS_CORRECT_ANSWERED."'
318  END question_answer_status
319  ";
320  }
321 
322  $selectFields = implode(",\n\t\t\t\t", $selectFields);
323 
324  return "
325  SELECT {$selectFields}
326  ";
327  }
+ Here is the call graph for this function:

◆ getTableJoinExpression()

ilAssQuestionList::getTableJoinExpression ( )
private

Definition at line 270 of file class.ilAssQuestionList.php.

References getAnswerStatusActiveId().

271  {
272  $tableJoin = "
273  INNER JOIN qpl_qst_type
274  ON qpl_qst_type.question_type_id = qpl_questions.question_type_fi
275  ";
276 
277  if( $this->getAnswerStatusActiveId() )
278  {
279  $tableJoin .= "
280  LEFT JOIN tst_test_result
281  ON tst_test_result.question_fi = qpl_questions.question_id
282  AND tst_test_result.active_fi = {$this->db->quote($this->getAnswerStatusActiveId(), 'integer')}
283  ";
284  }
285 
286  return $tableJoin;
287  }
+ Here is the call graph for this function:

◆ getTaxonomyFilterExpressions()

ilAssQuestionList::getTaxonomyFilterExpressions ( )
private

Definition at line 201 of file class.ilAssQuestionList.php.

Referenced by getConditionalFilterExpression().

202  {
203  $expressions = array();
204 
205  require_once 'Services/Taxonomy/classes/class.ilTaxonomyTree.php';
206  require_once 'Services/Taxonomy/classes/class.ilTaxNodeAssignment.php';
207 
208  foreach($this->taxFilters as $taxId => $taxNodes)
209  {
210  $questionIds = array();
211 
212  $forceBypass = true;
213 
214  foreach($taxNodes as $taxNode)
215  {
216  $forceBypass = false;
217 
218  $taxTree = new ilTaxonomyTree($taxId);
219 
220  $taxNodeAssignment = new ilTaxNodeAssignment('qpl', $this->parentObjId, 'quest', $taxId);
221 
222  $subNodes = $taxTree->getSubTreeIds($taxNode);
223  $subNodes[] = $taxNode;
224 
225  $taxItems = $taxNodeAssignment->getAssignmentsOfNode($subNodes);
226 
227  foreach($taxItems as $taxItem)
228  {
229  $questionIds[$taxItem['item_id']] = $taxItem['item_id'];
230  }
231  }
232 
233  if( !$forceBypass )
234  {
235  $expressions[] = $this->db->in('question_id', $questionIds, false, 'integer');
236  }
237  }
238 
239  return $expressions;
240  }
Taxonomy node <-> item assignment.
+ Here is the caller graph for this function:

◆ getTitle()

ilAssQuestionList::getTitle (   $a_comp_id,
  $a_item_type,
  $a_item_id 
)

Get title of an assigned item.

(is used from ilObjTaxonomyGUI when item sorting is activated)

Parameters
string$a_comp_id('qpl' in our context)
string$a_item_type('quest' in our context)
integer$a_item_id(questionId in our context)

Implements ilTaxAssignedItemInfo.

Definition at line 450 of file class.ilAssQuestionList.php.

451  {
452  if( $a_comp_id != 'qpl' || $a_item_type != 'quest' || !(int)$a_item_id )
453  {
454  return '';
455  }
456 
457  if( !isset($this->questions[$a_item_id]) )
458  {
459  return '';
460  }
461 
462  return $this->questions[$a_item_id]['title'];
463  }

◆ isActiveQuestionType()

ilAssQuestionList::isActiveQuestionType (   $questionData)
private

Definition at line 421 of file class.ilAssQuestionList.php.

References IL_COMP_MODULE.

Referenced by load().

422  {
423  if( !isset($questionData['plugin']) )
424  {
425  return false;
426  }
427 
428  if( !$questionData['plugin'] )
429  {
430  return true;
431  }
432 
433  return $this->pluginAdmin->isActive(IL_COMP_MODULE, 'TestQuestionPool', 'qst', $questionData['type_tag']);
434  }
const IL_COMP_MODULE
+ Here is the caller graph for this function:

◆ load()

ilAssQuestionList::load ( )

Definition at line 361 of file class.ilAssQuestionList.php.

References $query, $res, $row, buildQuery(), checkFilters(), isActiveQuestionType(), and loadTaxonomyAssignmentData().

Referenced by ilObjQuestionPoolTaxonomyEditingCommandForwarder\forward().

362  {
363  $this->checkFilters();
364 
365  $query = $this->buildQuery();
366 
367  #vd($query);
368 
369  $res = $this->db->query($query);
370 
371  #vd($this->db->db->last_query);
372 
373  while( $row = $this->db->fetchAssoc($res) )
374  {
375  if( !$this->isActiveQuestionType($row) )
376  {
377  continue;
378  }
379 
380  $row['taxonomies'] = $this->loadTaxonomyAssignmentData($row['question_id']);
381 
382  $row['ttype'] = $this->lng->txt($row['type_tag']);
383 
384  $this->questions[ $row['question_id'] ] = $row;
385  }
386  }
isActiveQuestionType($questionData)
loadTaxonomyAssignmentData($questionId)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadTaxonomyAssignmentData()

ilAssQuestionList::loadTaxonomyAssignmentData (   $questionId)
private

Definition at line 388 of file class.ilAssQuestionList.php.

References getAvailableTaxonomyIds().

Referenced by load().

389  {
390  $taxAssignmentData = array();
391 
392  foreach($this->getAvailableTaxonomyIds() as $taxId)
393  {
394  require_once 'Services/Taxonomy/classes/class.ilTaxonomyTree.php';
395  require_once 'Services/Taxonomy/classes/class.ilTaxNodeAssignment.php';
396 
397  $taxTree = new ilTaxonomyTree($taxId);
398 
399  $taxAssignment = new ilTaxNodeAssignment('qpl', $this->parentObjId, 'quest', $taxId);
400 
401  $assignments = $taxAssignment->getAssignmentsOfItem($questionId);
402 
403  foreach($assignments as $assData)
404  {
405  if( !isset($taxAssignmentData[ $assData['tax_id'] ]) )
406  {
407  $taxAssignmentData[ $assData['tax_id'] ] = array();
408  }
409 
410  $nodeData = $taxTree->getNodeData($assData['node_id']);
411 
412  $assData['node_lft'] = $nodeData['lft'];
413 
414  $taxAssignmentData[ $assData['tax_id'] ][ $assData['node_id'] ] = $assData;
415  }
416  }
417 
418  return $taxAssignmentData;
419  }
Taxonomy node <-> item assignment.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAnswerStatusActiveId()

ilAssQuestionList::setAnswerStatusActiveId (   $answerStatusActiveId)

Definition at line 140 of file class.ilAssQuestionList.php.

References $answerStatusActiveId.

Referenced by ilTestDynamicQuestionSet\initCompleteQuestionList(), and ilTestDynamicQuestionSet\initFilteredQuestionList().

141  {
142  $this->answerStatusActiveId = $answerStatusActiveId;
143  }
+ Here is the caller graph for this function:

◆ setAnswerStatusFilter()

ilAssQuestionList::setAnswerStatusFilter (   $answerStatusFilter)

Definition at line 150 of file class.ilAssQuestionList.php.

References $answerStatusFilter.

151  {
152  $this->answerStatusFilter = $answerStatusFilter;
153  }

◆ setAvailableTaxonomyIds()

ilAssQuestionList::setAvailableTaxonomyIds (   $availableTaxonomyIds)

Definition at line 130 of file class.ilAssQuestionList.php.

References $availableTaxonomyIds.

131  {
132  $this->availableTaxonomyIds = $availableTaxonomyIds;
133  }

◆ setForcedQuestionIds()

ilAssQuestionList::setForcedQuestionIds (   $forcedQuestionIds)
Parameters
array$forcedQuestionIds

Definition at line 163 of file class.ilAssQuestionList.php.

References $forcedQuestionIds.

164  {
165  $this->forcedQuestionIds = $forcedQuestionIds;
166  }

Field Documentation

◆ $answerStatusActiveId

ilAssQuestionList::$answerStatusActiveId = null
private

Definition at line 71 of file class.ilAssQuestionList.php.

Referenced by getAnswerStatusActiveId(), and setAnswerStatusActiveId().

◆ $answerStatusFilter

ilAssQuestionList::$answerStatusFilter = null
private

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

Referenced by getAnswerStatusFilter(), and setAnswerStatusFilter().

◆ $availableTaxonomyIds

ilAssQuestionList::$availableTaxonomyIds = array()
private

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

Referenced by getAvailableTaxonomyIds(), and setAvailableTaxonomyIds().

◆ $db

ilAssQuestionList::$db = null
private

Definition at line 22 of file class.ilAssQuestionList.php.

Referenced by __construct().

◆ $fieldFilters

ilAssQuestionList::$fieldFilters = array()
private

Definition at line 57 of file class.ilAssQuestionList.php.

◆ $forcedQuestionIds

ilAssQuestionList::$forcedQuestionIds = array()
private

Definition at line 76 of file class.ilAssQuestionList.php.

Referenced by getForcedQuestionIds(), and setForcedQuestionIds().

◆ $lng

ilAssQuestionList::$lng = null
private

Definition at line 29 of file class.ilAssQuestionList.php.

Referenced by __construct().

◆ $parentObjId

ilAssQuestionList::$parentObjId = null
private

Definition at line 43 of file class.ilAssQuestionList.php.

Referenced by __construct().

◆ $pluginAdmin

ilAssQuestionList::$pluginAdmin = null
private

Definition at line 36 of file class.ilAssQuestionList.php.

Referenced by __construct().

◆ $questions

ilAssQuestionList::$questions = array()
private

Definition at line 104 of file class.ilAssQuestionList.php.

Referenced by getQuestionDataArray().

◆ $taxFilters

ilAssQuestionList::$taxFilters = array()
private

Definition at line 64 of file class.ilAssQuestionList.php.

◆ ANSWER_STATUS_FILTER_ALL_NON_CORRECT

const ilAssQuestionList::ANSWER_STATUS_FILTER_ALL_NON_CORRECT = 'allNonCorrect'

◆ ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY

const ilAssQuestionList::ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY = 'nonAnswered'

◆ ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY

const ilAssQuestionList::ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY = 'wrongAnswered'

◆ QUESTION_ANSWER_STATUS_CORRECT_ANSWERED

const ilAssQuestionList::QUESTION_ANSWER_STATUS_CORRECT_ANSWERED = 'correctAnswered'

◆ QUESTION_ANSWER_STATUS_NON_ANSWERED

const ilAssQuestionList::QUESTION_ANSWER_STATUS_NON_ANSWERED = 'nonAnswered'

answer status domain for single questions

Definition at line 81 of file class.ilAssQuestionList.php.

Referenced by ilTestPlayerDynamicQuestionSetGUI\buildQuestionSetAnswerStatisticRowArray().

◆ QUESTION_ANSWER_STATUS_WRONG_ANSWERED

const ilAssQuestionList::QUESTION_ANSWER_STATUS_WRONG_ANSWERED = 'wrongAnswered'

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