@@ -192,15 +192,34 @@ public function calc_score($stud_id = null)
192
192
/* the following query should be similar (in conditions) to the one used
193
193
in exercice/exercice.php, look for note-query-exe-results marker*/
194
194
$ session_id = api_get_session_id ();
195
+
196
+ $ exercise = new Exercise ();
197
+ $ exercise ->read ($ this ->get_ref_id ());
198
+
195
199
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
+ }
203
215
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
+ }
204
223
if (isset ($ stud_id )) {
205
224
$ course_code_exe = $ this ->get_course_code ();
206
225
$ sql .= " AND exe_cours_id = ' $ course_code_exe' AND exe_user_id = ' $ stud_id' " ;
0 commit comments