Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Included assignment_get_participants() function.

Please check it before continue with other modules.
  • Loading branch information...
commit 2bae0d446ca10af926bef522b0ecec343b9bfa37 1 parent cb29b02
stronk7 authored
Showing with 27 additions and 0 deletions.
  1. +27 −0 mod/assignment/lib.php
View
27 mod/assignment/lib.php
@@ -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);
+}
+
?>
Please sign in to comment.
Something went wrong with that request. Please try again.