ILIAS  release_8 Revision v8.24
ilAssQuestionPreviewHintTracking Class Reference
+ Collaboration diagram for ilAssQuestionPreviewHintTracking:

Public Member Functions

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

Private Attributes

 $db
 
 $previewSession
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

Member Function Documentation

◆ getNextRequestableHint()

ilAssQuestionPreviewHintTracking::getNextRequestableHint ( )

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

74 {
75 $query = "
76 SELECT qht_hint_id
77
78 FROM qpl_hints
79
80 WHERE qht_question_fi = %s
81
82 ORDER BY qht_hint_index ASC
83 ";
84
85 $res = $this->db->queryF(
86 $query,
87 array('integer'),
88 array($this->previewSession->getQuestionId())
89 );
90
91 while ($row = $this->db->fetchAssoc($res)) {
92 if (!$this->isRequested($row['qht_hint_id'])) {
93 return ilAssQuestionHint::getInstanceById($row['qht_hint_id']);
94 }
95 }
96
97 throw new ilTestException(
98 "no next hint found for questionId={$this->previewSession->getQuestionId()}, userId={$this->previewSession->getUserId()}"
99 );
100 }
static getInstanceById($hintId)
creates a hint object instance, loads the persisted hint dataset identified by passed hint id from da...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$res
Definition: ltiservices.php:69
$query

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

+ Here is the call graph for this function:

◆ getNumExistingRequests()

ilAssQuestionPreviewHintTracking::getNumExistingRequests ( )

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

112 : int
113 {
114 return $this->previewSession->getNumRequestedHints();
115 }

◆ getRequestedHintsList()

ilAssQuestionPreviewHintTracking::getRequestedHintsList ( )

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

118 {
119 $hintIds = $this->previewSession->getRequestedHints();
120
121 $requestedHintsList = ilAssQuestionHintList::getListByHintIds($hintIds);
122
123 return $requestedHintsList;
124 }
static getListByHintIds($hintIds)
instantiates a question hint list for the passed hint ids

References ilAssQuestionHintList\getListByHintIds().

Referenced by getRequestStatisticData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRequestStatisticData()

ilAssQuestionPreviewHintTracking::getRequestStatisticData ( )

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

127 {
128 $count = 0;
129 $points = 0;
130
131 foreach ($this->getRequestedHintsList() as $hint) {
132 $count++;
133 $points += $hint->getPoints();
134 }
135
136 $requestsStatisticData = new ilAssQuestionHintRequestStatisticData();
137 $requestsStatisticData->setRequestsCount($count);
138 $requestsStatisticData->setRequestsPoints($points);
139
140 return $requestsStatisticData;
141 }

References getRequestedHintsList().

+ Here is the call graph for this function:

◆ isRequested()

ilAssQuestionPreviewHintTracking::isRequested (   $hintId)

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

107 : bool
108 {
109 return $this->previewSession->isHintRequested($hintId);
110 }

Referenced by getNextRequestableHint().

+ Here is the caller graph for this function:

◆ requestsExist()

ilAssQuestionPreviewHintTracking::requestsExist ( )

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

43 : bool
44 {
45 return (
46 $this->previewSession->getNumRequestedHints() > 0
47 );
48 }

◆ requestsPossible()

ilAssQuestionPreviewHintTracking::requestsPossible ( )

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

50 : bool
51 {
52 $query = "
53 SELECT COUNT(qht_hint_id) cnt_available
54 FROM qpl_hints
55 WHERE qht_question_fi = %s
56 ";
57
58 $res = $this->db->queryF(
59 $query,
60 array('integer'),
61 array($this->previewSession->getQuestionId())
62 );
63
64 $row = $this->db->fetchAssoc($res);
65
66 if ($row['cnt_available'] > $this->previewSession->getNumRequestedHints()) {
67 return true;
68 }
69
70 return false;
71 }

References $query, and $res.

◆ storeRequest()

ilAssQuestionPreviewHintTracking::storeRequest ( ilAssQuestionHint  $questionHint)

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

102 : void
103 {
104 $this->previewSession->addRequestedHint($questionHint->getId());
105 }
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 30 of file class.ilAssQuestionPreviewHintTracking.php.

Referenced by __construct().

◆ $previewSession

ilAssQuestionPreviewHintTracking::$previewSession
private

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

Referenced by __construct().


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