Skip to content

Commit b042a11

Browse files
committed
Quiz: Fix hotspot questions by user #3044
1 parent 2092b5f commit b042a11

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

main/exercise/hotspot_actionscript.as.php

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@
3737

3838
// Query db for answers
3939
if ($answer_type == HOT_SPOT_DELINEATION) {
40-
$sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation
40+
$sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation
4141
FROM $TBL_ANSWERS
42-
WHERE
43-
c_id = $course_id AND
44-
question_id = $questionId AND
45-
hotspot_type = 'delineation'
42+
WHERE
43+
c_id = $course_id AND
44+
question_id = $questionId AND
45+
hotspot_type = 'delineation'
4646
ORDER BY iid";
4747
} else {
48-
$sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation
48+
$sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation
4949
FROM $TBL_ANSWERS
50-
WHERE c_id = $course_id AND question_id = $questionId
50+
WHERE c_id = $course_id AND question_id = $questionId
5151
ORDER BY position";
5252
}
5353
$result = Database::query($sql);
@@ -118,7 +118,29 @@
118118
$data['hotspots'][] = $hotSpot;
119119
}
120120

121-
$attemptList = Event::getAllExerciseEventByExeId($exerciseId);
121+
$attemptInfo = Database::select(
122+
'exe_id',
123+
Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES),
124+
[
125+
'where' => [
126+
'exe_exo_id = ? AND c_id = ? AND exe_user_id = ? AND status = ?' => [
127+
(int) $exerciseId,
128+
$course_id,
129+
api_get_user_id(),
130+
'incomplete',
131+
]
132+
],
133+
'order' => 'exe_id DESC',
134+
'limit' => 1,
135+
],
136+
'first'
137+
);
138+
139+
if (empty($attemptInfo)) {
140+
exit(0);
141+
}
142+
143+
$attemptList = Event::getAllExerciseEventByExeId($attemptInfo['exe_id']);
122144

123145
if (!empty($attemptList)) {
124146
if (isset($attemptList[$questionId])) {

0 commit comments

Comments
 (0)