ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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 ilComponentFactory $component_factory, 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 (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $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...
 
 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

 getParentObjFilterExpression ()
 
 getTaxItems (string $parentType, int $parentObjId, int $taxId, int $taxNode)
 
 buildBasicQuery ()
 
 getNumberOfCommentsForQuestion (int $question_id)
 
 isActiveQuestionType (array $questionData)
 

Protected Attributes

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

Private Member Functions

 getFieldFilterExpressions ()
 
 addFeedbackJoinIfNeeded (string $table_join)
 
 getTaxonomyFilterExpressions ()
 
 getFilterByAssignedTaxonomyIdsExpression ()
 
 getQuestionInstanceTypeFilterExpression ()
 
 getQuestionIdsFilterExpressions ()
 
 getAnswerStatusFilterExpressions ()
 
 getTableJoinExpression ()
 
 getConditionalFilterExpression ()
 
 getSelectFieldsExpression ()
 
 generateFeedbackSubquery ()
 
 generateTaxonomySubquery ()
 
 getHavingFilterExpression ()
 
 buildOrderQueryExpression ()
 
 buildLimitQueryExpression ()
 
 getOrderFieldAndDirection (?Order $order)
 
 buildQuery ()
 
 orderAndLimitByQuestionType (array $questions)
 
 loadTaxonomyAssignmentData (int $parent_obj_id, int $question_id)
 
 getQuestionTypeTranslation (array $question_data)
 
 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 = []
 
string $order_field = null
 
string $order_direction = 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 ilComponentFactory  $component_factory,
private ?NotesService  $notes_service = null 
)

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

85 {
86 }

Member Function Documentation

◆ addFeedbackJoinIfNeeded()

ilAssQuestionList::addFeedbackJoinIfNeeded ( string  $table_join)
private

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

221 : string
222 {
223 $feedback_join = match ($this->fieldFilters['feedback'] ?? null) {
224 'true' => 'INNER',
225 'false' => 'LEFT',
226 default => null
227 };
228
229 if (isset($feedback_join)) {
230 $sql = "{$feedback_join} JOIN qpl_fb_generic ON qpl_fb_generic.question_fi = qpl_questions.question_id ";
231 $table_join .= !str_contains($table_join, $sql) ? $sql : '';
232 }
233
234 return $table_join;
235 }

Referenced by getTableJoinExpression().

+ Here is the caller graph for this function:

◆ addFieldFilter()

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

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

136 : void
137 {
138 $this->fieldFilters[$fieldName] = $fieldValue;
139 }

◆ addTaxonomyFilter()

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

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

141 : void
142 {
143 $this->taxFilters[$taxId] = $taxNodes;
144 $this->taxParentIds[$taxId] = $parentObjId;
145 $this->taxParentTypes[$taxId] = $parentObjType;
146 }

References $parentObjId, and $parentObjType.

◆ addTaxonomyFilterNoTaxonomySet()

ilAssQuestionList::addTaxonomyFilterNoTaxonomySet ( bool  $flag)

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

148 : void
149 {
150 $this->taxFiltersExcludeAnyObjectsWithTaxonomies = $flag;
151 }

◆ buildBasicQuery()

ilAssQuestionList::buildBasicQuery ( )
protected

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

492 : string
493 {
494 return "{$this->getSelectFieldsExpression()} FROM qpl_questions {$this->getTableJoinExpression()} WHERE qpl_questions.tstamp > 0";
495 }

Referenced by buildQuery().

+ Here is the caller graph for this function:

◆ buildLimitQueryExpression()

ilAssQuestionList::buildLimitQueryExpression ( )
private

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

523 : string
524 {
525 if ($this->order_field === 'question_type'
526 || $this->range === null) {
527 return '';
528 }
529
530 $limit = max($this->range->getLength(), 0);
531 $offset = max($this->range->getStart(), 0);
532
533 return " LIMIT {$limit} OFFSET {$offset}";
534 }

Referenced by buildQuery().

+ Here is the caller graph for this function:

◆ buildOrderQueryExpression()

ilAssQuestionList::buildOrderQueryExpression ( )
private

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

516 : string
517 {
518 return $this->order_field === null || $this->order_direction === null || $this->order_field === 'question_type'
519 ? ''
520 : " ORDER BY `$this->order_field` $this->order_direction";
521 }

Referenced by buildQuery().

+ Here is the caller graph for this function:

◆ buildQuery()

ilAssQuestionList::buildQuery ( )
private

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

557 : string
558 {
559 return implode(PHP_EOL, array_filter([
560 $this->buildBasicQuery(),
565 ]));
566 }

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

Referenced by load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkFilters()

ilAssQuestionList::checkFilters ( )
private

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

756 : void
757 {
758 if ($this->answerStatusFilter !== '' && !$this->answerStatusActiveId) {
760 'No active id given! You cannot use the answer status filter without giving an active id.'
761 );
762 }
763 }

Referenced by load().

+ Here is the caller graph for this function:

◆ generateFeedbackSubquery()

ilAssQuestionList::generateFeedbackSubquery ( )
private

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

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

References ilAssQuestionFeedback\PAGE_OBJECT_TYPE_GENERIC_FEEDBACK, and ilAssQuestionFeedback\PAGE_OBJECT_TYPE_SPECIFIC_FEEDBACK.

Referenced by getSelectFieldsExpression().

+ Here is the caller graph for this function:

◆ generateTaxonomySubquery()

ilAssQuestionList::generateTaxonomySubquery ( )
private

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

485 : string
486 {
487 $tax_node_assignment_table = 'tax_node_assignment';
488 $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'";
489 return "CASE WHEN EXISTS ($tax_subquery) THEN TRUE ELSE FALSE END AS taxonomies";
490 }

Referenced by getSelectFieldsExpression().

+ Here is the caller graph for this function:

◆ getAnswerStatusFilterExpressions()

ilAssQuestionList::getAnswerStatusFilterExpressions ( )
private

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

359 : array
360 {
361 return match ($this->answerStatusFilter) {
362 self::ANSWER_STATUS_FILTER_ALL_NON_CORRECT => ['
363 (tst_test_result.question_fi IS NULL OR tst_test_result.points < qpl_questions.points)
364 '],
365 self::ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY => ['tst_test_result.question_fi IS NULL'],
366 self::ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY => [
367 'tst_test_result.question_fi IS NOT NULL',
368 'tst_test_result.points < qpl_questions.points'
369 ],
370 default => [],
371 };
372 }

Referenced by getConditionalFilterExpression().

+ Here is the caller graph for this function:

◆ getConditionalFilterExpression()

ilAssQuestionList::getConditionalFilterExpression ( )
private

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

405 : string
406 {
407 $conditions = [];
408
409 if ($this->getQuestionInstanceTypeFilterExpression() !== null) {
410 $conditions[] = $this->getQuestionInstanceTypeFilterExpression();
411 }
412
413 if ($this->getParentObjFilterExpression() !== null) {
414 $conditions[] = $this->getParentObjFilterExpression();
415 }
416
417 $conditions = array_merge(
418 $conditions,
423 );
424
425 $conditions = implode(' AND ', $conditions);
426 return $conditions !== '' ? "AND $conditions" : '';
427 }

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

Referenced by buildQuery().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDataArrayForQuestionId()

ilAssQuestionList::getDataArrayForQuestionId ( int  $questionId)

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

723 : array
724 {
725 return $this->questions[$questionId];
726 }

◆ getFieldFilterExpressions()

ilAssQuestionList::getFieldFilterExpressions ( )
private

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

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

References ilDBConstants\T_INTEGER, and ilDBConstants\T_TEXT.

Referenced by getConditionalFilterExpression().

+ Here is the caller graph for this function:

◆ getFilterByAssignedTaxonomyIdsExpression()

ilAssQuestionList::getFilterByAssignedTaxonomyIdsExpression ( )
private

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

265 : array
266 {
267 if ($this->taxFiltersExcludeAnyObjectsWithTaxonomies) {
268 return ['question_id NOT IN (SELECT DISTINCT item_id FROM tax_node_assignment)'];
269 }
270
271 $expressions = [];
272 foreach ($this->taxFilters as $tax_id => $tax_nodes) {
273 $question_ids = [];
274
275 if ($tax_nodes === []) {
276 continue;
277 }
278
279 foreach ($tax_nodes as $tax_node) {
280 $tax_items_by_tax_parent = $this->getTaxItems(
281 $this->taxParentTypes[$tax_id],
282 $this->taxParentIds[$tax_id],
283 $tax_id,
284 $tax_node
285 );
286
287 $tax_items_by_parent = $this->getTaxItems(
288 $this->parentObjType,
289 $this->parentObjId,
290 $tax_id,
291 $tax_node
292 );
293
294 $tax_items = array_merge($tax_items_by_tax_parent, $tax_items_by_parent);
295 foreach ($tax_items as $tax_item) {
296 $question_ids[$tax_item['item_id']] = $tax_item['item_id'];
297 }
298 }
299
300 $expressions[] = $this->db->in('question_id', $question_ids, false, ilDBConstants::T_INTEGER);
301 }
302
303 return $expressions;
304 }
getTaxItems(string $parentType, int $parentObjId, int $taxId, int $taxNode)

References getTaxItems(), and ilDBConstants\T_INTEGER.

Referenced by getTaxonomyFilterExpressions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHavingFilterExpression()

ilAssQuestionList::getHavingFilterExpression ( )
private

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

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

Referenced by buildQuery().

+ Here is the caller graph for this function:

◆ getNumberOfCommentsForQuestion()

ilAssQuestionList::getNumberOfCommentsForQuestion ( int  $question_id)
protected

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

638 : int
639 {
640 if ($this->notes_service === null) {
641 return 0;
642 }
643 $notes_context = $this->notes_service->data()->context(
644 $this->getParentObjId(),
645 $question_id,
646 'quest'
647 );
648 return $this->notes_service->domain()->getNrOfCommentsForContext($notes_context);
649 }

Referenced by load().

+ Here is the caller graph for this function:

◆ getOrderFieldAndDirection()

ilAssQuestionList::getOrderFieldAndDirection ( ?Order  $order)
private

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

536 : ?array
537 {
538 if ($order === null) {
539 return ['order_field' => null, 'order_direction' => null];
540 }
541
542 [$order_field, $order_direction] = $order->join(
543 '',
544 static fn(string $index, string $key, string $value): array => [
545 $key,
546 strtoupper($value)
547 ]
548 );
549
550 if (!in_array($order_direction, [Order::ASC, Order::DESC], true)) {
551 $order_direction = Order::ASC;
552 }
553
554 return ['order_field' => $order_field, 'order_direction' => $order_direction];
555 }

References $order_direction, $order_field, and ILIAS\Data\Order\join().

Referenced by setOrder().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParentObjFilterExpression()

ilAssQuestionList::getParentObjFilterExpression ( )
protected

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

176 : ?string
177 {
178 if ($this->parentObjId) {
179 return "qpl_questions.obj_fi = {$this->db->quote($this->parentObjId, ilDBConstants::T_INTEGER)}";
180 }
181
182 if (!empty($this->parentObjIdsFilter)) {
183 return $this->db->in('qpl_questions.obj_fi', $this->parentObjIdsFilter, false, ilDBConstants::T_INTEGER);
184 }
185
186 return null;
187 }

References ilDBConstants\T_INTEGER.

Referenced by getConditionalFilterExpression().

+ Here is the caller graph for this function:

◆ getParentObjId()

ilAssQuestionList::getParentObjId ( )

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

101 : ?int
102 {
103 return $this->parentObjId;
104 }

References $parentObjId.

Referenced by ilTestSkillEvaluation\init().

+ Here is the caller graph for this function:

◆ getQuestionDataArray()

ilAssQuestionList::getQuestionDataArray ( )

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

728 : array
729 {
730 return $this->questions;
731 }

Referenced by ilTestSkillEvaluation\initTestQuestionData().

+ Here is the caller graph for this function:

◆ getQuestionIdsFilterExpressions()

ilAssQuestionList::getQuestionIdsFilterExpressions ( )
private

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

332 : array
333 {
334 $expressions = [];
335
336 if (!empty($this->includeQuestionIdsFilter)) {
337 $expressions[] = $this->db->in(
338 'qpl_questions.question_id',
339 $this->includeQuestionIdsFilter,
340 false,
342 );
343 }
344
345 if (!empty($this->excludeQuestionIdsFilter)) {
346 $IN = $this->db->in(
347 'qpl_questions.question_id',
348 $this->excludeQuestionIdsFilter,
349 true,
351 );
352
353 $expressions[] = $IN === ' 1=2 ' ? ' 1=1 ' : $IN; // required for ILIAS < 5.0
354 }
355
356 return $expressions;
357 }

References ilDBConstants\T_INTEGER.

Referenced by getConditionalFilterExpression().

+ Here is the caller graph for this function:

◆ getQuestionInstanceTypeFilterExpression()

ilAssQuestionList::getQuestionInstanceTypeFilterExpression ( )
private

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

323 : ?string
324 {
325 return match ($this->questionInstanceTypeFilter) {
326 self::QUESTION_INSTANCE_TYPE_ORIGINALS => 'qpl_questions.original_id IS NULL',
327 self::QUESTION_INSTANCE_TYPE_DUPLICATES => 'qpl_questions.original_id IS NOT NULL',
328 default => null
329 };
330 }

Referenced by getConditionalFilterExpression().

+ Here is the caller graph for this function:

◆ getQuestionTypeTranslation()

ilAssQuestionList::getQuestionTypeTranslation ( array  $question_data)
private

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

708 : string
709 {
710 if (!($question_data['plugin'] ?? false)) {
711 return $this->lng->txt($question_data['question_type']);
712 }
713
714 foreach ($this->component_factory->getActivePluginsInSlot('qst') as $plugin) {
715 if ($plugin->getQuestionType() === $question_data['question_type']) {
716 return $plugin->getQuestionTypeTranslation();
717 }
718 }
719
720 return $this->lng->txt($question_data['question_type']);
721 }

References XapiProxy\$plugin, and ILIAS\Repository\lng().

Referenced by load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSelectFieldsExpression()

ilAssQuestionList::getSelectFieldsExpression ( )
private

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

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

References generateFeedbackSubquery(), and generateTaxonomySubquery().

+ Here is the call graph for this function:

◆ getTableJoinExpression()

ilAssQuestionList::getTableJoinExpression ( )
private

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

374 : string
375 {
376 $table_join = 'INNER JOIN qpl_qst_type ON qpl_qst_type.question_type_id = qpl_questions.question_type_fi ';
377
378 if ($this->join_obj_data) {
379 $table_join .= '
380 INNER JOIN object_data ON object_data.obj_id = qpl_questions.obj_fi
381 INNER JOIN object_reference ON object_reference.obj_id = object_data.obj_id
382 ';
383 }
384
385 if (
386 $this->parentObjType === 'tst'
387 && $this->questionInstanceTypeFilter === self::QUESTION_INSTANCE_TYPE_ALL
388 ) {
389 $table_join .= 'INNER JOIN tst_test_question tstquest ON tstquest.question_fi = qpl_questions.question_id';
390 }
391
392 $table_join = $this->addFeedbackJoinIfNeeded($table_join);
393
394 if ($this->answerStatusActiveId) {
395 $table_join .= "
396 LEFT JOIN tst_test_result
397 ON tst_test_result.question_fi = qpl_questions.question_id
398 AND tst_test_result.active_fi = {$this->db->quote($this->answerStatusActiveId, ilDBConstants::T_INTEGER)}
399 ";
400 }
401
402 return $table_join;
403 }
addFeedbackJoinIfNeeded(string $table_join)

References addFeedbackJoinIfNeeded().

+ Here is the call graph for this function:

◆ getTaxItems()

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

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

306 : array
307 {
308 $taxTree = new ilTaxonomyTree($taxId);
309
310 $taxNodeAssignment = new ilTaxNodeAssignment(
311 $parentType,
313 'quest',
314 $taxId
315 );
316
317 $subNodes = $taxTree->getSubTreeIds($taxNode);
318 $subNodes[] = $taxNode;
319
320 return $taxNodeAssignment->getAssignmentsOfNode($subNodes);
321 }
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...

References $parentObjId.

Referenced by getFilterByAssignedTaxonomyIdsExpression().

+ Here is the caller graph for this function:

◆ getTaxonomyFilterExpressions()

ilAssQuestionList::getTaxonomyFilterExpressions ( )
private

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

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

References getFilterByAssignedTaxonomyIdsExpression().

Referenced by getConditionalFilterExpression().

+ 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 747 of file class.ilAssQuestionList.php.

747 : string
748 {
749 if ($a_comp_id !== 'qpl' || $a_item_type !== 'quest' || !$a_item_id) {
750 return '';
751 }
752
753 return $this->questions[$a_item_id]['title'] ?? '';
754 }

◆ getTotalRowCount()

ilAssQuestionList::getTotalRowCount ( mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)

Reimplemented in ILIAS\TestQuestionPool\Questions\Presentation\QuestionTable.

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

629 : ?int {
630 $this->checkFilters();
631
632 $count = 'COUNT(*)';
633 $query = "SELECT $count FROM qpl_questions {$this->getTableJoinExpression()} WHERE qpl_questions.tstamp > 0 {$this->getConditionalFilterExpression()}";
634
635 return (int) ($this->db->query($query)->fetch()[$count] ?? 0);
636 }

◆ isActiveQuestionType()

ilAssQuestionList::isActiveQuestionType ( array  $questionData)
protected

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

681 : bool
682 {
683 if (!isset($questionData['plugin'])) {
684 return false;
685 }
686
687 if (!$questionData['plugin']) {
688 return true;
689 }
690
691 if (
692 !isset($questionData['plugin_name'])
693 || !$this->component_repository->getComponentByTypeAndName(
695 'TestQuestionPool'
696 )->getPluginSlotById('qst')->hasPluginName($questionData['plugin_name'])
697 ) {
698 return false;
699 }
700
701 return $this->component_repository
702 ->getComponentByTypeAndName(ilComponentInfo::TYPE_COMPONENT, 'TestQuestionPool')
703 ->getPluginSlotById('qst')
704 ->getPluginByName($questionData['plugin_name'])
705 ->isActive();
706 }

References ilComponentInfo\TYPE_COMPONENT.

Referenced by load().

+ Here is the caller graph for this function:

◆ isInList()

ilAssQuestionList::isInList ( int  $questionId)

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

733 : bool
734 {
735 return isset($this->questions[$questionId]);
736 }

◆ load()

ilAssQuestionList::load ( )

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

568 : void
569 {
570 $this->checkFilters();
571
572 $tags_trafo = $this->refinery->encode()->htmlSpecialCharsAsEntities();
573
574 $res = $this->db->query($this->buildQuery());
575 while ($row_from_db = $this->db->fetchAssoc($res)) {
577
578 if (!$this->isActiveQuestionType($row)) {
579 continue;
580 }
581
582 $row['title'] = $tags_trafo->transform($row['title'] ?? '&nbsp;');
583 $row['description'] = $tags_trafo->transform($row['description'] ?? '');
584 $row['author'] = $tags_trafo->transform($row['author']);
585 $row['taxonomies'] = $this->loadTaxonomyAssignmentData($row['obj_fi'], $row['question_id']);
586 $row['question_type'] = $this->getQuestionTypeTranslation($row);
587 $row['feedback'] = $row['feedback'] === 1;
588 $row['comments'] = $this->getNumberOfCommentsForQuestion($row['question_id']);
589
590 if (
591 $this->filter_comments === self::QUESTION_COMMENTED_ONLY && $row['comments'] === 0
592 || $this->filter_comments === self::QUESTION_COMMENTED_EXCLUDED && $row['comments'] > 0
593 ) {
594 continue;
595 }
596
597 $this->questions[$row['question_id']] = $row;
598 }
599
600 if ($this->order_field === 'question_type') {
601 $this->questions = $this->orderAndLimitByQuestionType($this->questions);
602 }
603 }
isActiveQuestionType(array $questionData)
getQuestionTypeTranslation(array $question_data)
getNumberOfCommentsForQuestion(int $question_id)
loadTaxonomyAssignmentData(int $parent_obj_id, int $question_id)
orderAndLimitByQuestionType(array $questions)
static completeMissingPluginName(array $question_type_data)
foreach($_POST as $key=> $value) $res

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

+ Here is the call graph for this function:

◆ loadTaxonomyAssignmentData()

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

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

659 : array {
660 $tax_assignment_data = [];
661 foreach ($this->availableTaxonomyIds as $tax_id) {
662 $tax_tree = new ilTaxonomyTree($tax_id);
663
664 $tax_assignment = new ilTaxNodeAssignment('qpl', $parent_obj_id, 'quest', $tax_id);
665 $assignments = $tax_assignment->getAssignmentsOfItem($question_id);
666
667 foreach ($assignments as $ass_data) {
668 if (!isset($tax_assignment_data[$ass_data['tax_id']])) {
669 $tax_assignment_data[$ass_data['tax_id']] = [];
670 }
671
672 $ass_data['node_lft'] = $tax_tree->getNodeData($ass_data['node_id']);
673
674 $tax_assignment_data[$ass_data['tax_id']][$ass_data['node_id']] = $ass_data;
675 }
676 }
677
678 return $tax_assignment_data;
679 }

Referenced by load().

+ Here is the caller graph for this function:

◆ orderAndLimitByQuestionType()

ilAssQuestionList::orderAndLimitByQuestionType ( array  $questions)
private

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

607 : array {
608 $direction = $this->order_direction === Order::DESC ? -1 : 1;
609 usort(
611 fn(array $a, array $b): int => $direction * ($a['question_type'] <=> $b['question_type'])
612 );
613
614 if ($this->range !== null) {
615 $questions = array_slice(
617 $this->range->getStart(),
618 $this->range->getLength()
619 );
620 }
621
622 return $questions;
623 }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

Referenced by load().

+ Here is the caller graph for this function:

◆ setAnswerStatusActiveId()

ilAssQuestionList::setAnswerStatusActiveId ( ?int  $answerStatusActiveId)

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

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

References $answerStatusActiveId.

◆ setAnswerStatusFilter()

ilAssQuestionList::setAnswerStatusFilter ( string  $answerStatusFilter)

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

163 : void
164 {
165 $this->answerStatusFilter = $answerStatusFilter;
166 }

References $answerStatusFilter.

◆ setAvailableTaxonomyIds()

ilAssQuestionList::setAvailableTaxonomyIds ( array  $availableTaxonomyIds)

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

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

References $availableTaxonomyIds.

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

+ Here is the caller graph for this function:

◆ setCommentFilter()

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

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

651 : void
652 {
653 $this->filter_comments = $commented;
654 }

◆ setExcludeQuestionIdsFilter()

ilAssQuestionList::setExcludeQuestionIdsFilter ( array  $excludeQuestionIdsFilter)

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

131 : void
132 {
133 $this->excludeQuestionIdsFilter = $excludeQuestionIdsFilter;
134 }

References $excludeQuestionIdsFilter.

Referenced by ilTestQuestionBrowserTableGUI\addModeParametersToQuestionList().

+ Here is the caller graph for this function:

◆ setIncludeQuestionIdsFilter()

ilAssQuestionList::setIncludeQuestionIdsFilter ( array  $questionIdsFilter)

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

126 : void
127 {
128 $this->includeQuestionIdsFilter = $questionIdsFilter;
129 }

◆ setJoinObjectData()

ilAssQuestionList::setJoinObjectData ( bool  $a_val)

Set if object data table should be joined.

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

171 : void
172 {
173 $this->join_obj_data = $a_val;
174 }

◆ setOrder()

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

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

88 : void
89 {
90 [
91 'order_field' => $this->order_field,
92 'order_direction' => $this->order_direction
93 ] = $this->getOrderFieldAndDirection($order);
94 }
getOrderFieldAndDirection(?Order $order)

References $order_direction, $order_field, and getOrderFieldAndDirection().

+ Here is the call graph for this function:

◆ setParentObjectType()

ilAssQuestionList::setParentObjectType ( string  $parentObjType)

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

111 : void
112 {
113 $this->parentObjType = $parentObjType;
114 }

References $parentObjType.

Referenced by ilTestQuestionBrowserTableGUI\addModeParametersToQuestionList().

+ Here is the caller graph for this function:

◆ setParentObjId()

ilAssQuestionList::setParentObjId ( ?int  $parentObjId)

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

106 : void
107 {
108 $this->parentObjId = $parentObjId;
109 }

References $parentObjId.

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

+ Here is the caller graph for this function:

◆ setParentObjIdsFilter()

ilAssQuestionList::setParentObjIdsFilter ( array  $parentObjIdsFilter)

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

116 : void
117 {
118 $this->parentObjIdsFilter = $parentObjIdsFilter;
119 }

References $parentObjIdsFilter.

Referenced by ilTestQuestionBrowserTableGUI\addModeParametersToQuestionList().

+ Here is the caller graph for this function:

◆ setQuestionInstanceTypeFilter()

ilAssQuestionList::setQuestionInstanceTypeFilter ( ?string  $questionInstanceTypeFilter)

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

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

References $questionInstanceTypeFilter.

Referenced by ilTestQuestionBrowserTableGUI\addModeParametersToQuestionList().

+ Here is the caller graph for this function:

◆ setRange()

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

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

96 : void
97 {
98 $this->range = $range;
99 }

References $range.

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_direction

string ilAssQuestionList::$order_direction = null
private

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

Referenced by getOrderFieldAndDirection(), and setOrder().

◆ $order_field

string ilAssQuestionList::$order_field = null
private

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

Referenced by getOrderFieldAndDirection(), and setOrder().

◆ $parentObjId

int ilAssQuestionList::$parentObjId = null
private

◆ $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.

Referenced by setQuestionInstanceTypeFilter().

◆ $questions

array ilAssQuestionList::$questions = []
protected

◆ $range

Range ilAssQuestionList::$range = null
private

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

Referenced by 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: