]> git.mjollnir.org Git - moodle.git/commitdiff
Function exercise_get_participants() included and working. :-)
authorstronk7 <stronk7>
Tue, 14 Oct 2003 17:31:54 +0000 (17:31 +0000)
committerstronk7 <stronk7>
Tue, 14 Oct 2003 17:31:54 +0000 (17:31 +0000)
mod/exercise/lib.php

index 47c7d5e12d06a757442731e392c5720e5fb49306..4b24a49aaaaee9d48efc06e21f15a161935dbc95 100644 (file)
@@ -546,6 +546,35 @@ function exercise_user_outline($course, $user, $mod, $exercise) {
     return NULL;
 }
 
+/*******************************************************************/
+function exercise_get_participants($exerciseid) {
+//Returns the users with data in one exercise
+//(users with records in exercise_submissions and exercise_assessments, students)
+
+    global $CFG;
+
+    //Get students from exercise_submissions
+    $st_submissions = get_records_sql("SELECT DISTINCT u.*
+                                       FROM {$CFG->prefix}user u,
+                                            {$CFG->prefix}exercise_submissions s
+                                       WHERE s.exerciseid = '$exerciseid' and
+                                             u.id = s.userid");
+    //Get students from exercise_assessments
+    $st_assessments = get_records_sql("SELECT DISTINCT u.*
+                                 FROM {$CFG->prefix}user u,
+                                      {$CFG->prefix}exercise_assessments a
+                                 WHERE a.exerciseid = '$exerciseid' and
+                                       u.id = a.userid");
+
+    //Add st_assessments to st_submissions
+    if ($st_assessments) {
+        foreach ($st_assessments as $st_assessment) {
+            $st_submissions[$st_assessment->id] = $st_assessment;
+        }
+    }
+    //Return st_submissions array (it contains an array of unique users)
+    return ($st_submissions);
+}
 
 //////////////////////////////////////////////////////////////////////////////////////