ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 
 setOrder (?Order $order=null)
 
 setRange (?Range $range=null)
 
 getParentObjId ()
 
 setParentObjId (?int $parentObjId)
 
 setParentObjectType (string $parentObjType)
 
 setParentObjIdsFilter (array $parentObjIdsFilter)
 
 setQuestionInstanceTypeFilter (?string $questionInstanceTypeFilter)
 
 setIncludeQuestionIdsFilter (array $questionIdsFilter)
 
 setExcludeQuestionIdsFilter (array $excludeQuestionIdsFilter)
 
 addFieldFilter (string $fieldName, mixed $fieldValue)
 
 addTaxonomyFilter ($taxId, $taxNodes, $parentObjId, $parentObjType)
 
 addTaxonomyFilterNoTaxonomySet (bool $flag)
 
 setAvailableTaxonomyIds (array $availableTaxonomyIds)
 
 setAnswerStatusActiveId (?int $answerStatusActiveId)
 
 setAnswerStatusFilter (string $answerStatusFilter)
 
 setJoinObjectData (bool $a_val)
 Set if object data table should be joined. More...
 
 load ()
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 
 setCommentFilter (?int $commented=null)
 
 getDataArrayForQuestionId (int $questionId)
 
 getQuestionDataArray ()
 
 isInList (int $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_COMMENTED_ONLY = '1'
 
const QUESTION_COMMENTED_EXCLUDED = '2'
 

Protected Member Functions

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

Protected Attributes

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

Private Member Functions

 getParentObjFilterExpression ()
 
 getFieldFilterExpressions ()
 
 handleFeedbackJoin (string $tableJoin)
 
 handleHintJoin (string $tableJoin)
 
 getTaxonomyFilterExpressions ()
 
 getFilterByAssignedTaxonomyIdsExpression ()
 
 getQuestionInstanceTypeFilterExpression ()
 
 getQuestionIdsFilterExpressions ()
 
 getAnswerStatusFilterExpressions ()
 
 getTableJoinExpression ()
 
 getConditionalFilterExpression ()
 
 getSelectFieldsExpression ()
 
 generateFeedbackSubquery ()
 
 generateHintSubquery ()
 
 generateTaxonomySubquery ()
 
 buildBasicQuery ()
 
 getHavingFilterExpression ()
 
 buildOrderQueryExpression ()
 
 buildLimitQueryExpression ()
 
 buildQuery ()
 
 loadTaxonomyAssignmentData (int $parent_obj_id, int $question_id)
 
 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
 
string $answerStatusFilter = ''
 
string $questionInstanceTypeFilter = self::QUESTION_INSTANCE_TYPE_ORIGINALS
 
array $includeQuestionIdsFilter = []
 
array $excludeQuestionIdsFilter = []
 
Order $order = null
 
Range $range = null
 

Detailed Description

Definition at line 30 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 77 of file class.ilAssQuestionList.php.

83  {
84  }

Member Function Documentation

◆ addFieldFilter()

ilAssQuestionList::addFieldFilter ( string  $fieldName,
mixed  $fieldValue 
)

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

131  : void
132  {
133  $this->fieldFilters[$fieldName] = $fieldValue;
134  }

◆ addTaxonomyFilter()

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

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

References $parentObjId, and $parentObjType.

136  : void
137  {
138  $this->taxFilters[$taxId] = $taxNodes;
139  $this->taxParentIds[$taxId] = $parentObjId;
140  $this->taxParentTypes[$taxId] = $parentObjType;
141  }

◆ addTaxonomyFilterNoTaxonomySet()

ilAssQuestionList::addTaxonomyFilterNoTaxonomySet ( bool  $flag)

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

143  : void
144  {
145  $this->taxFiltersExcludeAnyObjectsWithTaxonomies = $flag;
146  }

◆ buildBasicQuery()

ilAssQuestionList::buildBasicQuery ( )
private

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

Referenced by buildQuery().

513  : string
514  {
515  return "{$this->getSelectFieldsExpression()} FROM qpl_questions {$this->getTableJoinExpression()} WHERE qpl_questions.tstamp > 0";
516  }
+ Here is the caller graph for this function:

◆ buildLimitQueryExpression()

ilAssQuestionList::buildLimitQueryExpression ( )
private

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

References $range, ILIAS\Data\Range\getLength(), ILIAS\Data\Range\getStart(), and null.

Referenced by buildQuery().

564  : string
565  {
567  if ($range === null) {
568  return '';
569  }
570 
571  $limit = max($range->getLength(), 0);
572  $offset = max($range->getStart(), 0);
573 
574  return " LIMIT $limit OFFSET $offset";
575  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildOrderQueryExpression()

ilAssQuestionList::buildOrderQueryExpression ( )
private

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

References $order, ILIAS\Data\Order\join(), and null.

Referenced by buildQuery().

544  : string
545  {
547  if ($order === null) {
548  return '';
549  }
550 
551  [$order_field, $order_direction] = $order->join(
552  '',
553  static fn(string $index, string $key, string $value): array => [$key, $value]
554  );
555 
556  $order_direction = strtoupper($order_direction);
557  if (!in_array($order_direction, [Order::ASC, Order::DESC], true)) {
558  $order_direction = Order::ASC;
559  }
560 
561  return " ORDER BY `$order_field` $order_direction";
562  }
join($init, callable $fn)
Definition: Order.php:75
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuery()

ilAssQuestionList::buildQuery ( )
private

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

References buildBasicQuery(), buildLimitQueryExpression(), buildOrderQueryExpression(), getConditionalFilterExpression(), and getHavingFilterExpression().

Referenced by load().

577  : string
578  {
579  return implode(PHP_EOL, array_filter([
580  $this->buildBasicQuery(),
582  $this->getHavingFilterExpression(),
583  $this->buildOrderQueryExpression(),
584  $this->buildLimitQueryExpression(),
585  ]));
586  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkFilters()

ilAssQuestionList::checkFilters ( )
private

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

Referenced by getTotalRowCount(), and load().

735  : void
736  {
737  if ($this->answerStatusFilter !== '' && !$this->answerStatusActiveId) {
738  throw new ilTestQuestionPoolException(
739  'No active id given! You cannot use the answer status filter without giving an active id.'
740  );
741  }
742  }
+ Here is the caller graph for this function:

◆ generateFeedbackSubquery()

ilAssQuestionList::generateFeedbackSubquery ( )
private

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

References ilAssQuestionFeedback\PAGE_OBJECT_TYPE_GENERIC_FEEDBACK, and ilAssQuestionFeedback\PAGE_OBJECT_TYPE_SPECIFIC_FEEDBACK.

Referenced by getSelectFieldsExpression().

476  : string
477  {
478  $cases = [];
479  $tables = ['qpl_fb_generic', 'qpl_fb_specific'];
480 
481  foreach ($tables as $table) {
482  $subquery = "SELECT 1 FROM $table WHERE $table.question_fi = qpl_questions.question_id AND $table.feedback <> ''";
483  $cases[] = "WHEN EXISTS ($subquery) THEN TRUE";
484  }
485 
486  $page_object_table = 'page_object';
487  foreach ($tables as $table) {
488  $subquery = sprintf(
489  "SELECT 1 FROM $table JOIN $page_object_table ON $page_object_table.page_id = $table.feedback_id WHERE $page_object_table.parent_type IN ('%s', '%s') AND $page_object_table.is_empty <> 1 AND $table.question_fi = qpl_questions.question_id",
492  );
493  $cases[] = "WHEN EXISTS ($subquery) THEN TRUE";
494  }
495 
496  $feedback_case_subquery = implode(' ', $cases);
497  return "CASE $feedback_case_subquery ELSE FALSE END AS feedback";
498  }
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 caller graph for this function:

◆ generateHintSubquery()

ilAssQuestionList::generateHintSubquery ( )
private

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

Referenced by getSelectFieldsExpression().

500  : string
501  {
502  $hint_subquery = 'SELECT 1 FROM qpl_hints WHERE qpl_hints.qht_question_fi = qpl_questions.question_id';
503  return "CASE WHEN EXISTS ($hint_subquery) THEN TRUE ELSE FALSE END AS hints";
504  }
+ Here is the caller graph for this function:

◆ generateTaxonomySubquery()

ilAssQuestionList::generateTaxonomySubquery ( )
private

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

Referenced by getSelectFieldsExpression().

506  : string
507  {
508  $tax_node_assignment_table = 'tax_node_assignment';
509  $tax_subquery = "SELECT 1 FROM $tax_node_assignment_table WHERE $tax_node_assignment_table.item_id = qpl_questions.question_id AND $tax_node_assignment_table.item_type = 'quest'";
510  return "CASE WHEN EXISTS ($tax_subquery) THEN TRUE ELSE FALSE END AS taxonomies";
511  }
+ Here is the caller graph for this function:

◆ getAnswerStatusFilterExpressions()

ilAssQuestionList::getAnswerStatusFilterExpressions ( )
private

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

Referenced by getConditionalFilterExpression().

370  : array
371  {
372  return match ($this->answerStatusFilter) {
373  self::ANSWER_STATUS_FILTER_ALL_NON_CORRECT => ['
374  (tst_test_result.question_fi IS NULL OR tst_test_result.points < qpl_questions.points)
375  '],
376  self::ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY => ['tst_test_result.question_fi IS NULL'],
377  self::ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY => [
378  'tst_test_result.question_fi IS NOT NULL',
379  'tst_test_result.points < qpl_questions.points'
380  ],
381  default => [],
382  };
383  }
+ Here is the caller graph for this function:

◆ getConditionalFilterExpression()

ilAssQuestionList::getConditionalFilterExpression ( )
private

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

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

Referenced by buildQuery().

420  : string
421  {
422  $conditions = [];
423 
425  $conditions[] = $this->getQuestionInstanceTypeFilterExpression();
426  }
427 
428  if ($this->getParentObjFilterExpression() !== null) {
429  $conditions[] = $this->getParentObjFilterExpression();
430  }
431 
432  $conditions = array_merge(
433  $conditions,
435  $this->getFieldFilterExpressions(),
438  );
439 
440  $conditions = implode(' AND ', $conditions);
441  return $conditions !== '' ? "AND $conditions" : '';
442  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDataArrayForQuestionId()

ilAssQuestionList::getDataArrayForQuestionId ( int  $questionId)

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

703  {
704  return $this->questions[$questionId];
705  }

◆ getFieldFilterExpressions()

ilAssQuestionList::getFieldFilterExpressions ( )
private

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

References ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

Referenced by getConditionalFilterExpression().

184  : array
185  {
186  $expressions = [];
187 
188  foreach ($this->fieldFilters as $fieldName => $fieldValue) {
189  switch ($fieldName) {
190  case 'title':
191  case 'description':
192  case 'author':
193  case 'lifecycle':
194  $expressions[] = $this->db->like("qpl_questions.$fieldName", ilDBConstants::T_TEXT, "%%$fieldValue%%");
195  break;
196  case 'type':
197  $expressions[] = "qpl_qst_type.type_tag = {$this->db->quote($fieldValue, ilDBConstants::T_TEXT)}";
198  break;
199  case 'question_id':
200  if ($fieldValue !== '' && !is_array($fieldValue)) {
201  $fieldValue = [$fieldValue];
202  }
203  $expressions[] = $this->db->in('qpl_questions.question_id', $fieldValue, false, ilDBConstants::T_INTEGER);
204  break;
205  case 'parent_title':
206  if ($this->join_obj_data) {
207  $expressions[] = $this->db->like('object_data.title', ilDBConstants::T_TEXT, "%%$fieldValue%%");
208  }
209  break;
210  }
211  }
212 
213  return $expressions;
214  }
+ Here is the caller graph for this function:

◆ getFilterByAssignedTaxonomyIdsExpression()

ilAssQuestionList::getFilterByAssignedTaxonomyIdsExpression ( )
private

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

References getTaxItems(), and ilDBConstants\T_INTEGER.

Referenced by getTaxonomyFilterExpressions().

276  : array
277  {
278  if ($this->taxFiltersExcludeAnyObjectsWithTaxonomies) {
279  return ['question_id NOT IN (SELECT DISTINCT item_id FROM tax_node_assignment)'];
280  }
281 
282  $expressions = [];
283  foreach ($this->taxFilters as $tax_id => $tax_nodes) {
284  $question_ids = [];
285 
286  if ($tax_nodes === []) {
287  continue;
288  }
289 
290  foreach ($tax_nodes as $tax_node) {
291  $tax_items_by_tax_parent = $this->getTaxItems(
292  $this->taxParentTypes[$tax_id],
293  $this->taxParentIds[$tax_id],
294  $tax_id,
295  $tax_node
296  );
297 
298  $tax_items_by_parent = $this->getTaxItems(
299  $this->parentObjType,
300  $this->parentObjId,
301  $tax_id,
302  $tax_node
303  );
304 
305  $tax_items = array_merge($tax_items_by_tax_parent, $tax_items_by_parent);
306  foreach ($tax_items as $tax_item) {
307  $question_ids[$tax_item['item_id']] = $tax_item['item_id'];
308  }
309  }
310 
311  $expressions[] = $this->db->in('question_id', $question_ids, false, ilDBConstants::T_INTEGER);
312  }
313 
314  return $expressions;
315  }
getTaxItems(string $parentType, int $parentObjId, int $taxId, int $taxNode)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHavingFilterExpression()

ilAssQuestionList::getHavingFilterExpression ( )
private

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

Referenced by buildQuery().

518  : string
519  {
520  $expressions = [];
521 
522  foreach ($this->fieldFilters as $fieldName => $fieldValue) {
523  if ($fieldName === 'feedback') {
524  $fieldValue = strtoupper($fieldValue);
525  if (in_array($fieldValue, ['TRUE', 'FALSE'], true)) {
526  $expressions[] = "feedback IS $fieldValue";
527  }
528  continue;
529 
530  }
531 
532  if ($fieldName === 'hints') {
533  $fieldValue = strtoupper($fieldValue);
534  if (in_array($fieldValue, ['TRUE', 'FALSE'], true)) {
535  $expressions[] = "hints IS $fieldValue";
536  }
537  }
538  }
539 
540  $having = implode(' AND ', $expressions);
541  return $having !== '' ? "HAVING $having" : '';
542  }
+ Here is the caller graph for this function:

◆ getNumberOfCommentsForQuestion()

ilAssQuestionList::getNumberOfCommentsForQuestion ( int  $question_id)
protected

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

References getParentObjId(), and null.

Referenced by load().

632  : int
633  {
634  if ($this->notes_service === null) {
635  return 0;
636  }
637  $notes_context = $this->notes_service->data()->context(
638  $this->getParentObjId(),
639  $question_id,
640  'quest'
641  );
642  return $this->notes_service->domain()->getNrOfCommentsForContext($notes_context);
643  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParentObjFilterExpression()

ilAssQuestionList::getParentObjFilterExpression ( )
private

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

References null, and ilDBConstants\T_INTEGER.

Referenced by getConditionalFilterExpression().

171  : ?string
172  {
173  if ($this->parentObjId) {
174  return "qpl_questions.obj_fi = {$this->db->quote($this->parentObjId, ilDBConstants::T_INTEGER)}";
175  }
176 
177  if (!empty($this->parentObjIdsFilter)) {
178  return $this->db->in('qpl_questions.obj_fi', $this->parentObjIdsFilter, false, ilDBConstants::T_INTEGER);
179  }
180 
181  return null;
182  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getParentObjId()

ilAssQuestionList::getParentObjId ( )

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

References $parentObjId.

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

96  : ?int
97  {
98  return $this->parentObjId;
99  }
+ Here is the caller graph for this function:

◆ getQuestionDataArray()

ilAssQuestionList::getQuestionDataArray ( )

◆ getQuestionIdsFilterExpressions()

ilAssQuestionList::getQuestionIdsFilterExpressions ( )
private

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

References ilDBConstants\T_INTEGER.

Referenced by getConditionalFilterExpression().

343  : array
344  {
345  $expressions = [];
346 
347  if (!empty($this->includeQuestionIdsFilter)) {
348  $expressions[] = $this->db->in(
349  'qpl_questions.question_id',
350  $this->includeQuestionIdsFilter,
351  false,
353  );
354  }
355 
356  if (!empty($this->excludeQuestionIdsFilter)) {
357  $IN = $this->db->in(
358  'qpl_questions.question_id',
359  $this->excludeQuestionIdsFilter,
360  true,
362  );
363 
364  $expressions[] = $IN === ' 1=2 ' ? ' 1=1 ' : $IN; // required for ILIAS < 5.0
365  }
366 
367  return $expressions;
368  }
+ Here is the caller graph for this function:

◆ getQuestionInstanceTypeFilterExpression()

ilAssQuestionList::getQuestionInstanceTypeFilterExpression ( )
private

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

References null.

Referenced by getConditionalFilterExpression().

334  : ?string
335  {
336  return match ($this->questionInstanceTypeFilter) {
337  self::QUESTION_INSTANCE_TYPE_ORIGINALS => 'qpl_questions.original_id IS NULL',
338  self::QUESTION_INSTANCE_TYPE_DUPLICATES => 'qpl_questions.original_id IS NOT NULL',
339  default => null
340  };
341  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getSelectFieldsExpression()

ilAssQuestionList::getSelectFieldsExpression ( )
private

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

References generateFeedbackSubquery(), generateHintSubquery(), and generateTaxonomySubquery().

444  : string
445  {
446  $select_fields = [
447  'qpl_questions.*',
448  'qpl_qst_type.type_tag',
449  'qpl_qst_type.plugin',
450  'qpl_qst_type.plugin_name',
451  'qpl_questions.points max_points'
452  ];
453 
454  if ($this->join_obj_data) {
455  $select_fields[] = 'object_data.title parent_title';
456  }
457 
458  if ($this->answerStatusActiveId) {
459  $select_fields[] = 'tst_test_result.points reached_points';
460  $select_fields[] = "CASE
461  WHEN tst_test_result.points IS NULL THEN '" . self::QUESTION_ANSWER_STATUS_NON_ANSWERED . "'
462  WHEN tst_test_result.points < qpl_questions.points THEN '" . self::QUESTION_ANSWER_STATUS_WRONG_ANSWERED . "'
463  ELSE '" . self::QUESTION_ANSWER_STATUS_CORRECT_ANSWERED . "'
464  END question_answer_status
465  ";
466  }
467 
468  $select_fields[] = $this->generateFeedbackSubquery();
469  $select_fields[] = $this->generateHintSubquery();
470  $select_fields[] = $this->generateTaxonomySubquery();
471 
472  $select_fields = implode(', ', $select_fields);
473  return "SELECT DISTINCT $select_fields";
474  }
+ Here is the call graph for this function:

◆ getTableJoinExpression()

ilAssQuestionList::getTableJoinExpression ( )
private

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

References handleFeedbackJoin(), and handleHintJoin().

385  : string
386  {
387  $tableJoin = '
388  INNER JOIN qpl_qst_type
389  ON qpl_qst_type.question_type_id = qpl_questions.question_type_fi
390  ';
391 
392  if ($this->join_obj_data) {
393  $tableJoin .= '
394  INNER JOIN object_data
395  ON object_data.obj_id = qpl_questions.obj_fi
396  ';
397  }
398 
399  if (
400  $this->parentObjType === 'tst'
401  && $this->questionInstanceTypeFilter === self::QUESTION_INSTANCE_TYPE_ALL
402  ) {
403  $tableJoin .= 'INNER JOIN tst_test_question tstquest ON tstquest.question_fi = qpl_questions.question_id';
404  }
405 
406  $tableJoin = $this->handleFeedbackJoin($tableJoin);
407  $tableJoin = $this->handleHintJoin($tableJoin);
408 
409  if ($this->answerStatusActiveId) {
410  $tableJoin .= "
411  LEFT JOIN tst_test_result
412  ON tst_test_result.question_fi = qpl_questions.question_id
413  AND tst_test_result.active_fi = {$this->db->quote($this->answerStatusActiveId, ilDBConstants::T_INTEGER)}
414  ";
415  }
416 
417  return $tableJoin;
418  }
handleHintJoin(string $tableJoin)
handleFeedbackJoin(string $tableJoin)
+ Here is the call graph for this function:

◆ getTaxItems()

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

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

Referenced by getFilterByAssignedTaxonomyIdsExpression().

317  : array
318  {
319  $taxTree = new ilTaxonomyTree($taxId);
320 
321  $taxNodeAssignment = new ilTaxNodeAssignment(
322  $parentType,
323  $parentObjId,
324  'quest',
325  $taxId
326  );
327 
328  $subNodes = $taxTree->getSubTreeIds($taxNode);
329  $subNodes[] = $taxNode;
330 
331  return $taxNodeAssignment->getAssignmentsOfNode($subNodes);
332  }
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 248 of file class.ilAssQuestionList.php.

References getFilterByAssignedTaxonomyIdsExpression().

Referenced by getConditionalFilterExpression().

248  : array
249  {
250  $expressions = $this->getFilterByAssignedTaxonomyIdsExpression();
251 
252  $taxonomy_title = $this->fieldFilters['taxonomy_title'] ?? '';
253  $taxonomy_node_title = $this->fieldFilters['taxonomy_node_title'] ?? '';
254 
255  if ($taxonomy_title === '' && $taxonomy_node_title === '') {
256  return $expressions;
257  }
258 
259  $base = 'SELECT DISTINCT item_id FROM tax_node_assignment';
260 
261  $like_taxonomy_title = $taxonomy_title !== ''
262  ? "AND {$this->db->like('object_data.title', ilDBConstants::T_TEXT, "%$taxonomy_title%", false)}"
263  : '';
264  $like_taxonomy_node_title = $taxonomy_node_title !== ''
265  ? "AND {$this->db->like('tax_node.title', ilDBConstants::T_TEXT, "%$taxonomy_node_title%", false)}"
266  : '';
267 
268  $inner_join_object_data = "INNER JOIN object_data ON (object_data.obj_id = tax_node_assignment.tax_id AND object_data.type = 'tax' $like_taxonomy_title)";
269  $inner_join_tax_node = "INNER JOIN tax_node ON (tax_node.tax_id = tax_node_assignment.tax_id AND tax_node.type = 'taxn' AND tax_node_assignment.node_id = tax_node.obj_id $like_taxonomy_node_title)";
270 
271  $expressions[] = "qpl_questions.question_id IN ($base $inner_join_object_data $inner_join_tax_node)";
272 
273  return $expressions;
274  }
+ 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 726 of file class.ilAssQuestionList.php.

726  : string
727  {
728  if ($a_comp_id !== 'qpl' || $a_item_type !== 'quest' || !$a_item_id) {
729  return '';
730  }
731 
732  return $this->questions[$a_item_id]['title'] ?? '';
733  }

◆ getTotalRowCount()

ilAssQuestionList::getTotalRowCount ( ?array  $filter_data,
?array  $additional_parameters 
)

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

References checkFilters().

622  : ?int
623  {
624  $this->checkFilters();
625 
626  $count = 'COUNT(*)';
627  $query = "SELECT $count FROM qpl_questions {$this->getTableJoinExpression()} WHERE qpl_questions.tstamp > 0 {$this->getConditionalFilterExpression()}";
628 
629  return (int) ($this->db->query($query)->fetch()[$count] ?? 0);
630  }
+ Here is the call graph for this function:

◆ handleFeedbackJoin()

ilAssQuestionList::handleFeedbackJoin ( string  $tableJoin)
private

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

References null.

Referenced by getTableJoinExpression().

216  : string
217  {
218  $feedback_join = match ($this->fieldFilters['feedback'] ?? null) {
219  'true' => 'INNER',
220  'false' => 'LEFT',
221  default => null
222  };
223 
224  if (isset($feedback_join)) {
225  $SQL = "$feedback_join JOIN qpl_fb_generic ON qpl_fb_generic.question_fi = qpl_questions.question_id ";
226  $tableJoin .= !str_contains($tableJoin, $SQL) ? $SQL : '';
227  }
228 
229  return $tableJoin;
230  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ handleHintJoin()

ilAssQuestionList::handleHintJoin ( string  $tableJoin)
private

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

References null.

Referenced by getTableJoinExpression().

232  : string
233  {
234  $feedback_join = match ($this->fieldFilters['hints'] ?? null) {
235  'true' => 'INNER',
236  'false' => 'LEFT',
237  default => null
238  };
239 
240  if (isset($feedback_join)) {
241  $SQL = "$feedback_join JOIN qpl_hints ON qpl_hints.qht_question_fi = qpl_questions.question_id ";
242  $tableJoin .= !str_contains($tableJoin, $SQL) ? $SQL : '';
243  }
244 
245  return $tableJoin;
246  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ isActiveQuestionType()

ilAssQuestionList::isActiveQuestionType ( array  $questionData)
private

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

References ilComponentInfo\TYPE_MODULES.

Referenced by load().

675  : bool
676  {
677  if (!isset($questionData['plugin'])) {
678  return false;
679  }
680 
681  if (!$questionData['plugin']) {
682  return true;
683  }
684 
685  if (
686  !isset($questionData['plugin_name'])
687  || !$this->component_repository->getComponentByTypeAndName(
689  'TestQuestionPool'
690  )->getPluginSlotById('qst')->hasPluginName($questionData['plugin_name'])
691  ) {
692  return false;
693  }
694 
695  return $this->component_repository
696  ->getComponentByTypeAndName(ilComponentInfo::TYPE_MODULES, 'TestQuestionPool')
697  ->getPluginSlotById('qst')
698  ->getPluginByName($questionData['plugin_name'])
699  ->isActive();
700  }
+ Here is the caller graph for this function:

◆ isInList()

ilAssQuestionList::isInList ( int  $questionId)

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

712  : bool
713  {
714  return isset($this->questions[$questionId]);
715  }

◆ load()

ilAssQuestionList::load ( )

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

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

Referenced by ILIAS\TestQuestionPool\Questions\Presentation\QuestionTable\getData(), and ILIAS\TestQuestionPool\Questions\Presentation\QuestionTable\getTotalRowCount().

588  : void
589  {
590  $this->checkFilters();
591 
592  $tags_trafo = $this->refinery->encode()->htmlSpecialCharsAsEntities();
593 
594  $res = $this->db->query($this->buildQuery());
595  while ($row = $this->db->fetchAssoc($res)) {
597 
598  if (!$this->isActiveQuestionType($row)) {
599  continue;
600  }
601 
602  $row['title'] = $tags_trafo->transform($row['title'] ?? '&nbsp;');
603  $row['description'] = $tags_trafo->transform($row['description'] !== '' && $row['description'] !== null ? $row['description'] : '&nbsp;');
604  $row['author'] = $tags_trafo->transform($row['author']);
605  $row['taxonomies'] = $this->loadTaxonomyAssignmentData($row['obj_fi'], $row['question_id']);
606  $row['ttype'] = $this->lng->txt($row['type_tag']);
607  $row['feedback'] = $row['feedback'] === 1;
608  $row['hints'] = $row['hints'] === 1;
609  $row['comments'] = $this->getNumberOfCommentsForQuestion($row['question_id']);
610 
611  if (
612  $this->filter_comments === self::QUESTION_COMMENTED_ONLY && $row['comments'] === 0
613  || $this->filter_comments === self::QUESTION_COMMENTED_EXCLUDED && $row['comments'] > 0
614  ) {
615  continue;
616  }
617 
618  $this->questions[$row['question_id']] = $row;
619  }
620  }
static completeMissingPluginName(array $question_type_data)
$res
Definition: ltiservices.php:66
isActiveQuestionType(array $questionData)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
loadTaxonomyAssignmentData(int $parent_obj_id, int $question_id)
getNumberOfCommentsForQuestion(int $question_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadTaxonomyAssignmentData()

ilAssQuestionList::loadTaxonomyAssignmentData ( int  $parent_obj_id,
int  $question_id 
)
private

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

Referenced by load().

653  : array {
654  $tax_assignment_data = [];
655  foreach ($this->availableTaxonomyIds as $tax_id) {
656  $tax_tree = new ilTaxonomyTree($tax_id);
657 
658  $tax_assignment = new ilTaxNodeAssignment('qpl', $parent_obj_id, 'quest', $tax_id);
659  $assignments = $tax_assignment->getAssignmentsOfItem($question_id);
660 
661  foreach ($assignments as $ass_data) {
662  if (!isset($tax_assignment_data[$ass_data['tax_id']])) {
663  $tax_assignment_data[$ass_data['tax_id']] = [];
664  }
665 
666  $ass_data['node_lft'] = $tax_tree->getNodeData($ass_data['node_id']);
667 
668  $tax_assignment_data[$ass_data['tax_id']][$ass_data['node_id']] = $ass_data;
669  }
670  }
671 
672  return $tax_assignment_data;
673  }
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:

◆ setAnswerStatusActiveId()

ilAssQuestionList::setAnswerStatusActiveId ( ?int  $answerStatusActiveId)

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

References $answerStatusActiveId.

153  : void
154  {
155  $this->answerStatusActiveId = $answerStatusActiveId;
156  }

◆ setAnswerStatusFilter()

ilAssQuestionList::setAnswerStatusFilter ( string  $answerStatusFilter)

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

References $answerStatusFilter.

158  : void
159  {
160  $this->answerStatusFilter = $answerStatusFilter;
161  }

◆ setAvailableTaxonomyIds()

ilAssQuestionList::setAvailableTaxonomyIds ( array  $availableTaxonomyIds)

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

References $availableTaxonomyIds.

Referenced by ILIAS\TestQuestionPool\Questions\Presentation\QuestionTable\__construct().

148  : void
149  {
150  $this->availableTaxonomyIds = $availableTaxonomyIds;
151  }
+ Here is the caller graph for this function:

◆ setCommentFilter()

ilAssQuestionList::setCommentFilter ( ?int  $commented = null)

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

645  : void
646  {
647  $this->filter_comments = $commented;
648  }

◆ setExcludeQuestionIdsFilter()

ilAssQuestionList::setExcludeQuestionIdsFilter ( array  $excludeQuestionIdsFilter)

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

References $excludeQuestionIdsFilter.

Referenced by ilTestQuestionBrowserTableGUI\addModeParametersToQuestionList().

126  : void
127  {
128  $this->excludeQuestionIdsFilter = $excludeQuestionIdsFilter;
129  }
+ Here is the caller graph for this function:

◆ setIncludeQuestionIdsFilter()

ilAssQuestionList::setIncludeQuestionIdsFilter ( array  $questionIdsFilter)

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

121  : void
122  {
123  $this->includeQuestionIdsFilter = $questionIdsFilter;
124  }

◆ setJoinObjectData()

ilAssQuestionList::setJoinObjectData ( bool  $a_val)

Set if object data table should be joined.

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

166  : void
167  {
168  $this->join_obj_data = $a_val;
169  }

◆ setOrder()

ilAssQuestionList::setOrder ( ?Order  $order = null)

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

References $order.

86  : void
87  {
88  $this->order = $order;
89  }

◆ setParentObjectType()

ilAssQuestionList::setParentObjectType ( string  $parentObjType)

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

References $parentObjType.

Referenced by ilTestQuestionBrowserTableGUI\addModeParametersToQuestionList().

106  : void
107  {
108  $this->parentObjType = $parentObjType;
109  }
+ Here is the caller graph for this function:

◆ setParentObjId()

ilAssQuestionList::setParentObjId ( ?int  $parentObjId)

◆ setParentObjIdsFilter()

ilAssQuestionList::setParentObjIdsFilter ( array  $parentObjIdsFilter)

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

References $parentObjIdsFilter.

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

111  : void
112  {
113  $this->parentObjIdsFilter = $parentObjIdsFilter;
114  }
+ Here is the caller graph for this function:

◆ setQuestionInstanceTypeFilter()

ilAssQuestionList::setQuestionInstanceTypeFilter ( ?string  $questionInstanceTypeFilter)

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

Referenced by ilTestQuestionBrowserTableGUI\addModeParametersToQuestionList().

116  : void
117  {
118  $this->questionInstanceTypeFilter = (string) $questionInstanceTypeFilter;
119  }
+ Here is the caller graph for this function:

◆ setRange()

ilAssQuestionList::setRange ( ?Range  $range = null)

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

References $range.

91  : void
92  {
93  $this->range = $range;
94  }

Field Documentation

◆ $answerStatusActiveId

int ilAssQuestionList::$answerStatusActiveId = null
private

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

Referenced by setAnswerStatusActiveId().

◆ $answerStatusFilter

string ilAssQuestionList::$answerStatusFilter = ''
private

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

Referenced by setAnswerStatusFilter().

◆ $availableTaxonomyIds

array ilAssQuestionList::$availableTaxonomyIds = []
private

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

Referenced by setAvailableTaxonomyIds().

◆ $excludeQuestionIdsFilter

array ilAssQuestionList::$excludeQuestionIdsFilter = []
private

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

Referenced by setExcludeQuestionIdsFilter().

◆ $fieldFilters

array ilAssQuestionList::$fieldFilters = []
private

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

◆ $filter_comments

string ilAssQuestionList::$filter_comments = null
protected

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

◆ $includeQuestionIdsFilter

array ilAssQuestionList::$includeQuestionIdsFilter = []
private

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

◆ $join_obj_data

bool ilAssQuestionList::$join_obj_data = true
protected

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

◆ $order

Order ilAssQuestionList::$order = null
private

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

Referenced by buildOrderQueryExpression(), and setOrder().

◆ $parentObjId

int ilAssQuestionList::$parentObjId = null
private

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

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

◆ $parentObjIdsFilter

array ilAssQuestionList::$parentObjIdsFilter = []
private

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

Referenced by setParentObjIdsFilter().

◆ $parentObjType

string ilAssQuestionList::$parentObjType = 'qpl'
private

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

Referenced by addTaxonomyFilter(), and setParentObjectType().

◆ $questionInstanceTypeFilter

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

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

◆ $questions

array ilAssQuestionList::$questions = []
protected

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

Referenced by getQuestionDataArray().

◆ $range

Range ilAssQuestionList::$range = null
private

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

Referenced by buildLimitQueryExpression(), and setRange().

◆ $taxFilters

array ilAssQuestionList::$taxFilters = []
private

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

◆ $taxFiltersExcludeAnyObjectsWithTaxonomies

bool ilAssQuestionList::$taxFiltersExcludeAnyObjectsWithTaxonomies = false
private

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

◆ $taxParentIds

array ilAssQuestionList::$taxParentIds = []
private

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

◆ $taxParentTypes

array ilAssQuestionList::$taxParentTypes = []
private

Definition at line 40 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 54 of file class.ilAssQuestionList.php.

◆ ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY

const ilAssQuestionList::ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY = 'nonAnswered'

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

◆ ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY

const ilAssQuestionList::ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY = 'wrongAnswered'

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

◆ QUESTION_ANSWER_STATUS_CORRECT_ANSWERED

const ilAssQuestionList::QUESTION_ANSWER_STATUS_CORRECT_ANSWERED = 'correctAnswered'

Definition at line 49 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 47 of file class.ilAssQuestionList.php.

◆ QUESTION_ANSWER_STATUS_WRONG_ANSWERED

const ilAssQuestionList::QUESTION_ANSWER_STATUS_WRONG_ANSWERED = 'wrongAnswered'

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

◆ QUESTION_COMMENTED_EXCLUDED

const ilAssQuestionList::QUESTION_COMMENTED_EXCLUDED = '2'

◆ QUESTION_COMMENTED_ONLY

const ilAssQuestionList::QUESTION_COMMENTED_ONLY = '1'

◆ QUESTION_INSTANCE_TYPE_ALL

const ilAssQuestionList::QUESTION_INSTANCE_TYPE_ALL = 'QST_INSTANCE_TYPE_ALL'

◆ QUESTION_INSTANCE_TYPE_DUPLICATES

const ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES = 'QST_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: