Included assignment_get_participants() function.

Please check it before continue with other modules.
This commit is contained in:
stronk7
2003-09-03 22:10:51 +00:00
parent cb29b02006
commit 2bae0d446c
+27
View 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);
}
?>