Skip to content

Commit 96ab630

Browse files
committed
Fix Exercise result if was added inside a LP see BT#9494
1 parent 4235e46 commit 96ab630

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

main/gradebook/lib/be/exerciselink.class.php

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,34 @@ public function calc_score($stud_id = null)
192192
/* the following query should be similar (in conditions) to the one used
193193
in exercice/exercice.php, look for note-query-exe-results marker*/
194194
$session_id = api_get_session_id();
195+
196+
$exercise = new Exercise();
197+
$exercise->read($this->get_ref_id());
198+
195199
if (!$this->is_hp) {
196-
$sql = "SELECT * FROM $tblStats
197-
WHERE
198-
exe_exo_id = ".intval($this->get_ref_id())." AND
199-
orig_lp_id = 0 AND
200-
orig_lp_item_id = 0 AND
201-
status <> 'incomplete' AND
202-
session_id = $session_id";
200+
if ($exercise->exercise_was_added_in_lp == false) {
201+
$sql = "SELECT * FROM $tblStats
202+
WHERE
203+
exe_exo_id = ".intval($this->get_ref_id())." AND
204+
orig_lp_id = 0 AND
205+
orig_lp_item_id = 0 AND
206+
status <> 'incomplete' AND
207+
session_id = $session_id";
208+
} else {
209+
$lpId = null;
210+
if (!empty($exercise->lpList)) {
211+
// Taking only the first LP
212+
$lpId = current($exercise->lpList);
213+
$lpId = $lpId['lp_id'];
214+
}
203215

216+
$sql = "SELECT * FROM $tblStats
217+
WHERE
218+
exe_exo_id = ".intval($this->get_ref_id())." AND
219+
orig_lp_id = $lpId AND
220+
status <> 'incomplete' AND
221+
session_id = $session_id";
222+
}
204223
if (isset($stud_id)) {
205224
$course_code_exe = $this->get_course_code();
206225
$sql .= " AND exe_cours_id = '$course_code_exe' AND exe_user_id = '$stud_id' ";

0 commit comments

Comments
 (0)