ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAssQuestionList Class Reference
+ Inheritance diagram for ilAssQuestionList:
+ Collaboration diagram for ilAssQuestionList:

Public Member Functions

 __construct (ilDB $db, ilLanguage $lng, ilPluginAdmin $pluginAdmin, $parentObjId)
 Constructor.
 addFieldFilter ($fieldName, $fieldValue)
 addTaxonomyFilter ($taxId, $taxNodes)
 setAvailableTaxonomyIds ($availableTaxonomyIds)
 getAvailableTaxonomyIds ()
 setAnswerStatusActiveId ($answerStatusActiveId)
 getAnswerStatusActiveId ()
 setAnswerStatusFilter ($answerStatusFilter)
 getAnswerStatusFilter ()
 setForcedQuestionIds ($forcedQuestionIds)
 getForcedQuestionIds ()
 load ()
 getQuestionDataArray ()
 getTitle ($a_comp_id, $a_item_type, $a_item_id)
 Get title of an assigned item.

Data Fields

const QUESTION_ANSWER_STATUS_NON_ANSWERED = 'nonAnswered'
 answer status domain for single questions
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
const ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY = 'nonAnswered'
const ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY = 'wrongAnswered'

Private Member Functions

 getFieldFilterExpressions ()
 getTaxonomyFilterExpressions ()
 getAnswerStatusFilterExpressions ()
 getTableJoinExpression ()
 getConditionalFilterExpression ()
 getSelectFieldsExpression ()
 buildBasicQuery ()
 buildQuery ()
 loadTaxonomyAssignmentData ($questionId)
 isActiveQuestionType ($questionData)
 checkFilters ()

Private Attributes

 $db = null
 $lng = null
 $pluginAdmin = null
 $parentObjId = null
 $availableTaxonomyIds = array()
 $fieldFilters = array()
 $taxFilters = array()
 $answerStatusActiveId = null
 $forcedQuestionIds = array()
 $answerStatusFilter = null
 $questions = array()

Detailed Description

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

Constructor & Destructor Documentation

ilAssQuestionList::__construct ( ilDB  $db,
ilLanguage  $lng,
ilPluginAdmin  $pluginAdmin,
  $parentObjId 
)

Constructor.

Parameters
ilDB$db
integer$parentObjId

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

References $db, $lng, $parentObjId, and $pluginAdmin.

{
$this->db = $db;
$this->lng = $lng;
$this->pluginAdmin = $pluginAdmin;
$this->parentObjId = $parentObjId;
}

Member Function Documentation

ilAssQuestionList::addFieldFilter (   $fieldName,
  $fieldValue 
)

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

{
$this->fieldFilters[$fieldName] = $fieldValue;
}
ilAssQuestionList::addTaxonomyFilter (   $taxId,
  $taxNodes 
)

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

Referenced by ilObjQuestionPoolGUI\buildQuestionBrowserTableGUI().

{
$this->taxFilters[$taxId] = $taxNodes;
}

+ Here is the caller graph for this function:

ilAssQuestionList::buildBasicQuery ( )
private

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

Referenced by buildQuery().

{
return "
{$this->getSelectFieldsExpression()}
FROM qpl_questions
{$this->getTableJoinExpression()}
WHERE qpl_questions.original_id IS NULL
AND qpl_questions.obj_fi = {$this->db->quote($this->parentObjId, 'integer')}
AND qpl_questions.tstamp > 0
";
}

+ Here is the caller graph for this function:

ilAssQuestionList::buildQuery ( )
private

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

References $query, buildBasicQuery(), and getForcedQuestionIds().

Referenced by load().

{
$query = $this->buildBasicQuery()."
{$this->getConditionalFilterExpression()}
";
if( count($this->getForcedQuestionIds()) )
{
$query .= "
UNION {$this->buildBasicQuery()}
AND {$this->db->in('qpl_questions.question_id', $this->getForcedQuestionIds(), false, 'integer')}
";
}
return $query;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAssQuestionList::checkFilters ( )
private

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

References getAnswerStatusActiveId(), and getAnswerStatusFilter().

Referenced by load().

{
if( strlen($this->getAnswerStatusFilter()) && !$this->getAnswerStatusActiveId() )
{
require_once 'Modules/TestQuestionPool/exceptions/class.ilTestQuestionPoolException.php';
'No active id given! You cannot use the answer status filter without giving an active id.'
);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAssQuestionList::getAnswerStatusActiveId ( )

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

References $answerStatusActiveId.

Referenced by checkFilters(), getSelectFieldsExpression(), and getTableJoinExpression().

+ Here is the caller graph for this function:

ilAssQuestionList::getAnswerStatusFilter ( )

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

References $answerStatusFilter.

Referenced by checkFilters(), and getAnswerStatusFilterExpressions().

+ Here is the caller graph for this function:

ilAssQuestionList::getAnswerStatusFilterExpressions ( )
private

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

References getAnswerStatusFilter().

Referenced by getConditionalFilterExpression().

{
$expressions = array();
switch( $this->getAnswerStatusFilter() )
{
case self::ANSWER_STATUS_FILTER_ALL_NON_CORRECT:
$expressions[] = '
(tst_test_result.question_fi IS NULL OR tst_test_result.points < qpl_questions.points)
';
break;
case self::ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY:
$expressions[] = 'tst_test_result.question_fi IS NULL';
break;
case self::ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY:
$expressions[] = 'tst_test_result.question_fi IS NOT NULL';
$expressions[] = 'tst_test_result.points < qpl_questions.points';
break;
}
return $expressions;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAssQuestionList::getAvailableTaxonomyIds ( )

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

References $availableTaxonomyIds.

Referenced by loadTaxonomyAssignmentData().

+ Here is the caller graph for this function:

ilAssQuestionList::getConditionalFilterExpression ( )
private

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

References getAnswerStatusFilterExpressions(), getFieldFilterExpressions(), and getTaxonomyFilterExpressions().

{
$CONDITIONS = array_merge(
);
$CONDITIONS = implode(' AND ', $CONDITIONS);
return strlen($CONDITIONS) ? 'AND '.$CONDITIONS : '';
}

+ Here is the call graph for this function:

ilAssQuestionList::getFieldFilterExpressions ( )
private

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

Referenced by getConditionalFilterExpression().

{
$expressions = array();
foreach($this->fieldFilters as $fieldName => $fieldValue)
{
switch($fieldName)
{
case 'title':
case 'description':
case 'author':
$expressions[] = $this->db->like('qpl_questions.' . $fieldName, 'text', "%%$fieldValue%%");
break;
case 'type':
$expressions[] = "qpl_qst_type.type_tag = {$this->db->quote($fieldValue, 'text')}";
break;
}
}
return $expressions;
}

+ Here is the caller graph for this function:

ilAssQuestionList::getForcedQuestionIds ( )
Returns
array

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

References $forcedQuestionIds.

Referenced by buildQuery().

+ Here is the caller graph for this function:

ilAssQuestionList::getQuestionDataArray ( )
ilAssQuestionList::getSelectFieldsExpression ( )
private

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

References getAnswerStatusActiveId().

{
$selectFields = array(
'qpl_questions.*',
'qpl_qst_type.type_tag',
'qpl_qst_type.plugin',
'qpl_questions.points max_points'
);
if( $this->getAnswerStatusActiveId() )
{
$selectFields[] = 'tst_test_result.points reached_points';
$selectFields[] = "CASE
WHEN tst_test_result.points IS NULL THEN '".self::QUESTION_ANSWER_STATUS_NON_ANSWERED."'
WHEN tst_test_result.points < qpl_questions.points THEN '".self::QUESTION_ANSWER_STATUS_WRONG_ANSWERED."'
ELSE '".self::QUESTION_ANSWER_STATUS_CORRECT_ANSWERED."'
END question_answer_status
";
}
$selectFields = implode(",\n\t\t\t\t", $selectFields);
return "
SELECT {$selectFields}
";
}

+ Here is the call graph for this function:

ilAssQuestionList::getTableJoinExpression ( )
private

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

References getAnswerStatusActiveId().

{
$tableJoin = "
INNER JOIN qpl_qst_type
ON qpl_qst_type.question_type_id = qpl_questions.question_type_fi
";
if( $this->getAnswerStatusActiveId() )
{
$tableJoin .= "
LEFT JOIN tst_test_result
ON tst_test_result.question_fi = qpl_questions.question_id
AND tst_test_result.active_fi = {$this->db->quote($this->getAnswerStatusActiveId(), 'integer')}
";
}
return $tableJoin;
}

+ Here is the call graph for this function:

ilAssQuestionList::getTaxonomyFilterExpressions ( )
private

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

Referenced by getConditionalFilterExpression().

{
$expressions = array();
require_once 'Services/Taxonomy/classes/class.ilTaxonomyTree.php';
require_once 'Services/Taxonomy/classes/class.ilTaxNodeAssignment.php';
foreach($this->taxFilters as $taxId => $taxNodes)
{
$questionIds = array();
$forceBypass = true;
foreach($taxNodes as $taxNode)
{
$forceBypass = false;
$taxTree = new ilTaxonomyTree($taxId);
$taxNodeAssignment = new ilTaxNodeAssignment('qpl', $this->parentObjId, 'quest', $taxId);
$subNodes = $taxTree->getSubTreeIds($taxNode);
$subNodes[] = $taxNode;
$taxItems = $taxNodeAssignment->getAssignmentsOfNode($subNodes);
foreach($taxItems as $taxItem)
{
$questionIds[$taxItem['item_id']] = $taxItem['item_id'];
}
}
if( !$forceBypass )
{
$expressions[] = $this->db->in('question_id', $questionIds, false, 'integer');
}
}
return $expressions;
}

+ Here is the caller graph for this function:

ilAssQuestionList::getTitle (   $a_comp_id,
  $a_item_type,
  $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 450 of file class.ilAssQuestionList.php.

{
if( $a_comp_id != 'qpl' || $a_item_type != 'quest' || !(int)$a_item_id )
{
return '';
}
if( !isset($this->questions[$a_item_id]) )
{
return '';
}
return $this->questions[$a_item_id]['title'];
}
ilAssQuestionList::isActiveQuestionType (   $questionData)
private

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

References IL_COMP_MODULE.

Referenced by load().

{
if( !isset($questionData['plugin']) )
{
return false;
}
if( !$questionData['plugin'] )
{
return true;
}
return $this->pluginAdmin->isActive(IL_COMP_MODULE, 'TestQuestionPool', 'qst', $questionData['type_tag']);
}

+ Here is the caller graph for this function:

ilAssQuestionList::load ( )

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

References $query, $res, $row, buildQuery(), checkFilters(), isActiveQuestionType(), and loadTaxonomyAssignmentData().

Referenced by ilObjQuestionPoolTaxonomyEditingCommandForwarder\forward().

{
$this->checkFilters();
$query = $this->buildQuery();
#vd($query);
$res = $this->db->query($query);
#vd($this->db->db->last_query);
while( $row = $this->db->fetchAssoc($res) )
{
if( !$this->isActiveQuestionType($row) )
{
continue;
}
$row['taxonomies'] = $this->loadTaxonomyAssignmentData($row['question_id']);
$row['ttype'] = $this->lng->txt($row['type_tag']);
$this->questions[ $row['question_id'] ] = $row;
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAssQuestionList::loadTaxonomyAssignmentData (   $questionId)
private

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

References getAvailableTaxonomyIds().

Referenced by load().

{
$taxAssignmentData = array();
foreach($this->getAvailableTaxonomyIds() as $taxId)
{
require_once 'Services/Taxonomy/classes/class.ilTaxonomyTree.php';
require_once 'Services/Taxonomy/classes/class.ilTaxNodeAssignment.php';
$taxTree = new ilTaxonomyTree($taxId);
$taxAssignment = new ilTaxNodeAssignment('qpl', $this->parentObjId, 'quest', $taxId);
$assignments = $taxAssignment->getAssignmentsOfItem($questionId);
foreach($assignments as $assData)
{
if( !isset($taxAssignmentData[ $assData['tax_id'] ]) )
{
$taxAssignmentData[ $assData['tax_id'] ] = array();
}
$nodeData = $taxTree->getNodeData($assData['node_id']);
$assData['node_lft'] = $nodeData['lft'];
$taxAssignmentData[ $assData['tax_id'] ][ $assData['node_id'] ] = $assData;
}
}
return $taxAssignmentData;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAssQuestionList::setAnswerStatusActiveId (   $answerStatusActiveId)

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

References $answerStatusActiveId.

Referenced by ilTestDynamicQuestionSet\initCompleteQuestionList(), and ilTestDynamicQuestionSet\initFilteredQuestionList().

{
$this->answerStatusActiveId = $answerStatusActiveId;
}

+ Here is the caller graph for this function:

ilAssQuestionList::setAnswerStatusFilter (   $answerStatusFilter)

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

References $answerStatusFilter.

{
$this->answerStatusFilter = $answerStatusFilter;
}
ilAssQuestionList::setAvailableTaxonomyIds (   $availableTaxonomyIds)

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

References $availableTaxonomyIds.

{
$this->availableTaxonomyIds = $availableTaxonomyIds;
}
ilAssQuestionList::setForcedQuestionIds (   $forcedQuestionIds)
Parameters
array$forcedQuestionIds

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

References $forcedQuestionIds.

{
$this->forcedQuestionIds = $forcedQuestionIds;
}

Field Documentation

ilAssQuestionList::$answerStatusActiveId = null
private

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

Referenced by getAnswerStatusActiveId(), and setAnswerStatusActiveId().

ilAssQuestionList::$answerStatusFilter = null
private

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

Referenced by getAnswerStatusFilter(), and setAnswerStatusFilter().

ilAssQuestionList::$availableTaxonomyIds = array()
private

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

Referenced by getAvailableTaxonomyIds(), and setAvailableTaxonomyIds().

ilAssQuestionList::$db = null
private

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

Referenced by __construct().

ilAssQuestionList::$fieldFilters = array()
private

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

ilAssQuestionList::$forcedQuestionIds = array()
private

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

Referenced by getForcedQuestionIds(), and setForcedQuestionIds().

ilAssQuestionList::$lng = null
private

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

Referenced by __construct().

ilAssQuestionList::$parentObjId = null
private

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

Referenced by __construct().

ilAssQuestionList::$pluginAdmin = null
private

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

Referenced by __construct().

ilAssQuestionList::$questions = array()
private

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

Referenced by getQuestionDataArray().

ilAssQuestionList::$taxFilters = array()
private

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

const ilAssQuestionList::ANSWER_STATUS_FILTER_ALL_NON_CORRECT = 'allNonCorrect'
const ilAssQuestionList::ANSWER_STATUS_FILTER_NON_ANSWERED_ONLY = 'nonAnswered'
const ilAssQuestionList::ANSWER_STATUS_FILTER_WRONG_ANSWERED_ONLY = 'wrongAnswered'
const ilAssQuestionList::QUESTION_ANSWER_STATUS_CORRECT_ANSWERED = 'correctAnswered'
const ilAssQuestionList::QUESTION_ANSWER_STATUS_NON_ANSWERED = 'nonAnswered'

answer status domain for single questions

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

Referenced by ilTestPlayerDynamicQuestionSetGUI\buildQuestionSetAnswerStatisticRowArray().

const ilAssQuestionList::QUESTION_ANSWER_STATUS_WRONG_ANSWERED = 'wrongAnswered'

The documentation for this class was generated from the following file: