210 $this->includeQuestionIdsFilter = $questionIdsFilter;
240 $this->fieldFilters[$fieldName] = $fieldValue;
245 $this->taxFilters[$taxId] = $taxNodes;
287 $this->join_obj_data = $a_val;
319 return 'qpl_questions.obj_fi = ' . $this->db->quote($this->
getParentObjId(),
'integer');
331 $expressions = array();
333 foreach ($this->fieldFilters as $fieldName => $fieldValue) {
334 switch ($fieldName) {
340 $expressions[] = $this->db->like(
'qpl_questions.' . $fieldName,
'text',
"%%$fieldValue%%");
345 $expressions[] =
"qpl_qst_type.type_tag = {$this->db->quote($fieldValue, 'text')}";
349 if ($fieldValue !=
"" && !is_array($fieldValue)) {
350 $fieldValue = array($fieldValue);
352 $expressions[] = $this->db->in(
"qpl_questions.question_id", $fieldValue,
false,
"integer");
356 if ($this->join_obj_data) {
357 $expressions[] = $this->db->like(
'object_data.title',
'text',
"%%$fieldValue%%");
368 $expressions = array();
370 require_once
'Services/Taxonomy/classes/class.ilTaxonomyTree.php';
371 require_once
'Services/Taxonomy/classes/class.ilTaxNodeAssignment.php';
373 foreach ($this->taxFilters as $taxId => $taxNodes) {
374 $questionIds = array();
378 foreach ($taxNodes as $taxNode) {
379 $forceBypass =
false;
382 $this->taxParentTypes[$taxId],
383 $this->taxParentIds[$taxId],
389 $this->parentObjType,
395 $taxItems = array_merge($taxItemsByTaxParent, $taxItemsByParent);
396 foreach ($taxItems as $taxItem) {
397 $questionIds[$taxItem[
'item_id']] = $taxItem[
'item_id'];
402 $expressions[] = $this->db->in(
'question_id', $questionIds,
false,
'integer');
427 $subNodes = $taxTree->getSubTreeIds($taxNode);
428 $subNodes[] = $taxNode;
430 return $taxNodeAssignment->getAssignmentsOfNode($subNodes);
437 return 'qpl_questions.original_id IS NULL';
439 return 'qpl_questions.original_id IS NOT NULL';
450 $expressions = array();
453 $expressions[] = $this->db->in(
454 'qpl_questions.question_id',
463 'qpl_questions.question_id',
469 if ($IN ==
' 1=2 ') {
473 $expressions[] = $IN;
481 if ($this->parentObjId) {
482 return "qpl_questions.obj_fi = {$this->db->quote($this->parentObjId, 'integer')}";
490 $expressions = array();
496 (tst_test_result.question_fi IS NULL OR tst_test_result.points < qpl_questions.points)
502 $expressions[] =
'tst_test_result.question_fi IS NULL';
507 $expressions[] =
'tst_test_result.question_fi IS NOT NULL';
508 $expressions[] =
'tst_test_result.points < qpl_questions.points';
518 INNER JOIN qpl_qst_type
519 ON qpl_qst_type.question_type_id = qpl_questions.question_type_fi
522 if ($this->join_obj_data) {
524 INNER JOIN object_data
525 ON object_data.obj_id = qpl_questions.obj_fi
532 INNER JOIN tst_test_question tstquest
533 ON tstquest.question_fi = qpl_questions.question_id
539 LEFT JOIN tst_test_result
540 ON tst_test_result.question_fi = qpl_questions.question_id
541 AND tst_test_result.active_fi = {$this->db->quote($this->getAnswerStatusActiveId(), 'integer')}
550 $CONDITIONS = array();
564 $CONDITIONS = array_merge(
572 $CONDITIONS = implode(
' AND ', $CONDITIONS);
574 return strlen($CONDITIONS) ?
'AND ' . $CONDITIONS :
'';
579 $selectFields = array(
581 'qpl_qst_type.type_tag',
582 'qpl_qst_type.plugin',
583 'qpl_qst_type.plugin_name',
584 'qpl_questions.points max_points'
587 if ($this->join_obj_data) {
588 $selectFields[] =
'object_data.title parent_title';
592 $selectFields[] =
'tst_test_result.points reached_points';
593 $selectFields[] =
"CASE
594 WHEN tst_test_result.points IS NULL THEN '" . self::QUESTION_ANSWER_STATUS_NON_ANSWERED .
"'
595 WHEN tst_test_result.points < qpl_questions.points THEN '" . self::QUESTION_ANSWER_STATUS_WRONG_ANSWERED .
"'
596 ELSE '" . self::QUESTION_ANSWER_STATUS_CORRECT_ANSWERED .
"'
597 END question_answer_status
601 $selectFields = implode(
",\n\t\t\t\t", $selectFields);
604 SELECT {$selectFields}
611 {$this->getSelectFieldsExpression()}
615 {$this->getTableJoinExpression()}
617 WHERE qpl_questions.tstamp > 0
624 {$this->getConditionalFilterExpression()}
629 UNION {$this->buildBasicQuery()}
630 AND {$this->db->in('qpl_questions.question_id', $this->getForcedQuestionIds(), false, 'integer')}
641 $tags_trafo = $this->
refinery->string()->stripTags();
647 while ($row = $this->db->fetchAssoc(
$res)) {
654 $row[
'title'] = $tags_trafo->transform($row[
'title'] ??
' ');
655 $row[
'description'] = $tags_trafo->transform($row[
'description'] !==
'' && $row[
'description'] !==
null ? $row[
'description'] :
' ');
656 $row[
'author'] = $tags_trafo->transform($row[
'author']);
658 $row[
'ttype'] = $this->
lng->txt($row[
'type_tag']);
660 $this->questions[ $row[
'question_id'] ] = $row;
666 $taxAssignmentData = array();
669 require_once
'Services/Taxonomy/classes/class.ilTaxonomyTree.php';
670 require_once
'Services/Taxonomy/classes/class.ilTaxNodeAssignment.php';
676 $assignments = $taxAssignment->getAssignmentsOfItem($questionId);
678 foreach ($assignments as $assData) {
679 if (!isset($taxAssignmentData[ $assData[
'tax_id'] ])) {
680 $taxAssignmentData[ $assData[
'tax_id'] ] = array();
683 $nodeData = $taxTree->getNodeData($assData[
'node_id']);
685 $assData[
'node_lft'] = $nodeData[
'lft'];
687 $taxAssignmentData[ $assData[
'tax_id'] ][ $assData[
'node_id'] ] = $assData;
691 return $taxAssignmentData;
696 if (!isset($questionData[
'plugin'])) {
700 if (!$questionData[
'plugin']) {
704 if (!$this->component_repository->getComponentByTypeAndName(
707 )->getPluginSlotById(
'qst')->hasPluginName($questionData[
'plugin_name'])) {
711 return $this->component_repository
712 ->getComponentByTypeAndName(
720 $questionData[
'plugin_name']
726 return $this->questions[$questionId];
736 return isset($this->questions[$questionId]);
748 public function getTitle(
string $a_comp_id,
string $a_item_type,
int $a_item_id): string
750 if ($a_comp_id !=
'qpl' || $a_item_type !=
'quest' || !$a_item_id) {
754 if (!isset($this->questions[$a_item_id])) {
758 return $this->questions[$a_item_id][
'title'];
764 require_once
'Modules/TestQuestionPool/exceptions/class.ilTestQuestionPoolException.php';
767 'No active id given! You cannot use the answer status filter without giving an active id.'
isActiveQuestionType(array $questionData)
getExcludeQuestionIdsFilter()
getAvailableTaxonomyIds()
$questionInstanceTypeFilter
setAnswerStatusActiveId($answerStatusActiveId)
getIncludeQuestionIdsFilter()
const ANSWER_STATUS_FILTER_ALL_NON_CORRECT
answer status filter value domain
getAnswerStatusActiveId()
setExcludeQuestionIdsFilter($excludeQuestionIdsFilter)
getTaxonomyFilterExpressions()
const QUESTION_INSTANCE_TYPE_ALL
__construct(ilDBInterface $db, ilLanguage $lng, Refinery $refinery, ilComponentRepository $component_repository)
getDataArrayForQuestionId($questionId)
getQuestionInstanceTypeFilterExpression()
const QUESTION_INSTANCE_TYPE_ORIGINALS
$includeQuestionIdsFilter
setParentObjectType($parentObjType)
const ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY
getParentObjFilterExpression()
getTaxItems($parentType, $parentObjId, $taxId, $taxNode)
const QUESTION_COMPLETION_STATUS_COMPLETE
setIncludeQuestionIdsFilter($questionIdsFilter)
setQuestionCompletionStatusFilter($questionCompletionStatusFilter)
setForcedQuestionIds($forcedQuestionIds)
$questionCompletionStatusFilter
addTaxonomyFilter($taxId, $taxNodes, $parentObjId, $parentObjType)
getQuestionInstanceTypeFilter()
getFieldFilterExpressions()
getQuestionIdsFilterExpressions()
const QUESTION_ANSWER_STATUS_WRONG_ANSWERED
getParentObjectIdFilterExpression()
setAvailableTaxonomyIds($availableTaxonomyIds)
getJoinObjectData()
Get if object data table should be joined.
const QUESTION_ANSWER_STATUS_CORRECT_ANSWERED
setAnswerStatusFilter($answerStatusFilter)
const QUESTION_INSTANCE_TYPE_DUPLICATES
const QUESTION_COMPLETION_STATUS_BOTH
ilComponentRepository $component_repository
setJoinObjectData($a_val)
Set if object data table should be joined.
const ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY
getTitle(string $a_comp_id, string $a_item_type, int $a_item_id)
Get title of an assigned item.
setParentObjIdsFilter($parentObjIdsFilter)
setParentObjId($parentObjId)
getSelectFieldsExpression()
loadTaxonomyAssignmentData($parentObjId, $questionId)
getConditionalFilterExpression()
setQuestionInstanceTypeFilter($questionInstanceTypeFilter)
getAnswerStatusFilterExpressions()
const QUESTION_ANSWER_STATUS_NON_ANSWERED
answer status domain for single questions
$excludeQuestionIdsFilter
addFieldFilter($fieldName, $fieldValue)
const QUESTION_COMPLETION_STATUS_INCOMPLETE
getQuestionCompletionStatusFilter()
static completeMissingPluginName($questionTypeData)
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...
Readable part of repository interface to ilComponentDataDB.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...