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

Public Member Functions

 current ()
 iterator interface method
 rewind ()
 iterator interface method
 next ()
 iterator interface method
 key ()
 iterator interface method
 valid ()
 iterator interface method
 __construct ()
 Constructor.
 addHint (ilAssQuestionHint $questionHint)
 adds a question hint object to the current list instance
 getHint ($hintId)
 returns the question hint object relating to the passed hint id
 hintExists ($hintId)
 checks wether a question hint object relating to the passed id exists or not
 reIndex ()
 re-indexes the list's hints sequentially by current order (starting with index "1")
 getTableData ()
 returns an array with data of the hints in this list that is adopted to be used as table gui data

Static Public Member Functions

static duplicateListForQuestion ($originalQuestionId, $duplicateQuestionId)
 duplicates a hint list from given original question id to given duplicate question id and returns an array of duplicate hint ids mapped to the corresponding original hint ids
static getListByQuestionId ($questionId)
 instantiates a question hint list for the passed question id
static getListByHintIds ($hintIds)
 instantiates a question hint list for the passed hint ids
static getNextIndexByQuestionId ($questionId)
 determines the next index to be used for a new hint that is to be added to the list of existing hints regarding to the question with passed question id
static deleteHintsByQuestionIds ($questionIds)
 Deletes all question hints relating to questions included in given question ids.

Private Attributes

 $questionHints = array()

Detailed Description

Definition at line 14 of file class.ilAssQuestionHintList.php.

Constructor & Destructor Documentation

ilAssQuestionHintList::__construct ( )

Constructor.

public

Definition at line 69 of file class.ilAssQuestionHintList.php.

{ }

Member Function Documentation

ilAssQuestionHintList::addHint ( ilAssQuestionHint  $questionHint)

adds a question hint object to the current list instance

public

Parameters
ilAssQuestionHint$questionHint

Definition at line 77 of file class.ilAssQuestionHintList.php.

Referenced by ilAssQuestionHintsGUI\pasteFromOrderingClipboardAfterCmd().

{
$this->questionHints[] = $questionHint;
}

+ Here is the caller graph for this function:

ilAssQuestionHintList::current ( )

iterator interface method

public

Returns
mixed

Definition at line 30 of file class.ilAssQuestionHintList.php.

References current().

Referenced by current().

{ return current($this->questionHints); }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAssQuestionHintList::deleteHintsByQuestionIds (   $questionIds)
static

Deletes all question hints relating to questions included in given question ids.

ilDB $ilDB

Parameters
array[integer]$questionIds

Definition at line 338 of file class.ilAssQuestionHintList.php.

References $query.

Referenced by assQuestion\delete().

{
global $ilDB;
$__qht_question_fi__IN__questionIds = $ilDB->in('qht_question_fi', $questionIds, false, 'integer');
$query = "
DELETE FROM qpl_hints
WHERE $__qht_question_fi__IN__questionIds
";
return $ilDB->manipulate($query);
}

+ Here is the caller graph for this function:

static ilAssQuestionHintList::duplicateListForQuestion (   $originalQuestionId,
  $duplicateQuestionId 
)
static

duplicates a hint list from given original question id to given duplicate question id and returns an array of duplicate hint ids mapped to the corresponding original hint ids

Parameters
integer$originalQuestionId
integer$duplicateQuestionId
Returns
array $hintIds containing the map from original hint ids to duplicate hint ids

Definition at line 159 of file class.ilAssQuestionHintList.php.

References getListByQuestionId().

Referenced by assQuestion\duplicateQuestionHints().

{
$hintIds = array();
$questionHintList = self::getListByQuestionId($originalQuestionId);
foreach($questionHintList as $questionHint)
{
/* @var $questionHint ilAssQuestionHint */
$originalHintId = $questionHint->getId();
$questionHint->setId(null);
$questionHint->setQuestionId($duplicateQuestionId);
$questionHint->save();
$duplicateHintId = $questionHint->getId();
$hintIds[$originalHintId] = $duplicateHintId;
}
return $hintIds;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAssQuestionHintList::getHint (   $hintId)

returns the question hint object relating to the passed hint id

public

Parameters
integer$hintId
Returns
ilAssQuestionHint $questionHint

Definition at line 89 of file class.ilAssQuestionHintList.php.

{
foreach($this as $questionHint)
{
/* @var $questionHint ilAssQuestionHint */
if( $questionHint->getId() == $hintId )
{
return $questionHint;
}
}
require_once 'Modules/TestQuestionPool/exceptions/class.ilTestQuestionPoolException.php';
throw new ilTestQuestionPoolException("hint with id $hintId does not exist in this list");
}
static ilAssQuestionHintList::getListByHintIds (   $hintIds)
static

instantiates a question hint list for the passed hint ids

public ilDB $ilDB

Parameters
array$hintIds
Returns
self $questionHintList

Definition at line 264 of file class.ilAssQuestionHintList.php.

References $query, $res, $row, and ilAssQuestionHint\assignDbRow().

Referenced by ilAssQuestionHintTracking\getRequestedHintsList().

{
global $ilDB;
$qht_hint_id__IN__hintIds = $ilDB->in('qht_hint_id', $hintIds, false, 'integer');
$query = "
SELECT qht_hint_id,
qht_question_fi,
qht_hint_index,
qht_hint_points,
qht_hint_text
FROM qpl_hints
WHERE $qht_hint_id__IN__hintIds
ORDER BY qht_hint_index ASC
";
$res = $ilDB->query($query);
$questionHintList = new self();
while( $row = $ilDB->fetchAssoc($res) )
{
$questionHint = new ilAssQuestionHint();
$questionHintList->addHint($questionHint);
}
return $questionHintList;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAssQuestionHintList::getListByQuestionId (   $questionId)
static

instantiates a question hint list for the passed question id

public ilDB $ilDB

Parameters
integer$questionId
Returns
self $questionHintList

Definition at line 219 of file class.ilAssQuestionHintList.php.

References $query, $res, $row, and ilAssQuestionHint\assignDbRow().

Referenced by ilAssQuestionHintsGUI\checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure(), ilAssQuestionHintsGUI\confirmDeleteCmd(), duplicateListForQuestion(), ilAssQuestionHintsGUI\pasteFromOrderingClipboardAfterCmd(), ilAssQuestionHintsGUI\pasteFromOrderingClipboardBeforeCmd(), ilAssQuestionHintsGUI\performDeleteCmd(), ilAssQuestionHintsGUI\saveListOrderCmd(), and ilAssQuestionHintsGUI\showListCmd().

{
global $ilDB;
$query = "
SELECT qht_hint_id,
qht_question_fi,
qht_hint_index,
qht_hint_points,
qht_hint_text
FROM qpl_hints
WHERE qht_question_fi = %s
ORDER BY qht_hint_index ASC
";
$res = $ilDB->queryF(
$query, array('integer'), array((int)$questionId)
);
$questionHintList = new self();
while( $row = $ilDB->fetchAssoc($res) )
{
$questionHint = new ilAssQuestionHint();
$questionHintList->addHint($questionHint);
}
return $questionHintList;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilAssQuestionHintList::getNextIndexByQuestionId (   $questionId)
static

determines the next index to be used for a new hint that is to be added to the list of existing hints regarding to the question with passed question id

public ilDB $ilDB

Parameters
integer$questionId
Returns
integer $nextIndex

Definition at line 311 of file class.ilAssQuestionHintList.php.

References $query, $res, and $row.

Referenced by ilAssQuestionHintGUI\saveFormCmd().

{
global $ilDB;
$query = "
SELECT 1 + COALESCE( MAX(qht_hint_index), 0 ) next_index
FROM qpl_hints
WHERE qht_question_fi = %s
";
$res = $ilDB->queryF(
$query, array('integer'), array((int)$questionId)
);
$row = $ilDB->fetchAssoc($res);
return $row['next_index'];
}

+ Here is the caller graph for this function:

ilAssQuestionHintList::getTableData ( )

returns an array with data of the hints in this list that is adopted to be used as table gui data

public

Returns
array $tableData

Definition at line 191 of file class.ilAssQuestionHintList.php.

Referenced by ilAssQuestionHintsTableGUI\__construct().

{
$tableData = array();
foreach($this as $questionHint)
{
/* @var $questionHint ilAssQuestionHint */
$tableData[] = array(
'hint_id' => $questionHint->getId(),
'hint_index' => $questionHint->getIndex(),
'hint_points' => $questionHint->getPoints(),
'hint_text' => $questionHint->getText()
);
}
return $tableData;
}

+ Here is the caller graph for this function:

ilAssQuestionHintList::hintExists (   $hintId)

checks wether a question hint object relating to the passed id exists or not

public

Parameters
integer$hintId
Returns
boolean $hintExists

Definition at line 113 of file class.ilAssQuestionHintList.php.

{
foreach($this as $questionHint)
{
/* @var $questionHint ilAssQuestionHint */
if( $questionHint->getId() == $hintId )
{
return true;
}
}
return false;
}
ilAssQuestionHintList::key ( )

iterator interface method

public

Returns
mixed

Definition at line 54 of file class.ilAssQuestionHintList.php.

References key().

Referenced by key(), and valid().

{ return key($this->questionHints); }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAssQuestionHintList::next ( )

iterator interface method

public

Returns
mixed

Definition at line 46 of file class.ilAssQuestionHintList.php.

References next().

Referenced by next().

{ return next($this->questionHints); }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAssQuestionHintList::reIndex ( )

re-indexes the list's hints sequentially by current order (starting with index "1")

ATTENTION: it also persists this index to db by performing an update of hint object via id. do not re-index any hint list objects unless this lists contain ALL hint objects for a SINGLE question and no more hints apart of that.

public

Definition at line 137 of file class.ilAssQuestionHintList.php.

{
$counter = 0;
foreach($this as $questionHint)
{
/* @var $questionHint ilAssQuestionHint */
$questionHint->setIndex(++$counter);
$questionHint->save();
}
}
ilAssQuestionHintList::rewind ( )

iterator interface method

public

Returns
mixed

Definition at line 38 of file class.ilAssQuestionHintList.php.

{ return reset($this->questionHints); }
ilAssQuestionHintList::valid ( )

iterator interface method

public

Returns
boolean

Definition at line 62 of file class.ilAssQuestionHintList.php.

References key().

{ return key($this->questionHints) !== null; }

+ Here is the call graph for this function:

Field Documentation

ilAssQuestionHintList::$questionHints = array()
private

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


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