Skip to content
Browse files

Included journal_get_participants() function.

  • Loading branch information...
1 parent eaa3298 commit 058a2215efcadc3a6640a1a5fb7d7ae7587ff065 stronk7 committed
Showing with 29 additions and 0 deletions.
  1. +29 −0 mod/journal/lib.php
View
29 mod/journal/lib.php
@@ -428,4 +428,33 @@ function journal_print_feedback($course, $entry, $grades) {
echo "</TD></TR></TABLE>";
}
+function journal_get_participants($journalid) {
+//Returns the users with data in one journal
+//(users with records in journal_entries, students and teachers)
+
+ global $CFG;
+
+ //Get students
+ $students = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}journal_entries j
+ WHERE j.journal = '$journalid' and
+ u.id = j.userid");
+ //Get teachers
+ $teachers = get_records_sql("SELECT DISTINCT u.*
+ FROM {$CFG->prefix}user u,
+ {$CFG->prefix}journal_entries j
+ WHERE j.journal = '$journalid' and
+ u.id = j.teacher");
+
+ //Add teachers to students
+ if ($teachers) {
+ foreach ($teachers as $teacher) {
+ $students[$teacher->id] = $teacher;
+ }
+ }
+ //Return students array (it contains an array of unique users)
+ return ($students);
+}
+
?>

0 comments on commit 058a221

Please sign in to comment.
Something went wrong with that request. Please try again.