Skip to content

Commit

Permalink
NOMDL workshop_get_participants() though it does not seem to be used …
Browse files Browse the repository at this point in the history
…by core any more
  • Loading branch information
mudrd8mz committed Jul 26, 2010
1 parent 26f073f commit 34860fc
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions mod/workshop/lib.php
Expand Up @@ -244,16 +244,44 @@ function workshop_cron () {
}

/**
* Must return an array of user records (all data) who are participants
* for a given instance of workshop. Must include every user involved
* in the instance, independient of his role (student, teacher, admin...)
* See other modules as example.
* Returns an array of user ids who are participanting in this workshop
*
* Participants are either submission authors or reviewers or both.
* Authors of the example submissions and their referential assessments
* are not returned as the example submission is considered non-user
* data for the purpose of workshop backup.
*
* @param int $workshopid ID of an instance of this module
* @return mixed boolean/array of students
* @return array of user ids, empty if there are no participants
*/
function workshop_get_participants($workshopid) {
return false;
global $DB;

$sql = "SELECT u.id
FROM {workshop} w
JOIN {workshop_submissions} s ON s.workshopid = w.id
JOIN {user} u ON s.authorid = u.id
WHERE w.id = ? AND s.example = 0
UNION
SELECT u.id
FROM {workshop} w
JOIN {workshop_submissions} s ON s.workshopid = w.id
JOIN {workshop_assessments} a ON a.submissionid = s.id
JOIN {user} u ON a.reviewerid = u.id
WHERE w.id = ? AND (s.example = 0 OR a.weight = 0)";

$users = array();
$rs = $DB->get_recordset_sql($sql, array($workshopid, $workshopid));
foreach ($rs as $user) {
if (empty($users[$user->id])) {
$users[$user->id] = $user;
}
}
$rs->close();

return $users;
}

/**
Expand Down

0 comments on commit 34860fc

Please sign in to comment.