]> git.mjollnir.org Git - moodle.git/commitdiff
Simply, move the XXXX_get_participants() function from
authorstronk7 <stronk7>
Mon, 29 Sep 2003 15:27:30 +0000 (15:27 +0000)
committerstronk7 <stronk7>
Mon, 29 Sep 2003 15:27:30 +0000 (15:27 +0000)
bottom to the common function area.
See bug 807

mod/assignment/lib.php
mod/attendance/lib.php
mod/chat/lib.php
mod/choice/lib.php
mod/forum/lib.php
mod/glossary/lib.php
mod/journal/lib.php
mod/survey/lib.php
mod/workshop/lib.php

index 710acfb53cfc5631432f53846d333b2b83b15cc9..8dfacf800cd24afa5911d069855ee7a5bc0b8373 100644 (file)
@@ -262,6 +262,35 @@ function assignment_grades($assignmentid) {
     return $return;
 }
 
+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
+    if ($teachers) {
+        foreach ($teachers as $teacher) {
+            $students[$teacher->id] = $teacher;
+        }
+    }
+    //Return students array (it contains an array of unique users)
+    return ($students);
+}
+
 /// SQL STATEMENTS //////////////////////////////////////////////////////////////////
 
 function assignment_log_info($log) {
@@ -500,33 +529,4 @@ 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
-    if ($teachers) {
-        foreach ($teachers as $teacher) {
-            $students[$teacher->id] = $teacher;
-        }
-    }
-    //Return students array (it contains an array of unique users)
-    return ($students);
-}
-
 ?>
index 54ab5f3d160c0d4d0e70428051762cc9eeb24fc7..f26f42f2011243e582f8b07bbd4292450c3b2097 100755 (executable)
@@ -329,6 +329,34 @@ function attendance_grades($attendanceid) {
     return $return;
 }
 
+/**
+* Returns user records for all users who have DATA in a given attendance instance
+*
+* This function is present only for the backup routines.  It won't return meaningful data
+* for an attendance roll because it only returns records for users who have been counted as
+* tardy or absent in the rolls for a single attendance instance, since these are the only
+* records I store in the database - for brevity's sake of course.
+*
+* @param        int     $attendanceid   the id of the attendance record we're looging for student data from
+* @return       (object)recordset       associative array of records containing the student records we wanted
+*/
+function attendance_get_participants($attendanceid) {
+//Returns the users with data in one attendance
+//(users with records in attendance_roll, students)
+
+    global $CFG;
+
+    //Get students
+    $students = get_records_sql("SELECT DISTINCT u.*
+                                 FROM {$CFG->prefix}user u,
+                                      {$CFG->prefix}attendance_roll a
+                                 WHERE a.dayid = '$attendanceid' and
+                                       u.id = a.userid");
+
+    //Return students array (it contains an array of unique users)
+    return ($students);
+}
+
 
 //////////////////////////////////////////////////////////////////////////////////////
 /// Any other attendance functions go here.  Each of them must have a name that 
@@ -536,34 +564,6 @@ function get_attendance_for_week($id, $courseid) {
   return get_records_sql($sql);
 }
 
-/**
-* Returns user records for all users who have DATA in a given attendance instance
-* 
-* This function is present only for the backup routines.  It won't return meaningful data
-* for an attendance roll because it only returns records for users who have been counted as 
-* tardy or absent in the rolls for a single attendance instance, since these are the only 
-* records I store in the database - for brevity's sake of course.
-*
-* @param       int     $attendanceid   the id of the attendance record we're looging for student data from
-* @return      (object)recordset       associative array of records containing the student records we wanted 
-*/
-function attendance_get_participants($attendanceid) {
-//Returns the users with data in one attendance
-//(users with records in attendance_roll, students)
-
-    global $CFG;
-
-    //Get students
-    $students = get_records_sql("SELECT DISTINCT u.*
-                                 FROM {$CFG->prefix}user u,
-                                      {$CFG->prefix}attendance_roll a
-                                 WHERE a.dayid = '$attendanceid' and
-                                       u.id = a.userid");
-
-    //Return students array (it contains an array of unique users)
-    return ($students);
-}
-
 /**
 * Determines if two dates are on the same day
 * 
index 20919684a52523a8ba0cc93dfea83e53d346e3d5..6d26c5d6d06eb45fa4b337ef0a2fc4965b728d32 100644 (file)
@@ -161,7 +161,22 @@ function chat_cron () {
     return true;
 }
 
+function chat_get_participants($chatid) {
+//Returns the users with data in one chat
+//(users with records in chat_messages, students)
+
+    global $CFG;
+
+    //Get students
+    $students = get_records_sql("SELECT DISTINCT u.*
+                                 FROM {$CFG->prefix}user u,
+                                      {$CFG->prefix}chat_messages c
+                                 WHERE c.chatid = '$chatid' and
+                                       u.id = c.userid");
 
+    //Return students array (it contains an array of unique users)
+    return ($students);
+}
 
 //////////////////////////////////////////////////////////////////////
 /// Functions that require some SQL
@@ -545,21 +560,4 @@ function chat_format_message($message, $courseid=0) {
 
 }
 
-function chat_get_participants($chatid) {
-//Returns the users with data in one chat
-//(users with records in chat_messages, students)
-
-    global $CFG;
-
-    //Get students
-    $students = get_records_sql("SELECT DISTINCT u.*
-                                 FROM {$CFG->prefix}user u,
-                                      {$CFG->prefix}chat_messages c
-                                 WHERE c.chatid = '$chatid' and
-                                       u.id = c.userid");
-
-    //Return students array (it contains an array of unique users)
-    return ($students);
-}
-
 ?>
index 25ba513acd0d15ff8034edcee12217c1b7a7e672..2ca987dd636286afb32d1a237a1c69a9cb12c9bf 100644 (file)
@@ -82,6 +82,23 @@ function choice_delete_instance($id) {
     return $result;
 }
 
+function choice_get_participants($choiceid) {
+//Returns the users with data in one choice
+//(users with records in choice_answers, students)
+
+    global $CFG;
+
+    //Get students
+    $students = get_records_sql("SELECT DISTINCT u.*
+                                 FROM {$CFG->prefix}user u,
+                                      {$CFG->prefix}choice_answers c
+                                 WHERE c.choice = '$choiceid' and
+                                       u.id = c.userid");
+
+    //Return students array (it contains an array of unique users)
+    return ($students);
+}
+
 
 function choice_get_answer($choice, $code) {
 // Returns text string which is the answer that matches the code
@@ -119,21 +136,4 @@ function choice_get_choice($choiceid) {
     }
 }
 
-function choice_get_participants($choiceid) {
-//Returns the users with data in one choice
-//(users with records in choice_answers, students)
-
-    global $CFG;
-
-    //Get students
-    $students = get_records_sql("SELECT DISTINCT u.*
-                                 FROM {$CFG->prefix}user u,
-                                      {$CFG->prefix}choice_answers c
-                                 WHERE c.choice = '$choiceid' and
-                                       u.id = c.userid");
-
-    //Return students array (it contains an array of unique users)
-    return ($students);
-}
-
 ?>
index 5d706689c6940c826fd095332156a8b43d8b5eaf..b5053c66107f7a181209e7d0cead1a1f331a7378 100644 (file)
@@ -504,6 +504,53 @@ function forum_grades($forumid) {
     return $return;
 }
 
+function forum_get_participants($forumid) {
+//Returns the users with data in one forum
+//(users with records in forum_subscriptions, forum_posts and forum_ratings, students)     
+
+    global $CFG;
+
+    //Get students from forum_subscriptions
+    $st_subscriptions = get_records_sql("SELECT DISTINCT u.*
+                                         FROM {$CFG->prefix}user u,
+                                              {$CFG->prefix}forum_subscriptions s
+                                         WHERE s.forum = '$forumid' and
+                                               u.id = s.userid");    
+    //Get students from forum_posts
+    $st_posts = get_records_sql("SELECT DISTINCT u.*
+                                 FROM {$CFG->prefix}user u,
+                                      {$CFG->prefix}forum_discussions d,
+                                      {$CFG->prefix}forum_posts p
+                                 WHERE d.forum = '$forumid' and
+                                       p.discussion = d.id and
+                                       u.id = p.userid");
+
+    //Get students from forum_ratings
+    $st_ratings = get_records_sql("SELECT DISTINCT u.*
+                                   FROM {$CFG->prefix}user u,
+                                        {$CFG->prefix}forum_discussions d,
+                                        {$CFG->prefix}forum_posts p,
+                                        {$CFG->prefix}forum_ratings r
+                                   WHERE d.forum = '$forumid' and
+                                         p.discussion = d.id and
+                                         r.post = p.id and
+                                         u.id = r.userid");
+
+    //Add st_posts to st_subscriptions
+    if ($st_posts) {
+        foreach ($st_posts as $st_post) {
+            $st_subscriptions[$st_post->id] = $st_post;
+        }
+    }
+    //Add st_ratings to st_subscriptions
+    if ($st_ratings) {
+        foreach ($st_ratings as $st_rating) {
+            $st_subscriptions[$st_rating->id] = $st_rating;
+        }
+    }
+    //Return st_subscriptions array (it contains an array of unique users)
+    return ($st_subscriptions);
+}
 
 /// SQL FUNCTIONS ///////////////////////////////////////////////////////////
 
@@ -2132,52 +2179,4 @@ function forum_set_display_mode($mode=0) {
     }
 }
 
-function forum_get_participants($forumid) {
-//Returns the users with data in one forum
-//(users with records in forum_subscriptions, forum_posts and forum_ratings, students)
-
-    global $CFG;
-
-    //Get students from forum_subscriptions
-    $st_subscriptions = get_records_sql("SELECT DISTINCT u.*
-                                         FROM {$CFG->prefix}user u,
-                                              {$CFG->prefix}forum_subscriptions s
-                                         WHERE s.forum = '$forumid' and
-                                               u.id = s.userid");
-    //Get students from forum_posts
-    $st_posts = get_records_sql("SELECT DISTINCT u.*
-                                 FROM {$CFG->prefix}user u,
-                                      {$CFG->prefix}forum_discussions d,
-                                      {$CFG->prefix}forum_posts p
-                                 WHERE d.forum = '$forumid' and
-                                       p.discussion = d.id and
-                                       u.id = p.userid");
-
-    //Get students from forum_ratings
-    $st_ratings = get_records_sql("SELECT DISTINCT u.*
-                                   FROM {$CFG->prefix}user u,
-                                        {$CFG->prefix}forum_discussions d,    
-                                        {$CFG->prefix}forum_posts p,
-                                        {$CFG->prefix}forum_ratings r
-                                   WHERE d.forum = '$forumid' and          
-                                         p.discussion = d.id and
-                                         r.post = p.id and
-                                         u.id = r.userid");
-
-    //Add st_posts to st_subscriptions
-    if ($st_posts) {
-        foreach ($st_posts as $st_post) {
-            $st_subscriptions[$st_post->id] = $st_post;
-        }
-    }
-    //Add st_ratings to st_subscriptions
-    if ($st_ratings) {
-        foreach ($st_ratings as $st_rating) { 
-            $st_subscriptions[$st_rating->id] = $st_rating;
-        }
-    }
-    //Return st_subscriptions array (it contains an array of unique users)
-    return ($st_subscriptions);
-}
-
 ?>
index 9b00916df945ba5ad2806ade247b7f3ca651c149..5a90ecf948a6e5ff2076eab6a68a386f3cfce728 100644 (file)
@@ -145,6 +145,22 @@ function glossary_grades($glossaryid) {
     return $return;
 }
 
+function glossary_get_participants($glossaryid) {
+//Returns the users with data in one glossary
+//(users with records in glossary_entries, students)
+
+    global $CFG;
+
+    //Get students
+    $students = get_records_sql("SELECT DISTINCT u.*
+                                 FROM {$CFG->prefix}user u,
+                                      {$CFG->prefix}glossary_entries g
+                                 WHERE g.glossaryid = '$glossaryid' and
+                                       u.id = g.userid");
+
+    //Return students array (it contains an array of unique users)
+    return ($students);
+}
 
 //////////////////////////////////////////////////////////////////////////////////////
 /// Any other glossary functions go here.  Each of them must have a name that
@@ -327,24 +343,6 @@ function glossary_search_entries($searchterms, $glossary, $includedefinition) {
                             $selectsql ORDER BY e.concept ASC $limit");
 }
 
-function glossary_get_participants($glossaryid) {
-//Returns the users with data in one glossary
-//(users with records in glossary_entries, students)
-
-    global $CFG;
-
-    //Get students
-    $students = get_records_sql("SELECT DISTINCT u.*
-                                 FROM {$CFG->prefix}user u,
-                                      {$CFG->prefix}glossary_entries g
-                                 WHERE g.glossaryid = '$glossaryid' and
-                                       u.id = g.userid");
-
-    //Return students array (it contains an array of unique users)
-    return ($students);
-}
-
-
 function glossary_file_area_name($entry) {
 //  Creates a directory file name, suitable for make_upload_directory()
     global $CFG;
index a8451b4f18c42b0d89d5caabdf86446289ccfeeb..65a7809b5b7118e3bbea2057d69c552d953936f9 100644 (file)
@@ -253,6 +253,34 @@ function journal_grades($journalid) {
     return $return;
 }
 
+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);
+}
 
 // SQL FUNCTIONS ///////////////////////////////////////////////////////////////////
 
@@ -428,33 +456,4 @@ 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);
-}
-
 ?>
index 40e6d6e5a9a2eccd345548e9de51b1b42196755f..650f549cfa9687848e9bb88caaa60dad61b3b955 100644 (file)
@@ -144,6 +144,34 @@ function survey_print_recent_activity($course, $isteacher, $timestart) {
     return $content;
 }
 
+function survey_get_participants($surveyid) {
+//Returns the users with data in one survey
+//(users with records in survey_analysis and survey_answers, students)
+
+    global $CFG;
+
+    //Get students from survey_analysis
+    $st_analysis = get_records_sql("SELECT DISTINCT u.*
+                                    FROM {$CFG->prefix}user u,
+                                         {$CFG->prefix}survey_analysis a
+                                    WHERE a.survey = '$surveyid' and
+                                          u.id = a.userid");
+    //Get students from survey_answers
+    $st_answers = get_records_sql("SELECT DISTINCT u.*
+                                   FROM {$CFG->prefix}user u,
+                                        {$CFG->prefix}survey_answers a
+                                   WHERE a.survey = '$surveyid' and
+                                         u.id = a.userid");
+
+    //Add st_answers to st_analysis
+    if ($st_answers) {
+        foreach ($st_answers as $st_answer) {
+            $st_analysis[$st_answer->id] = $st_answer;
+        }
+    }
+    //Return st_analysis array (it contains an array of unique users)
+    return ($st_analysis);
+}
 
 // SQL FUNCTIONS ////////////////////////////////////////////////////////
 
@@ -410,33 +438,4 @@ function survey_print_graph($url) {
     }
 }
 
-function survey_get_participants($surveyid) {
-//Returns the users with data in one survey
-//(users with records in survey_analysis and survey_answers, students)
-
-    global $CFG;
-
-    //Get students from survey_analysis
-    $st_analysis = get_records_sql("SELECT DISTINCT u.*    
-                                    FROM {$CFG->prefix}user u,
-                                         {$CFG->prefix}survey_analysis a
-                                    WHERE a.survey = '$surveyid' and
-                                          u.id = a.userid");
-    //Get students from survey_answers
-    $st_answers = get_records_sql("SELECT DISTINCT u.*    
-                                   FROM {$CFG->prefix}user u,
-                                        {$CFG->prefix}survey_answers a
-                                   WHERE a.survey = '$surveyid' and
-                                         u.id = a.userid");
-
-    //Add st_answers to st_analysis
-    if ($st_answers) {
-        foreach ($st_answers as $st_answer) {
-            $st_analysis[$st_answer->id] = $st_answer;
-        }
-    }
-    //Return st_analysis array (it contains an array of unique users)
-    return ($st_analysis);
-}
-
 ?>
index 71d3e98a8a2fbfa4032008314f0ddc53f46e9404..7f8783589649326654ba1625bb20d49c9b96901d 100644 (file)
@@ -702,6 +702,48 @@ function workshop_user_outline($course, $user, $mod, $workshop) {
     return NULL;
 }
 
+//////////////////////////////////////////////////////////////////////////////////////
+function workshop_get_participants($workshopid) {      
+//Returns the users with data in one workshop
+//(users with records in workshop_submissions, workshop_assessments and workshop_comments, students)
+
+    global $CFG;
+
+    //Get students from workshop_submissions
+    $st_submissions = get_records_sql("SELECT DISTINCT u.*
+                                       FROM {$CFG->prefix}user u,
+                                            {$CFG->prefix}workshop_submissions s
+                                       WHERE s.workshopid = '$workshopid' and
+                                             u.id = s.userid");
+    //Get students from workshop_assessments
+    $st_assessments = get_records_sql("SELECT DISTINCT u.*
+                                 FROM {$CFG->prefix}user u,
+                                      {$CFG->prefix}workshop_assessments a
+                                 WHERE a.workshopid = '$workshopid' and
+                                       u.id = a.userid");
+
+    //Get students from workshop_comments
+    $st_comments = get_records_sql("SELECT DISTINCT u.*
+                                   FROM {$CFG->prefix}user u,
+                                        {$CFG->prefix}workshop_comments c
+                                   WHERE c.workshopid = '$workshopid' and
+                                         u.id = c.userid");
+
+    //Add st_assessments to st_submissions
+    if ($st_assessments) {
+        foreach ($st_assessments as $st_assessment) {
+            $st_submissions[$st_assessment->id] = $st_assessment;
+        }
+    }
+    //Add st_comments to st_submissions
+    if ($st_comments) {
+        foreach ($st_comments as $st_comment) {
+            $st_submissions[$st_comment->id] = $st_comment;
+        }
+    }
+    //Return st_submissions array (it contains an array of unique users)
+    return ($st_submissions);
+}
 
 //////////////////////////////////////////////////////////////////////////////////////
 
@@ -1244,51 +1286,6 @@ function workshop_get_grade_logs($course, $timestart) {
                                                                AND u.id = s.userid AND e.id = a.workshopid");
 }
 
-
-//////////////////////////////////////////////////////////////////////////////////////
-function workshop_get_participants($workshopid) {
-//Returns the users with data in one workshop
-//(users with records in workshop_submissions, workshop_assessments and workshop_comments, students)
-
-    global $CFG;
-
-    //Get students from workshop_submissions
-    $st_submissions = get_records_sql("SELECT DISTINCT u.*    
-                                       FROM {$CFG->prefix}user u,
-                                            {$CFG->prefix}workshop_submissions s
-                                       WHERE s.workshopid = '$workshopid' and
-                                             u.id = s.userid");
-    //Get students from workshop_assessments
-    $st_assessments = get_records_sql("SELECT DISTINCT u.*
-                                 FROM {$CFG->prefix}user u,
-                                      {$CFG->prefix}workshop_assessments a
-                                 WHERE a.workshopid = '$workshopid' and
-                                       u.id = a.userid");
-
-    //Get students from workshop_comments
-    $st_comments = get_records_sql("SELECT DISTINCT u.*
-                                   FROM {$CFG->prefix}user u,
-                                        {$CFG->prefix}workshop_comments c
-                                   WHERE c.workshopid = '$workshopid' and
-                                         u.id = c.userid");
-
-    //Add st_assessments to st_submissions
-    if ($st_assessments) {
-        foreach ($st_assessments as $st_assessment) {
-            $st_submissions[$st_assessment->id] = $st_assessment;
-        }
-    }
-    //Add st_comments to st_submissions
-    if ($st_comments) {
-        foreach ($st_comments as $st_comment) {
-            $st_submissions[$st_comment->id] = $st_comment;
-        }
-    }
-    //Return st_submissions array (it contains an array of unique users)
-    return ($st_submissions);
-}
-
-
 //////////////////////////////////////////////////////////////////////////////////////
 function workshop_get_student_assessments($workshop, $user) {
 // Return all assessments on the student submissions by a user, order by youngest first, oldest last