]> git.mjollnir.org Git - moodle.git/commitdiff
Included assignment_get_participants() function.
authorstronk7 <stronk7>
Wed, 3 Sep 2003 22:10:51 +0000 (22:10 +0000)
committerstronk7 <stronk7>
Wed, 3 Sep 2003 22:10:51 +0000 (22:10 +0000)
Please check it before continue with other modules.

mod/assignment/lib.php

index 71f31433ea175bcf012d14ab73c087a62340745a..9e36202199efb6611f0fee6aea324725ef17e9cc 100644 (file)
@@ -500,4 +500,31 @@ function assignment_print_upload_form($assignment) {
     echo "</DIV>";
 }
 
+function assignment_get_participants($assignmentid) {
+//Returns the users with data in one assignment
+//(users with records in assignment_submissions, students and teachers)
+
+    global $CFG;
+
+    //Get students
+    $students = get_records_sql("SELECT DISTINCT u.* 
+                                 FROM {$CFG->prefix}user u,
+                                      {$CFG->prefix}assignment_submissions a
+                                 WHERE a.assignment = '$assignmentid' and
+                                       u.id = a.userid");
+    //Get teachers
+    $teachers = get_records_sql("SELECT DISTINCT u.*
+                                 FROM {$CFG->prefix}user u,       
+                                      {$CFG->prefix}assignment_submissions a       
+                                 WHERE a.assignment = '$assignmentid' and
+                                       u.id = a.teacher");
+
+    //Add teachers to students
+    foreach ($teachers as $teacher) {
+        $students[$teacher->id] = $teacher;
+    }
+    //Return students array (it contains an array of unique users)
+    return ($students);
+}
+
 ?>