mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 04:30:15 +01:00
Big clean up of survey functions and removal of deadwood (more to go still though)
This commit is contained in:
parent
8f9c8aaf31
commit
551b0b9806
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -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>
|
||||
|
@ -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> </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>
|
||||
|
@ -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>
|
@ -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>
|
@ -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;
|
||||
@ -162,7 +162,7 @@
|
||||
$maxbuckets2 = max($buckets2);
|
||||
|
||||
|
||||
$graph = new graph($GWIDTH,$GHEIGHT);
|
||||
$graph = new graph($SURVEY_GWIDTH,$SURVEY_GHEIGHT);
|
||||
$graph->parameter['title'] = "$question->text";
|
||||
|
||||
$graph->x_data = $names;
|
||||
@ -287,7 +287,7 @@
|
||||
$maxbuckets2 = max($buckets2);
|
||||
|
||||
|
||||
$graph = new graph($GWIDTH,$GHEIGHT);
|
||||
$graph = new graph($SURVEY_GWIDTH,$SURVEY_GHEIGHT);
|
||||
$graph->parameter['title'] = "$survey->name";
|
||||
|
||||
$graph->x_data = $names;
|
||||
@ -433,7 +433,7 @@
|
||||
$maxbuckets2 = max($buckets2);
|
||||
|
||||
|
||||
$graph = new graph($GWIDTH,$GHEIGHT);
|
||||
$graph = new graph($SURVEY_GWIDTH,$SURVEY_GHEIGHT);
|
||||
$graph->parameter['title'] = "$survey->name";
|
||||
|
||||
$graph->x_data = $names;
|
||||
@ -578,7 +578,7 @@
|
||||
$maxbuckets2 = max($buckets2);
|
||||
|
||||
|
||||
$graph = new graph($GWIDTH,$GHEIGHT);
|
||||
$graph = new graph($SURVEY_GWIDTH,$SURVEY_GHEIGHT);
|
||||
$graph->parameter['title'] = "$question->text";
|
||||
|
||||
$graph->x_data = $names;
|
||||
|
@ -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;
|
||||
|
||||
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_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");
|
||||
}
|
||||
|
||||
function print_all_responses($survey, $results) {
|
||||
function survey_count_reponses($survey) {
|
||||
if ($responses = survey_get_responses($survey)) {
|
||||
return count($responses);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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'");
|
||||
|
@ -1,65 +0,0 @@
|
||||
<CENTER>
|
||||
<H3>You need to log in before you can fill out this survey</H3>
|
||||
|
||||
<table cellpadding=10>
|
||||
<tr valign=top>
|
||||
<td bgcolor=#f0f0f0>
|
||||
<form name="form" method="post" action="login.php">
|
||||
<table cellpadding=10>
|
||||
<tr>
|
||||
<td><P>Survey Password:<BR>(from your teacher)</td>
|
||||
<td valign=top>
|
||||
<input type="password" name="password" size=20 value="<? p($frm["password"]) ?>" >
|
||||
<? formerr($err["password"]) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><P>Your first name:</td>
|
||||
<td valign=top>
|
||||
<input type="text" name="firstname" size=20 value="<? p($frm["firstname"]) ?>">
|
||||
<? formerr($err["firstname"]) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><P>Your last name:</td>
|
||||
<td valign=top>
|
||||
<input type="text" name="lastname" size=20 value="<? p($frm["lastname"]) ?>">
|
||||
<? formerr($err["lastname"]) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><P>Your email address:</td>
|
||||
<td valign=top>
|
||||
<input type="text" name="email" size=20 value="<? p($frm["email"]) ?>">
|
||||
<? formerr($err["email"]) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><P>Student ID Number:<BR>(optional)</td>
|
||||
<td valign=top>
|
||||
<input type="text" name="idnumber" size=20 value="<? p($frm["idnumber"]) ?>">
|
||||
<? formerr($err["idnumber"]) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td valign=bottom>
|
||||
<BR>
|
||||
<input type="submit" value="Login to the survey">
|
||||
</form>
|
||||
<form name=cancel method=post action="/mod/survey/">
|
||||
<input type="submit" value="Cancel">
|
||||
</form>
|
||||
</td>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</CENTER>
|
||||
|
||||
<HR>
|
||||
<CENTER>
|
||||
<FONT SIZE=1>
|
||||
<P><A HREF="<?=$CFG->wwwroot ?>">Home</A></P>
|
||||
</BODY>
|
||||
|
@ -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>";
|
||||
}
|
||||
@ -102,7 +102,7 @@
|
||||
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>";
|
||||
}
|
||||
@ -151,13 +151,13 @@
|
||||
$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>";
|
||||
@ -220,10 +220,10 @@
|
||||
|
||||
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);
|
||||
@ -237,12 +237,12 @@
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
@ -255,7 +255,7 @@
|
||||
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)");
|
||||
@ -276,13 +276,13 @@
|
||||
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 = "";
|
||||
|
@ -1,10 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
include( "lib/psxlsgen.php" );
|
||||
|
||||
$myxls = new PhpSimpleXlsGen();
|
||||
$myxls->totalcol = 2;
|
||||
for ($i=0; $i<10; $i++) {
|
||||
$myxls->WriteText_pos($i, $i, "$i stuff");
|
||||
}
|
||||
$myxls->SendFile();
|
||||
?>
|
@ -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\">";
|
||||
|
Loading…
x
Reference in New Issue
Block a user