ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
class.ilAssQuestionPreviewHintTracking.php
Go to the documentation of this file.
1
<?
php
2
/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
11
class
ilAssQuestionPreviewHintTracking
12
{
16
private
$db
;
17
21
private
$previewSession
;
22
23
public
function
__construct
(
ilDBInterface
$db
,
ilAssQuestionPreviewSession
$previewSession
)
24
{
25
$this->db =
$db
;
26
$this->previewSession =
$previewSession
;
27
}
28
29
public
function
requestsExist
()
30
{
31
return
(
32
$this->previewSession->getNumRequestedHints() > 0
33
);
34
}
35
36
public
function
requestsPossible
()
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
}
58
59
public
function
getNextRequestableHint
()
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
}
87
88
public
function
storeRequest
(
ilAssQuestionHint
$questionHint)
89
{
90
$this->previewSession->addRequestedHint($questionHint->
getId
());
91
}
92
93
public
function
isRequested
($hintId)
94
{
95
return
$this->previewSession->isHintRequested($hintId);
96
}
97
98
public
function
getNumExistingRequests
()
99
{
100
return
$this->previewSession->getNumRequestedHints();
101
}
102
103
public
function
getRequestedHintsList
()
104
{
105
$hintIds = $this->previewSession->getRequestedHints();
106
107
$requestedHintsList =
ilAssQuestionHintList::getListByHintIds
($hintIds);
108
109
return
$requestedHintsList;
110
}
111
112
public
function
getRequestStatisticData
()
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
}
128
}
ilAssQuestionHint\getInstanceById
static getInstanceById($hintId)
creates a hint object instance, loads the persisted hint dataset identified by passed hint id from da...
Definition:
class.ilAssQuestionHint.php:360
ilAssQuestionPreviewHintTracking\isRequested
isRequested($hintId)
Definition:
class.ilAssQuestionPreviewHintTracking.php:93
ilAssQuestionPreviewHintTracking\$previewSession
$previewSession
Definition:
class.ilAssQuestionPreviewHintTracking.php:21
ilAssQuestionPreviewHintTracking\$db
$db
Definition:
class.ilAssQuestionPreviewHintTracking.php:16
ilTestException
Base Exception for all Exceptions relating to Modules/Test.
Definition:
class.ilTestException.php:14
ilAssQuestionHint\getId
getId()
returns the hint id
Definition:
class.ilAssQuestionHint.php:75
ilAssQuestionPreviewHintTracking\requestsExist
requestsExist()
Definition:
class.ilAssQuestionPreviewHintTracking.php:29
ilAssQuestionHint
Definition:
class.ilAssQuestionHint.php:14
ilAssQuestionHintRequestStatisticData
Definition:
class.ilAssQuestionHintRequestStatisticData.php:12
ilAssQuestionHintList\getListByHintIds
static getListByHintIds($hintIds)
instantiates a question hint list for the passed hint ids
Definition:
class.ilAssQuestionHintList.php:276
ilAssQuestionPreviewHintTracking\getRequestedHintsList
getRequestedHintsList()
Definition:
class.ilAssQuestionPreviewHintTracking.php:103
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
ilAssQuestionPreviewSession
Definition:
class.ilAssQuestionPreviewSession.php:11
ilAssQuestionPreviewHintTracking
Definition:
class.ilAssQuestionPreviewHintTracking.php:11
ilAssQuestionPreviewHintTracking\getNumExistingRequests
getNumExistingRequests()
Definition:
class.ilAssQuestionPreviewHintTracking.php:98
ilDBInterface
$query
$query
Definition:
proxy_ylocal.php:13
ilAssQuestionPreviewHintTracking\requestsPossible
requestsPossible()
Definition:
class.ilAssQuestionPreviewHintTracking.php:36
ilAssQuestionPreviewHintTracking\getNextRequestableHint
getNextRequestableHint()
Definition:
class.ilAssQuestionPreviewHintTracking.php:59
$row
$row
Definition:
migrateto20.php:360
ilAssQuestionPreviewHintTracking\__construct
__construct(ilDBInterface $db, ilAssQuestionPreviewSession $previewSession)
Definition:
class.ilAssQuestionPreviewHintTracking.php:23
ilAssQuestionPreviewHintTracking\getRequestStatisticData
getRequestStatisticData()
Definition:
class.ilAssQuestionPreviewHintTracking.php:112
ilAssQuestionPreviewHintTracking\storeRequest
storeRequest(ilAssQuestionHint $questionHint)
Definition:
class.ilAssQuestionPreviewHintTracking.php:88
php
Modules
TestQuestionPool
classes
class.ilAssQuestionPreviewHintTracking.php
Generated on Thu Jan 30 2025 19:01:48 for ILIAS by
1.8.13 (using
Doxyfile
)