ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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.

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

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  }
$res
Definition: ltiservices.php:69
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...
$query
+ 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.

References ilAssQuestionHintList\getListByHintIds().

Referenced by getRequestStatisticData().

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
+ 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.

References getRequestedHintsList().

Referenced by assQuestion\deductHintPointsFromReachedPoints().

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  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isRequested()

ilAssQuestionPreviewHintTracking::isRequested (   $hintId)

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

Referenced by getNextRequestableHint().

107  : bool
108  {
109  return $this->previewSession->isHintRequested($hintId);
110  }
+ 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.

References $query, and $res.

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  }
$res
Definition: ltiservices.php:69
$query

◆ storeRequest()

ilAssQuestionPreviewHintTracking::storeRequest ( ilAssQuestionHint  $questionHint)

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

References ilAssQuestionHint\getId().

102  : void
103  {
104  $this->previewSession->addRequestedHint($questionHint->getId());
105  }
getId()
returns the hint id
+ 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: