From 7c8c335fa3a7e10ac93267e1f7882ff02cdf089c Mon Sep 17 00:00:00 2001
From: moodler
Date: Mon, 16 Feb 2004 16:13:31 +0000
Subject: [PATCH] Complete clean-up of the survey reports.
Frames are GONE. :-)
Also, a new survey: CIQ = Critical Incident Questionnaire
---
mod/survey/db/mysql.php | 11 ++
mod/survey/db/mysql.sql | 6 +
mod/survey/db/postgres7.php | 9 ++
mod/survey/db/postgres7.sql | 6 +
mod/survey/lib.php | 42 ++---
mod/survey/report.php | 299 +++++++++++++++++++-----------------
mod/survey/version.php | 2 +-
mod/survey/view.php | 39 ++++-
8 files changed, 249 insertions(+), 165 deletions(-)
diff --git a/mod/survey/db/mysql.php b/mod/survey/db/mysql.php
index 41c7c0e715..48df9e725d 100644
--- a/mod/survey/db/mysql.php
+++ b/mod/survey/db/mysql.php
@@ -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;
}
diff --git a/mod/survey/db/mysql.sql b/mod/survey/db/mysql.sql
index 40df0fbc0a..6ae60272ca 100755
--- a/mod/survey/db/mysql.sql
+++ b/mod/survey/db/mysql.sql
@@ -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, '');
#
diff --git a/mod/survey/db/postgres7.php b/mod/survey/db/postgres7.php
index 91c00d0017..eaab3078e1 100644
--- a/mod/survey/db/postgres7.php
+++ b/mod/survey/db/postgres7.php
@@ -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;
}
diff --git a/mod/survey/db/postgres7.sql b/mod/survey/db/postgres7.sql
index d3865c7e53..5a1a860704 100755
--- a/mod/survey/db/postgres7.sql
+++ b/mod/survey/db/postgres7.sql
@@ -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
diff --git a/mod/survey/lib.php b/mod/survey/lib.php
index 64ab2da230..2844f7f59d 100644
--- a/mod/survey/lib.php
+++ b/mod/survey/lib.php
@@ -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 "";
- echo "Name | Time | Answered |
";
+ $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 "";
- echo "id&id=$survey\">".fullname($a)." | ";
- echo "".userdate($a->time, $dateformat)." | ";
- echo "$a->numanswers | ";
- echo "
";
+ $table->data[] = array(print_user_picture($a->id, $courseid, $a->picture, false, true, false),
+ "id&id=$cmid\">".fullname($a)."",
+ userdate($a->time), $a->numanswers);
}
- echo "
";
+
+ print_table($table);
}
diff --git a/mod/survey/report.php b/mod/survey/report.php
index 6cd5dc77c3..035e16e959 100644
--- a/mod/survey/report.php
+++ b/mod/survey/report.php
@@ -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 = "id\">$course->shortname ->
+ id\">$strsurveys ->
+ id\">$survey->name -> ";
+ } else {
+ $navigation = "id\">$strsurveys ->
+ id\">$survey->name -> ";
}
- if (!empty($display)) { // Display the frame containing something.
- add_to_log($course->id, "survey", "view report", "report.php?id=$cm->id", "$survey->id");
- echo "$course->shortname: $strreport: $survey->name\n";
- echo "\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 "$strsummary";
+ echo " $strscales";
+ echo " $strquestions";
+ echo " $course->students";
+ echo " $strdownload";
+ } else {
+ echo "$strquestions";
+ echo " $course->students";
+ echo " $strdownload";
}
+ print_simple_box_end();
- switch ($action) {
- case "top":
- if ($course->category) {
- $navigation = "framename}\" HREF=\"../../course/view.php?id=$course->id\">$course->shortname ->
- framename}\" HREF=\"index.php?id=$course->id\">$strsurveys ->
- framename}\" HREF=\"view.php?id=$cm->id\">$survey->name -> ";
- } else {
- $navigation = "framename}\" HREF=\"index.php?id=$course->id\">$strsurveys ->
- framename}\" HREF=\"view.php?id=$cm->id\">$survey->name -> ";
- }
- print_header("$course->shortname: $survey->name", "$course->fullname", "$navigation $strreport");
- break;
+ print_spacer(30,30);
- case "menu":
- print_header();
- echo "$strsummary
";
- echo "$strscales
";
- echo "$strquestions
";
- echo "$course->student:
";
- if ($users = survey_get_responses($survey->id)) {
- foreach ($users as $user) {
- echo "";
- echo "id&id=$id\">";
- echo "$user->firstname $user->lastname";
- echo "";
- }
- }
- echo "$strdownload
";
- break;
+
+/// Print the menu across the top
+
+ switch ($action) {
case "summary":
- print_header("$survey->name: $strsummary", "$strsummary - $strallscales");
+ print_heading($strsummary);
if (survey_count_responses($survey->id)) {
- echo "";
+ echo "";
survey_print_graph("id=$id&type=overall.png");
- echo "";
+ echo "
";
} else {
- echo "
".get_string("nobodyyet","survey")."
";
+ echo "".get_string("nobodyyet","survey")."
";
}
- 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 "multi>";
+ echo "multi>";
survey_print_graph("id=$id&qid=$question->id&type=multiquestion.png");
- echo "
";
+ echo "
";
}
}
- 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 "$question->text:
";
+ echo "$question->text:
";
$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 "";
- echo "id\">";
+ echo "";
+ echo "id\">";
survey_print_graph("id=$id&qid=$subquestion->id&type=question.png");
- echo "
";
+ echo "
";
}
}
} else if ($question->type > 0 ) {
- echo "";
- echo "id\">";
+ echo "";
+ echo "id\">";
survey_print_graph("id=$id&qid=$question->id&type=question.png");
- echo "
";
+ echo "
";
} else {
- echo "$question->text:
";
- if ($aaa = survey_get_user_answers($survey->id, $question->id)) {
- echo "";
+ $table = NULL;
+ $table->head = array($question->text);
+ $table->align = array ("left");
+
+ $contents = '';
+
+ if ($aaa = survey_get_user_answers($survey->id, $question->id, "sa.time ASC")) {
foreach ($aaa as $a) {
- echo "- $a->firstname $a->lastname: $a->answer1";
+ $contents .= "
";
+ $contents .= ''.fullname($a).' | ';
+ $contents .= ''.$a->answer1.' | ';
+ $contents .= "
";
}
- echo "";
}
+ $contents .= "
";
+
+ $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 " | $strname | $strtime | $stractual | $strpreferred |
";
+ $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 "";
- echo "";
- print_user_picture($a->userid, $course->id, $a->picture, false);
- echo " | ";
- echo "userid\">$a->firstname $a->lastname | ";
- echo "".userdate($a->time, $strdateformat)." | ";
- echo "cellcontent\"> ";
if ($a->answer1) {
- echo "$a->answer1 - ".$answers[$a->answer1 - 1];
+ $answer1 = "$a->answer1 - ".$answers[$a->answer1 - 1];
} else {
- echo " ";
+ $answer1 = " ";
}
- echo " | cellcontent\"> ";
if ($a->answer2) {
- echo "$a->answer2 - ".$answers[$a->answer2 - 1];
+ $answer2 = "$a->answer2 - ".$answers[$a->answer2 - 1];
} else {
- echo " ";
+ $answer2 = " ";
}
- echo " |
";
+
+ $table->data[] = array(
+ print_user_picture($a->userid, $course->id, $a->picture, false, true, true),
+ "userid\">".fullname($a)."",
+ userdate($a->time),
+ $answer1, $answer2);
}
}
- echo "
";
+ 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 "";
+ echo "
";
print_user_picture($user->id, $course->id, $user->picture, true);
- echo "
";
+ echo "
";
- // Print overall summary
- echo "";
- survey_print_graph("id=$id&sid=$student&type=student.png");
- echo "
";
-
- // 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;
+
+ if ($showscales) {
+ // Print overall summary
+ echo "";
+ survey_print_graph("id=$id&sid=$student&type=student.png");
+ echo "
";
+
+ // 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;
+ }
}
- }
-
+
+ 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 "";
+ echo "multi>";
+ survey_print_graph("id=$id&qid=$question->id&sid=$student&type=studentmultiquestion.png");
+ echo "
";
+ }
+ }
+ }
+
+ // Print non-scale questions
+
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 ($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);
}
- echo "";
- echo "multi>";
- survey_print_graph("id=$id&qid=$question->id&sid=$student&type=studentmultiquestion.png");
- echo "
";
- }
+ }
}
if ($rs = survey_get_analysis($survey->id, $user->id)) {
@@ -328,40 +346,41 @@
} else {
$notes = "";
}
- echo "
";
- echo "";
- echo "";
+ echo "";
- 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 ''.get_string("downloadinfo", "survey").'
';
- echo "$strdownloadinfo
";
+ echo '';
+ $options["id"] = "$cm->id";
+ $options["type"] = "xls";
+ print_single_button("download.php", $options, get_string("downloadexcel", "survey"));
- echo "";
- echo "";
-
- print_footer($course);
+ $options["type"] = "txt";
+ print_single_button("download.php", $options, get_string("downloadtext", "survey"));
+ echo '';
+
break;
}
+ print_footer($course);
?>
diff --git a/mod/survey/version.php b/mod/survey/version.php
index cf8e3400d0..5e80d3b154 100644
--- a/mod/survey/version.php
+++ b/mod/survey/version.php
@@ -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;
diff --git a/mod/survey/view.php b/mod/survey/view.php
index f58baf466f..f88a6217da 100644
--- a/mod/survey/view.php
+++ b/mod/survey/view.php
@@ -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 = "id\">$course->shortname ->";
@@ -32,7 +38,7 @@
if (isteacher($course->id)) {
$numusers = survey_count_responses($survey->id);
- echo "id\">".
+ echo "id\">".
get_string("viewsurveyresponses", "survey", $numusers)."
";
} 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 "";
- survey_print_graph("id=$cm->id&sid=$USER->id&type=student.png");
- echo "";
+
+ if ($showscales) {
+ print_heading(get_string("surveycompleted", "survey"));
+ print_heading(get_string("peoplecompleted", "survey", $numusers));
+ echo "";
+ survey_print_graph("id=$cm->id&sid=$USER->id&type=student.png");
+ echo "";
+
+ } 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;
}
--
2.39.5