4require_once
'Services/Taxonomy/interfaces/interface.ilTaxAssignedItemInfo.php';
5require_once
'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionType.php';
223 $this->includeQuestionIdsFilter = $questionIdsFilter;
253 $this->fieldFilters[$fieldName] = $fieldValue;
258 $this->taxFilters[$taxId] = $taxNodes;
300 $this->join_obj_data = $a_val;
332 return 'qpl_questions.obj_fi = ' . $this->db->quote($this->
getParentObjId(),
'integer');
344 $expressions = array();
346 foreach ($this->fieldFilters as $fieldName => $fieldValue) {
347 switch ($fieldName) {
353 $expressions[] = $this->db->like(
'qpl_questions.' . $fieldName,
'text',
"%%$fieldValue%%");
358 $expressions[] =
"qpl_qst_type.type_tag = {$this->db->quote($fieldValue, 'text')}";
362 if ($fieldValue !=
"" && !is_array($fieldValue)) {
363 $fieldValue = array($fieldValue);
365 $expressions[] = $this->db->in(
"qpl_questions.question_id", $fieldValue,
false,
"integer");
369 if ($this->join_obj_data) {
370 $expressions[] = $this->db->like(
'object_data.title',
'text',
"%%$fieldValue%%");
381 $expressions = array();
383 require_once
'Services/Taxonomy/classes/class.ilTaxonomyTree.php';
384 require_once
'Services/Taxonomy/classes/class.ilTaxNodeAssignment.php';
386 foreach ($this->taxFilters as $taxId => $taxNodes) {
387 $questionIds = array();
391 foreach ($taxNodes as $taxNode) {
392 $forceBypass =
false;
395 $this->taxParentTypes[$taxId],
396 $this->taxParentIds[$taxId],
402 $this->parentObjType,
408 $taxItems = array_merge($taxItemsByTaxParent, $taxItemsByParent);
409 foreach ($taxItems as $taxItem) {
410 $questionIds[$taxItem[
'item_id']] = $taxItem[
'item_id'];
415 $expressions[] = $this->db->in(
'question_id', $questionIds,
false,
'integer');
440 $subNodes = $taxTree->getSubTreeIds($taxNode);
441 $subNodes[] = $taxNode;
443 return $taxNodeAssignment->getAssignmentsOfNode($subNodes);
450 return 'qpl_questions.original_id IS NULL';
452 return 'qpl_questions.original_id IS NOT NULL';
463 $expressions = array();
466 $expressions[] = $this->db->in(
467 'qpl_questions.question_id',
476 'qpl_questions.question_id',
482 if ($IN ==
' 1=2 ') {
486 $expressions[] = $IN;
494 if ($this->parentObjId) {
495 return "qpl_questions.obj_fi = {$this->db->quote($this->parentObjId, 'integer')}";
503 $expressions = array();
509 (tst_test_result.question_fi IS NULL OR tst_test_result.points < qpl_questions.points)
515 $expressions[] =
'tst_test_result.question_fi IS NULL';
520 $expressions[] =
'tst_test_result.question_fi IS NOT NULL';
521 $expressions[] =
'tst_test_result.points < qpl_questions.points';
531 INNER JOIN qpl_qst_type
532 ON qpl_qst_type.question_type_id = qpl_questions.question_type_fi
535 if ($this->join_obj_data) {
537 INNER JOIN object_data
538 ON object_data.obj_id = qpl_questions.obj_fi
545 INNER JOIN tst_test_question tstquest
546 ON tstquest.question_fi = qpl_questions.question_id
552 LEFT JOIN tst_test_result
553 ON tst_test_result.question_fi = qpl_questions.question_id
554 AND tst_test_result.active_fi = {$this->db->quote($this->getAnswerStatusActiveId(), 'integer')}
563 $CONDITIONS = array();
577 $CONDITIONS = array_merge(
585 $CONDITIONS = implode(
' AND ', $CONDITIONS);
587 return strlen($CONDITIONS) ?
'AND ' . $CONDITIONS :
'';
592 $selectFields = array(
594 'qpl_qst_type.type_tag',
595 'qpl_qst_type.plugin',
596 'qpl_qst_type.plugin_name',
597 'qpl_questions.points max_points'
600 if ($this->join_obj_data) {
601 $selectFields[] =
'object_data.title parent_title';
605 $selectFields[] =
'tst_test_result.points reached_points';
606 $selectFields[] =
"CASE
607 WHEN tst_test_result.points IS NULL THEN '" . self::QUESTION_ANSWER_STATUS_NON_ANSWERED .
"'
608 WHEN tst_test_result.points < qpl_questions.points THEN '" . self::QUESTION_ANSWER_STATUS_WRONG_ANSWERED .
"'
609 ELSE '" . self::QUESTION_ANSWER_STATUS_CORRECT_ANSWERED .
"'
610 END question_answer_status
614 $selectFields = implode(
",\n\t\t\t\t", $selectFields);
617 SELECT {$selectFields}
624 {$this->getSelectFieldsExpression()}
628 {$this->getTableJoinExpression()}
630 WHERE qpl_questions.tstamp > 0
637 {$this->getConditionalFilterExpression()}
642 UNION {$this->buildBasicQuery()}
643 AND {$this->db->in('qpl_questions.question_id', $this->getForcedQuestionIds(), false, 'integer')}
654 $tags_trafo = $this->refinery->string()->stripTags();
660 while ($row = $this->db->fetchAssoc(
$res)) {
667 $row[
'title'] = $tags_trafo->transform($row[
'title'] ??
' ');
668 $row[
'description'] = $tags_trafo->transform($row[
'description'] !==
'' && $row[
'description'] !==
null ? $row[
'description'] :
' ');
669 $row[
'author'] = $tags_trafo->transform($row[
'author']);
671 $row[
'ttype'] = $this->lng->txt($row[
'type_tag']);
673 $this->questions[ $row[
'question_id'] ] = $row;
679 $taxAssignmentData = array();
682 require_once
'Services/Taxonomy/classes/class.ilTaxonomyTree.php';
683 require_once
'Services/Taxonomy/classes/class.ilTaxNodeAssignment.php';
689 $assignments = $taxAssignment->getAssignmentsOfItem($questionId);
691 foreach ($assignments as $assData) {
692 if (!isset($taxAssignmentData[ $assData[
'tax_id'] ])) {
693 $taxAssignmentData[ $assData[
'tax_id'] ] = array();
696 $nodeData = $taxTree->getNodeData($assData[
'node_id']);
698 $assData[
'node_lft'] = $nodeData[
'lft'];
700 $taxAssignmentData[ $assData[
'tax_id'] ][ $assData[
'node_id'] ] = $assData;
704 return $taxAssignmentData;
709 if (!isset($questionData[
'plugin'])) {
713 if (!$questionData[
'plugin']) {
717 return $this->pluginAdmin->isActive(
IL_COMP_MODULE,
'TestQuestionPool',
'qst', $questionData[
'plugin_name']);
722 return $this->questions[$questionId];
732 return isset($this->questions[$questionId]);
744 public function getTitle($a_comp_id, $a_item_type, $a_item_id)
746 if ($a_comp_id !=
'qpl' || $a_item_type !=
'quest' || !(
int) $a_item_id) {
750 if (!isset($this->questions[$a_item_id])) {
754 return $this->questions[$a_item_id][
'title'];
760 require_once
'Modules/TestQuestionPool/exceptions/class.ilTestQuestionPoolException.php';
763 'No active id given! You cannot use the answer status filter without giving an active id.'
An exception for terminatinating execution or to throw for unit testing.
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
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)
__construct(ilDBInterface $db, ilLanguage $lng, ILIAS\Refinery\Factory $refinery, ilPluginAdmin $pluginAdmin)
setQuestionCompletionStatusFilter($questionCompletionStatusFilter)
setForcedQuestionIds($forcedQuestionIds)
$questionCompletionStatusFilter
addTaxonomyFilter($taxId, $taxNodes, $parentObjId, $parentObjType)
isActiveQuestionType($questionData)
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
setJoinObjectData($a_val)
Set if object data table should be joined.
const ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY
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)
getTitle($a_comp_id, $a_item_type, $a_item_id)
Get title of an assigned item.
const QUESTION_COMPLETION_STATUS_INCOMPLETE
getQuestionCompletionStatusFilter()
static completeMissingPluginName($questionTypeData)
Administration class for plugins.
Taxonomy node <-> item assignment.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface for assigned items of taxonomies.
Class ChatMainBarProvider \MainMenu\Provider.
foreach($_POST as $key=> $value) $res