ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilAssQuestionPreviewHintTracking Class Reference
+ Collaboration diagram for ilAssQuestionPreviewHintTracking:

Public Member Functions

 __construct (ilDB $db, ilAssQuestionPreviewSession $previewSession)
 
 requestsExist ()
 
 requestsPossible ()
 
 getNextRequestableHint ()
 
 storeRequest (ilAssQuestionHint $questionHint)
 
 isRequested ($hintId)
 
 getNumExistingRequests ()
 
 getRequestedHintsList ()
 

Private Attributes

 $db
 
 $previewSession
 

Detailed Description

Definition at line 11 of file class.ilAssQuestionPreviewHintTracking.php.

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionPreviewHintTracking::__construct ( ilDB  $db,
ilAssQuestionPreviewSession  $previewSession 
)

Member Function Documentation

◆ getNextRequestableHint()

ilAssQuestionPreviewHintTracking::getNextRequestableHint ( )

Definition at line 58 of file class.ilAssQuestionPreviewHintTracking.php.

59 {
60 $query = "
61 SELECT qht_hint_id
62
63 FROM qpl_hints
64
65 WHERE qht_question_fi = %s
66
67 ORDER BY qht_hint_index ASC
68 ";
69
70 $res = $this->db->queryF(
71 $query, array('integer'), array($this->previewSession->getQuestionId())
72 );
73
74 while( $row = $this->db->fetchAssoc($res) )
75 {
76 if( !$this->isRequested($row['qht_hint_id']) )
77 {
78 return ilAssQuestionHint::getInstanceById($row['qht_hint_id']);
79 }
80 }
81
82 throw new ilTestException(
83 "no next hint found for questionId={$this->previewSession->getQuestionId()}, userId={$this->previewSession->getUserId()}"
84 );
85 }
static getInstanceById($hintId)
creates a hint object instance, loads the persisted hint dataset identified by passed hint id from da...
Base Exception for all Exceptions relating to Modules/Test.

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

+ Here is the call graph for this function:

◆ getNumExistingRequests()

ilAssQuestionPreviewHintTracking::getNumExistingRequests ( )

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

98 {
99 return $this->previewSession->getNumRequestedHints();
100 }

◆ getRequestedHintsList()

ilAssQuestionPreviewHintTracking::getRequestedHintsList ( )

Definition at line 102 of file class.ilAssQuestionPreviewHintTracking.php.

103 {
104 $hintIds = $this->previewSession->getRequestedHints();
105
106 $requestedHintsList = ilAssQuestionHintList::getListByHintIds($hintIds);
107
108 return $requestedHintsList;
109 }
static getListByHintIds($hintIds)
instantiates a question hint list for the passed hint ids

References ilAssQuestionHintList\getListByHintIds().

+ Here is the call graph for this function:

◆ isRequested()

ilAssQuestionPreviewHintTracking::isRequested (   $hintId)

Definition at line 92 of file class.ilAssQuestionPreviewHintTracking.php.

93 {
94 return $this->previewSession->isHintRequested($hintId);
95 }

Referenced by getNextRequestableHint().

+ Here is the caller graph for this function:

◆ requestsExist()

ilAssQuestionPreviewHintTracking::requestsExist ( )

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

30 {
31 return (
32 $this->previewSession->getNumRequestedHints() > 0
33 );
34 }

◆ requestsPossible()

ilAssQuestionPreviewHintTracking::requestsPossible ( )

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

37 {
38 $query = "
39 SELECT COUNT(qht_hint_id) cnt_available
40 FROM qpl_hints
41 WHERE qht_question_fi = %s
42 ";
43
44 $res = $this->db->queryF(
45 $query, array('integer'), array($this->previewSession->getQuestionId())
46 );
47
48 $row = $this->db->fetchAssoc($res);
49
50 if( $row['cnt_available'] > $this->previewSession->getNumRequestedHints() )
51 {
52 return true;
53 }
54
55 return false;
56 }

References $query, $res, and $row.

◆ storeRequest()

ilAssQuestionPreviewHintTracking::storeRequest ( ilAssQuestionHint  $questionHint)

Definition at line 87 of file class.ilAssQuestionPreviewHintTracking.php.

88 {
89 $this->previewSession->addRequestedHint($questionHint->getId());
90 }
getId()
returns the hint id

References ilAssQuestionHint\getId().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilAssQuestionPreviewHintTracking::$db
private

Definition at line 16 of file class.ilAssQuestionPreviewHintTracking.php.

Referenced by __construct().

◆ $previewSession

ilAssQuestionPreviewHintTracking::$previewSession
private

Definition at line 21 of file class.ilAssQuestionPreviewHintTracking.php.

Referenced by __construct().


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