ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 11 of file class.ilAssQuestionPreviewHintTracking.php.

Constructor & Destructor Documentation

◆ __construct()

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

Member Function Documentation

◆ getNextRequestableHint()

ilAssQuestionPreviewHintTracking::getNextRequestableHint ( )

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

60 {
61 $query = "
62 SELECT qht_hint_id
63
64 FROM qpl_hints
65
66 WHERE qht_question_fi = %s
67
68 ORDER BY qht_hint_index ASC
69 ";
70
71 $res = $this->db->queryF(
72 $query,
73 array('integer'),
74 array($this->previewSession->getQuestionId())
75 );
76
77 while ($row = $this->db->fetchAssoc($res)) {
78 if (!$this->isRequested($row['qht_hint_id'])) {
79 return ilAssQuestionHint::getInstanceById($row['qht_hint_id']);
80 }
81 }
82
83 throw new ilTestException(
84 "no next hint found for questionId={$this->previewSession->getQuestionId()}, userId={$this->previewSession->getUserId()}"
85 );
86 }
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.
$query
foreach($_POST as $key=> $value) $res

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

+ Here is the call graph for this function:

◆ getNumExistingRequests()

ilAssQuestionPreviewHintTracking::getNumExistingRequests ( )

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

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

◆ getRequestedHintsList()

ilAssQuestionPreviewHintTracking::getRequestedHintsList ( )

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

104 {
105 $hintIds = $this->previewSession->getRequestedHints();
106
107 $requestedHintsList = ilAssQuestionHintList::getListByHintIds($hintIds);
108
109 return $requestedHintsList;
110 }
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 112 of file class.ilAssQuestionPreviewHintTracking.php.

113 {
114 $count = 0;
115 $points = 0;
116
117 foreach ($this->getRequestedHintsList() as $hint) {
118 $count++;
119 $points += $hint->getPoints();
120 }
121
122 $requestsStatisticData = new ilAssQuestionHintRequestStatisticData();
123 $requestsStatisticData->setRequestsCount($count);
124 $requestsStatisticData->setRequestsPoints($points);
125
126 return $requestsStatisticData;
127 }

References getRequestedHintsList().

+ Here is the call graph for this function:

◆ isRequested()

ilAssQuestionPreviewHintTracking::isRequested (   $hintId)

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

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

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,
46 array('integer'),
47 array($this->previewSession->getQuestionId())
48 );
49
50 $row = $this->db->fetchAssoc($res);
51
52 if ($row['cnt_available'] > $this->previewSession->getNumRequestedHints()) {
53 return true;
54 }
55
56 return false;
57 }

References $query, and $res.

◆ storeRequest()

ilAssQuestionPreviewHintTracking::storeRequest ( ilAssQuestionHint  $questionHint)

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

89 {
90 $this->previewSession->addRequestedHint($questionHint->getId());
91 }
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: