2004-09-12 17:34:35 +00:00
|
|
|
<?php // $Id$
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2003-01-05 14:19:20 +00:00
|
|
|
require_once("../../config.php");
|
|
|
|
require_once("lib.php");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
// Check that all the parameters have been provided.
|
2005-02-16 10:40:48 +00:00
|
|
|
|
2006-04-27 21:30:18 +00:00
|
|
|
$id = required_param('id', PARAM_INT); // Course Module ID
|
|
|
|
$action = optional_param('action', '', PARAM_ALPHA); // What to look at
|
2006-08-17 21:34:39 +00:00
|
|
|
$qid = optional_param('qid', 0, PARAM_RAW); // Question IDs comma-separated list
|
2006-04-27 21:30:18 +00:00
|
|
|
$student = optional_param('student', 0, PARAM_INT); // Student ID
|
|
|
|
$notes = optional_param('notes', '', PARAM_RAW); // Save teachers notes
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2006-08-17 21:34:39 +00:00
|
|
|
$qids = explode(',', $qid);
|
|
|
|
$qids = clean_param($qids, PARAM_INT);
|
|
|
|
$qid = implode (',', $qids);
|
|
|
|
|
2006-08-08 22:09:55 +00:00
|
|
|
if (! $cm = get_coursemodule_from_id('survey', $id)) {
|
2001-11-22 06:23:56 +00:00
|
|
|
error("Course Module ID was incorrect");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! $course = get_record("course", "id", $cm->course)) {
|
|
|
|
error("Course is misconfigured");
|
|
|
|
}
|
|
|
|
|
2007-08-17 12:49:28 +00:00
|
|
|
require_login($course->id, false, $cm);
|
2006-08-08 05:13:06 +00:00
|
|
|
|
2006-08-09 13:39:44 +00:00
|
|
|
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
2006-08-14 05:55:40 +00:00
|
|
|
|
|
|
|
require_capability('mod/survey:readresponses', $context);
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
if (! $survey = get_record("survey", "id", $cm->instance)) {
|
|
|
|
error("Survey ID was incorrect");
|
|
|
|
}
|
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
if (! $template = get_record("survey", "id", $survey->template)) {
|
|
|
|
error("Template ID was incorrect");
|
|
|
|
}
|
|
|
|
|
|
|
|
$showscales = ($template->name != 'ciqname');
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
|
2002-08-12 17:54:00 +00:00
|
|
|
$strreport = get_string("report", "survey");
|
2004-02-16 16:13:31 +00:00
|
|
|
$strsurvey = get_string("modulename", "survey");
|
2002-08-12 17:54:00 +00:00
|
|
|
$strsurveys = get_string("modulenameplural", "survey");
|
|
|
|
$strsummary = get_string("summary", "survey");
|
|
|
|
$strscales = get_string("scales", "survey");
|
|
|
|
$strquestion = get_string("question", "survey");
|
|
|
|
$strquestions = get_string("questions", "survey");
|
|
|
|
$strdownload = get_string("download", "survey");
|
|
|
|
$strallscales = get_string("allscales", "survey");
|
|
|
|
$strallquestions = get_string("allquestions", "survey");
|
|
|
|
$strselectedquestions = get_string("selectedquestions", "survey");
|
|
|
|
$strseemoredetail = get_string("seemoredetail", "survey");
|
|
|
|
$strnotes = get_string("notes", "survey");
|
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
add_to_log($course->id, "survey", "view report", "report.php?id=$cm->id", "$survey->id", $cm->id);
|
|
|
|
|
2006-11-12 08:55:13 +00:00
|
|
|
if ($course->id != SITEID) {
|
2004-02-16 16:13:31 +00:00
|
|
|
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->
|
|
|
|
<a href=\"index.php?id=$course->id\">$strsurveys</a> ->
|
2005-04-06 18:20:05 +00:00
|
|
|
<a href=\"view.php?id=$cm->id\">".format_string($survey->name,true)."</a> -> ";
|
2004-02-16 16:13:31 +00:00
|
|
|
} else {
|
|
|
|
$navigation = "<a href=\"index.php?id=$course->id\">$strsurveys</a> ->
|
2005-04-06 18:20:05 +00:00
|
|
|
<a href=\"view.php?id=$cm->id\">".format_string($survey->name,true)."</a> -> ";
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2007-04-16 21:29:42 +00:00
|
|
|
|
2007-10-12 15:55:49 +00:00
|
|
|
$navigation = build_navigation($strreport, $cm);
|
2007-04-16 21:29:42 +00:00
|
|
|
print_header("$course->shortname: ".format_string($survey->name), $course->fullname, $navigation,
|
2004-02-16 16:13:31 +00:00
|
|
|
"", "", true,
|
|
|
|
update_module_button($cm->id, $course->id, $strsurvey), navmenu($course, $cm));
|
|
|
|
|
2004-02-20 16:03:05 +00:00
|
|
|
/// Check to see if groups are being used in this survey
|
2007-08-28 00:12:01 +00:00
|
|
|
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
|
2004-03-13 13:33:20 +00:00
|
|
|
$menuaction = $action == "student" ? "students" : $action;
|
2007-08-28 00:12:01 +00:00
|
|
|
$currentgroup = groups_get_activity_group($cm, true);
|
|
|
|
groups_print_activity_menu($cm, "report.php?id=$cm->id&action=$menuaction&qid=$qid");
|
2004-02-20 16:03:05 +00:00
|
|
|
} else {
|
|
|
|
$currentgroup = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($currentgroup) {
|
2007-08-28 00:12:01 +00:00
|
|
|
$users = groups_get_members($currentgroup);
|
|
|
|
} else if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
|
|
|
|
$users = groups_get_grouping_members($cm->groupingid);
|
2004-02-20 16:03:05 +00:00
|
|
|
} else {
|
|
|
|
$users = get_course_users($course->id);
|
|
|
|
}
|
2007-08-28 00:12:01 +00:00
|
|
|
$groupingid = $cm->groupingid;
|
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
print_simple_box_start("center");
|
|
|
|
if ($showscales) {
|
2004-09-16 17:13:57 +00:00
|
|
|
echo "<a href=\"report.php?action=summary&id=$id\">$strsummary</a>";
|
|
|
|
echo " <a href=\"report.php?action=scales&id=$id\">$strscales</a>";
|
|
|
|
echo " <a href=\"report.php?action=questions&id=$id\">$strquestions</a>";
|
|
|
|
echo " <a href=\"report.php?action=students&id=$id\">$course->students</a>";
|
2006-08-14 05:55:40 +00:00
|
|
|
if (has_capability('mod/survey:download', $context)) {
|
2006-08-09 13:39:44 +00:00
|
|
|
echo " <a href=\"report.php?action=download&id=$id\">$strdownload</a>";
|
2006-08-08 05:13:06 +00:00
|
|
|
}
|
2004-02-20 16:03:05 +00:00
|
|
|
if (empty($action)) {
|
|
|
|
$action = "summary";
|
|
|
|
}
|
2004-02-16 16:13:31 +00:00
|
|
|
} else {
|
2004-09-16 17:13:57 +00:00
|
|
|
echo "<a href=\"report.php?action=questions&id=$id\">$strquestions</a>";
|
|
|
|
echo " <a href=\"report.php?action=students&id=$id\">$course->students</a>";
|
2006-08-14 05:55:40 +00:00
|
|
|
if (has_capability('mod/survey:download', $context)) {
|
2006-08-09 13:39:44 +00:00
|
|
|
echo " <a href=\"report.php?action=download&id=$id\">$strdownload</a>";
|
|
|
|
}
|
2004-02-20 16:03:05 +00:00
|
|
|
if (empty($action)) {
|
|
|
|
$action = "questions";
|
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2004-02-16 16:13:31 +00:00
|
|
|
print_simple_box_end();
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
print_spacer(30,30);
|
2002-08-12 17:54:00 +00:00
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
|
|
|
|
/// Print the menu across the top
|
|
|
|
|
2006-04-27 21:30:18 +00:00
|
|
|
$virtualscales = false;
|
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
switch ($action) {
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
case "summary":
|
2004-02-16 16:13:31 +00:00
|
|
|
print_heading($strsummary);
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2007-08-28 00:12:01 +00:00
|
|
|
if (survey_count_responses($survey->id, $currentgroup, $groupingid)) {
|
2007-01-08 05:47:12 +00:00
|
|
|
echo "<div class='reportsummary'><a href=\"report.php?action=scales&id=$id\">";
|
2004-09-16 17:13:57 +00:00
|
|
|
survey_print_graph("id=$id&group=$currentgroup&type=overall.png");
|
2007-01-08 05:47:12 +00:00
|
|
|
echo "</a></div>";
|
2002-06-25 07:17:51 +00:00
|
|
|
} else {
|
2004-03-20 09:39:17 +00:00
|
|
|
notify(get_string("nobodyyet","survey"));
|
2002-06-25 07:17:51 +00:00
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case "scales":
|
2004-02-16 16:13:31 +00:00
|
|
|
print_heading($strscales);
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2007-08-28 00:12:01 +00:00
|
|
|
if (! $results = survey_get_responses($survey->id, $currentgroup, $groupingid) ) {
|
2004-03-20 09:39:17 +00:00
|
|
|
notify(get_string("nobodyyet","survey"));
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-03-20 09:39:17 +00:00
|
|
|
} else {
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-03-20 09:39:17 +00:00
|
|
|
$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;
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2004-03-20 09:39:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($questionorder as $key => $val) {
|
|
|
|
$question = $questions[$val];
|
|
|
|
if ($question->multi) {
|
2005-03-11 14:57:07 +00:00
|
|
|
if (!empty($virtualscales) && $question->type > 0) { // Don't show non-virtual scales if virtual
|
2004-03-20 09:39:17 +00:00
|
|
|
continue;
|
|
|
|
}
|
2007-01-08 05:47:12 +00:00
|
|
|
echo "<p class=\"centerpara\"><a title=\"$strseemoredetail\" href=\"report.php?action=questions&id=$id&qid=$question->multi\">";
|
2004-09-16 17:13:57 +00:00
|
|
|
survey_print_graph("id=$id&qid=$question->id&group=$currentgroup&type=multiquestion.png");
|
2004-09-12 14:41:49 +00:00
|
|
|
echo "</a></p><br />";
|
2005-02-16 10:40:48 +00:00
|
|
|
}
|
2004-03-20 09:39:17 +00:00
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "questions":
|
|
|
|
|
|
|
|
if ($qid) { // just get one multi-question
|
2002-12-23 05:57:05 +00:00
|
|
|
$questions = get_records_list("survey_questions", "id", $qid);
|
2001-11-22 06:23:56 +00:00
|
|
|
$questionorder = explode(",", $qid);
|
|
|
|
|
2002-08-14 06:13:20 +00:00
|
|
|
if ($scale = get_records("survey_questions", "multi", "$qid")) {
|
|
|
|
$scale = array_pop($scale);
|
2004-02-16 16:13:31 +00:00
|
|
|
print_heading("$scale->text - $strselectedquestions");
|
2002-08-14 06:27:24 +00:00
|
|
|
} else {
|
2004-02-16 16:13:31 +00:00
|
|
|
print_heading($strselectedquestions);
|
2002-08-14 06:13:20 +00:00
|
|
|
}
|
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
} else { // get all top-level questions
|
2002-12-23 05:57:05 +00:00
|
|
|
$questions = get_records_list("survey_questions", "id", $survey->questions);
|
2001-11-22 06:23:56 +00:00
|
|
|
$questionorder = explode(",", $survey->questions);
|
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
print_heading($strallquestions);
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
2007-08-28 00:12:01 +00:00
|
|
|
if (! $results = survey_get_responses($survey->id, $currentgroup, $groupingid) ) {
|
2004-03-20 09:39:17 +00:00
|
|
|
notify(get_string("nobodyyet","survey"));
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-03-20 09:39:17 +00:00
|
|
|
} else {
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-03-20 09:39:17 +00:00
|
|
|
foreach ($questionorder as $key => $val) {
|
|
|
|
$question = $questions[$val];
|
|
|
|
if ($question->type < 0) { // We have some virtual scales. DON'T show them.
|
|
|
|
$virtualscales = true;
|
|
|
|
break;
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2004-03-20 09:39:17 +00:00
|
|
|
}
|
2003-01-05 06:45:20 +00:00
|
|
|
|
2004-03-20 09:39:17 +00:00
|
|
|
foreach ($questionorder as $key => $val) {
|
|
|
|
$question = $questions[$val];
|
|
|
|
|
|
|
|
if ($question->type < 0) { // We have some virtual scales. DON'T show them.
|
|
|
|
continue;
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2004-03-20 09:39:17 +00:00
|
|
|
$question->text = get_string($question->text, "survey");
|
|
|
|
|
|
|
|
if ($question->multi) {
|
|
|
|
echo "<h3>$question->text:</h3>";
|
|
|
|
|
|
|
|
$subquestions = get_records_list("survey_questions", "id", $question->multi);
|
|
|
|
$subquestionorder = explode(",", $question->multi);
|
|
|
|
foreach ($subquestionorder as $key => $val) {
|
|
|
|
$subquestion = $subquestions[$val];
|
|
|
|
if ($subquestion->type > 0) {
|
2007-01-08 05:47:12 +00:00
|
|
|
echo "<p class=\"centerpara\">";
|
2004-09-16 17:13:57 +00:00
|
|
|
echo "<a title=\"$strseemoredetail\" href=\"report.php?action=question&id=$id&qid=$subquestion->id\">";
|
|
|
|
survey_print_graph("id=$id&qid=$subquestion->id&group=$currentgroup&type=question.png");
|
2004-03-20 09:39:17 +00:00
|
|
|
echo "</a></p>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ($question->type > 0 ) {
|
2007-01-08 05:47:12 +00:00
|
|
|
echo "<p class=\"centerpara\">";
|
2004-09-16 17:13:57 +00:00
|
|
|
echo "<a title=\"$strseemoredetail\" href=\"report.php?action=question&id=$id&qid=$question->id\">";
|
|
|
|
survey_print_graph("id=$id&qid=$question->id&group=$currentgroup&type=question.png");
|
2004-03-20 09:39:17 +00:00
|
|
|
echo "</a></p>";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$table = NULL;
|
|
|
|
$table->head = array($question->text);
|
|
|
|
$table->align = array ("left");
|
|
|
|
|
|
|
|
$contents = '<table cellpadding="15" width="100%">';
|
|
|
|
|
|
|
|
if ($aaa = survey_get_user_answers($survey->id, $question->id, $currentgroup, "sa.time ASC")) {
|
|
|
|
foreach ($aaa as $a) {
|
|
|
|
$contents .= "<tr>";
|
2007-01-08 05:47:12 +00:00
|
|
|
$contents .= '<td class="fullnamecell">'.fullname($a).'</td>';
|
2004-03-20 09:39:17 +00:00
|
|
|
$contents .= '<td valign="top">'.$a->answer1.'</td>';
|
|
|
|
$contents .= "</tr>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$contents .= "</table>";
|
2004-02-16 16:13:31 +00:00
|
|
|
|
2004-03-20 09:39:17 +00:00
|
|
|
$table->data[] = array($contents);
|
2004-02-16 16:13:31 +00:00
|
|
|
|
2004-03-20 09:39:17 +00:00
|
|
|
print_table($table);
|
|
|
|
print_spacer(30);
|
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "question":
|
|
|
|
if (!$question = get_record("survey_questions", "id", $qid)) {
|
|
|
|
error("Question doesn't exist");
|
|
|
|
}
|
2002-12-23 10:18:51 +00:00
|
|
|
$question->text = get_string($question->text, "survey");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-11-09 06:22:57 +00:00
|
|
|
$answers = explode(",", get_string($question->options, "survey"));
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
print_heading("$strquestion: $question->text");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
|
2002-08-12 17:54:00 +00:00
|
|
|
$strname = get_string("name", "survey");
|
|
|
|
$strtime = get_string("time", "survey");
|
|
|
|
$stractual = get_string("actual", "survey");
|
|
|
|
$strpreferred = get_string("preferred", "survey");
|
2003-01-15 10:55:54 +00:00
|
|
|
$strdateformat = get_string("strftimedatetime");
|
2002-08-12 17:54:00 +00:00
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
$table = NULL;
|
|
|
|
$table->head = array("", $strname, $strtime, $stractual, $strpreferred);
|
|
|
|
$table->align = array ("left", "left", "left", "left", "right");
|
|
|
|
$table->size = array (35, "", "", "", "");
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-02-20 16:03:05 +00:00
|
|
|
if ($aaa = survey_get_user_answers($survey->id, $question->id, $currentgroup)) {
|
2002-12-23 05:57:05 +00:00
|
|
|
foreach ($aaa as $a) {
|
|
|
|
if ($a->answer1) {
|
2004-02-16 16:13:31 +00:00
|
|
|
$answer1 = "$a->answer1 - ".$answers[$a->answer1 - 1];
|
2002-12-23 05:57:05 +00:00
|
|
|
} else {
|
2004-02-16 16:13:31 +00:00
|
|
|
$answer1 = " ";
|
2002-12-23 05:57:05 +00:00
|
|
|
}
|
|
|
|
if ($a->answer2) {
|
2004-02-16 16:13:31 +00:00
|
|
|
$answer2 = "$a->answer2 - ".$answers[$a->answer2 - 1];
|
2002-12-23 05:57:05 +00:00
|
|
|
} else {
|
2004-02-16 16:13:31 +00:00
|
|
|
$answer2 = " ";
|
2002-12-23 05:57:05 +00:00
|
|
|
}
|
2004-02-16 16:13:31 +00:00
|
|
|
|
|
|
|
$table->data[] = array(
|
|
|
|
print_user_picture($a->userid, $course->id, $a->picture, false, true, true),
|
2004-09-16 17:13:57 +00:00
|
|
|
"<a href=\"report.php?id=$id&action=student&student=$a->userid\">".fullname($a)."</a>",
|
2005-02-16 10:40:48 +00:00
|
|
|
userdate($a->time),
|
2004-02-16 16:13:31 +00:00
|
|
|
$answer1, $answer2);
|
2005-02-16 10:40:48 +00:00
|
|
|
|
2002-12-23 05:57:05 +00:00
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
print_table($table);
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "students":
|
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
print_heading(get_string("analysisof", "survey", "$course->students"));
|
2005-02-16 10:40:48 +00:00
|
|
|
|
2007-08-28 00:12:01 +00:00
|
|
|
if (! $results = survey_get_responses($survey->id, $currentgroup, $groupingid) ) {
|
2002-08-12 17:54:00 +00:00
|
|
|
notify(get_string("nobodyyet","survey"));
|
2001-11-22 06:23:56 +00:00
|
|
|
} else {
|
2004-02-16 16:13:31 +00:00
|
|
|
survey_print_all_responses($cm->id, $results, $course->id);
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "student":
|
|
|
|
if (!$user = get_record("user", "id", $student)) {
|
|
|
|
error("Student doesn't exist");
|
|
|
|
}
|
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
print_heading(get_string("analysisof", "survey", fullname($user)));
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2006-04-27 21:30:18 +00:00
|
|
|
if ($notes != '' and confirm_sesskey()) {
|
2002-08-01 04:49:26 +00:00
|
|
|
if (survey_get_analysis($survey->id, $user->id)) {
|
|
|
|
if (! survey_update_analysis($survey->id, $user->id, $notes)) {
|
2001-11-22 06:23:56 +00:00
|
|
|
notify("An error occurred while saving your notes. Sorry.");
|
2002-08-12 17:54:00 +00:00
|
|
|
} else {
|
|
|
|
notify(get_string("savednotes", "survey"));
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
} else {
|
2002-08-01 04:49:26 +00:00
|
|
|
if (! survey_add_analysis($survey->id, $user->id, $notes)) {
|
2001-11-22 06:23:56 +00:00
|
|
|
notify("An error occurred while saving your notes. Sorry.");
|
2002-08-12 17:54:00 +00:00
|
|
|
} else {
|
|
|
|
notify(get_string("savednotes", "survey"));
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-08 05:47:12 +00:00
|
|
|
echo "<p <p class=\"centerpara\">";
|
2001-11-22 06:23:56 +00:00
|
|
|
print_user_picture($user->id, $course->id, $user->picture, true);
|
2004-02-16 16:13:31 +00:00
|
|
|
echo "</p>";
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-12-23 05:57:05 +00:00
|
|
|
$questions = get_records_list("survey_questions", "id", $survey->questions);
|
2001-11-22 06:23:56 +00:00
|
|
|
$questionorder = explode(",", $survey->questions);
|
2004-02-16 16:13:31 +00:00
|
|
|
|
|
|
|
if ($showscales) {
|
|
|
|
// Print overall summary
|
2007-01-08 05:47:12 +00:00
|
|
|
echo "<p <p class=\"centerpara\">>";
|
2004-09-16 17:13:57 +00:00
|
|
|
survey_print_graph("id=$id&sid=$student&type=student.png");
|
2004-02-16 16:13:31 +00:00
|
|
|
echo "</p>";
|
2005-02-16 10:40:48 +00:00
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
// Print scales
|
2005-02-16 10:40:48 +00:00
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
foreach ($questionorder as $key => $val) {
|
|
|
|
$question = $questions[$val];
|
|
|
|
if ($question->type < 0) { // We have some virtual scales. Just show them.
|
|
|
|
$virtualscales = true;
|
|
|
|
break;
|
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2005-02-16 10:40:48 +00:00
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
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;
|
|
|
|
}
|
2007-01-08 05:47:12 +00:00
|
|
|
echo "<p class=\"centerpara\">";
|
2004-09-16 17:13:57 +00:00
|
|
|
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");
|
2004-09-12 14:41:49 +00:00
|
|
|
echo "</a></p><br />";
|
2005-02-16 10:40:48 +00:00
|
|
|
}
|
2004-02-16 16:13:31 +00:00
|
|
|
}
|
2005-02-16 10:40:48 +00:00
|
|
|
}
|
2004-02-16 16:13:31 +00:00
|
|
|
|
|
|
|
// Print non-scale questions
|
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
foreach ($questionorder as $key => $val) {
|
|
|
|
$question = $questions[$val];
|
2004-02-16 16:13:31 +00:00
|
|
|
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");
|
2006-04-27 21:30:18 +00:00
|
|
|
$table->data[] = array(s($answer->answer1)); // no html here, just plain text
|
2004-02-16 16:13:31 +00:00
|
|
|
print_table($table);
|
|
|
|
print_spacer(30);
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
2004-02-16 16:13:31 +00:00
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
}
|
|
|
|
|
2002-08-01 04:49:26 +00:00
|
|
|
if ($rs = survey_get_analysis($survey->id, $user->id)) {
|
2001-11-22 06:23:56 +00:00
|
|
|
$notes = $rs->notes;
|
|
|
|
} else {
|
|
|
|
$notes = "";
|
|
|
|
}
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<hr noshade=\"noshade\" size=\"1\" />";
|
2007-01-08 05:47:12 +00:00
|
|
|
echo "<div class='studentreport'>";
|
2007-01-04 21:32:36 +00:00
|
|
|
echo "<form action=\"report.php\" method=\"post\">";
|
2004-02-16 16:13:31 +00:00
|
|
|
echo "<h3>$strnotes:</h3>";
|
|
|
|
echo "<blockquote>";
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<textarea name=\"notes\" rows=\"10\" cols=\"60\">";
|
2001-11-22 06:23:56 +00:00
|
|
|
p($notes);
|
2004-09-12 14:41:49 +00:00
|
|
|
echo "</textarea><br />";
|
2004-09-12 17:34:35 +00:00
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"student\" />";
|
2006-04-27 21:30:18 +00:00
|
|
|
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />";
|
2004-09-12 17:34:35 +00:00
|
|
|
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")."\" />";
|
2004-02-16 16:13:31 +00:00
|
|
|
echo "</blockquote>";
|
|
|
|
echo "</form>";
|
2007-01-08 05:47:12 +00:00
|
|
|
echo "</div>";
|
2005-02-16 10:40:48 +00:00
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "download":
|
2004-02-16 16:13:31 +00:00
|
|
|
print_heading($strdownload);
|
2002-08-12 17:54:00 +00:00
|
|
|
|
2006-08-14 05:55:40 +00:00
|
|
|
require_capability('mod/survey:download', $context);
|
|
|
|
|
2007-01-08 05:47:12 +00:00
|
|
|
echo '<p class="centerpara">'.get_string("downloadinfo", "survey").'</p>';
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2007-01-08 05:47:12 +00:00
|
|
|
echo '<div class="reportbuttons">';
|
2006-12-21 19:46:29 +00:00
|
|
|
$optons = array();
|
2004-02-16 16:13:31 +00:00
|
|
|
$options["id"] = "$cm->id";
|
2004-02-20 16:03:05 +00:00
|
|
|
$options["group"] = $currentgroup;
|
2006-12-21 19:46:29 +00:00
|
|
|
|
|
|
|
$options["type"] = "ods";
|
|
|
|
print_single_button("download.php", $options, get_string("downloadods"));
|
|
|
|
|
|
|
|
$options["type"] = "xls";
|
|
|
|
print_single_button("download.php", $options, get_string("downloadexcel"));
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2004-02-16 16:13:31 +00:00
|
|
|
$options["type"] = "txt";
|
2006-12-21 19:46:29 +00:00
|
|
|
print_single_button("download.php", $options, get_string("downloadtext"));
|
2007-01-08 05:47:12 +00:00
|
|
|
echo '</div>';
|
2005-02-16 10:40:48 +00:00
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2004-02-16 16:13:31 +00:00
|
|
|
print_footer($course);
|
2002-06-25 07:10:01 +00:00
|
|
|
?>
|