]> git.mjollnir.org Git - moodle.git/commitdiff
Big clean up of survey functions and removal of deadwood (more to go still though)
authormartin <martin>
Thu, 1 Aug 2002 04:49:26 +0000 (04:49 +0000)
committermartin <martin>
Thu, 1 Aug 2002 04:49:26 +0000 (04:49 +0000)
mod/survey/edit.php [deleted file]
mod/survey/edit_form.html [deleted file]
mod/survey/edit_form.phtml [deleted file]
mod/survey/edit_new.html [deleted file]
mod/survey/edit_new.phtml [deleted file]
mod/survey/graph.php
mod/survey/lib.php
mod/survey/login_form.html [deleted file]
mod/survey/report.php
mod/survey/test.php [deleted file]
mod/survey/view.php

diff --git a/mod/survey/edit.php b/mod/survey/edit.php
deleted file mode 100644 (file)
index d7350e1..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-<?PHP // $Id$
-       require("../../config.php");
-       require("surveylib.php");
-
-       require_login();
-
-       print_header("Edit my surveys", "Edit my surveys", "Edit my surveys", "");
-
-       if ($edit == "new") {
-               include("edit_new.phtml");
-               print_footer($course);
-               die;
-       } 
-
-       if ($edit == "release") {
-               release_survey($id);
-               unset($edit);
-       }
-
-       if ($edit == "update") {
-               if (match_referer() && isset($HTTP_POST_VARS)) {
-                       $survey = (object)$HTTP_POST_VARS;
-                       validate_form($survey, $err);
-                       if (count($err) == 0) {
-                               update_survey($survey);
-                               notify("The survey \"$survey->name\" was updated.");
-                               unset($edit);
-                       }
-               } else {
-                       notify("Error: This page was called wrongly.");
-               }
-       }
-
-       if ($edit == "delete") {
-               if ($id) {
-
-                       if (get_responses_for_survey($id) > 0) {
-                               notify("Could not delete survey as it has responses");
-
-                       } else if ($ss = $db->Execute("DELETE FROM surveys WHERE owner = $USER->id AND id = $id")) {
-                               notify("The survey was deleted.");
-
-                       } else {
-                               notify("Serious error: could not find any templates.");
-                       }
-
-               } else {
-                       notify("Serious error: could not find any templates.");
-               }
-               unset($edit);
-       } 
-
-
-       if ($edit == "add") {
-               if ($template) {
-                       if ($tt = $db->Execute("SELECT * FROM surveys WHERE id = $template")) {
-                               $survey = (object)$tt->fields;
-                               $survey->owner = $USER->id;
-                $survey->name = "";
-                               $survey->template = $template;
-                               add_survey($survey);
-                       } else {
-                               notify("Serious error: could not find template $template");
-                       }
-               } else {
-                       unset($edit);
-               }
-       }
-
-       if ($edit == "edit") {
-               if ($id) {
-                       $survey = get_survey($id);
-               } else {
-                       notify("Error: script called badly.");
-                       die;
-               }
-       }
-       
-       if ($edit) {
-           $survey->status = get_survey_status($survey);
-               include("edit_form.phtml");
-
-       } else {
-        clean_up_surveys();
-           print_list_of_my_surveys();
-        print_additional_commands();
-       }
-       print_footer($course);
-
-
-
-
-/// FUNCTIONS //////////////////
-
-function print_additional_commands() {
-    echo "<HR><P ALIGN=center><A HREF=\"edit.php?edit=new\">Add a new survey</A></P>";
-}
-
-function validate_form(&$survey, &$err) {
-
-       if (empty($survey->id)) {
-               notify("A serious error occurred.");
-               die;
-       }
-
-       if (empty($survey->name))
-               $err["name"] = "Missing name";
-
-       if (empty($survey->password))
-               $err["password"] = "Missing password";
-
-       else if ($survey->password == "changeme")
-               $err["password"] = "You should change this password";
-
-    settype($survey->days, "integer");
-
-       if ($survey->days < 0 || $survey->days > 365)
-               $err["days"] = "Must be a number between 0 and 365";
-
-
-}
-
-function add_survey(&$survey) {
-
-       global $db, $USER;
-
-       $timenow = time();
-
-       $survey->intro = addslashes($survey->intro);     // to make sure
-
-       $rs = $db->Execute("INSERT INTO surveys SET
-                                               timecreated = $timenow,
-                                               timemodified = $timenow,
-                                               template  = '$survey->template',
-                                               course    = '$survey->course', 
-                                               owner     = '$survey->owner', 
-                                               name      = '$survey->name', 
-                                               password  = '$survey->password',
-                                               intro     = '$survey->intro', 
-                                               url       = '$survey->url', 
-                                               questions = '$survey->questions' ");
-        
-       if (!$rs) {
-               notify("Could not insert a record");
-               die;
-       }
-
-//  Now get it out again (most compatible way to get the id)
-
-       $rs = $db->Execute("SELECT * FROM surveys WHERE owner = $survey->owner AND timecreated = $timenow");
-       if ($rs) {
-               $survey = (object) $rs->fields;
-               $survey->intro = stripslashes($survey->intro);
-       } else {
-               notify("Error: Could not find the record I just inserted!");
-               die;
-       }
-}
-
-function release_survey($id) {
-
-       global $db;
-
-       if ($ss = $db->Execute("SELECT * FROM surveys WHERE id = $id")) {
-               $survey = (object)$ss->fields;
-       } else {
-               notify("Serious error: could not find survey $id");
-               die;
-       }
-
-       $timenow = time();
-       $timeend = $timenow + ($survey->days * 86400);
-
-       if ($ss = $db->Execute("UPDATE surveys SET locked=1, timeopen = $timenow, timeclose = $timeend 
-                                                                                  WHERE id = $survey->id")) {
-               notify("The survey \"$survey->name\" was released and can no longer be edited.");
-       } else {
-               notify("An error occurred while releasing \"$survey->name\"");
-       }
-}
-
-
-function update_survey($survey) {
-
-       global $db, $USER;
-
-       $timenow = time();
-
-       $rs = $db->Execute("UPDATE surveys SET
-                                                       timemodified = $timenow,
-                                                       name      = '$survey->name', 
-                                                       password  = '$survey->password',
-                                                       intro     = '$survey->intro', 
-                                                       url       = '$survey->url',
-                                                       days      =  $survey->days
-                                               WHERE
-                                                       id        =  $survey->id AND
-                                                       owner     =  $USER->id ");
-        
-       if ($rs) {
-               return true;
-       } else {
-               notify("Could not update the survey!");
-               die;
-       }
-}
-
-function get_survey($id) {
-       global $db, $USER;
-
-       if ($ss = $db->Execute("SELECT * FROM surveys WHERE id = $id AND owner = $USER->id")) {
-               $survey = (object)$ss->fields;
-               $survey->intro = stripslashes($survey->intro);
-               $survey->name = stripslashes($survey->name);
-               $survey->password = stripslashes($survey->password);
-               return $survey;
-       } else {
-               notify("Serious error: could not find specified survey.");
-               die;
-       }
-}
-
-
-function make_survey_menu($chosenid) {
-       global $db;
-
-       $chosenname = get_template_name($chosenid);
-       if ($ss = $db->Execute("SELECT name,id FROM surveys WHERE owner = 0 ORDER BY id")) {
-               print $ss->GetMenu("template", $chosenname, true);
-       } else {
-               notify("Serious error: could not find any templates.");
-       }
-}
-
-function clean_up_surveys() {
-       global $db, $USER;
-
-    if (!$rs = $db->Execute("DELETE FROM surveys WHERE owner = $USER->id AND name = ''")) {
-               notify("Error: could not clean up surveys");
-    }
-}
-
-function print_list_of_my_surveys() {
-       global $db, $USER;
-       
-       if ($rs = $db->Execute("SELECT * FROM surveys WHERE owner = $USER->id ORDER BY id")) {
-               if ($rs->RowCount()) {
-                       echo "<H3 ALIGN=center>Existing surveys</H3>";
-                       echo "<TABLE align=center cellpadding=6>";
-                       echo "<TR><TD><B><P>Survey name<TD><B><P>Survey type<TD><B><P>Details<TD><B><P>Status<TD><B><P></TR>";
-                       while (!$rs->EOF) {
-                               $survey = (object)$rs->fields;
-
-                               $numresponses = get_responses_for_survey($survey->id);
-                               $templatename = get_template_name($survey->template);
-                               $status = get_survey_status($survey);
-
-                               echo "<TR bgcolor=#f0f0f0>";
-                               echo "<TD><P><B><A HREF=\"view.php?id=$survey->id\">$survey->name</A>";
-                               echo "<TD><P>$templatename";
-                               if ($status == "editing") {
-                                       echo "<TD><P><B><A HREF=\"edit.php?edit=edit&id=$survey->id\">Edit</A>";
-                                       echo "<TD><P><B><FONT COLOR=#990000>$status";
-                                       echo "<TD><P><A HREF=\"edit.php?edit=release&id=$survey->id\">Release to students</A>";
-                               } else {
-                                       echo "<TD><P><B><A HREF=\"edit.php?edit=edit&id=$survey->id\">View</A>";
-                                       echo "<TD><P><B><FONT COLOR=#009900>$status";
-                                       echo "<TD><P><A HREF=\"report.php?id=$survey->id\">$numresponses responses</A>";
-                               }
-                               echo "</TR>";
-                               $rs->MoveNext();
-                       }
-                       echo "</TABLE>";
-               } else {
-                       echo "<H3 align=center>You don't have any surveys yet</H3>";
-               }
-       } else {
-               notify("Error: could not list surveys");
-       }
-
-}
-
-?>
diff --git a/mod/survey/edit_form.html b/mod/survey/edit_form.html
deleted file mode 100644 (file)
index df51f89..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<table align=center cellpadding=20> <tr> <td bgcolor=#f0f0f0>
-
-<form name="form" method="post" action="edit.php">
-<table cellpadding=5>
-<tr valign=top>
-    <td><P><? link_to_popup_window("/mod/survey/docs/surveytype.html", "info", "Survey type") ?>:</td>
-    <td><? print get_template_name($survey->template) ?>
-        <input type="hidden" name=template value="<? p($survey->template) ?>">
-    </td>
-</tr>
-<tr valign=top>
-    <td><P><? link_to_popup_window("/mod/survey/docs/name.html", "info", "Survey name") ?>:</td>
-    <td><input type="text" name="name" size=40 value="<? p($survey->name) ?>">
-    <? formerr($err["name"]) ?>
-    </td>
-</tr>
-<tr valign=top>
-    <td><P><? link_to_popup_window("/mod/survey/docs/password.html", "info", "Password") ?>:</td>
-    <td><input type="text" name="password" size=20 value="<? p($survey->password) ?>">
-    <? formerr($err["password"]) ?>
-    </td>
-</tr>
-<tr valign=top>
-    <td><P><? link_to_popup_window("/mod/survey/docs/days.html", "info", "Available Days") ?>:</td>
-    <td><input type="text" name="days" size=3 value="<? p($survey->days) ?>">
-    <? formerr($err["days"]) ?>
-    </td>
-</tr>
-<tr valign=top>
-    <td><P><? link_to_popup_window("/mod/survey/docs/url.html", "info", "Course URL") ?>:</td>
-    <td><input type="text" name="url" size=50 value="<? p($survey->url) ?>">
-    <? formerr($err["url"]) ?>
-    </td>
-</tr>
-<tr valign=top>
-    <td><P><? link_to_popup_window("/mod/survey/docs/intro.html", "info", "Introduction") ?>:</td>
-    <td><textarea name=intro rows=15 cols=50 wrap=virtual><? p($survey->intro) ?></textarea>
-    </td>
-</tr>
-<tr>
-    <td></td>
-    <td>
-       <table><tr><td valign=top>
-           <input type="hidden" name=id value="<? p($survey->id) ?>">
-        <input type="hidden" name=edit value="update">
-           <? if ($survey->status == "editing") { ?>
-                  <input type="submit" value="Save changes">
-               <? } ?>
-               </FORM>
-               <td valign=top>
-           <? if (get_responses_for_survey($survey->id) == 0) { ?>
-               <FORM name="delete" method="post" action="edit.php">
-       <input type="hidden" name=id value="<? p($survey->id) ?>">
-        <input type="hidden" name=edit value="delete">
-               <input type="submit" value="Delete this survey">
-               </FORM>
-               <? } ?>
-               <td valign=top>
-               <FORM name="cancel" method="post" action="edit.php">
-               <input type="submit" value="Cancel">
-               </FORM>
-       </td></tr></table>
-</table>
-
-</td></tr></table>
-
diff --git a/mod/survey/edit_form.phtml b/mod/survey/edit_form.phtml
deleted file mode 100644 (file)
index 50ed637..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<table align=center cellpadding=20> <tr> <td bgcolor=#f0f0f0>
-
-<form name="form" method="post" action="edit.php">
-<table cellpadding=5>
-<tr valign=top>
-    <td><P><FONT SIZE=-3>(Click on the links below<BR>for help on each field)</FONT></P></td>
-    <td>&nbsp;</td>
-</tr>
-<tr valign=top>
-    <td><P>Survey type:</td>
-    <td><? print get_template_name($survey->template) ?>
-        <input type="hidden" name=template value="<? p($survey->template) ?>">
-    </td>
-</tr>
-<tr valign=top>
-    <td><P><? link_to_popup_window("/mod/survey/docs/name.phtml", "info", "Survey name") ?>:</td>
-    <td><input type="text" name="name" size=40 value="<? p($survey->name) ?>">
-    <? formerr($err["name"]) ?>
-    </td>
-</tr>
-<tr valign=top>
-    <td><P><? link_to_popup_window("/mod/survey/docs/password.phtml", "info", "Password") ?>:</td>
-    <td><input type="text" name="password" size=20 value="<? p($survey->password) ?>">
-    <? formerr($err["password"]) ?>
-    </td>
-</tr>
-<tr valign=top>
-    <td><P><? link_to_popup_window("/mod/survey/docs/days.phtml", "info", "Available Days") ?>:</td>
-    <td><input type="text" name="days" size=3 value="<? p($survey->days) ?>">
-    <? formerr($err["days"]) ?>
-    </td>
-</tr>
-<tr valign=top>
-    <td><P><? link_to_popup_window("/mod/survey/docs/url.phtml", "info", "Course URL") ?>:</td>
-    <td><input type="text" name="url" size=50 value="<? p($survey->url) ?>">
-    <? formerr($err["url"]) ?>
-    </td>
-</tr>
-<tr valign=top>
-    <td><P><? link_to_popup_window("/mod/survey/docs/intro.phtml", "info", "Introduction") ?>:</td>
-    <td><textarea name=intro rows=15 cols=50 wrap=hard><? p($survey->intro) ?></textarea>
-    </td>
-</tr>
-<tr>
-    <td></td>
-    <td>
-       <table><tr><td valign=top>
-           <input type="hidden" name=id value="<? p($survey->id) ?>">
-        <input type="hidden" name=edit value="update">
-           <? if ($survey->status == "editing") { ?>
-                  <input type="submit" value="Save changes">
-               <? } ?>
-               </FORM>
-               <td valign=top>
-           <? if (get_responses_for_survey($survey->id) == 0) { ?>
-               <FORM name="delete" method="post" action="edit.php">
-       <input type="hidden" name=id value="<? p($survey->id) ?>">
-        <input type="hidden" name=edit value="delete">
-               <input type="submit" value="Delete this survey">
-               </FORM>
-               <? } ?>
-               <td valign=top>
-               <FORM name="cancel" method="post" action="edit.php">
-               <input type="submit" value="Cancel">
-               </FORM>
-       </td></tr></table>
-</table>
-
-</td></tr></table>
-
diff --git a/mod/survey/edit_new.html b/mod/survey/edit_new.html
deleted file mode 100644 (file)
index ff37e05..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<CENTER>
-<H3>Choose a template for your new survey</H3>
-
-<P><? link_to_popup_window("/mod/survey/docs/surveytype.html", "info", "About the different survey types") ?></P>
-
-<FORM METHOD=post ACTION=edit.php>
-<INPUT TYPE=hidden NAME=edit VALUE=add>
-<? make_survey_menu("") ?>
-
-<INPUT TYPE=submit VALUE=OK>
-<P>
-
-</FORM>
-</CENTER>
diff --git a/mod/survey/edit_new.phtml b/mod/survey/edit_new.phtml
deleted file mode 100644 (file)
index 9d86be8..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<CENTER>
-<H3>Choose a template for your new survey</H3>
-
-<P><? link_to_popup_window("/surveys/", "info", "About the different survey types") ?></P>
-
-<FORM METHOD=post ACTION=edit.php>
-<INPUT TYPE=hidden NAME=edit VALUE=add>
-<? make_survey_menu("") ?>
-
-<INPUT TYPE=submit VALUE=OK>
-<P>
-
-</FORM>
-</CENTER>
index a9f78cf2e37b8fa8143be5b05915f27996fdeb68..d8e34b1adbedbea9f6b89524778d67efbc6496d9 100644 (file)
@@ -58,7 +58,7 @@
        $maxbuckets2 = max($buckets2);
        $maxbuckets = ($maxbuckets1 > $maxbuckets2) ? $maxbuckets1 : $maxbuckets2;
 
-       $graph = new graph($GWIDTH,$GHEIGHT);
+       $graph = new graph($SURVEY_GWIDTH,$SURVEY_GHEIGHT);
        $graph->parameter['title'] = "$question->text";
 
        $graph->x_data               = $options;
        $maxbuckets2 = max($buckets2);
 
 
-       $graph = new graph($GWIDTH,$GHEIGHT);
+       $graph = new graph($SURVEY_GWIDTH,$SURVEY_GHEIGHT);
        $graph->parameter['title'] = "$question->text";
 
        $graph->x_data               = $names;
        $maxbuckets2 = max($buckets2);
 
 
-       $graph = new graph($GWIDTH,$GHEIGHT);
+       $graph = new graph($SURVEY_GWIDTH,$SURVEY_GHEIGHT);
        $graph->parameter['title'] = "$survey->name";
 
        $graph->x_data               = $names;
        $maxbuckets2 = max($buckets2);
 
 
-       $graph = new graph($GWIDTH,$GHEIGHT);
+       $graph = new graph($SURVEY_GWIDTH,$SURVEY_GHEIGHT);
        $graph->parameter['title'] = "$survey->name";
 
        $graph->x_data               = $names;
        $maxbuckets2 = max($buckets2);
 
 
-       $graph = new graph($GWIDTH,$GHEIGHT);
+       $graph = new graph($SURVEY_GWIDTH,$SURVEY_GHEIGHT);
        $graph->parameter['title'] = "$question->text";
 
        $graph->x_data               = $names;
index fce203cadeb51bf65484e6b452a838480146340c..63fab365a2bf1eaf510314a95b153e9592ba4930 100644 (file)
@@ -1,10 +1,10 @@
 <?PHP // $Id$
 
 // Graph size
-$GHEIGHT = 500;
-$GWIDTH  = 900;
+$SURVEY_GHEIGHT = 500;
+$SURVEY_GWIDTH  = 900;
 
-$QTYPE = array (
+$SURVEY_QTYPE = array (
         "-3" => "Virtual Actual and Preferred",
         "-2" => "Virtual Preferred",
         "-1" => "Virtual Actual",
@@ -18,7 +18,7 @@ function survey_already_done($survey, $user) {
    return record_exists_sql("SELECT * FROM survey_answers WHERE survey='$survey' AND user='$user'");
 }
 
-function get_survey_status($survey) {
+function survey_get_status($survey) {
 
     $timenow = time();
     if ($survey->locked) {
@@ -35,22 +35,25 @@ function get_survey_status($survey) {
 
 }
 
-function get_responses_for_survey($surveyid) {
-        global $db;
+function survey_get_responses($survey) {
+    return get_records_sql("SELECT a.time as time, count(*) as numanswers, u.*
+                            FROM survey_answers AS a, user AS u
+                            WHERE a.answer1 <> '0' AND a.answer2 <> '0'
+                                  AND a.survey = $survey 
+                                  AND a.user = u.id
+                            GROUP BY a.user ORDER BY a.time ASC");
+}
 
-        if ($aa = $db->Execute("SELECT user FROM survey_answers WHERE survey = $surveyid GROUP BY user")) {
-                if ($aa) {
-                        return $aa->RowCount();
-                } else {
-                        return -1;
-                }
-        } else {
-                return -1;
-        }
+function survey_count_reponses($survey) {
+    if ($responses = survey_get_responses($survey)) {
+        return count($responses);
+    } else {
+        return 0;
+    }
 }
 
-function print_all_responses($survey, $results) {
 
+function survey_print_all_responses($survey, $results) {
     global $THEME;
 
     echo "<TABLE CELLPADDING=5 CELLSPACING=2 ALIGN=CENTER>";
@@ -67,26 +70,8 @@ function print_all_responses($survey, $results) {
     echo "</TABLE>";
 }
 
-          
-function get_survey_responses($survey) {
-    return get_records_sql("SELECT a.time as time, count(*) as numanswers, u.*
-                            FROM survey_answers AS a, user AS u
-                            WHERE a.answer1 <> '0' AND a.answer2 <> '0'
-                                  AND a.survey = $survey 
-                                  AND a.user = u.id
-                            GROUP BY a.user ORDER BY a.time ASC");
-}
 
-function count_completed_surveys($survey) {
-    if ($responses = get_survey_responses($survey)) {
-        return count($responses);
-    } else {
-        return 0;
-    }
-}
-
-
-function get_template_name($templateid) {
+function survey_get_template_name($templateid) {
     global $db;
 
     if ($templateid) {
@@ -99,14 +84,20 @@ function get_template_name($templateid) {
 }
 
 
-function update_survey_analysis($survey, $user, $notes) {
+function survey_get_analysis($survey, $user) {
+    global $db;
+
+    return get_record_sql("SELECT notes from survey_analysis WHERE survey='$survey' and user='$user'");
+}
+
+function survey_update_analysis($survey, $user, $notes) {
     global $db;
 
     return $db->Execute("UPDATE survey_analysis SET notes='$notes' WHERE survey='$survey' and user='$user'");
 }
 
 
-function add_survey_analysis($survey, $user, $notes) {
+function survey_add_analysis($survey, $user, $notes) {
     global $db;
 
     return $db->Execute("INSERT INTO survey_analysis SET notes='$notes', survey='$survey', user='$user'");
diff --git a/mod/survey/login_form.html b/mod/survey/login_form.html
deleted file mode 100644 (file)
index a2d5341..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<CENTER>\r
-<H3>You need to log in before you can fill out this survey</H3>\r
-\r
-<table cellpadding=10>\r
-  <tr valign=top> \r
-    <td bgcolor=#f0f0f0> \r
-      <form name="form" method="post" action="login.php">\r
-        <table cellpadding=10>\r
-          <tr> \r
-            <td><P>Survey Password:<BR>(from your teacher)</td>\r
-            <td valign=top> \r
-              <input type="password" name="password" size=20 value="<? p($frm["password"]) ?>" >\r
-                         <? formerr($err["password"]) ?>\r
-            </td>\r
-                 </tr>\r
-          <tr> \r
-            <td><P>Your first name:</td>\r
-            <td valign=top> \r
-              <input type="text" name="firstname" size=20 value="<? p($frm["firstname"]) ?>">\r
-                         <? formerr($err["firstname"]) ?>\r
-            </td>\r
-          </tr>\r
-          <tr> \r
-            <td><P>Your last name:</td>\r
-            <td valign=top> \r
-              <input type="text" name="lastname" size=20 value="<? p($frm["lastname"]) ?>">\r
-                         <? formerr($err["lastname"]) ?>\r
-            </td>\r
-          </tr>\r
-          <tr> \r
-            <td><P>Your email address:</td>\r
-            <td valign=top> \r
-              <input type="text" name="email" size=20 value="<? p($frm["email"]) ?>">\r
-                         <? formerr($err["email"]) ?>\r
-            </td>\r
-          </tr>\r
-          <tr> \r
-            <td><P>Student ID Number:<BR>(optional)</td>\r
-            <td valign=top> \r
-              <input type="text" name="idnumber" size=20 value="<? p($frm["idnumber"]) ?>">\r
-                         <? formerr($err["idnumber"]) ?>\r
-            </td>\r
-          </tr>\r
-          <tr> \r
-            <td>&nbsp;</td>\r
-            <td valign=bottom> \r
-                         <BR>\r
-              <input type="submit" value="Login to the survey">\r
-                         </form>\r
-                         <form name=cancel method=post action="/mod/survey/">\r
-              <input type="submit" value="Cancel">\r
-              </form>\r
-            </td>\r
-        </table>\r
-    </td>\r
-  </tr>\r
-</table>\r
-</CENTER>\r
-\r
-<HR>\r
-<CENTER>\r
-<FONT SIZE=1>\r
-<P><A HREF="<?=$CFG->wwwroot ?>">Home</A></P>\r
-</BODY>\r
-\r
index 30226e3a1d03171b11233b7cf35c7b146acaf2dc..a6f0648e124ab74991cd1203ff19f5208cb268b0 100644 (file)
@@ -53,7 +53,7 @@
         echo "<P><FONT SIZE=2><A TARGET=reportmain HREF=\"report.php?action=scales&id=$id\">Scales</A></FONT></P>";
         echo "<P><FONT SIZE=2><A TARGET=reportmain HREF=\"report.php?action=questions&id=$id\">Questions</A></FONT></P>";
         echo "<P><FONT SIZE=2><A TARGET=reportmain HREF=\"report.php?action=students&id=$id\">Students</A></FONT></P>";
-        if ($users = get_survey_responses($survey->id)) {
+        if ($users = survey_get_responses($survey->id)) {
             foreach ($users as $user) {
                 echo "<LI><FONT SIZE=1>";
                 echo "<A TARGET=reportmain HREF=\"report.php?action=student&student=$user->id&id=$id\">";
@@ -71,8 +71,8 @@
 
         print_heading("All scales, all students");
 
-        if (count_completed_surveys($survey->id)) {
-            echo "<P ALIGN=CENTER><A HREF=\"report.php?action=scales&id=$id\"><IMG HEIGHT=$GHEIGHT WIDTH=$GWIDTH ALT=\"Click here to see the scales in more detail\" BORDER=0 SRC=\"graph.php?id=$id&type=overall.png\"></A>";
+        if (survey_count_responses($survey->id)) {
+            echo "<P ALIGN=CENTER><A HREF=\"report.php?action=scales&id=$id\"><IMG HEIGHT=$SURVEY_GHEIGHT WIDTH=$SURVEY_GWIDTH ALT=\"Click here to see the scales in more detail\" BORDER=0 SRC=\"graph.php?id=$id&type=overall.png\"></A>";
         } else {
             echo "<P ALIGN=CENTER>Nobody has yet completed this survey</P>";
         }
                     continue;
                 }
                 echo "<P ALIGN=center><A HREF=report.php?action=questions&id=$id&qid=$question->multi>";
-                echo "<IMG HEIGHT=$GHEIGHT WIDTH=$GWIDTH ALT=\"Click here to see subquestions\" BORDER=0
+                echo "<IMG HEIGHT=$SURVEY_GHEIGHT WIDTH=$SURVEY_GWIDTH ALT=\"Click here to see subquestions\" BORDER=0
                        SRC=\"graph.php?id=$id&qid=$question->id&type=multiquestion.png\">";
                 echo "</A></P><BR>";
             } 
                     $subquestion = $subquestions[$val];
                     if ($subquestion->type > 0) {
                         echo "<P ALIGN=CENTER><A HREF=\"report.php?action=question&id=$id&qid=$subquestion->id\">
-                              <IMG HEIGHT=$GHEIGHT WIDTH=$GWIDTH ALT=\"Click here to see all responses\" 
+                              <IMG HEIGHT=$SURVEY_GHEIGHT WIDTH=$SURVEY_GWIDTH ALT=\"Click here to see all responses\" 
                                    BORDER=0 SRC=\"graph.php?id=$id&qid=$subquestion->id&type=question.png\"></A></P>";
                     }
                 }
             } else if ($question->type > 0 ) {
                 echo "<P ALIGN=CENTER><A HREF=\"report.php?action=question&id=$id&qid=$question->id\">
-                      <IMG HEIGHT=$GHEIGHT WIDTH=$GWIDTH ALT=\"Click here to see all responses\"
+                      <IMG HEIGHT=$SURVEY_GHEIGHT WIDTH=$SURVEY_GWIDTH ALT=\"Click here to see all responses\"
                            BORDER=0 SRC=\"graph.php?id=$id&qid=$question->id&type=question.png\"></A></P>";
             } else {
                 echo "<H3>$question->text</H3>";
 
          print_header("Analysis by Student", "$survey->name: Students", "", "");
         
-         if (! $results = get_survey_responses($survey->id) ) {
+         if (! $results = survey_get_responses($survey->id) ) {
              notify("There are no responses for this survey.");
          } else {
-             print_all_responses($cm->id, $results);
+             survey_print_all_responses($cm->id, $results);
          }
 
         print_footer($course);
 
          print_header("Analysis of $user->firstname $user->lastname", "$survey->name: Analysis of a student", "", "");
          if (isset($notes)) {
-             if (record_exists_sql("SELECT * FROM survey_analysis WHERE survey='$survey->id' and user='$user->id'")) {
-                 if (! update_survey_analysis($survey->id, $user->id, $notes)) {
+             if (survey_get_analysis($survey->id, $user->id)) {
+                 if (! survey_update_analysis($survey->id, $user->id, $notes)) {
                      notify("An error occurred while saving your notes.  Sorry.");
                  }
              } else {
-                 if (!add_survey_analysis($survey->id, $user->id, $notes)) {
+                 if (! survey_add_analysis($survey->id, $user->id, $notes)) {
                      notify("An error occurred while saving your notes.  Sorry.");
                  }
              }
          echo "</P>";
 
          // Print overall summary
-         echo "<P ALIGN=CENTER><IMG HEIGHT=$GHEIGHT WIDTH=$GWIDTH ALIGN=CENTER SRC=\"graph.php?id=$id&sid=$student&type=student.png\"></P>";
+         echo "<P ALIGN=CENTER><IMG HEIGHT=$SURVEY_GHEIGHT WIDTH=$SURVEY_GWIDTH ALIGN=CENTER SRC=\"graph.php?id=$id&sid=$student&type=student.png\"></P>";
          
          // Print scales
          $questions = get_records_sql("SELECT * FROM survey_questions WHERE id in ($survey->questions)");
                      continue;
                  }
                  echo "<P ALIGN=center><A HREF=report.php?action=questions&id=$id&qid=$question->multi>";
-                 echo "<IMG HEIGHT=$GHEIGHT WIDTH=$GWIDTH ALT=\"Click here to see subquestions\" BORDER=0
+                 echo "<IMG HEIGHT=$SURVEY_GHEIGHT WIDTH=$SURVEY_GWIDTH ALT=\"Click here to see subquestions\" BORDER=0
                         SRC=\"graph.php?id=$id&qid=$question->id&sid=$student&type=studentmultiquestion.png\">";
                  echo "</A></P><BR>";
              } 
          }
 
-         if ($rs = get_record_sql("SELECT notes from survey_analysis WHERE survey='$survey->id' and user='$user->id'")) {
+         if ($rs = survey_get_analysis($survey->id, $user->id)) {
             $notes = $rs->notes;
          } else {
             $notes = "";
diff --git a/mod/survey/test.php b/mod/survey/test.php
deleted file mode 100644 (file)
index 025a8ae..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?PHP // $Id$\r
-include( "lib/psxlsgen.php" );\r
-\r
-$myxls = new PhpSimpleXlsGen();\r
-$myxls->totalcol = 2;\r
-for ($i=0; $i<10; $i++) {\r
-    $myxls->WriteText_pos($i, $i, "$i stuff");\r
-}\r
-$myxls->SendFile();\r
-?>\r
index 691d3e5f9fbb2f169372f55cd43af5cde52a0d80..5d010f9340bfe8563db36916e176424a2f258efb 100644 (file)
@@ -35,7 +35,7 @@
     if (survey_already_done($survey->id, $USER->id)) {
         add_to_log($course->id, "survey", "view graph", "view.php?id=$cm->id", "$survey->id");
         print_heading("You've completed this survey.  The graph below shows a summary of your results compared to the class averages.");
-        $numusers = count_completed_surveys($survey->id);
+        $numusers = survey_count_responses($survey->id);
         print_heading("$numusers people have completed the survey so far");
         echo "<CENTER>";
         echo "<IMG SRC=\"$CFG->wwwroot/mod/survey/graph.php?id=$cm->id&sid=$USER->id&type=student.png\">";