]> git.mjollnir.org Git - moodle.git/commitdiff
Included survey_get_participants() function.
authorstronk7 <stronk7>
Sun, 7 Sep 2003 22:09:23 +0000 (22:09 +0000)
committerstronk7 <stronk7>
Sun, 7 Sep 2003 22:09:23 +0000 (22:09 +0000)
mod/survey/lib.php

index 119c7e4efa2b522fde9f3ee9214da7693ed3f9d4..40e6d6e5a9a2eccd345548e9de51b1b42196755f 100644 (file)
@@ -410,4 +410,33 @@ 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);
+}
+
 ?>