ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilAssQuestionList Class Reference
+ Inheritance diagram for ilAssQuestionList:
+ Collaboration diagram for ilAssQuestionList:

Public Member Functions

 __construct (private ilDBInterface $db, private ilLanguage $lng, private Refinery $refinery, private ilComponentRepository $component_repository, private ?NotesService $notes_service=null)
 
 getParentObjId ()
 
 setParentObjId ($parentObjId)
 
 getParentObjectType ()
 
 setParentObjectType ($parentObjType)
 
 getParentObjIdsFilter ()
 
 setParentObjIdsFilter ($parentObjIdsFilter)
 
 setQuestionInstanceTypeFilter ($questionInstanceTypeFilter)
 
 getQuestionInstanceTypeFilter ()
 
 setIncludeQuestionIdsFilter ($questionIdsFilter)
 
 getIncludeQuestionIdsFilter ()
 
 getExcludeQuestionIdsFilter ()
 
 setExcludeQuestionIdsFilter ($excludeQuestionIdsFilter)
 
 getQuestionCompletionStatusFilter ()
 
 setQuestionCompletionStatusFilter ($questionCompletionStatusFilter)
 
 addFieldFilter ($fieldName, $fieldValue)
 
 addTaxonomyFilter ($taxId, $taxNodes, $parentObjId, $parentObjType)
 
 addTaxonomyFilterNoTaxonomySet (bool $flag)
 
 setAvailableTaxonomyIds ($availableTaxonomyIds)
 
 getAvailableTaxonomyIds ()
 
 setAnswerStatusActiveId ($answerStatusActiveId)
 
 getAnswerStatusActiveId ()
 
 setAnswerStatusFilter ($answerStatusFilter)
 
 getAnswerStatusFilter ()
 
 setJoinObjectData ($a_val)
 Set if object data table should be joined. More...
 
 getJoinObjectData ()
 Get if object data table should be joined. More...
 
 setForcedQuestionIds ($forcedQuestionIds)
 
 getForcedQuestionIds ()
 
 load ()
 
 setCommentFilter (int $commented=null)
 
 getDataArrayForQuestionId ($questionId)
 
 getQuestionDataArray ()
 
 isInList ($questionId)
 
 getTitle (string $a_comp_id, string $a_item_type, int $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'
 
const QUESTION_INSTANCE_TYPE_ORIGINALS = 'QST_INSTANCE_TYPE_ORIGINALS'
 
const QUESTION_INSTANCE_TYPE_DUPLICATES = 'QST_INSTANCE_TYPE_DUPLICATES'
 
const QUESTION_INSTANCE_TYPE_ALL = 'QST_INSTANCE_TYPE_ALL'
 
const QUESTION_COMPLETION_STATUS_COMPLETE = 'complete'
 
const QUESTION_COMPLETION_STATUS_INCOMPLETE = 'incomplete'
 
const QUESTION_COMPLETION_STATUS_BOTH = 'complete/incomplete'
 
const QUESTION_COMMENTED_ONLY = '1'
 
const QUESTION_COMMENTED_EXCLUDED = '2'
 

Protected Member Functions

 getTaxItems ($parentType, $parentObjId, $taxId, $taxNode)
 
 getNumberOfCommentsForQuestion (int $question_id)
 
 hasFeedback (int $question_id)
 
 hasHints (int $question_id)
 

Protected Attributes

bool $join_obj_data = true
 
string $filter_comments = null
 
array $questions = []
 

Private Member Functions

 getParentObjFilterExpression ()
 
 getFieldFilterExpressions ()
 
 getTaxonomyFilterExpressions ()
 
 getQuestionInstanceTypeFilterExpression ()
 
 getQuestionIdsFilterExpressions ()
 
 getParentObjectIdFilterExpression ()
 
 getAnswerStatusFilterExpressions ()
 
 getTableJoinExpression ()
 
 getConditionalFilterExpression ()
 
 getSelectFieldsExpression ()
 
 buildBasicQuery ()
 
 buildQuery ()
 
 loadTaxonomyAssignmentData ($parentObjId, $questionId)
 
 isActiveQuestionType (array $questionData)
 
 checkFilters ()
 

Private Attributes

array $parentObjIdsFilter = []
 
int $parentObjId = null
 
string $parentObjType = 'qpl'
 
array $availableTaxonomyIds = []
 
array $fieldFilters = []
 
array $taxFilters = []
 
bool $taxFiltersExcludeAnyObjectsWithTaxonomies = false
 
array $taxParentIds = []
 
array $taxParentTypes = []
 
int $answerStatusActiveId = null
 
array $forcedQuestionIds = []
 
 $answerStatusFilter = null
 
string $questionInstanceTypeFilter = self::QUESTION_INSTANCE_TYPE_ORIGINALS
 
 $includeQuestionIdsFilter = null
 
 $excludeQuestionIdsFilter = null
 
string $questionCompletionStatusFilter = self::QUESTION_COMPLETION_STATUS_BOTH
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionList::__construct ( private ilDBInterface  $db,
private ilLanguage  $lng,
private Refinery  $refinery,
private ilComponentRepository  $component_repository,
private ?NotesService  $notes_service = null 
)

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

84  {
85  }

Member Function Documentation

◆ addFieldFilter()

ilAssQuestionList::addFieldFilter (   $fieldName,
  $fieldValue 
)

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

160  : void
161  {
162  $this->fieldFilters[$fieldName] = $fieldValue;
163  }

◆ addTaxonomyFilter()

ilAssQuestionList::addTaxonomyFilter (   $taxId,
  $taxNodes,
  $parentObjId,
  $parentObjType 
)

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

References $parentObjId, and $parentObjType.

165  : void
166  {
167  $this->taxFilters[$taxId] = $taxNodes;
168  $this->taxParentIds[$taxId] = $parentObjId;
169  $this->taxParentTypes[$taxId] = $parentObjType;
170  }

◆ addTaxonomyFilterNoTaxonomySet()

ilAssQuestionList::addTaxonomyFilterNoTaxonomySet ( bool  $flag)

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

172  : void
173  {
174  $this->taxFiltersExcludeAnyObjectsWithTaxonomies = $flag;
175  }

◆ buildBasicQuery()

ilAssQuestionList::buildBasicQuery ( )
private

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

Referenced by buildQuery().

536  : string
537  {
538  return "
539  {$this->getSelectFieldsExpression()}
540 
541  FROM qpl_questions
542 
543  {$this->getTableJoinExpression()}
544 
545  WHERE qpl_questions.tstamp > 0
546  ";
547  }
+ Here is the caller graph for this function:

◆ buildQuery()

ilAssQuestionList::buildQuery ( )
private

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

References buildBasicQuery(), and getForcedQuestionIds().

Referenced by load().

549  : string
550  {
551  $query = $this->buildBasicQuery() . "
552  {$this->getConditionalFilterExpression()}
553  ";
554 
555  if (count($this->getForcedQuestionIds())) {
556  $query .= "
557  UNION {$this->buildBasicQuery()}
558  AND {$this->db->in('qpl_questions.question_id', $this->getForcedQuestionIds(), false, 'integer')}
559  ";
560  }
561 
562  return $query;
563  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkFilters()

ilAssQuestionList::checkFilters ( )
private

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

References getAnswerStatusActiveId(), and getAnswerStatusFilter().

Referenced by load().

746  : void
747  {
748  if ($this->getAnswerStatusFilter() !== null && !$this->getAnswerStatusActiveId()) {
749  throw new ilTestQuestionPoolException(
750  'No active id given! You cannot use the answer status filter without giving an active id.'
751  );
752  }
753  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAnswerStatusActiveId()

ilAssQuestionList::getAnswerStatusActiveId ( )

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

References $answerStatusActiveId.

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

192  : ?int
193  {
195  }
+ Here is the caller graph for this function:

◆ getAnswerStatusFilter()

ilAssQuestionList::getAnswerStatusFilter ( )

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

References $answerStatusFilter.

Referenced by checkFilters(), and getAnswerStatusFilterExpressions().

202  : ?string
203  {
205  }
+ Here is the caller graph for this function:

◆ getAnswerStatusFilterExpressions()

ilAssQuestionList::getAnswerStatusFilterExpressions ( )
private

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

References getAnswerStatusFilter().

Referenced by getConditionalFilterExpression().

416  : array
417  {
418  $expressions = [];
419 
420  switch ($this->getAnswerStatusFilter()) {
421  case self::ANSWER_STATUS_FILTER_ALL_NON_CORRECT:
422 
423  $expressions[] = '
424  (tst_test_result.question_fi IS NULL OR tst_test_result.points < qpl_questions.points)
425  ';
426  break;
427 
428  case self::ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY:
429 
430  $expressions[] = 'tst_test_result.question_fi IS NULL';
431  break;
432 
433  case self::ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY:
434 
435  $expressions[] = 'tst_test_result.question_fi IS NOT NULL';
436  $expressions[] = 'tst_test_result.points < qpl_questions.points';
437  break;
438  }
439 
440  return $expressions;
441  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAvailableTaxonomyIds()

ilAssQuestionList::getAvailableTaxonomyIds ( )

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

References $availableTaxonomyIds.

Referenced by loadTaxonomyAssignmentData().

182  : array
183  {
185  }
+ Here is the caller graph for this function:

◆ getConditionalFilterExpression()

ilAssQuestionList::getConditionalFilterExpression ( )
private

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

References getAnswerStatusFilterExpressions(), getFieldFilterExpressions(), getParentObjectIdFilterExpression(), getParentObjFilterExpression(), getQuestionIdsFilterExpressions(), getQuestionInstanceTypeFilterExpression(), and getTaxonomyFilterExpressions().

476  : string
477  {
478  $CONDITIONS = [];
479 
480  if ($this->getQuestionInstanceTypeFilterExpression() !== null) {
481  $CONDITIONS[] = $this->getQuestionInstanceTypeFilterExpression();
482  }
483 
484  if ($this->getParentObjFilterExpression() !== null) {
485  $CONDITIONS[] = $this->getParentObjFilterExpression();
486  }
487 
488  if ($this->getParentObjectIdFilterExpression() !== null) {
489  $CONDITIONS[] = $this->getParentObjectIdFilterExpression();
490  }
491 
492  $CONDITIONS = array_merge(
493  $CONDITIONS,
495  $this->getFieldFilterExpressions(),
498  );
499 
500  $CONDITIONS = implode(' AND ', $CONDITIONS);
501 
502  return strlen($CONDITIONS) ? 'AND ' . $CONDITIONS : '';
503  }
+ Here is the call graph for this function:

◆ getDataArrayForQuestionId()

ilAssQuestionList::getDataArrayForQuestionId (   $questionId)

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

710  {
711  return $this->questions[$questionId];
712  }

◆ getExcludeQuestionIdsFilter()

ilAssQuestionList::getExcludeQuestionIdsFilter ( )

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

References $excludeQuestionIdsFilter.

Referenced by getQuestionIdsFilterExpressions().

+ Here is the caller graph for this function:

◆ getFieldFilterExpressions()

ilAssQuestionList::getFieldFilterExpressions ( )
private

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

Referenced by getConditionalFilterExpression().

256  : array
257  {
258  $expressions = [];
259 
260  foreach ($this->fieldFilters as $fieldName => $fieldValue) {
261  switch ($fieldName) {
262  case 'title':
263  case 'description':
264  case 'author':
265  case 'lifecycle':
266 
267  $expressions[] = $this->db->like('qpl_questions.' . $fieldName, 'text', "%%$fieldValue%%");
268  break;
269 
270  case 'type':
271 
272  $expressions[] = "qpl_qst_type.type_tag = {$this->db->quote($fieldValue, 'text')}";
273  break;
274 
275  case 'question_id':
276  if ($fieldValue != "" && !is_array($fieldValue)) {
277  $fieldValue = array($fieldValue);
278  }
279  $expressions[] = $this->db->in("qpl_questions.question_id", $fieldValue, false, "integer");
280  break;
281 
282  case 'parent_title':
283  if ($this->join_obj_data) {
284  $expressions[] = $this->db->like('object_data.title', 'text', "%%$fieldValue%%");
285  }
286  break;
287  }
288  }
289 
290  return $expressions;
291  }
+ Here is the caller graph for this function:

◆ getForcedQuestionIds()

ilAssQuestionList::getForcedQuestionIds ( )
Returns
array

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

References $forcedQuestionIds.

Referenced by buildQuery().

238  : array
239  {
241  }
+ Here is the caller graph for this function:

◆ getIncludeQuestionIdsFilter()

ilAssQuestionList::getIncludeQuestionIdsFilter ( )

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

References $includeQuestionIdsFilter.

Referenced by getQuestionIdsFilterExpressions().

+ Here is the caller graph for this function:

◆ getJoinObjectData()

ilAssQuestionList::getJoinObjectData ( )

Get if object data table should be joined.

Returns
bool join object_data

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

References $join_obj_data.

222  : bool
223  {
224  return $this->join_obj_data;
225  }

◆ getNumberOfCommentsForQuestion()

ilAssQuestionList::getNumberOfCommentsForQuestion ( int  $question_id)
protected

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

References getParentObjId().

Referenced by load().

600  : int
601  {
602  if ($this->notes_service === null) {
603  return 0;
604  }
605  $notes_context = $this->notes_service->data()->context(
606  $this->getParentObjId(),
607  $question_id,
608  'quest'
609  );
610  return $this->notes_service->domain()->getNrOfCommentsForContext($notes_context);
611  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParentObjectIdFilterExpression()

ilAssQuestionList::getParentObjectIdFilterExpression ( )
private

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

Referenced by getConditionalFilterExpression().

407  : ?string
408  {
409  if ($this->parentObjId) {
410  return "qpl_questions.obj_fi = {$this->db->quote($this->parentObjId, 'integer')}";
411  }
412 
413  return null;
414  }
+ Here is the caller graph for this function:

◆ getParentObjectType()

ilAssQuestionList::getParentObjectType ( )

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

References $parentObjType.

Referenced by getTableJoinExpression().

97  : string
98  {
99  return $this->parentObjType;
100  }
+ Here is the caller graph for this function:

◆ getParentObjFilterExpression()

ilAssQuestionList::getParentObjFilterExpression ( )
private

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

References getParentObjId(), and getParentObjIdsFilter().

Referenced by getConditionalFilterExpression().

243  : ?string
244  {
245  if ($this->getParentObjId()) {
246  return 'qpl_questions.obj_fi = ' . $this->db->quote($this->getParentObjId(), 'integer');
247  }
248 
249  if (count($this->getParentObjIdsFilter())) {
250  return $this->db->in('qpl_questions.obj_fi', $this->getParentObjIdsFilter(), false, 'integer');
251  }
252 
253  return null;
254  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParentObjId()

ilAssQuestionList::getParentObjId ( )

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

References $parentObjId.

Referenced by getNumberOfCommentsForQuestion(), getParentObjFilterExpression(), and ilTestSkillEvaluation\init().

87  : ?int
88  {
89  return $this->parentObjId;
90  }
+ Here is the caller graph for this function:

◆ getParentObjIdsFilter()

ilAssQuestionList::getParentObjIdsFilter ( )

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

References $parentObjIdsFilter.

Referenced by getParentObjFilterExpression().

107  : array
108  {
110  }
+ Here is the caller graph for this function:

◆ getQuestionCompletionStatusFilter()

ilAssQuestionList::getQuestionCompletionStatusFilter ( )

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

References $questionCompletionStatusFilter.

150  : string
151  {
153  }

◆ getQuestionDataArray()

ilAssQuestionList::getQuestionDataArray ( )

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

References $questions.

Referenced by QuestionTable\getData(), QuestionTable\getTotalRowCount(), and ilTestSkillEvaluation\initTestQuestionData().

714  : array
715  {
716  return $this->questions;
717  }
+ Here is the caller graph for this function:

◆ getQuestionIdsFilterExpressions()

ilAssQuestionList::getQuestionIdsFilterExpressions ( )
private

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

References getExcludeQuestionIdsFilter(), and getIncludeQuestionIdsFilter().

Referenced by getConditionalFilterExpression().

376  : array
377  {
378  $expressions = [];
379 
380  if (is_array($this->getIncludeQuestionIdsFilter())) {
381  $expressions[] = $this->db->in(
382  'qpl_questions.question_id',
384  false,
385  'integer'
386  );
387  }
388 
389  if (is_array($this->getExcludeQuestionIdsFilter())) {
390  $IN = $this->db->in(
391  'qpl_questions.question_id',
393  true,
394  'integer'
395  );
396 
397  if ($IN == ' 1=2 ') {
398  $IN = ' 1=1 ';
399  } // required for ILIAS < 5.0
400 
401  $expressions[] = $IN;
402  }
403 
404  return $expressions;
405  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionInstanceTypeFilter()

ilAssQuestionList::getQuestionInstanceTypeFilter ( )

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

References $questionInstanceTypeFilter.

Referenced by getQuestionInstanceTypeFilterExpression(), and getTableJoinExpression().

126  {
128  }
+ Here is the caller graph for this function:

◆ getQuestionInstanceTypeFilterExpression()

ilAssQuestionList::getQuestionInstanceTypeFilterExpression ( )
private

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

References getQuestionInstanceTypeFilter().

Referenced by getConditionalFilterExpression().

361  : ?string
362  {
363  switch ($this->getQuestionInstanceTypeFilter()) {
364  case self::QUESTION_INSTANCE_TYPE_ORIGINALS:
365  return 'qpl_questions.original_id IS NULL';
366  case self::QUESTION_INSTANCE_TYPE_DUPLICATES:
367  return 'qpl_questions.original_id IS NOT NULL';
368  case self::QUESTION_INSTANCE_TYPE_ALL:
369  default:
370  return null;
371  }
372 
373  return null;
374  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSelectFieldsExpression()

ilAssQuestionList::getSelectFieldsExpression ( )
private

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

References getAnswerStatusActiveId().

505  : string
506  {
507  $selectFields = array(
508  'qpl_questions.*',
509  'qpl_qst_type.type_tag',
510  'qpl_qst_type.plugin',
511  'qpl_qst_type.plugin_name',
512  'qpl_questions.points max_points'
513  );
514 
515  if ($this->join_obj_data) {
516  $selectFields[] = 'object_data.title parent_title';
517  }
518 
519  if ($this->getAnswerStatusActiveId()) {
520  $selectFields[] = 'tst_test_result.points reached_points';
521  $selectFields[] = "CASE
522  WHEN tst_test_result.points IS NULL THEN '" . self::QUESTION_ANSWER_STATUS_NON_ANSWERED . "'
523  WHEN tst_test_result.points < qpl_questions.points THEN '" . self::QUESTION_ANSWER_STATUS_WRONG_ANSWERED . "'
524  ELSE '" . self::QUESTION_ANSWER_STATUS_CORRECT_ANSWERED . "'
525  END question_answer_status
526  ";
527  }
528 
529  $selectFields = implode(",\n\t\t\t\t", $selectFields);
530 
531  return "
532  SELECT {$selectFields}
533  ";
534  }
+ Here is the call graph for this function:

◆ getTableJoinExpression()

ilAssQuestionList::getTableJoinExpression ( )
private

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

References getAnswerStatusActiveId(), getParentObjectType(), and getQuestionInstanceTypeFilter().

443  : string
444  {
445  $tableJoin = "
446  INNER JOIN qpl_qst_type
447  ON qpl_qst_type.question_type_id = qpl_questions.question_type_fi
448  ";
449 
450  if ($this->join_obj_data) {
451  $tableJoin .= "
452  INNER JOIN object_data
453  ON object_data.obj_id = qpl_questions.obj_fi
454  ";
455  }
456 
457  if ($this->getParentObjectType() === 'tst'
458  && $this->getQuestionInstanceTypeFilter() === self::QUESTION_INSTANCE_TYPE_ALL) {
459  $tableJoin .= "
460  INNER JOIN tst_test_question tstquest
461  ON tstquest.question_fi = qpl_questions.question_id
462  ";
463  }
464 
465  if ($this->getAnswerStatusActiveId()) {
466  $tableJoin .= "
467  LEFT JOIN tst_test_result
468  ON tst_test_result.question_fi = qpl_questions.question_id
469  AND tst_test_result.active_fi = {$this->db->quote($this->getAnswerStatusActiveId(), 'integer')}
470  ";
471  }
472 
473  return $tableJoin;
474  }
+ Here is the call graph for this function:

◆ getTaxItems()

ilAssQuestionList::getTaxItems (   $parentType,
  $parentObjId,
  $taxId,
  $taxNode 
)
protected
Parameters
string$parentType
int$parentObjId
int$taxId
int$taxNode
Returns
array

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

Referenced by getTaxonomyFilterExpressions().

344  : array
345  {
346  $taxTree = new ilTaxonomyTree($taxId);
347 
348  $taxNodeAssignment = new ilTaxNodeAssignment(
349  $parentType,
350  $parentObjId,
351  'quest',
352  $taxId
353  );
354 
355  $subNodes = $taxTree->getSubTreeIds($taxNode);
356  $subNodes[] = $taxNode;
357 
358  return $taxNodeAssignment->getAssignmentsOfNode($subNodes);
359  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getTaxonomyFilterExpressions()

ilAssQuestionList::getTaxonomyFilterExpressions ( )
private

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

References getTaxItems().

Referenced by getConditionalFilterExpression().

293  : array
294  {
295  $expressions = [];
296  if ($this->taxFiltersExcludeAnyObjectsWithTaxonomies) {
297  $expressions[] = 'question_id NOT IN (SELECT DISTINCT item_id FROM tax_node_assignment)';
298  return $expressions;
299  }
300 
301  foreach ($this->taxFilters as $taxId => $taxNodes) {
302  $questionIds = [];
303 
304  $forceBypass = true;
305 
306  foreach ($taxNodes as $taxNode) {
307  $forceBypass = false;
308 
309  $taxItemsByTaxParent = $this->getTaxItems(
310  $this->taxParentTypes[$taxId],
311  $this->taxParentIds[$taxId],
312  $taxId,
313  $taxNode
314  );
315 
316  $taxItemsByParent = $this->getTaxItems(
317  $this->parentObjType,
318  $this->parentObjId,
319  $taxId,
320  $taxNode
321  );
322 
323  $taxItems = array_merge($taxItemsByTaxParent, $taxItemsByParent);
324  foreach ($taxItems as $taxItem) {
325  $questionIds[$taxItem['item_id']] = $taxItem['item_id'];
326  }
327  }
328 
329  if (!$forceBypass) {
330  $expressions[] = $this->db->in('question_id', $questionIds, false, 'integer');
331  }
332  }
333 
334  return $expressions;
335  }
getTaxItems($parentType, $parentObjId, $taxId, $taxNode)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitle()

ilAssQuestionList::getTitle ( string  $a_comp_id,
string  $a_item_type,
int  $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 733 of file class.ilAssQuestionList.php.

733  : string
734  {
735  if ($a_comp_id != 'qpl' || $a_item_type != 'quest' || !$a_item_id) {
736  return '';
737  }
738 
739  if (!isset($this->questions[$a_item_id])) {
740  return '';
741  }
742 
743  return $this->questions[$a_item_id]['title'];
744  }

◆ hasFeedback()

ilAssQuestionList::hasFeedback ( int  $question_id)
protected

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

References $res, ilPageUtil\_existsAndNotEmpty(), ilAssQuestionFeedback\PAGE_OBJECT_TYPE_GENERIC_FEEDBACK, and ilAssQuestionFeedback\PAGE_OBJECT_TYPE_SPECIFIC_FEEDBACK.

Referenced by load().

618  : bool
619  {
620  $pagetypes = [
623  ];
624  $res = $this->db->queryF(
625  "SELECT feedback, feedback_id FROM qpl_fb_generic
626  WHERE question_fi = %s
627  UNION ALL
628  SELECT feedback, feedback_id FROM qpl_fb_specific
629  WHERE question_fi = %s",
630  ['integer', 'integer', ],
631  [$question_id, $question_id]
632  );
633  while ($row = $this->db->fetchAssoc($res)) {
634  if (trim((string) $row['feedback']) !== '') {
635  return true;
636  }
637  foreach ($pagetypes as $pagetype) {
638  if (\ilPageUtil::_existsAndNotEmpty($pagetype, $row['feedback_id'])) {
639  return true;
640  }
641  }
642  }
643  return false;
644  }
$res
Definition: ltiservices.php:69
static _existsAndNotEmpty(string $a_parent_type, int $a_id, string $a_lang="-")
checks whether page exists and is not empty (may return true on some empty pages) ...
const PAGE_OBJECT_TYPE_GENERIC_FEEDBACK
type for generic feedback page objects
const PAGE_OBJECT_TYPE_SPECIFIC_FEEDBACK
type for specific feedback page objects
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasHints()

ilAssQuestionList::hasHints ( int  $question_id)
protected

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

References ilAssQuestionHintList\getListByQuestionId().

Referenced by load().

646  : bool
647  {
648  $questionHintList = ilAssQuestionHintList::getListByQuestionId($question_id);
649  return iterator_count($questionHintList) > 0;
650  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isActiveQuestionType()

ilAssQuestionList::isActiveQuestionType ( array  $questionData)
private

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

References ilComponentInfo\TYPE_MODULES.

Referenced by load().

679  : bool
680  {
681  if (!isset($questionData['plugin'])) {
682  return false;
683  }
684 
685  if (!$questionData['plugin']) {
686  return true;
687  }
688 
689  if (!$this->component_repository->getComponentByTypeAndName(
691  'TestQuestionPool'
692  )->getPluginSlotById('qst')->hasPluginName((string) $questionData['plugin_name'])) {
693  return false;
694  }
695 
696  return $this->component_repository
697  ->getComponentByTypeAndName(
699  'TestQuestionPool'
700  )
701  ->getPluginSlotById(
702  'qst'
703  )
704  ->getPluginByName(
705  (string) $questionData['plugin_name']
706  )->isActive();
707  }
+ Here is the caller graph for this function:

◆ isInList()

ilAssQuestionList::isInList (   $questionId)

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

719  : bool
720  {
721  return isset($this->questions[$questionId]);
722  }

◆ load()

ilAssQuestionList::load ( )

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

References $res, buildQuery(), checkFilters(), ilAssQuestionType\completeMissingPluginName(), getNumberOfCommentsForQuestion(), hasFeedback(), hasHints(), isActiveQuestionType(), ILIAS\Repository\lng(), loadTaxonomyAssignmentData(), and ILIAS\Repository\refinery().

Referenced by QuestionTable\getData(), and QuestionTable\getTotalRowCount().

565  : void
566  {
567  $this->checkFilters();
568 
569  $tags_trafo = $this->refinery->string()->stripTags();
570 
571  $query = $this->buildQuery();
572  $res = $this->db->query($query);
573  while ($row = $this->db->fetchAssoc($res)) {
575 
576  if (!$this->isActiveQuestionType($row)) {
577  continue;
578  }
579 
580  $row['title'] = $tags_trafo->transform($row['title'] ?? '&nbsp;');
581  $row['description'] = $tags_trafo->transform($row['description'] !== '' && $row['description'] !== null ? $row['description'] : '&nbsp;');
582  $row['author'] = $tags_trafo->transform($row['author']);
583  $row['taxonomies'] = $this->loadTaxonomyAssignmentData($row['obj_fi'], $row['question_id']);
584  $row['ttype'] = $this->lng->txt($row['type_tag']);
585  $row['feedback'] = $this->hasFeedback((int) $row['question_id']);
586  $row['hints'] = $this->hasHints((int) $row['question_id']);
587  $row['comments'] = $this->getNumberOfCommentsForQuestion($row['question_id']);
588 
589  if (
590  $this->filter_comments === self::QUESTION_COMMENTED_ONLY && $row['comments'] === 0
591  || $this->filter_comments === self::QUESTION_COMMENTED_EXCLUDED && $row['comments'] > 0
592  ) {
593  continue;
594  }
595 
596  $this->questions[ $row['question_id'] ] = $row;
597  }
598  }
$res
Definition: ltiservices.php:69
isActiveQuestionType(array $questionData)
static completeMissingPluginName($question_type_data)
hasFeedback(int $question_id)
getNumberOfCommentsForQuestion(int $question_id)
hasHints(int $question_id)
loadTaxonomyAssignmentData($parentObjId, $questionId)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadTaxonomyAssignmentData()

ilAssQuestionList::loadTaxonomyAssignmentData (   $parentObjId,
  $questionId 
)
private

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

References getAvailableTaxonomyIds().

Referenced by load().

652  : array
653  {
654  $taxAssignmentData = [];
655 
656  foreach ($this->getAvailableTaxonomyIds() as $taxId) {
657  $taxTree = new ilTaxonomyTree($taxId);
658 
659  $taxAssignment = new ilTaxNodeAssignment('qpl', $parentObjId, 'quest', $taxId);
660 
661  $assignments = $taxAssignment->getAssignmentsOfItem($questionId);
662 
663  foreach ($assignments as $assData) {
664  if (!isset($taxAssignmentData[ $assData['tax_id'] ])) {
665  $taxAssignmentData[ $assData['tax_id'] ] = [];
666  }
667 
668  $nodeData = $taxTree->getNodeData($assData['node_id']);
669 
670  $assData['node_lft'] = $nodeData['lft'];
671 
672  $taxAssignmentData[ $assData['tax_id'] ][ $assData['node_id'] ] = $assData;
673  }
674  }
675 
676  return $taxAssignmentData;
677  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAnswerStatusActiveId()

ilAssQuestionList::setAnswerStatusActiveId (   $answerStatusActiveId)

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

References $answerStatusActiveId.

187  : void
188  {
189  $this->answerStatusActiveId = $answerStatusActiveId;
190  }

◆ setAnswerStatusFilter()

ilAssQuestionList::setAnswerStatusFilter (   $answerStatusFilter)

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

References $answerStatusFilter.

197  : void
198  {
199  $this->answerStatusFilter = $answerStatusFilter;
200  }

◆ setAvailableTaxonomyIds()

ilAssQuestionList::setAvailableTaxonomyIds (   $availableTaxonomyIds)

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

References $availableTaxonomyIds.

Referenced by QuestionTable\__construct().

177  : void
178  {
179  $this->availableTaxonomyIds = $availableTaxonomyIds;
180  }
+ Here is the caller graph for this function:

◆ setCommentFilter()

ilAssQuestionList::setCommentFilter ( int  $commented = null)

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

614  {
615  $this->filter_comments = $commented;
616  }

◆ setExcludeQuestionIdsFilter()

ilAssQuestionList::setExcludeQuestionIdsFilter (   $excludeQuestionIdsFilter)

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

References $excludeQuestionIdsFilter.

145  : void
146  {
147  $this->excludeQuestionIdsFilter = $excludeQuestionIdsFilter;
148  }

◆ setForcedQuestionIds()

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

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

References $forcedQuestionIds.

230  : void
231  {
232  $this->forcedQuestionIds = $forcedQuestionIds;
233  }

◆ setIncludeQuestionIdsFilter()

ilAssQuestionList::setIncludeQuestionIdsFilter (   $questionIdsFilter)

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

130  : void
131  {
132  $this->includeQuestionIdsFilter = $questionIdsFilter;
133  }

◆ setJoinObjectData()

ilAssQuestionList::setJoinObjectData (   $a_val)

Set if object data table should be joined.

Parameters
bool$a_valjoin object_data

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

212  : void
213  {
214  $this->join_obj_data = $a_val;
215  }

◆ setParentObjectType()

ilAssQuestionList::setParentObjectType (   $parentObjType)

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

References $parentObjType.

102  : void
103  {
104  $this->parentObjType = $parentObjType;
105  }

◆ setParentObjId()

ilAssQuestionList::setParentObjId (   $parentObjId)

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

References $parentObjId.

Referenced by QuestionTable\getData(), ilCopySelfAssQuestionTableGUI\getQuestions(), and QuestionTable\getTotalRowCount().

92  : void
93  {
94  $this->parentObjId = $parentObjId;
95  }
+ Here is the caller graph for this function:

◆ setParentObjIdsFilter()

ilAssQuestionList::setParentObjIdsFilter (   $parentObjIdsFilter)
Parameters
array$parentObjIdsFilter

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

References $parentObjIdsFilter.

Referenced by ilAsqFactory\getQuestionDataArray(), and ilAsqFactory\getQuestionInstances().

115  : void
116  {
117  $this->parentObjIdsFilter = $parentObjIdsFilter;
118  }
+ Here is the caller graph for this function:

◆ setQuestionCompletionStatusFilter()

ilAssQuestionList::setQuestionCompletionStatusFilter (   $questionCompletionStatusFilter)

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

References $questionCompletionStatusFilter.

155  : void
156  {
157  $this->questionCompletionStatusFilter = $questionCompletionStatusFilter;
158  }

◆ setQuestionInstanceTypeFilter()

ilAssQuestionList::setQuestionInstanceTypeFilter (   $questionInstanceTypeFilter)

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

120  : void
121  {
122  $this->questionInstanceTypeFilter = (string) $questionInstanceTypeFilter;
123  }

Field Documentation

◆ $answerStatusActiveId

int ilAssQuestionList::$answerStatusActiveId = null
private

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

Referenced by getAnswerStatusActiveId(), and setAnswerStatusActiveId().

◆ $answerStatusFilter

ilAssQuestionList::$answerStatusFilter = null
private

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

Referenced by getAnswerStatusFilter(), and setAnswerStatusFilter().

◆ $availableTaxonomyIds

array ilAssQuestionList::$availableTaxonomyIds = []
private

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

Referenced by getAvailableTaxonomyIds(), and setAvailableTaxonomyIds().

◆ $excludeQuestionIdsFilter

ilAssQuestionList::$excludeQuestionIdsFilter = null
private

◆ $fieldFilters

array ilAssQuestionList::$fieldFilters = []
private

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

◆ $filter_comments

string ilAssQuestionList::$filter_comments = null
protected

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

◆ $forcedQuestionIds

array ilAssQuestionList::$forcedQuestionIds = []
private

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

Referenced by getForcedQuestionIds(), and setForcedQuestionIds().

◆ $includeQuestionIdsFilter

ilAssQuestionList::$includeQuestionIdsFilter = null
private

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

Referenced by getIncludeQuestionIdsFilter().

◆ $join_obj_data

bool ilAssQuestionList::$join_obj_data = true
protected

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

Referenced by getJoinObjectData().

◆ $parentObjId

int ilAssQuestionList::$parentObjId = null
private

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

Referenced by addTaxonomyFilter(), getParentObjId(), and setParentObjId().

◆ $parentObjIdsFilter

array ilAssQuestionList::$parentObjIdsFilter = []
private

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

Referenced by getParentObjIdsFilter(), and setParentObjIdsFilter().

◆ $parentObjType

string ilAssQuestionList::$parentObjType = 'qpl'
private

◆ $questionCompletionStatusFilter

string ilAssQuestionList::$questionCompletionStatusFilter = self::QUESTION_COMPLETION_STATUS_BOTH
private

◆ $questionInstanceTypeFilter

string ilAssQuestionList::$questionInstanceTypeFilter = self::QUESTION_INSTANCE_TYPE_ORIGINALS
private

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

Referenced by getQuestionInstanceTypeFilter().

◆ $questions

array ilAssQuestionList::$questions = []
protected

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

Referenced by getQuestionDataArray().

◆ $taxFilters

array ilAssQuestionList::$taxFilters = []
private

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

◆ $taxFiltersExcludeAnyObjectsWithTaxonomies

bool ilAssQuestionList::$taxFiltersExcludeAnyObjectsWithTaxonomies = false
private

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

◆ $taxParentIds

array ilAssQuestionList::$taxParentIds = []
private

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

◆ $taxParentTypes

array ilAssQuestionList::$taxParentTypes = []
private

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

◆ ANSWER_STATUS_FILTER_ALL_NON_CORRECT

const ilAssQuestionList::ANSWER_STATUS_FILTER_ALL_NON_CORRECT = 'allNonCorrect'

answer status filter value domain

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

◆ ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY

const ilAssQuestionList::ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY = 'nonAnswered'

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

◆ ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY

const ilAssQuestionList::ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY = 'wrongAnswered'

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

◆ QUESTION_ANSWER_STATUS_CORRECT_ANSWERED

const ilAssQuestionList::QUESTION_ANSWER_STATUS_CORRECT_ANSWERED = 'correctAnswered'

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

◆ QUESTION_ANSWER_STATUS_NON_ANSWERED

const ilAssQuestionList::QUESTION_ANSWER_STATUS_NON_ANSWERED = 'nonAnswered'

answer status domain for single questions

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

◆ QUESTION_ANSWER_STATUS_WRONG_ANSWERED

const ilAssQuestionList::QUESTION_ANSWER_STATUS_WRONG_ANSWERED = 'wrongAnswered'

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

◆ QUESTION_COMMENTED_EXCLUDED

const ilAssQuestionList::QUESTION_COMMENTED_EXCLUDED = '2'

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

Referenced by QuestionTable\getFilter().

◆ QUESTION_COMMENTED_ONLY

const ilAssQuestionList::QUESTION_COMMENTED_ONLY = '1'

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

Referenced by QuestionTable\getFilter().

◆ QUESTION_COMPLETION_STATUS_BOTH

const ilAssQuestionList::QUESTION_COMPLETION_STATUS_BOTH = 'complete/incomplete'

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

◆ QUESTION_COMPLETION_STATUS_COMPLETE

const ilAssQuestionList::QUESTION_COMPLETION_STATUS_COMPLETE = 'complete'

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

◆ QUESTION_COMPLETION_STATUS_INCOMPLETE

const ilAssQuestionList::QUESTION_COMPLETION_STATUS_INCOMPLETE = 'incomplete'

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

◆ QUESTION_INSTANCE_TYPE_ALL

const ilAssQuestionList::QUESTION_INSTANCE_TYPE_ALL = 'QST_INSTANCE_TYPE_ALL'

◆ QUESTION_INSTANCE_TYPE_DUPLICATES

◆ QUESTION_INSTANCE_TYPE_ORIGINALS

const ilAssQuestionList::QUESTION_INSTANCE_TYPE_ORIGINALS = 'QST_INSTANCE_TYPE_ORIGINALS'

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