ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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)
 
 getTaxonomyFilterExpressions ()
 
 getFilterByAssignedTaxonomyIdsExpression ()
 
 getQuestionInstanceTypeFilterExpression ()
 
 getQuestionIdsFilterExpressions ()
 
 getAnswerStatusFilterExpressions ()
 
 getTableJoinExpression ()
 
 getConditionalFilterExpression ()
 
 getSelectFieldsExpression ()
 
 generateFeedbackSubquery ()
 
 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 490 of file class.ilAssQuestionList.php.

Referenced by buildQuery().

490  : string
491  {
492  return "{$this->getSelectFieldsExpression()} FROM qpl_questions {$this->getTableJoinExpression()} WHERE qpl_questions.tstamp > 0";
493  }
+ Here is the caller graph for this function:

◆ buildLimitQueryExpression()

ilAssQuestionList::buildLimitQueryExpression ( )
private

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

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

Referenced by buildQuery().

534  : string
535  {
537  if ($range === null) {
538  return '';
539  }
540 
541  $limit = max($range->getLength(), 0);
542  $offset = max($range->getStart(), 0);
543 
544  return " LIMIT $limit OFFSET $offset";
545  }
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 514 of file class.ilAssQuestionList.php.

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

Referenced by buildQuery().

514  : string
515  {
517  if ($order === null) {
518  return '';
519  }
520 
521  [$order_field, $order_direction] = $order->join(
522  '',
523  static fn(string $index, string $key, string $value): array => [$key, $value]
524  );
525 
526  $order_direction = strtoupper($order_direction);
527  if (!in_array($order_direction, [Order::ASC, Order::DESC], true)) {
528  $order_direction = Order::ASC;
529  }
530 
531  return " ORDER BY `$order_field` $order_direction";
532  }
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 547 of file class.ilAssQuestionList.php.

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

Referenced by load().

547  : string
548  {
549  return implode(PHP_EOL, array_filter([
550  $this->buildBasicQuery(),
552  $this->getHavingFilterExpression(),
553  $this->buildOrderQueryExpression(),
554  $this->buildLimitQueryExpression(),
555  ]));
556  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkFilters()

ilAssQuestionList::checkFilters ( )
private

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

Referenced by getTotalRowCount(), and load().

704  : void
705  {
706  if ($this->answerStatusFilter !== '' && !$this->answerStatusActiveId) {
707  throw new ilTestQuestionPoolException(
708  'No active id given! You cannot use the answer status filter without giving an active id.'
709  );
710  }
711  }
+ Here is the caller graph for this function:

◆ generateFeedbackSubquery()

ilAssQuestionList::generateFeedbackSubquery ( )
private

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

References ilAssQuestionFeedback\PAGE_OBJECT_TYPE_GENERIC_FEEDBACK, and ilAssQuestionFeedback\PAGE_OBJECT_TYPE_SPECIFIC_FEEDBACK.

Referenced by getSelectFieldsExpression().

459  : string
460  {
461  $cases = [];
462  $tables = ['qpl_fb_generic', 'qpl_fb_specific'];
463 
464  foreach ($tables as $table) {
465  $subquery = "SELECT 1 FROM $table WHERE $table.question_fi = qpl_questions.question_id AND $table.feedback <> ''";
466  $cases[] = "WHEN EXISTS ($subquery) THEN TRUE";
467  }
468 
469  $page_object_table = 'page_object';
470  foreach ($tables as $table) {
471  $subquery = sprintf(
472  "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",
475  );
476  $cases[] = "WHEN EXISTS ($subquery) THEN TRUE";
477  }
478 
479  $feedback_case_subquery = implode(' ', $cases);
480  return "CASE $feedback_case_subquery ELSE FALSE END AS feedback";
481  }
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:

◆ generateTaxonomySubquery()

ilAssQuestionList::generateTaxonomySubquery ( )
private

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

Referenced by getSelectFieldsExpression().

483  : string
484  {
485  $tax_node_assignment_table = 'tax_node_assignment';
486  $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'";
487  return "CASE WHEN EXISTS ($tax_subquery) THEN TRUE ELSE FALSE END AS taxonomies";
488  }
+ Here is the caller graph for this function:

◆ getAnswerStatusFilterExpressions()

ilAssQuestionList::getAnswerStatusFilterExpressions ( )
private

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

Referenced by getConditionalFilterExpression().

354  : array
355  {
356  return match ($this->answerStatusFilter) {
357  self::ANSWER_STATUS_FILTER_ALL_NON_CORRECT => ['
358  (tst_test_result.question_fi IS NULL OR tst_test_result.points < qpl_questions.points)
359  '],
360  self::ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY => ['tst_test_result.question_fi IS NULL'],
361  self::ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY => [
362  'tst_test_result.question_fi IS NOT NULL',
363  'tst_test_result.points < qpl_questions.points'
364  ],
365  default => [],
366  };
367  }
+ Here is the caller graph for this function:

◆ getConditionalFilterExpression()

ilAssQuestionList::getConditionalFilterExpression ( )
private

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

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

Referenced by buildQuery().

403  : string
404  {
405  $conditions = [];
406 
408  $conditions[] = $this->getQuestionInstanceTypeFilterExpression();
409  }
410 
411  if ($this->getParentObjFilterExpression() !== null) {
412  $conditions[] = $this->getParentObjFilterExpression();
413  }
414 
415  $conditions = array_merge(
416  $conditions,
418  $this->getFieldFilterExpressions(),
421  );
422 
423  $conditions = implode(' AND ', $conditions);
424  return $conditions !== '' ? "AND $conditions" : '';
425  }
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 671 of file class.ilAssQuestionList.php.

672  {
673  return $this->questions[$questionId];
674  }

◆ 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 260 of file class.ilAssQuestionList.php.

References getTaxItems(), and ilDBConstants\T_INTEGER.

Referenced by getTaxonomyFilterExpressions().

260  : array
261  {
262  if ($this->taxFiltersExcludeAnyObjectsWithTaxonomies) {
263  return ['question_id NOT IN (SELECT DISTINCT item_id FROM tax_node_assignment)'];
264  }
265 
266  $expressions = [];
267  foreach ($this->taxFilters as $tax_id => $tax_nodes) {
268  $question_ids = [];
269 
270  if ($tax_nodes === []) {
271  continue;
272  }
273 
274  foreach ($tax_nodes as $tax_node) {
275  $tax_items_by_tax_parent = $this->getTaxItems(
276  $this->taxParentTypes[$tax_id],
277  $this->taxParentIds[$tax_id],
278  $tax_id,
279  $tax_node
280  );
281 
282  $tax_items_by_parent = $this->getTaxItems(
283  $this->parentObjType,
284  $this->parentObjId,
285  $tax_id,
286  $tax_node
287  );
288 
289  $tax_items = array_merge($tax_items_by_tax_parent, $tax_items_by_parent);
290  foreach ($tax_items as $tax_item) {
291  $question_ids[$tax_item['item_id']] = $tax_item['item_id'];
292  }
293  }
294 
295  $expressions[] = $this->db->in('question_id', $question_ids, false, ilDBConstants::T_INTEGER);
296  }
297 
298  return $expressions;
299  }
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 495 of file class.ilAssQuestionList.php.

Referenced by buildQuery().

495  : string
496  {
497  $expressions = [];
498 
499  foreach ($this->fieldFilters as $fieldName => $fieldValue) {
500  if ($fieldName === 'feedback') {
501  $fieldValue = strtoupper($fieldValue);
502  if (in_array($fieldValue, ['TRUE', 'FALSE'], true)) {
503  $expressions[] = "feedback IS $fieldValue";
504  }
505  continue;
506 
507  }
508  }
509 
510  $having = implode(' AND ', $expressions);
511  return $having !== '' ? "HAVING $having" : '';
512  }
+ Here is the caller graph for this function:

◆ getNumberOfCommentsForQuestion()

ilAssQuestionList::getNumberOfCommentsForQuestion ( int  $question_id)
protected

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

References getParentObjId(), and null.

Referenced by load().

601  : int
602  {
603  if ($this->notes_service === null) {
604  return 0;
605  }
606  $notes_context = $this->notes_service->data()->context(
607  $this->getParentObjId(),
608  $question_id,
609  'quest'
610  );
611  return $this->notes_service->domain()->getNrOfCommentsForContext($notes_context);
612  }
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 327 of file class.ilAssQuestionList.php.

References ilDBConstants\T_INTEGER.

Referenced by getConditionalFilterExpression().

327  : array
328  {
329  $expressions = [];
330 
331  if (!empty($this->includeQuestionIdsFilter)) {
332  $expressions[] = $this->db->in(
333  'qpl_questions.question_id',
334  $this->includeQuestionIdsFilter,
335  false,
337  );
338  }
339 
340  if (!empty($this->excludeQuestionIdsFilter)) {
341  $IN = $this->db->in(
342  'qpl_questions.question_id',
343  $this->excludeQuestionIdsFilter,
344  true,
346  );
347 
348  $expressions[] = $IN === ' 1=2 ' ? ' 1=1 ' : $IN; // required for ILIAS < 5.0
349  }
350 
351  return $expressions;
352  }
+ Here is the caller graph for this function:

◆ getQuestionInstanceTypeFilterExpression()

ilAssQuestionList::getQuestionInstanceTypeFilterExpression ( )
private

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

References null.

Referenced by getConditionalFilterExpression().

318  : ?string
319  {
320  return match ($this->questionInstanceTypeFilter) {
321  self::QUESTION_INSTANCE_TYPE_ORIGINALS => 'qpl_questions.original_id IS NULL',
322  self::QUESTION_INSTANCE_TYPE_DUPLICATES => 'qpl_questions.original_id IS NOT NULL',
323  default => null
324  };
325  }
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 427 of file class.ilAssQuestionList.php.

References generateFeedbackSubquery(), and generateTaxonomySubquery().

427  : string
428  {
429  $select_fields = [
430  'qpl_questions.*',
431  'qpl_qst_type.type_tag',
432  'qpl_qst_type.plugin',
433  'qpl_qst_type.plugin_name',
434  'qpl_questions.points max_points'
435  ];
436 
437  if ($this->join_obj_data) {
438  $select_fields[] = 'object_data.title parent_title';
439  }
440 
441  if ($this->answerStatusActiveId) {
442  $select_fields[] = 'tst_test_result.points reached_points';
443  $select_fields[] = "CASE
444  WHEN tst_test_result.points IS NULL THEN '" . self::QUESTION_ANSWER_STATUS_NON_ANSWERED . "'
445  WHEN tst_test_result.points < qpl_questions.points THEN '" . self::QUESTION_ANSWER_STATUS_WRONG_ANSWERED . "'
446  ELSE '" . self::QUESTION_ANSWER_STATUS_CORRECT_ANSWERED . "'
447  END question_answer_status
448  ";
449  }
450 
451  $select_fields[] = $this->generateFeedbackSubquery();
452 
453  $select_fields[] = $this->generateTaxonomySubquery();
454 
455  $select_fields = implode(', ', $select_fields);
456  return "SELECT DISTINCT $select_fields";
457  }
+ Here is the call graph for this function:

◆ getTableJoinExpression()

ilAssQuestionList::getTableJoinExpression ( )
private

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

References handleFeedbackJoin().

369  : string
370  {
371  $tableJoin = '
372  INNER JOIN qpl_qst_type
373  ON qpl_qst_type.question_type_id = qpl_questions.question_type_fi
374  ';
375 
376  if ($this->join_obj_data) {
377  $tableJoin .= '
378  INNER JOIN object_data
379  ON object_data.obj_id = qpl_questions.obj_fi
380  ';
381  }
382 
383  if (
384  $this->parentObjType === 'tst'
385  && $this->questionInstanceTypeFilter === self::QUESTION_INSTANCE_TYPE_ALL
386  ) {
387  $tableJoin .= 'INNER JOIN tst_test_question tstquest ON tstquest.question_fi = qpl_questions.question_id';
388  }
389 
390  $tableJoin = $this->handleFeedbackJoin($tableJoin);
391 
392  if ($this->answerStatusActiveId) {
393  $tableJoin .= "
394  LEFT JOIN tst_test_result
395  ON tst_test_result.question_fi = qpl_questions.question_id
396  AND tst_test_result.active_fi = {$this->db->quote($this->answerStatusActiveId, ilDBConstants::T_INTEGER)}
397  ";
398  }
399 
400  return $tableJoin;
401  }
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 301 of file class.ilAssQuestionList.php.

Referenced by getFilterByAssignedTaxonomyIdsExpression().

301  : array
302  {
303  $taxTree = new ilTaxonomyTree($taxId);
304 
305  $taxNodeAssignment = new ilTaxNodeAssignment(
306  $parentType,
307  $parentObjId,
308  'quest',
309  $taxId
310  );
311 
312  $subNodes = $taxTree->getSubTreeIds($taxNode);
313  $subNodes[] = $taxNode;
314 
315  return $taxNodeAssignment->getAssignmentsOfNode($subNodes);
316  }
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 232 of file class.ilAssQuestionList.php.

References getFilterByAssignedTaxonomyIdsExpression().

Referenced by getConditionalFilterExpression().

232  : array
233  {
234  $expressions = $this->getFilterByAssignedTaxonomyIdsExpression();
235 
236  $taxonomy_title = $this->fieldFilters['taxonomy_title'] ?? '';
237  $taxonomy_node_title = $this->fieldFilters['taxonomy_node_title'] ?? '';
238 
239  if ($taxonomy_title === '' && $taxonomy_node_title === '') {
240  return $expressions;
241  }
242 
243  $base = 'SELECT DISTINCT item_id FROM tax_node_assignment';
244 
245  $like_taxonomy_title = $taxonomy_title !== ''
246  ? "AND {$this->db->like('object_data.title', ilDBConstants::T_TEXT, "%$taxonomy_title%", false)}"
247  : '';
248  $like_taxonomy_node_title = $taxonomy_node_title !== ''
249  ? "AND {$this->db->like('tax_node.title', ilDBConstants::T_TEXT, "%$taxonomy_node_title%", false)}"
250  : '';
251 
252  $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)";
253  $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)";
254 
255  $expressions[] = "qpl_questions.question_id IN ($base $inner_join_object_data $inner_join_tax_node)";
256 
257  return $expressions;
258  }
+ 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 695 of file class.ilAssQuestionList.php.

695  : string
696  {
697  if ($a_comp_id !== 'qpl' || $a_item_type !== 'quest' || !$a_item_id) {
698  return '';
699  }
700 
701  return $this->questions[$a_item_id]['title'] ?? '';
702  }

◆ getTotalRowCount()

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

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

References checkFilters().

591  : ?int
592  {
593  $this->checkFilters();
594 
595  $count = 'COUNT(*)';
596  $query = "SELECT $count FROM qpl_questions {$this->getTableJoinExpression()} WHERE qpl_questions.tstamp > 0 {$this->getConditionalFilterExpression()}";
597 
598  return (int) ($this->db->query($query)->fetch()[$count] ?? 0);
599  }
+ 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:

◆ isActiveQuestionType()

ilAssQuestionList::isActiveQuestionType ( array  $questionData)
private

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

References ilComponentInfo\TYPE_COMPONENT.

Referenced by load().

644  : bool
645  {
646  if (!isset($questionData['plugin'])) {
647  return false;
648  }
649 
650  if (!$questionData['plugin']) {
651  return true;
652  }
653 
654  if (
655  !isset($questionData['plugin_name'])
656  || !$this->component_repository->getComponentByTypeAndName(
658  'TestQuestionPool'
659  )->getPluginSlotById('qst')->hasPluginName($questionData['plugin_name'])
660  ) {
661  return false;
662  }
663 
664  return $this->component_repository
665  ->getComponentByTypeAndName(ilComponentInfo::TYPE_COMPONENT, 'TestQuestionPool')
666  ->getPluginSlotById('qst')
667  ->getPluginByName($questionData['plugin_name'])
668  ->isActive();
669  }
+ Here is the caller graph for this function:

◆ isInList()

ilAssQuestionList::isInList ( int  $questionId)

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

681  : bool
682  {
683  return isset($this->questions[$questionId]);
684  }

◆ load()

ilAssQuestionList::load ( )

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

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

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

558  : void
559  {
560  $this->checkFilters();
561 
562  $tags_trafo = $this->refinery->encode()->htmlSpecialCharsAsEntities();
563 
564  $res = $this->db->query($this->buildQuery());
565  while ($row = $this->db->fetchAssoc($res)) {
567 
568  if (!$this->isActiveQuestionType($row)) {
569  continue;
570  }
571 
572  $row['title'] = $tags_trafo->transform($row['title'] ?? '&nbsp;');
573  $row['description'] = $tags_trafo->transform($row['description'] ?? '');
574  $row['author'] = $tags_trafo->transform($row['author']);
575  $row['taxonomies'] = $this->loadTaxonomyAssignmentData($row['obj_fi'], $row['question_id']);
576  $row['ttype'] = $this->lng->txt($row['type_tag']);
577  $row['feedback'] = $row['feedback'] === 1;
578  $row['comments'] = $this->getNumberOfCommentsForQuestion($row['question_id']);
579 
580  if (
581  $this->filter_comments === self::QUESTION_COMMENTED_ONLY && $row['comments'] === 0
582  || $this->filter_comments === self::QUESTION_COMMENTED_EXCLUDED && $row['comments'] > 0
583  ) {
584  continue;
585  }
586 
587  $this->questions[$row['question_id']] = $row;
588  }
589  }
static completeMissingPluginName(array $question_type_data)
$res
Definition: ltiservices.php:66
isActiveQuestionType(array $questionData)
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 619 of file class.ilAssQuestionList.php.

Referenced by load().

622  : array {
623  $tax_assignment_data = [];
624  foreach ($this->availableTaxonomyIds as $tax_id) {
625  $tax_tree = new ilTaxonomyTree($tax_id);
626 
627  $tax_assignment = new ilTaxNodeAssignment('qpl', $parent_obj_id, 'quest', $tax_id);
628  $assignments = $tax_assignment->getAssignmentsOfItem($question_id);
629 
630  foreach ($assignments as $ass_data) {
631  if (!isset($tax_assignment_data[$ass_data['tax_id']])) {
632  $tax_assignment_data[$ass_data['tax_id']] = [];
633  }
634 
635  $ass_data['node_lft'] = $tax_tree->getNodeData($ass_data['node_id']);
636 
637  $tax_assignment_data[$ass_data['tax_id']][$ass_data['node_id']] = $ass_data;
638  }
639  }
640 
641  return $tax_assignment_data;
642  }
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 614 of file class.ilAssQuestionList.php.

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

◆ 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().

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: