Included assignment_get_participants() function.
Please check it before continue with other modules.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user