]> git.mjollnir.org Git - moodle.git/commitdiff
Included journal_get_participants() function.
authorstronk7 <stronk7>
Sun, 7 Sep 2003 21:36:03 +0000 (21:36 +0000)
committerstronk7 <stronk7>
Sun, 7 Sep 2003 21:36:03 +0000 (21:36 +0000)
mod/journal/lib.php

index d126a26f6d9dcb8b114b39a61a0245ac5959d729..a8451b4f18c42b0d89d5caabdf86446289ccfeeb 100644 (file)
@@ -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);
+}
+
 ?>