]> git.mjollnir.org Git - moodle.git/commitdiff
Cleaner pages when there are no responses yet
authormoodler <moodler>
Sat, 20 Mar 2004 09:39:17 +0000 (09:39 +0000)
committermoodler <moodler>
Sat, 20 Mar 2004 09:39:17 +0000 (09:39 +0000)
mod/survey/report.php

index b183d80e0dedd14f1f8f58dd104834dde660b67d..fbdf83dd88fd870a1145c0e23679b831464c8103 100644 (file)
             survey_print_graph("id=$id&group=$currentgroup&type=overall.png");
             echo "</a>";
         } else {
-            echo "<p align=center>".get_string("nobodyyet","survey")."</p>";
+            notify(get_string("nobodyyet","survey"));
         }
         break;
 
       case "scales":
         print_heading($strscales);
 
-        $questions = get_records_list("survey_questions", "id", $survey->questions);
-        $questionorder = explode(",", $survey->questions);
+        if (! $results = survey_get_responses($survey->id, $currentgroup) ) {
+            notify(get_string("nobodyyet","survey"));
 
-        foreach ($questionorder as $key => $val) {
-            $question = $questions[$val];
-            if ($question->type < 0) {  // We have some virtual scales.  Just show them.
-                $virtualscales = true;
-                break;
-            }
-        }
+        } else {
 
-        foreach ($questionorder as $key => $val) {
-            $question = $questions[$val];
-            if ($question->multi) {
-                if ($virtualscales && $question->type > 0) {  // Don't show non-virtual scales if virtual
-                    continue;
+            $questions = get_records_list("survey_questions", "id", $survey->questions);
+            $questionorder = explode(",", $survey->questions);
+
+            foreach ($questionorder as $key => $val) {
+                $question = $questions[$val];
+                if ($question->type < 0) {  // We have some virtual scales.  Just show them.
+                    $virtualscales = true;
+                    break;
                 }
-                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&group=$currentgroup&type=multiquestion.png");
-                echo "</a></p><br>";
-            } 
+            }
+
+            foreach ($questionorder as $key => $val) {
+                $question = $questions[$val];
+                if ($question->multi) {
+                    if ($virtualscales && $question->type > 0) {  // Don't show non-virtual scales if virtual
+                        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&group=$currentgroup&type=multiquestion.png");
+                    echo "</a></p><br>";
+                } 
+            }
         }
 
         break;
             print_heading($strallquestions);
         }
 
-        foreach ($questionorder as $key => $val) {
-            $question = $questions[$val];
-            if ($question->type < 0) {  // We have some virtual scales.  DON'T show them.
-                $virtualscales = true;
-                break;
-            }
-        }
+        if (! $results = survey_get_responses($survey->id, $currentgroup) ) {
+            notify(get_string("nobodyyet","survey"));
 
-        foreach ($questionorder as $key => $val) {
-            $question = $questions[$val];
+        } else {
 
-            if ($question->type < 0) {  // We have some virtual scales.  DON'T show them.
-                continue;
+            foreach ($questionorder as $key => $val) {
+                $question = $questions[$val];
+                if ($question->type < 0) {  // We have some virtual scales.  DON'T show them.
+                    $virtualscales = true;
+                    break;
+                }
             }
-            $question->text = get_string($question->text, "survey");
-
-            if ($question->multi) {
-                echo "<h3>$question->text:</h3>";
-
-                $subquestions = get_records_list("survey_questions", "id", $question->multi);
-                $subquestionorder = explode(",", $question->multi);
-                foreach ($subquestionorder as $key => $val) {
-                    $subquestion = $subquestions[$val];
-                    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&group=$currentgroup&type=question.png");
-                        echo "</a></p>";
-                    }
+
+            foreach ($questionorder as $key => $val) {
+                $question = $questions[$val];
+
+                if ($question->type < 0) {  // We have some virtual scales.  DON'T show them.
+                    continue;
                 }
-            } 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&group=$currentgroup&type=question.png");
-                echo "</a></p>";
+                $question->text = get_string($question->text, "survey");
+
+                if ($question->multi) {
+                    echo "<h3>$question->text:</h3>";
+
+                    $subquestions = get_records_list("survey_questions", "id", $question->multi);
+                    $subquestionorder = explode(",", $question->multi);
+                    foreach ($subquestionorder as $key => $val) {
+                        $subquestion = $subquestions[$val];
+                        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&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&group=$currentgroup&type=question.png");
+                    echo "</a></p>";
 
-            } else {
-                $table = NULL;
-                $table->head = array($question->text);
-                $table->align = array ("left");
-
-                $contents = '<table cellpadding="15" width="100%">';
-
-                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>';
-                        $contents .= '<td valign="top">'.$a->answer1.'</td>';
-                        $contents .= "</tr>";
+                } else {
+                    $table = NULL;
+                    $table->head = array($question->text);
+                    $table->align = array ("left");
+
+                    $contents = '<table cellpadding="15" width="100%">';
+
+                    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>';
+                            $contents .= '<td valign="top">'.$a->answer1.'</td>';
+                            $contents .= "</tr>";
+                        }
                     }
-                }
-                $contents .= "</table>";
+                    $contents .= "</table>";
 
-                $table->data[] = array($contents);
+                    $table->data[] = array($contents);
 
-                print_table($table);
-                print_spacer(30);
+                    print_table($table);
+                    print_spacer(30);
+                }
             }
         }