]> git.mjollnir.org Git - moodle.git/commitdiff
Groups support on Surveys. Phew.
authormoodler <moodler>
Fri, 20 Feb 2004 16:03:05 +0000 (16:03 +0000)
committermoodler <moodler>
Fri, 20 Feb 2004 16:03:05 +0000 (16:03 +0000)
12 files changed:
mod/survey/db/mysql.php
mod/survey/db/mysql.sql
mod/survey/db/postgres7.php
mod/survey/db/postgres7.sql
mod/survey/details.php
mod/survey/download.php
mod/survey/graph.php
mod/survey/lib.php
mod/survey/report.php
mod/survey/save.php
mod/survey/version.php
mod/survey/view.php

index 70fa9eca5ad434e233ffbbdb131cd878664b041a..6ed3c66515eef9b56f1490c14e39e9e2e0d01718 100644 (file)
@@ -172,6 +172,11 @@ function survey_upgrade($oldversion) {
         table_column("survey_answers", "answer2", "answer2", "text", "", "", "");
     }
 
+    if ($oldversion < 2004021900) {
+        modify_database("", "INSERT INTO prefix_log_display VALUES ('survey', 'add', 'survey', 'name');");
+        modify_database("", "INSERT INTO prefix_log_display VALUES ('survey', 'update', 'survey', 'name');");
+    }
+
     return true;
 }
 
index 257c9b2e8af01ed6fa4ce3f754ecb4ed400db7ba..16f73eb24c1a1177f50539626b8f7eaa2ba86399 100755 (executable)
@@ -178,6 +178,8 @@ INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intr
 # Dumping data for table `log_display`\r
 #\r
 \r
+INSERT INTO prefix_log_display VALUES ('survey', 'add', 'survey', 'name');\r
+INSERT INTO prefix_log_display VALUES ('survey', 'update', 'survey', 'name');\r
 INSERT INTO prefix_log_display VALUES ('survey', 'download', 'survey', 'name');\r
 INSERT INTO prefix_log_display VALUES ('survey', 'view form', 'survey', 'name');\r
 INSERT INTO prefix_log_display VALUES ('survey', 'view graph', 'survey', 'name');\r
index 94c1764224494476ff296abecde32ee52214697a..3748daa273a4d8e9017840f4638dfac8a3c0bf1a 100644 (file)
@@ -19,6 +19,10 @@ function survey_upgrade($oldversion) {
         table_column("survey_answers", "answer1", "answer1", "text", "", "", "");
         table_column("survey_answers", "answer2", "answer2", "text", "", "", "");
     }
+    if ($oldversion < 2004021900) {
+        modify_database("", "INSERT INTO prefix_log_display VALUES ('survey', 'add', 'survey', 'name');");
+        modify_database("", "INSERT INTO prefix_log_display VALUES ('survey', 'update', 'survey', 'name');");
+    }
 
     return true;
 }
index 7af7bc5cb7411236b516f245d8a8dce3c7db6a8e..e86549ce8d32c91ae374d7f5882b9cef0a5c29b6 100755 (executable)
@@ -172,6 +172,8 @@ INSERT INTO prefix_survey_questions (id, text, shorttext, multi, intro, type, op
 # Dumping data for table log_display
 #
 
+INSERT INTO prefix_log_display VALUES ('survey', 'add', 'survey', 'name');
+INSERT INTO prefix_log_display VALUES ('survey', 'update', 'survey', 'name');
 INSERT INTO prefix_log_display VALUES ('survey', 'download', 'survey', 'name');
 INSERT INTO prefix_log_display VALUES ('survey', 'view form', 'survey', 'name');
 INSERT INTO prefix_log_display VALUES ('survey', 'view graph', 'survey', 'name');
index 1ac72bffd0315ec773022e57d5aa23137c36a3d9..5ca79fedbece8f8550ad5a6001552ecd0941a1f7 100644 (file)
         }
 
         $streditingasurvey = get_string("editingasurvey", "survey");
+        $strsurveys = get_string("modulenameplural", "survey");
 
         print_header("$course->shortname: $streditingasurvey", "$course->fullname",
-                      "<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> 
-                       -> $streditingasurvey");
+                      "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>".
+                      " -> <a href=\"index.php?id=$course->id\">$strsurveys</a>".
+                      " -> $form->name ($streditingasurvey)");
 
         if (!$form->name or !$form->template) {
             error(get_string("filloutallfields"), $_SERVER["HTTP_REFERER"]);
index 4c4d7c2e436e71921238cefaf57643f7b3b1c4be..854c49a8e76ecd0f1b68cbefa50dd044ec079405 100644 (file)
@@ -6,6 +6,7 @@
 
     require_variable($id);    // Course Module ID
     optional_variable($type, "xls");
+    optional_variable($group, 0);
 
     if (! $cm = get_record("course_modules", "id", $id)) {
         error("Course Module ID was incorrect");
         error("Survey ID was incorrect");
     }
 
-    add_to_log($course->id, "survey", "download", "download.php?id=$cm->id&type=$type", "$survey->id");
+    add_to_log($course->id, "survey", "download", "download.php?id=$cm->id&type=$type", "$survey->id", $cm->id);
 
+/// Check to see if groups are being used in this survey
+
+    $groupmode = groupmode($course, $cm);   // Groups are being used
+
+    if ($groupmode and $group) {
+        $users = get_users_in_group($group);
+    } else {
+        $users = get_course_users($course->id);
+        $group = false;
+    }
 
 // Get all the questions and their proper order
 
     }
    
     foreach ($aaa as $a) {
-        if (!$results["$a->userid"]) { // init new array
-            $results["$a->userid"]["time"] = $a->time;
-            foreach ($order as $key => $qid) {
-                $results["$a->userid"]["$qid"]["answer1"] = "";
-                $results["$a->userid"]["$qid"]["answer2"] = "";
+        if (!$group or isset($users[$a->userid])) {
+            if (!$results["$a->userid"]) { // init new array
+                $results["$a->userid"]["time"] = $a->time;
+                foreach ($order as $key => $qid) {
+                    $results["$a->userid"]["$qid"]["answer1"] = "";
+                    $results["$a->userid"]["$qid"]["answer2"] = "";
+                }
             }
+            $results["$a->userid"]["$a->question"]["answer1"] = $a->answer1;
+            $results["$a->userid"]["$a->question"]["answer2"] = $a->answer2;
         }
-        $results["$a->userid"]["$a->question"]["answer1"] = $a->answer1;
-        $results["$a->userid"]["$a->question"]["answer2"] = $a->answer2;
     }
 
 // Output the file as a valid Excel spreadsheet if required
index fed1e359a37424b517ad86830f6c7fe9d7ef848b..9bbd5b214c5076839565e826a4d548a628d24cb9 100644 (file)
@@ -6,6 +6,7 @@
 
     require_variable($id);    // Course Module ID
     require_variable($type);  // Graph Type
+    optional_variable($group, "0");  // Group ID
     optional_variable($sid);  // Student ID
 
     if (! $cm = get_record("course_modules", "id", $id)) {
 
     require_login($course->id);
 
-    if (!isteacher($course->id) && !isadmin()) {
-        if (! ($type == "student.png" && $sid == $USER->id) ) {
+    $groupmode = groupmode($course, $cm);   // Groups are being used
+
+    if (!isteacher($course->id)) {
+        if ($type != "student.png" or $sid != $USER->id ) {
+            error("Sorry, you aren't allowed to see this.");
+        } else if ($groupmode and !ismember($group)) {
             error("Sorry, you aren't allowed to see this.");
         }
     }
         error("Survey ID was incorrect");
     }
 
+/// Check to see if groups are being used in this survey
+    if ($groupmode and $group) {
+        $users = get_users_in_group($group);
+    } else {
+        $users = get_course_users($course->id);
+        $group = false;
+    }
+
     $stractual = get_string("actual", "survey");
     $stractualclass = get_string("actualclass", "survey");
     $stractualstudent = get_string("actualstudent", "survey", $course->student);
 
        if ($aaa = get_records_select("survey_answers", "survey = '$cm->instance' AND question = '$qid'")) {
            foreach ($aaa as $aa) {
-               if ($a1 = $aa->answer1) {
-                   $buckets1[$a1 - 1]++;
-               }
-               if ($a2 = $aa->answer2) {
-                   $buckets2[$a2 - 1]++;
+               if (!$group or isset($users[$aa->userid])) {
+                   if ($a1 = $aa->answer1) {
+                       $buckets1[$a1 - 1]++;
+                   }
+                   if ($a2 = $aa->answer2) {
+                       $buckets2[$a2 - 1]++;
+                   }
                }
            }
        }
 
        if ($aaa) {
            foreach ($aaa as $a) {
-               $index = $indexof[$a->question];
-               if ($a->answer1) {
-                   $buckets1[$index] += $a->answer1;
-                   $count1[$index]++;
-               }
-               if ($a->answer2) {
-                   $buckets2[$index] += $a->answer2;
-                   $count2[$index]++;
+               if (!$group or isset($users[$a->userid])) {
+                   $index = $indexof[$a->question];
+                   if ($a->answer1) {
+                       $buckets1[$index] += $a->answer1;
+                       $count1[$index]++;
+                   }
+                   if ($a->answer2) {
+                       $buckets2[$index] += $a->answer2;
+                       $count2[$index]++;
+                   }
                }
            }
        }
 
        if ($aaa) {
            foreach ($aaa as $a) {
-               $index = $indexof[$a->question];
-               if ($a->answer1) {
-                   $difference = (float) ($a->answer1 - $buckets1[$index]);
-                   $stdev1[$index] += ($difference * $difference);
-               }
-               if ($a->answer2) {
-                   $difference = (float) ($a->answer2 - $buckets2[$index]);
-                   $stdev2[$index] += ($difference * $difference);
+               if (!$group or isset($users[$a->userid])) {
+                   $index = $indexof[$a->question];
+                   if ($a->answer1) {
+                       $difference = (float) ($a->answer1 - $buckets1[$index]);
+                       $stdev1[$index] += ($difference * $difference);
+                   }
+                   if ($a->answer2) {
+                       $difference = (float) ($a->answer2 - $buckets2[$index]);
+                       $stdev2[$index] += ($difference * $difference);
+                   }
                }
            }
        }
 
            if ($aaa) {
                foreach ($aaa as $a) {
-                   if ($a->answer1) {
-                       $buckets1[$i] += $a->answer1;
-                       $count1[$i]++;
-                   }
-                   if ($a->answer2) {
-                       $buckets2[$i] += $a->answer2;
-                       $count2[$i]++;
+                   if (!$group or isset($users[$a->userid])) {
+                       if ($a->answer1) {
+                           $buckets1[$i] += $a->answer1;
+                           $count1[$i]++;
+                       }
+                       if ($a->answer2) {
+                           $buckets2[$i] += $a->answer2;
+                           $count2[$i]++;
+                       }
                    }
                }
            }
            // Calculate the standard devaiations
            if ($aaa) {
                foreach ($aaa as $a) {
-                   if ($a->answer1) {
-                       $difference = (float) ($a->answer1 - $buckets1[$i]);
-                       $stdev1[$i] += ($difference * $difference);
-                   }
-                   if ($a->answer2) {
-                       $difference = (float) ($a->answer2 - $buckets2[$i]);
-                       $stdev2[$i] += ($difference * $difference);
+                   if (!$group or isset($users[$a->userid])) {
+                       if ($a->answer1) {
+                           $difference = (float) ($a->answer1 - $buckets1[$i]);
+                           $stdev1[$i] += ($difference * $difference);
+                       }
+                       if ($a->answer2) {
+                           $difference = (float) ($a->answer2 - $buckets2[$i]);
+                           $stdev2[$i] += ($difference * $difference);
+                       }
                    }
                }
            }
 
            if ($aaa) {
                foreach ($aaa as $a) {
-                   if ($a->userid == $sid) {
+                   if (!$group or isset($users[$a->userid])) {
+                       if ($a->userid == $sid) {
+                           if ($a->answer1) {
+                               $studbuckets1[$i] += $a->answer1;
+                               $studcount1[$i]++;
+                           }
+                           if ($a->answer2) {
+                               $studbuckets2[$i] += $a->answer2;
+                               $studcount2[$i]++;
+                           }
+                       }
                        if ($a->answer1) {
-                           $studbuckets1[$i] += $a->answer1;
-                           $studcount1[$i]++;
+                           $buckets1[$i] += $a->answer1;
+                           $count1[$i]++;
                        }
                        if ($a->answer2) {
-                           $studbuckets2[$i] += $a->answer2;
-                           $studcount2[$i]++;
+                           $buckets2[$i] += $a->answer2;
+                           $count2[$i]++;
                        }
                    }
-                   if ($a->answer1) {
-                       $buckets1[$i] += $a->answer1;
-                       $count1[$i]++;
-                   }
-                   if ($a->answer2) {
-                       $buckets2[$i] += $a->answer2;
-                       $count2[$i]++;
-                   }
                }
            }
 
 
            // Calculate the standard devaiations
            foreach ($aaa as $a) {
-               if ($a->answer1) {
-                   $difference = (float) ($a->answer1 - $buckets1[$i]);
-                   $stdev1[$i] += ($difference * $difference);
-               }
-               if ($a->answer2) {
-                   $difference = (float) ($a->answer2 - $buckets2[$i]);
-                   $stdev2[$i] += ($difference * $difference);
+               if (!$group or isset($users[$a->userid])) {
+                   if ($a->answer1) {
+                       $difference = (float) ($a->answer1 - $buckets1[$i]);
+                       $stdev1[$i] += ($difference * $difference);
+                   }
+                   if ($a->answer2) {
+                       $difference = (float) ($a->answer2 - $buckets2[$i]);
+                       $stdev2[$i] += ($difference * $difference);
+                   }
                }
            }
 
 
        if ($aaa) {
            foreach ($aaa as $a) {
-               $index = $indexof[$a->question];
-                   if ($a->userid == $sid) {
-                       if ($a->answer1) {
-                           $studbuckets1[$index] += $a->answer1;
-                           $studcount1[$index]++;
-                       }
-                       if ($a->answer2) {
-                           $studbuckets2[$index] += $a->answer2;
-                           $studcount2[$index]++;
+               if (!$group or isset($users[$a->userid])) {
+                   $index = $indexof[$a->question];
+                       if ($a->userid == $sid) {
+                           if ($a->answer1) {
+                               $studbuckets1[$index] += $a->answer1;
+                               $studcount1[$index]++;
+                           }
+                           if ($a->answer2) {
+                               $studbuckets2[$index] += $a->answer2;
+                               $studcount2[$index]++;
+                           }
                        }
+                   if ($a->answer1) {
+                       $buckets1[$index] += $a->answer1;
+                       $count1[$index]++;
+                   }
+                   if ($a->answer2) {
+                       $buckets2[$index] += $a->answer2;
+                       $count2[$index]++;
                    }
-               if ($a->answer1) {
-                   $buckets1[$index] += $a->answer1;
-                   $count1[$index]++;
-               }
-               if ($a->answer2) {
-                   $buckets2[$index] += $a->answer2;
-                   $count2[$index]++;
                }
            }
        }
        }
 
        foreach ($aaa as $a) {
-           $index = $indexof[$a->question];
-           if ($a->answer1) {
-               $difference = (float) ($a->answer1 - $buckets1[$index]);
-               $stdev1[$index] += ($difference * $difference);
-           }
-           if ($a->answer2) {
-               $difference = (float) ($a->answer2 - $buckets2[$index]);
-               $stdev2[$index] += ($difference * $difference);
+           if (!$group or isset($users[$a->userid])) {
+               $index = $indexof[$a->question];
+               if ($a->answer1) {
+                   $difference = (float) ($a->answer1 - $buckets1[$index]);
+                   $stdev1[$index] += ($difference * $difference);
+               }
+               if ($a->answer2) {
+                   $difference = (float) ($a->answer2 - $buckets2[$index]);
+                   $stdev2[$index] += ($difference * $difference);
+               }
            }
        }
 
index 2844f7f59db6d8e09fd9816b5d73b91092236931..5f35efee798e94ff974ed35daa74e1d3dbf11a02 100644 (file)
@@ -185,15 +185,23 @@ function survey_log_info($log) {
                               AND u.id = '$log->userid'");
 }
 
-function survey_get_responses($survey) {
+function survey_get_responses($surveyid, $groupid) {
     global $CFG;
+
+    if ($groupid) {
+        $groupsql = "AND gm.groupid = $groupid AND u.id = gm.userid";
+    } else {
+        $groupsql = "";
+    }
+
     return get_records_sql("SELECT MAX(a.time) as time, 
                                    count(*) as numanswers, 
                                    u.id, u.firstname, u.lastname, u.picture
                               FROM {$CFG->prefix}survey_answers AS a, 
-                                   {$CFG->prefix}user AS u
-                             WHERE a.survey = $survey 
-                                   AND a.userid = u.id
+                                   {$CFG->prefix}user AS u,
+                                   {$CFG->prefix}groups_members AS gm
+                             WHERE a.survey = $surveyid 
+                                   AND a.userid = u.id $groupsql
                           GROUP BY u.id, u.firstname, u.lastname
                           ORDER BY time ASC");
 }
@@ -217,15 +225,22 @@ function survey_update_analysis($survey, $user, $notes) {
 }
 
 
-function survey_get_user_answers($surveyid, $questionid, $sort="sa.answer1,sa.answer2 ASC") {
+function survey_get_user_answers($surveyid, $questionid, $groupid, $sort="sa.answer1,sa.answer2 ASC") {
     global $CFG;
 
+    if ($groupid) {
+        $groupsql = "AND gm.groupid = $groupid AND u.id = gm.userid";
+    } else {
+        $groupsql = "";
+    }
+
     return get_records_sql("SELECT sa.*,u.firstname,u.lastname,u.picture 
                               FROM {$CFG->prefix}survey_answers sa, 
-                                   {$CFG->prefix}user u 
+                                   {$CFG->prefix}user u,
+                                   {$CFG->prefix}groups_members gm 
                              WHERE sa.survey = '$surveyid' 
                                AND sa.question = $questionid 
-                               AND u.id = sa.userid 
+                               AND u.id = sa.userid $groupsql
                           ORDER BY $sort");
 }
 
@@ -255,8 +270,8 @@ function survey_already_done($survey, $user) {
    return record_exists("survey_answers", "survey", $survey, "userid", $user);
 }
 
-function survey_count_responses($survey) {
-    if ($responses = survey_get_responses($survey)) {
+function survey_count_responses($surveyid, $groupid) {
+    if ($responses = survey_get_responses($surveyid, $groupid)) {
         return count($responses);
     } else {
         return 0;
@@ -439,8 +454,8 @@ function survey_print_graph($url) {
         echo "(".get_string("gdneed").")";
 
     } else {
-        echo "<IMG HEIGHT=\"$SURVEY_GHEIGHT\" WIDTH=\"$SURVEY_GWIDTH\" BORDER=1".
-             " SRC=\"$CFG->wwwroot/mod/survey/graph.php?$url\">";
+        echo "<img height=\"$survey_gheight\" width=\"$survey_gwidth\" border=\"1\"".
+             " src=\"$CFG->wwwroot/mod/survey/graph.php?$url\">";
     }
 }
 
index 035e16e9599434fe897134d16706d71bdfc5f0e3..4da44c863bc9697448bc63a3c7d9a8b482af0708 100644 (file)
@@ -5,8 +5,9 @@
 
 // Check that all the parameters have been provided.
  
-    require_variable($id);         // Course Module ID
-    optional_variable($action, "students");    // What to look at
+    require_variable($id);           // Course Module ID
+    optional_variable($action, "");  // What to look at
+    optional_variable($qid, "0");    // Question id
 
     if (! $cm = get_record("course_modules", "id", $id)) {
         error("Course Module ID was incorrect");
                  "", "", true,
                  update_module_button($cm->id, $course->id, $strsurvey), navmenu($course, $cm));
 
+/// Check to see if groups are being used in this survey
+    if ($groupmode = groupmode($course, $cm)) {   // Groups are being used
+        $currentgroup = setup_and_print_groups($course, $groupmode, 
+                                       "report.php?id=$cm->id&action=$action&qid=$qid");
+    } else {
+        $currentgroup = 0;
+    }
+
+    if ($currentgroup) {
+        $users = get_users_in_group($currentgroup);
+    } else {
+        $users = get_course_users($course->id);
+    }
+
     print_simple_box_start("center");
     if ($showscales) {
         echo "<a href=\"report.php?action=summary&id=$id\">$strsummary</a>";
         echo "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"report.php?action=questions&id=$id\">$strquestions</a>";
         echo "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"report.php?action=students&id=$id\">$course->students</a>";
         echo "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"report.php?action=download&id=$id\">$strdownload</a>";
+        if (empty($action)) {
+            $action = "summary";
+        }
     } else {
         echo "<a href=\"report.php?action=questions&id=$id\">$strquestions</a>";
         echo "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"report.php?action=students&id=$id\">$course->students</a>";
         echo "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"report.php?action=download&id=$id\">$strdownload</a>";
+        if (empty($action)) {
+            $action = "questions";
+        }
     }
     print_simple_box_end();
 
       case "summary":
         print_heading($strsummary);
 
-        if (survey_count_responses($survey->id)) {
+        if (survey_count_responses($survey->id, $currentgroup)) {
             echo "<p align=center><a href=\"report.php?action=scales&id=$id\">";
-            survey_print_graph("id=$id&type=overall.png");
+            survey_print_graph("id=$id&group=$currentgroup&type=overall.png");
             echo "</a>";
         } else {
             echo "<p align=center>".get_string("nobodyyet","survey")."</p>";
                     continue;
                 }
                 echo "<p align=center><a title=\"$strseemoredetail\" href=report.php?action=questions&id=$id&qid=$question->multi>";
-                survey_print_graph("id=$id&qid=$question->id&type=multiquestion.png");
+                survey_print_graph("id=$id&qid=$question->id&group=$currentgroup&type=multiquestion.png");
                 echo "</a></p><br>";
             } 
         }
                     if ($subquestion->type > 0) {
                         echo "<p align=center>";
                         echo "<a title=\"$strseemoredetail\" href=\"report.php?action=question&id=$id&qid=$subquestion->id\">";
-                        survey_print_graph("id=$id&qid=$subquestion->id&type=question.png");
+                        survey_print_graph("id=$id&qid=$subquestion->id&group=$currentgroup&type=question.png");
                         echo "</a></p>";
                     }
                 }
             } else if ($question->type > 0 ) {
                 echo "<p align=center>";
                 echo "<a title=\"$strseemoredetail\" href=\"report.php?action=question&id=$id&qid=$question->id\">";
-                survey_print_graph("id=$id&qid=$question->id&type=question.png");
+                survey_print_graph("id=$id&qid=$question->id&group=$currentgroup&type=question.png");
                 echo "</a></p>";
 
             } else {
 
                 $contents = '<table cellpadding="15" width="100%">';
 
-                if ($aaa = survey_get_user_answers($survey->id, $question->id, "sa.time ASC")) {
+                if ($aaa = survey_get_user_answers($survey->id, $question->id, $currentgroup, "sa.time ASC")) {
                     foreach ($aaa as $a) {
                         $contents .= "<tr>";
                         $contents .= '<td nowrap="nowrap" width="10%" valign="top">'.fullname($a).'</td>';
         $table->align = array ("left", "left", "left", "left", "right");
         $table->size = array (35, "", "", "", "");
 
-        if ($aaa = survey_get_user_answers($survey->id, $question->id)) {
+        if ($aaa = survey_get_user_answers($survey->id, $question->id, $currentgroup)) {
             foreach ($aaa as $a) {
                 if ($a->answer1) {
                     $answer1 =  "$a->answer1 - ".$answers[$a->answer1 - 1];
 
          print_heading(get_string("analysisof", "survey", "$course->students"));
         
-         if (! $results = survey_get_responses($survey->id) ) {
+         if (! $results = survey_get_responses($survey->id, $currentgroup) ) {
              notify(get_string("nobodyyet","survey"));
          } else {
              survey_print_all_responses($cm->id, $results, $course->id);
         echo '<center>';
         $options["id"] = "$cm->id";
         $options["type"] = "xls";
+        $options["group"] = $currentgroup;
         print_single_button("download.php", $options, get_string("downloadexcel", "survey"));
 
         $options["type"] = "txt";
index 8f696016d20ff2520d59503323d7cd81737d0355..6098088711a8e5ce1645ccee4d12f2a27ea2b96f 100644 (file)
@@ -90,8 +90,8 @@
     $strsurveysaved = get_string("surveysaved", "survey");
 
        print_header("$course->shortname: $strsurveysaved", "$course->fullname", 
-        "<A HREF=/course/view.php?id=$course->id>$course->shortname</A> ->
-         <A HREF=index.php?id=$course->id>$strsurveys</A> -> $survey->name -> $strsurveysaved", "");
+        "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
+         <a href=\"index.php?id=$course->id\">$strsurveys</a> -> $survey->name -> $strsurveysaved", "");
 
 
     notice(get_string("thanksforanswers","survey", $USER->firstname), "$CFG->wwwroot/course/view.php?id=$course->id");
index daa60c1cf16f0daf1c0c1704e7d703f6f7d119bd..9bea0284091d64128777ab6e08ac3a11175aa67e 100644 (file)
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2004021602;
+$module->version  = 2004021900;
 $module->requires = 2004013101;  // Requires this Moodle version
 $module->cron     = 0;
 
index b782bbc5b7bb7d13baa23a22104e75315a1a6228..a734920ea8c8ba03f7176dcdef22a6b371871307 100644 (file)
                  "$navigation <A HREF=index.php?id=$course->id>$strsurveys</A> -> $survey->name", "", "", true,
                   update_module_button($cm->id, $course->id, $strsurvey), navmenu($course, $cm));
 
+/// Check to see if groups are being used in this survey
+    if ($groupmode = groupmode($course, $cm)) {   // Groups are being used
+        $currentgroup = get_current_group($course->id);
+    } else {
+        $currentgroup = 0;
+    }
+
+    if (isteacheredit($course->id) or ($groupmode == VISIBLEGROUPS)) {
+        $currentgroup = 0;
+    }
+
     if (isteacher($course->id)) {
-        $numusers = survey_count_responses($survey->id);
+        $numusers = survey_count_responses($survey->id, $currentgroup);
         echo "<p align=right><a href=\"report.php?id=$cm->id\">".
               get_string("viewsurveyresponses", "survey", $numusers)."</A></P>";
     } else if (!$cm->visible) {
     if (survey_already_done($survey->id, $USER->id)) {
 
         add_to_log($course->id, "survey", "view graph", "view.php?id=$cm->id", $survey->id, $cm->id);
-        $numusers = survey_count_responses($survey->id);
+        $numusers = survey_count_responses($survey->id, $currentgroup);
 
         if ($showscales) {
             print_heading(get_string("surveycompleted", "survey"));
             print_heading(get_string("peoplecompleted", "survey", $numusers));
             echo "<center>";
-            survey_print_graph("id=$cm->id&sid=$USER->id&type=student.png");
+            survey_print_graph("id=$cm->id&sid=$USER->id&group=$currentgroup&type=student.png");
             echo "</center>";
 
         } else {