Complete clean-up of the survey reports.

Frames are GONE.  :-)

Also, a new survey: CIQ = Critical Incident Questionnaire
This commit is contained in:
moodler
2004-02-16 16:13:31 +00:00
parent 9be2bd0c39
commit 7c8c335fa3
8 changed files with 252 additions and 168 deletions
+11
View File
@@ -4,6 +4,8 @@ function survey_upgrade($oldversion) {
// This function does anything necessary to upgrade
// older versions to match current functionality
global $CFG;
if ($oldversion < 2002081400) {
execute_sql(" ALTER TABLE `survey_questions` DROP `owner` ");
@@ -156,6 +158,15 @@ function survey_upgrade($oldversion) {
execute_sql("ALTER TABLE `survey_answers` CHANGE `user` `userid` INT(10) UNSIGNED DEFAULT '0' NOT NULL ");
}
if ($oldversion < 2003051502) {
execute_sql("INSERT INTO `{$CFG->prefix}survey` (`id`, `course`, `template`, `days`, `timecreated`, `timemodified`, `name`, `intro`, `questions`) VALUES (5, 0, 0, 0, 985017600, 985017600, 'ciqname', 'ciqintro', '69,70,71,72,73')");
execute_sql("INSERT INTO `{$CFG->prefix}survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (69, 'ciq1', 'ciq1short', '', '', 0, '')");
execute_sql("INSERT INTO `{$CFG->prefix}survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (70, 'ciq2', 'ciq2short', '', '', 0, '')");
execute_sql("INSERT INTO `{$CFG->prefix}survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (71, 'ciq3', 'ciq3short', '', '', 0, '')");
execute_sql("INSERT INTO `{$CFG->prefix}survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (72, 'ciq4', 'ciq4short', '', '', 0, '')");
execute_sql("INSERT INTO `{$CFG->prefix}survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (73, 'ciq5', 'ciq5short', '', '', 0, '')");
}
return true;
}
+6
View File
@@ -35,6 +35,7 @@ INSERT INTO `prefix_survey` (`id`, `course`, `template`, `days`, `timecreated`,
INSERT INTO `prefix_survey` (`id`, `course`, `template`, `days`, `timecreated`, `timemodified`, `name`, `intro`, `questions`) VALUES (2, 0, 0, 0, 985017600, 985017600, 'collespname', 'collespintro', '31,32,33,34,35,36,43,44');
INSERT INTO `prefix_survey` (`id`, `course`, `template`, `days`, `timecreated`, `timemodified`, `name`, `intro`, `questions`) VALUES (3, 0, 0, 0, 985017600, 985017600, 'collesapname', 'collesapintro', '37,38,39,40,41,42,43,44');
INSERT INTO `prefix_survey` (`id`, `course`, `template`, `days`, `timecreated`, `timemodified`, `name`, `intro`, `questions`) VALUES (4, 0, 0, 0, 985017600, 985017600, 'attlsname', 'attlsintro', '65,67,68');
INSERT INTO `prefix_survey` (`id`, `course`, `template`, `days`, `timecreated`, `timemodified`, `name`, `intro`, `questions`) VALUES (5, 0, 0, 0, 985017600, 985017600, 'ciqname', 'ciqintro', '69,70,71,72,73');
@@ -166,6 +167,11 @@ INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intr
INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (67, 'attlsm2', 'attlsm2', '63,62,59,57,55,49,52,50,48,47', 'attlsmintro', -1, 'scaleagree5');
INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (68, 'attlsm3', 'attlsm3', '46,54,45,51,60,53,56,58,61,64', 'attlsmintro', -1, 'scaleagree5');
INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (69, 'ciq1', 'ciq1short', '', '', 0, '');
INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (70, 'ciq2', 'ciq2short', '', '', 0, '');
INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (71, 'ciq3', 'ciq3short', '', '', 0, '');
INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (72, 'ciq4', 'ciq4short', '', '', 0, '');
INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (73, 'ciq5', 'ciq5short', '', '', 0, '');
#
+9
View File
@@ -6,6 +6,15 @@ function survey_upgrade($oldversion) {
global $CFG;
if ($oldversion < 2003051501) {
modify_database("", "INSERT INTO `prefix_survey` (`id`, `course`, `template`, `days`, `timecreated`, `timemodified`, `name`, `intro`, `questions`) VALUES (5, 0, 0, 0, 985017600, 985017600, 'ciqname', 'ciqintro', '69,70,71,72,73')");
modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (69, 'ciq1', 'ciq1short', '', '', 0, '')");
modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (70, 'ciq2', 'ciq2short', '', '', 0, '')");
modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (71, 'ciq3', 'ciq3short', '', '', 0, '')");
modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (72, 'ciq4', 'ciq4short', '', '', 0, '')");
modify_database("", "INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intro`, `type`, `options`) VALUES (73, 'ciq5', 'ciq5short', '', '', 0, '')");
}
return true;
}
+6
View File
@@ -34,6 +34,7 @@ INSERT INTO prefix_survey (id, course, template, days, timecreated, timemodified
INSERT INTO prefix_survey (id, course, template, days, timecreated, timemodified, name, intro, questions) VALUES (2, 0, 0, 0, 985017600, 985017600, 'collespname', 'collespintro', '31,32,33,34,35,36,43,44');
INSERT INTO prefix_survey (id, course, template, days, timecreated, timemodified, name, intro, questions) VALUES (3, 0, 0, 0, 985017600, 985017600, 'collesapname', 'collesapintro', '37,38,39,40,41,42,43,44');
INSERT INTO prefix_survey (id, course, template, days, timecreated, timemodified, name, intro, questions) VALUES (4, 0, 0, 0, 985017600, 985017600, 'attlsname', 'attlsintro', '65,67,68');
INSERT INTO prefix_survey (id, course, template, days, timecreated, timemodified, name, intro, questions) VALUES (5, 0, 0, 0, 985017600, 985017600, 'ciqname', 'ciqintro', '69,70,71,72,73');
@@ -161,6 +162,11 @@ INSERT INTO prefix_survey_questions (id, text, shorttext, multi, intro, type, op
INSERT INTO prefix_survey_questions (id, text, shorttext, multi, intro, type, options) VALUES (68, 'attlsm3', 'attlsm3', '46,54,45,51,60,53,56,58,61,64', 'attlsmintro', -1, 'scaleagree5');
INSERT INTO prefix_survey_questions (id, text, shorttext, multi, intro, type, options) VALUES (69, 'ciq1', 'ciq1short', '', '', 0, '');
INSERT INTO prefix_survey_questions (id, text, shorttext, multi, intro, type, options) VALUES (70, 'ciq2', 'ciq2short', '', '', 0, '');
INSERT INTO prefix_survey_questions (id, text, shorttext, multi, intro, type, options) VALUES (71, 'ciq3', 'ciq3short', '', '', 0, '');
INSERT INTO prefix_survey_questions (id, text, shorttext, multi, intro, type, options) VALUES (72, 'ciq4', 'ciq4short', '', '', 0, '');
INSERT INTO prefix_survey_questions (id, text, shorttext, multi, intro, type, options) VALUES (73, 'ciq5', 'ciq5short', '', '', 0, '');
#
# Dumping data for table log_display
+24 -18
View File
@@ -178,7 +178,7 @@ function survey_get_participants($surveyid) {
function survey_log_info($log) {
global $CFG;
return get_record_sql("SELECT s.name, u.firstname, u.lastname
return get_record_sql("SELECT s.name, u.firstname, u.lastname, u.picture
FROM {$CFG->prefix}survey s,
{$CFG->prefix}user u
WHERE s.id = '$log->info'
@@ -189,11 +189,10 @@ function survey_get_responses($survey) {
global $CFG;
return get_records_sql("SELECT MAX(a.time) as time,
count(*) as numanswers,
u.id, u.firstname, u.lastname
u.id, u.firstname, u.lastname, u.picture
FROM {$CFG->prefix}survey_answers AS a,
{$CFG->prefix}user AS u
WHERE a.answer1 <> '0' AND a.answer2 <> '0'
AND a.survey = $survey
WHERE a.survey = $survey
AND a.userid = u.id
GROUP BY u.id, u.firstname, u.lastname
ORDER BY time ASC");
@@ -218,7 +217,7 @@ function survey_update_analysis($survey, $user, $notes) {
}
function survey_get_user_answers($surveyid, $questionid) {
function survey_get_user_answers($surveyid, $questionid, $sort="sa.answer1,sa.answer2 ASC") {
global $CFG;
return get_records_sql("SELECT sa.*,u.firstname,u.lastname,u.picture
@@ -227,7 +226,17 @@ function survey_get_user_answers($surveyid, $questionid) {
WHERE sa.survey = '$surveyid'
AND sa.question = $questionid
AND u.id = sa.userid
ORDER BY sa.answer1,sa.answer2 ASC");
ORDER BY $sort");
}
function survey_get_user_answer($surveyid, $questionid, $userid) {
global $CFG;
return get_record_sql("SELECT sa.*
FROM {$CFG->prefix}survey_answers sa
WHERE sa.survey = '$surveyid'
AND sa.question = '$questionid'
AND sa.userid = '$userid'");
}
// MODULE FUNCTIONS ////////////////////////////////////////////////////////
@@ -255,23 +264,20 @@ function survey_count_responses($survey) {
}
function survey_print_all_responses($survey, $results) {
function survey_print_all_responses($cmid, $results, $courseid) {
global $THEME;
$dateformat = get_string("strftimedatetime");
echo "<TABLE CELLPADDING=5 CELLSPACING=2 ALIGN=CENTER>";
echo "<TR><TD>Name<TD>Time<TD>Answered</TR>";
$table->head = array ("", get_string("name"), get_string("time"), get_string("answers", "survey"));
$table->align = array ("", "left", "left", "right");
$table->size = array (35, "", "", "");
foreach ($results as $a) {
echo "<TR>";
echo "<TD><A HREF=\"report.php?action=student&student=$a->id&id=$survey\">".fullname($a)."</A></TD>";
echo "<TD>".userdate($a->time, $dateformat)."</TD>";
echo "<TD align=right>$a->numanswers</TD>";
echo "</TR>";
$table->data[] = array(print_user_picture($a->id, $courseid, $a->picture, false, true, false),
"<a href=\"report.php?action=student&student=$a->id&id=$cmid\">".fullname($a)."</a>",
userdate($a->time), $a->numanswers);
}
echo "</TABLE>";
print_table($table);
}
+162 -143
View File
@@ -5,7 +5,8 @@
// Check that all the parameters have been provided.
require_variable($id); // Course Module ID
require_variable($id); // Course Module ID
optional_variable($action, "students"); // What to look at
if (! $cm = get_record("course_modules", "id", $id)) {
error("Course Module ID was incorrect");
@@ -25,10 +26,15 @@
error("Survey ID was incorrect");
}
if (! $template = get_record("survey", "id", $survey->template)) {
error("Template ID was incorrect");
}
$showscales = ($template->name != 'ciqname');
$ME = qualified_me()."?id=$id";
$strreport = get_string("report", "survey");
$strsurvey = get_string("modulename", "survey");
$strsurveys = get_string("modulenameplural", "survey");
$strsummary = get_string("summary", "survey");
$strscales = get_string("scales", "survey");
@@ -41,68 +47,56 @@
$strseemoredetail = get_string("seemoredetail", "survey");
$strnotes = get_string("notes", "survey");
if (empty($action)) {
$display = "summary";
add_to_log($course->id, "survey", "view report", "report.php?id=$cm->id", "$survey->id", $cm->id);
if ($course->category) {
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
<a href=\"index.php?id=$course->id\">$strsurveys</a> ->
<a href=\"view.php?id=$cm->id\">$survey->name</a> -> ";
} else {
$navigation = "<a href=\"index.php?id=$course->id\">$strsurveys</a> ->
<a href=\"view.php?id=$cm->id\">$survey->name</a> -> ";
}
if (!empty($display)) { // Display the frame containing something.
add_to_log($course->id, "survey", "view report", "report.php?id=$cm->id", "$survey->id");
echo "<HEAD><TITLE>$course->shortname: $strreport: $survey->name</TITLE>\n";
echo "<FRAMESET ROWS=70,* BORDER=1> ";
echo " <FRAME NAME=reporttop SRC=\"report.php?action=top&id=$id\"> \n";
echo " <FRAMESET COLS=150,* BORDER=1> ";
echo " <FRAME NAME=reportmenu SRC=\"report.php?action=menu&id=$id\"> \n";
echo " <FRAME NAME=reportmain SRC=\"report.php?action=$display&id=$id\"> \n";
echo " </FRAMESET>\n";
echo "</FRAMESET>\n";
exit;
print_header("$course->shortname: $survey->name", "$course->fullname", "$navigation $strreport",
"", "", true,
update_module_button($cm->id, $course->id, $strsurvey), navmenu($course, $cm));
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=scales&id=$id\">$strscales</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>";
} 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>";
}
print_simple_box_end();
print_spacer(30,30);
/// Print the menu across the top
switch ($action) {
case "top":
if ($course->category) {
$navigation = "<A TARGET=\"{$CFG->framename}\" HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->
<A TARGET=\"{$CFG->framename}\" HREF=\"index.php?id=$course->id\">$strsurveys</A> ->
<A TARGET=\"{$CFG->framename}\" HREF=\"view.php?id=$cm->id\">$survey->name</A> -> ";
} else {
$navigation = "<A TARGET=\"{$CFG->framename}\" HREF=\"index.php?id=$course->id\">$strsurveys</A> ->
<A TARGET=\"{$CFG->framename}\" HREF=\"view.php?id=$cm->id\">$survey->name</A> -> ";
}
print_header("$course->shortname: $survey->name", "$course->fullname", "$navigation $strreport");
break;
case "menu":
print_header();
echo "<P><FONT SIZE=2><A TARGET=reportmain HREF=\"report.php?action=summary&id=$id\">$strsummary</A></FONT></P>";
echo "<P><FONT SIZE=2><A TARGET=reportmain HREF=\"report.php?action=scales&id=$id\">$strscales</A></FONT></P>";
echo "<P><FONT SIZE=2><A TARGET=reportmain HREF=\"report.php?action=questions&id=$id\">$strquestions</A></FONT></P>";
echo "<P><FONT SIZE=2><A TARGET=reportmain HREF=\"report.php?action=students&id=$id\">$course->student:</A></FONT></P>";
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\">";
echo "$user->firstname $user->lastname";
echo "</A></FONT></LI>";
}
}
echo "<P><FONT SIZE=2><A TARGET=reportmain HREF=\"report.php?action=download&id=$id\">$strdownload</A></FONT></P>";
break;
case "summary":
print_header("$survey->name: $strsummary", "$strsummary - $strallscales");
print_heading($strsummary);
if (survey_count_responses($survey->id)) {
echo "<P ALIGN=CENTER><A HREF=\"report.php?action=scales&id=$id\">";
echo "<p align=center><a href=\"report.php?action=scales&id=$id\">";
survey_print_graph("id=$id&type=overall.png");
echo "</A>";
echo "</a>";
} else {
echo "<P ALIGN=CENTER>".get_string("nobodyyet","survey")."</P>";
echo "<p align=center>".get_string("nobodyyet","survey")."</p>";
}
print_footer($course);
break;
case "scales":
print_header("$survey->name: $strscales", "$strallscales");
print_heading($strscales);
$questions = get_records_list("survey_questions", "id", $survey->questions);
$questionorder = explode(",", $survey->questions);
@@ -121,13 +115,12 @@
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>";
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");
echo "</A></P><BR>";
echo "</a></p><br>";
}
}
print_footer($course);
break;
case "questions":
@@ -138,16 +131,16 @@
if ($scale = get_records("survey_questions", "multi", "$qid")) {
$scale = array_pop($scale);
print_header("$survey->name: $strquestions", "$scale->text - $strselectedquestions");
print_heading("$scale->text - $strselectedquestions");
} else {
print_header("$survey->name: $strquestions", "$strselectedquestions");
print_heading($strselectedquestions);
}
} else { // get all top-level questions
$questions = get_records_list("survey_questions", "id", $survey->questions);
$questionorder = explode(",", $survey->questions);
print_header("$survey->name: $strquestions", "$strallquestions");
print_heading($strallquestions);
}
foreach ($questionorder as $key => $val) {
@@ -167,38 +160,49 @@
$question->text = get_string($question->text, "survey");
if ($question->multi) {
echo "<H3>$question->text:</H3>";
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\">";
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");
echo "</A></P>";
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\">";
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");
echo "</A></P>";
echo "</a></p>";
} else {
echo "<H3>$question->text:</H3>";
if ($aaa = survey_get_user_answers($survey->id, $question->id)) {
echo "<UL>";
$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, "sa.time ASC")) {
foreach ($aaa as $a) {
echo "<LI>$a->firstname $a->lastname: $a->answer1";
$contents .= "<tr>";
$contents .= '<td nowrap="nowrap" width="10%" valign="top">'.fullname($a).'</td>';
$contents .= '<td valign="top">'.$a->answer1.'</td>';
$contents .= "</tr>";
}
echo "</UL>";
}
$contents .= "</table>";
$table->data[] = array($contents);
print_table($table);
print_spacer(30);
}
}
print_footer($course);
break;
case "question":
@@ -209,7 +213,7 @@
$answers = explode(",", get_string($question->options, "survey"));
print_header("$survey->name: $strquestion", "$strquestion: $question->text");
print_heading("$strquestion: $question->text");
$strname = get_string("name", "survey");
@@ -218,49 +222,47 @@
$strpreferred = get_string("preferred", "survey");
$strdateformat = get_string("strftimedatetime");
echo "<TABLE ALIGN=center CELLPADDING=0 CELLSPACING=10><TR><TD>&nbsp;<TH align=left>$strname<TH align=left>$strtime<TH align=left>$stractual<TH align=left>$strpreferred</TR>";
$table = NULL;
$table->head = array("", $strname, $strtime, $stractual, $strpreferred);
$table->align = array ("left", "left", "left", "left", "right");
$table->size = array (35, "", "", "", "");
if ($aaa = survey_get_user_answers($survey->id, $question->id)) {
foreach ($aaa as $a) {
echo "<TR>";
echo "<TD WIDTH=35>";
print_user_picture($a->userid, $course->id, $a->picture, false);
echo "</TD>";
echo "<TD><P><A HREF=\"report.php?id=$id&action=student&student=$a->userid\">$a->firstname $a->lastname</A></TD>";
echo "<TD><P>".userdate($a->time, $strdateformat)."</TD>";
echo "<TD BGCOLOR=\"$THEME->cellcontent\"><P>";
if ($a->answer1) {
echo "$a->answer1 - ".$answers[$a->answer1 - 1];
$answer1 = "$a->answer1 - ".$answers[$a->answer1 - 1];
} else {
echo "&nbsp;";
$answer1 = "&nbsp;";
}
echo "</TD><TD BGCOLOR=\"$THEME->cellcontent\"><P>";
if ($a->answer2) {
echo "$a->answer2 - ".$answers[$a->answer2 - 1];
$answer2 = "$a->answer2 - ".$answers[$a->answer2 - 1];
} else {
echo "&nbsp;";
$answer2 = "&nbsp;";
}
echo "</TD></TR>";
$table->data[] = array(
print_user_picture($a->userid, $course->id, $a->picture, false, true, true),
"<a href=\"report.php?id=$id&action=student&student=$a->userid\">".fullname($a)."</a>",
userdate($a->time),
$answer1, $answer2);
}
}
echo "</TABLE>";
print_table($table);
print_footer($course);
break;
case "students":
print_header("$survey->name: $course->student", get_string("analysisof", "survey", "$course->student"));
print_heading(get_string("analysisof", "survey", "$course->students"));
if (! $results = survey_get_responses($survey->id) ) {
notify(get_string("nobodyyet","survey"));
} else {
survey_print_all_responses($cm->id, $results);
survey_print_all_responses($cm->id, $results, $course->id);
}
print_footer($course);
break;
case "student":
@@ -268,8 +270,7 @@
error("Student doesn't exist");
}
print_header("$survey->name: $user->firstname $user->lastname",
get_string("analysisof", "survey", "$user->firstname $user->lastname"));
print_heading(get_string("analysisof", "survey", fullname($user)));
if (isset($notes)) {
if (survey_get_analysis($survey->id, $user->id)) {
@@ -287,40 +288,57 @@
}
}
print_heading("$user->firstname $user->lastname");
echo "<P ALIGN=CENTER>";
echo "<p align=center>";
print_user_picture($user->id, $course->id, $user->picture, true);
echo "</P>";
echo "</p>";
// Print overall summary
echo "<P ALIGN=CENTER>";
survey_print_graph("id=$id&sid=$student&type=student.png");
echo "</P>";
// Print scales
$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;
}
}
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;
if ($showscales) {
// Print overall summary
echo "<p align=center>";
survey_print_graph("id=$id&sid=$student&type=student.png");
echo "</p>";
// Print scales
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>";
echo "<A TITLE=\"$strseemoredetail\" HREF=report.php?action=questions&id=$id&qid=$question->multi>";
survey_print_graph("id=$id&qid=$question->id&sid=$student&type=studentmultiquestion.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>";
echo "<a title=\"$strseemoredetail\" href=report.php?action=questions&id=$id&qid=$question->multi>";
survey_print_graph("id=$id&qid=$question->id&sid=$student&type=studentmultiquestion.png");
echo "</a></p><br>";
}
}
}
// Print non-scale questions
foreach ($questionorder as $key => $val) {
$question = $questions[$val];
if ($question->type == 0 or $question->type == 1) {
if ($answer = survey_get_user_answer($survey->id, $question->id, $user->id)) {
$table = NULL;
$table->head = array(get_string($question->text, "survey"));
$table->align = array ("left");
$table->data[] = array("$answer->answer1");
print_table($table);
print_spacer(30);
}
}
}
if ($rs = survey_get_analysis($survey->id, $user->id)) {
@@ -328,40 +346,41 @@
} else {
$notes = "";
}
echo "<HR NOSHADE SIZE=1>";
echo "<CENTER>";
echo "<FORM ACTION=report.php METHOD=post NAME=form>";
echo "<H3>$strnotes:</H3>";
echo "<BLOCKQUOTE>";
echo "<TEXTAREA NAME=notes ROWS=10 COLS=60>";
echo "<hr noshade size=1>";
echo "<center>";
echo "<form action=report.php method=post name=form>";
echo "<h3>$strnotes:</h3>";
echo "<blockquote>";
echo "<textarea name=notes rows=10 cols=60>";
p($notes);
echo "</TEXTAREA><BR>";
echo "<INPUT TYPE=hidden NAME=action VALUE=student>";
echo "<INPUT TYPE=hidden NAME=student VALUE=$student>";
echo "<INPUT TYPE=hidden NAME=id VALUE=$cm->id>";
echo "<INPUT TYPE=submit VALUE=\"".get_string("savechanges")."\">";
echo "</BLOCKQUOTE>";
echo "</FORM>";
echo "</CENTER>";
echo "</textarea><br>";
echo "<input type=hidden name=action value=student>";
echo "<input type=hidden name=student value=$student>";
echo "<input type=hidden name=id value=$cm->id>";
echo "<input type=submit value=\"".get_string("savechanges")."\">";
echo "</blockquote>";
echo "</form>";
echo "</center>";
print_footer($course);
break;
case "download":
print_header("$survey->name: $strdownload", "$strdownload");
print_heading($strdownload);
$strdownloadinfo = get_string("downloadinfo", "survey");
$strdownloadexcel = get_string("downloadexcel", "survey");
$strdownloadtext = get_string("downloadtext", "survey");
echo '<p align="center">'.get_string("downloadinfo", "survey").'</p>';
echo "<P>$strdownloadinfo</P>";
echo '<center>';
$options["id"] = "$cm->id";
$options["type"] = "xls";
print_single_button("download.php", $options, get_string("downloadexcel", "survey"));
echo "<H2 ALIGN=CENTER><A HREF=\"download.php?id=$id&type=xls\">$strdownloadexcel</A></H2>";
echo "<H2 ALIGN=CENTER><A HREF=\"download.php?id=$id&type=text\">$strdownloadtext</A></H2>";
print_footer($course);
$options["type"] = "txt";
print_single_button("download.php", $options, get_string("downloadtext", "survey"));
echo '</center>';
break;
}
print_footer($course);
?>
+1 -1
View File
@@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2004013101;
$module->version = 2004021600;
$module->requires = 2004013101; // Requires this Moodle version
$module->cron = 0;
+33 -6
View File
@@ -18,6 +18,12 @@
if (! $survey = get_record("survey", "id", $cm->instance)) {
error("Survey ID was incorrect");
}
if (! $template = get_record("survey", "id", $survey->template)) {
error("Template ID was incorrect");
}
$showscales = ($template->name != 'ciqname');
if ($course->category) {
$navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
@@ -32,7 +38,7 @@
if (isteacher($course->id)) {
$numusers = survey_count_responses($survey->id);
echo "<P align=right><A HREF=\"report.php?id=$cm->id\">".
echo "<p align=right><a href=\"report.php?id=$cm->id\">".
get_string("viewsurveyresponses", "survey", $numusers)."</A></P>";
} else if (!$cm->visible) {
notice(get_string("activityiscurrentlyhidden"));
@@ -46,13 +52,34 @@
// Check the survey hasn't already been filled out.
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);
print_heading(get_string("surveycompleted", "survey"));
$numusers = survey_count_responses($survey->id);
print_heading(get_string("peoplecompleted", "survey", $numusers));
echo "<center>";
survey_print_graph("id=$cm->id&sid=$USER->id&type=student.png");
echo "</center>";
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");
echo "</center>";
} else {
$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 or $question->type == 1) {
if ($answer = survey_get_user_answer($survey->id, $question->id, $USER->id)) {
$table = NULL;
$table->head = array(get_string($question->text, "survey"));
$table->align = array ("left");
$table->data[] = array("$answer->answer1");
print_table($table);
}
}
}
}
print_footer($course);
exit;
}