mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Groups support on Surveys. Phew.
This commit is contained in:
parent
74c82136ba
commit
a9ccbf60bf
@ -172,6 +172,11 @@ function survey_upgrade($oldversion) {
|
||||
table_column("survey_answers", "answer2", "answer2", "text", "", "", "");
|
||||
}
|
||||
|
||||
if ($oldversion < 2004021900) {
|
||||
modify_database("", "INSERT INTO prefix_log_display VALUES ('survey', 'add', 'survey', 'name');");
|
||||
modify_database("", "INSERT INTO prefix_log_display VALUES ('survey', 'update', 'survey', 'name');");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -178,6 +178,8 @@ INSERT INTO `prefix_survey_questions` (`id`, `text`, `shorttext`, `multi`, `intr
|
||||
# Dumping data for table `log_display`
|
||||
#
|
||||
|
||||
INSERT INTO prefix_log_display VALUES ('survey', 'add', 'survey', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('survey', 'update', 'survey', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('survey', 'download', 'survey', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('survey', 'view form', 'survey', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('survey', 'view graph', 'survey', 'name');
|
||||
|
@ -19,6 +19,10 @@ function survey_upgrade($oldversion) {
|
||||
table_column("survey_answers", "answer1", "answer1", "text", "", "", "");
|
||||
table_column("survey_answers", "answer2", "answer2", "text", "", "", "");
|
||||
}
|
||||
if ($oldversion < 2004021900) {
|
||||
modify_database("", "INSERT INTO prefix_log_display VALUES ('survey', 'add', 'survey', 'name');");
|
||||
modify_database("", "INSERT INTO prefix_log_display VALUES ('survey', 'update', 'survey', 'name');");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -172,6 +172,8 @@ INSERT INTO prefix_survey_questions (id, text, shorttext, multi, intro, type, op
|
||||
# Dumping data for table log_display
|
||||
#
|
||||
|
||||
INSERT INTO prefix_log_display VALUES ('survey', 'add', 'survey', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('survey', 'update', 'survey', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('survey', 'download', 'survey', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('survey', 'view form', 'survey', 'name');
|
||||
INSERT INTO prefix_log_display VALUES ('survey', 'view graph', 'survey', 'name');
|
||||
|
@ -15,10 +15,12 @@
|
||||
}
|
||||
|
||||
$streditingasurvey = get_string("editingasurvey", "survey");
|
||||
$strsurveys = get_string("modulenameplural", "survey");
|
||||
|
||||
print_header("$course->shortname: $streditingasurvey", "$course->fullname",
|
||||
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A>
|
||||
-> $streditingasurvey");
|
||||
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>".
|
||||
" -> <a href=\"index.php?id=$course->id\">$strsurveys</a>".
|
||||
" -> $form->name ($streditingasurvey)");
|
||||
|
||||
if (!$form->name or !$form->template) {
|
||||
error(get_string("filloutallfields"), $_SERVER["HTTP_REFERER"]);
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
require_variable($id); // Course Module ID
|
||||
optional_variable($type, "xls");
|
||||
optional_variable($group, 0);
|
||||
|
||||
if (! $cm = get_record("course_modules", "id", $id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
@ -25,8 +26,18 @@
|
||||
error("Survey ID was incorrect");
|
||||
}
|
||||
|
||||
add_to_log($course->id, "survey", "download", "download.php?id=$cm->id&type=$type", "$survey->id");
|
||||
add_to_log($course->id, "survey", "download", "download.php?id=$cm->id&type=$type", "$survey->id", $cm->id);
|
||||
|
||||
/// Check to see if groups are being used in this survey
|
||||
|
||||
$groupmode = groupmode($course, $cm); // Groups are being used
|
||||
|
||||
if ($groupmode and $group) {
|
||||
$users = get_users_in_group($group);
|
||||
} else {
|
||||
$users = get_course_users($course->id);
|
||||
$group = false;
|
||||
}
|
||||
|
||||
// Get all the questions and their proper order
|
||||
|
||||
@ -94,15 +105,17 @@
|
||||
}
|
||||
|
||||
foreach ($aaa as $a) {
|
||||
if (!$results["$a->userid"]) { // init new array
|
||||
$results["$a->userid"]["time"] = $a->time;
|
||||
foreach ($order as $key => $qid) {
|
||||
$results["$a->userid"]["$qid"]["answer1"] = "";
|
||||
$results["$a->userid"]["$qid"]["answer2"] = "";
|
||||
if (!$group or isset($users[$a->userid])) {
|
||||
if (!$results["$a->userid"]) { // init new array
|
||||
$results["$a->userid"]["time"] = $a->time;
|
||||
foreach ($order as $key => $qid) {
|
||||
$results["$a->userid"]["$qid"]["answer1"] = "";
|
||||
$results["$a->userid"]["$qid"]["answer2"] = "";
|
||||
}
|
||||
}
|
||||
$results["$a->userid"]["$a->question"]["answer1"] = $a->answer1;
|
||||
$results["$a->userid"]["$a->question"]["answer2"] = $a->answer2;
|
||||
}
|
||||
$results["$a->userid"]["$a->question"]["answer1"] = $a->answer1;
|
||||
$results["$a->userid"]["$a->question"]["answer2"] = $a->answer2;
|
||||
}
|
||||
|
||||
// Output the file as a valid Excel spreadsheet if required
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
require_variable($id); // Course Module ID
|
||||
require_variable($type); // Graph Type
|
||||
optional_variable($group, "0"); // Group ID
|
||||
optional_variable($sid); // Student ID
|
||||
|
||||
if (! $cm = get_record("course_modules", "id", $id)) {
|
||||
@ -18,8 +19,12 @@
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
if (!isteacher($course->id) && !isadmin()) {
|
||||
if (! ($type == "student.png" && $sid == $USER->id) ) {
|
||||
$groupmode = groupmode($course, $cm); // Groups are being used
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
if ($type != "student.png" or $sid != $USER->id ) {
|
||||
error("Sorry, you aren't allowed to see this.");
|
||||
} else if ($groupmode and !ismember($group)) {
|
||||
error("Sorry, you aren't allowed to see this.");
|
||||
}
|
||||
}
|
||||
@ -28,6 +33,14 @@
|
||||
error("Survey ID was incorrect");
|
||||
}
|
||||
|
||||
/// Check to see if groups are being used in this survey
|
||||
if ($groupmode and $group) {
|
||||
$users = get_users_in_group($group);
|
||||
} else {
|
||||
$users = get_course_users($course->id);
|
||||
$group = false;
|
||||
}
|
||||
|
||||
$stractual = get_string("actual", "survey");
|
||||
$stractualclass = get_string("actualclass", "survey");
|
||||
$stractualstudent = get_string("actualstudent", "survey", $course->student);
|
||||
@ -53,11 +66,13 @@
|
||||
|
||||
if ($aaa = get_records_select("survey_answers", "survey = '$cm->instance' AND question = '$qid'")) {
|
||||
foreach ($aaa as $aa) {
|
||||
if ($a1 = $aa->answer1) {
|
||||
$buckets1[$a1 - 1]++;
|
||||
}
|
||||
if ($a2 = $aa->answer2) {
|
||||
$buckets2[$a2 - 1]++;
|
||||
if (!$group or isset($users[$aa->userid])) {
|
||||
if ($a1 = $aa->answer1) {
|
||||
$buckets1[$a1 - 1]++;
|
||||
}
|
||||
if ($a2 = $aa->answer2) {
|
||||
$buckets2[$a2 - 1]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -127,14 +142,16 @@
|
||||
|
||||
if ($aaa) {
|
||||
foreach ($aaa as $a) {
|
||||
$index = $indexof[$a->question];
|
||||
if ($a->answer1) {
|
||||
$buckets1[$index] += $a->answer1;
|
||||
$count1[$index]++;
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$buckets2[$index] += $a->answer2;
|
||||
$count2[$index]++;
|
||||
if (!$group or isset($users[$a->userid])) {
|
||||
$index = $indexof[$a->question];
|
||||
if ($a->answer1) {
|
||||
$buckets1[$index] += $a->answer1;
|
||||
$count1[$index]++;
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$buckets2[$index] += $a->answer2;
|
||||
$count2[$index]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -150,14 +167,16 @@
|
||||
|
||||
if ($aaa) {
|
||||
foreach ($aaa as $a) {
|
||||
$index = $indexof[$a->question];
|
||||
if ($a->answer1) {
|
||||
$difference = (float) ($a->answer1 - $buckets1[$index]);
|
||||
$stdev1[$index] += ($difference * $difference);
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$difference = (float) ($a->answer2 - $buckets2[$index]);
|
||||
$stdev2[$index] += ($difference * $difference);
|
||||
if (!$group or isset($users[$a->userid])) {
|
||||
$index = $indexof[$a->question];
|
||||
if ($a->answer1) {
|
||||
$difference = (float) ($a->answer1 - $buckets1[$index]);
|
||||
$stdev1[$index] += ($difference * $difference);
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$difference = (float) ($a->answer2 - $buckets2[$index]);
|
||||
$stdev2[$index] += ($difference * $difference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -266,13 +285,15 @@
|
||||
|
||||
if ($aaa) {
|
||||
foreach ($aaa as $a) {
|
||||
if ($a->answer1) {
|
||||
$buckets1[$i] += $a->answer1;
|
||||
$count1[$i]++;
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$buckets2[$i] += $a->answer2;
|
||||
$count2[$i]++;
|
||||
if (!$group or isset($users[$a->userid])) {
|
||||
if ($a->answer1) {
|
||||
$buckets1[$i] += $a->answer1;
|
||||
$count1[$i]++;
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$buckets2[$i] += $a->answer2;
|
||||
$count2[$i]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -287,13 +308,15 @@
|
||||
// Calculate the standard devaiations
|
||||
if ($aaa) {
|
||||
foreach ($aaa as $a) {
|
||||
if ($a->answer1) {
|
||||
$difference = (float) ($a->answer1 - $buckets1[$i]);
|
||||
$stdev1[$i] += ($difference * $difference);
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$difference = (float) ($a->answer2 - $buckets2[$i]);
|
||||
$stdev2[$i] += ($difference * $difference);
|
||||
if (!$group or isset($users[$a->userid])) {
|
||||
if ($a->answer1) {
|
||||
$difference = (float) ($a->answer1 - $buckets1[$i]);
|
||||
$stdev1[$i] += ($difference * $difference);
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$difference = (float) ($a->answer2 - $buckets2[$i]);
|
||||
$stdev2[$i] += ($difference * $difference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -406,24 +429,26 @@
|
||||
|
||||
if ($aaa) {
|
||||
foreach ($aaa as $a) {
|
||||
if ($a->userid == $sid) {
|
||||
if (!$group or isset($users[$a->userid])) {
|
||||
if ($a->userid == $sid) {
|
||||
if ($a->answer1) {
|
||||
$studbuckets1[$i] += $a->answer1;
|
||||
$studcount1[$i]++;
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$studbuckets2[$i] += $a->answer2;
|
||||
$studcount2[$i]++;
|
||||
}
|
||||
}
|
||||
if ($a->answer1) {
|
||||
$studbuckets1[$i] += $a->answer1;
|
||||
$studcount1[$i]++;
|
||||
$buckets1[$i] += $a->answer1;
|
||||
$count1[$i]++;
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$studbuckets2[$i] += $a->answer2;
|
||||
$studcount2[$i]++;
|
||||
$buckets2[$i] += $a->answer2;
|
||||
$count2[$i]++;
|
||||
}
|
||||
}
|
||||
if ($a->answer1) {
|
||||
$buckets1[$i] += $a->answer1;
|
||||
$count1[$i]++;
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$buckets2[$i] += $a->answer2;
|
||||
$count2[$i]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -442,13 +467,15 @@
|
||||
|
||||
// Calculate the standard devaiations
|
||||
foreach ($aaa as $a) {
|
||||
if ($a->answer1) {
|
||||
$difference = (float) ($a->answer1 - $buckets1[$i]);
|
||||
$stdev1[$i] += ($difference * $difference);
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$difference = (float) ($a->answer2 - $buckets2[$i]);
|
||||
$stdev2[$i] += ($difference * $difference);
|
||||
if (!$group or isset($users[$a->userid])) {
|
||||
if ($a->answer1) {
|
||||
$difference = (float) ($a->answer1 - $buckets1[$i]);
|
||||
$stdev1[$i] += ($difference * $difference);
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$difference = (float) ($a->answer2 - $buckets2[$i]);
|
||||
$stdev2[$i] += ($difference * $difference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -553,24 +580,26 @@
|
||||
|
||||
if ($aaa) {
|
||||
foreach ($aaa as $a) {
|
||||
$index = $indexof[$a->question];
|
||||
if ($a->userid == $sid) {
|
||||
if ($a->answer1) {
|
||||
$studbuckets1[$index] += $a->answer1;
|
||||
$studcount1[$index]++;
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$studbuckets2[$index] += $a->answer2;
|
||||
$studcount2[$index]++;
|
||||
if (!$group or isset($users[$a->userid])) {
|
||||
$index = $indexof[$a->question];
|
||||
if ($a->userid == $sid) {
|
||||
if ($a->answer1) {
|
||||
$studbuckets1[$index] += $a->answer1;
|
||||
$studcount1[$index]++;
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$studbuckets2[$index] += $a->answer2;
|
||||
$studcount2[$index]++;
|
||||
}
|
||||
}
|
||||
if ($a->answer1) {
|
||||
$buckets1[$index] += $a->answer1;
|
||||
$count1[$index]++;
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$buckets2[$index] += $a->answer2;
|
||||
$count2[$index]++;
|
||||
}
|
||||
if ($a->answer1) {
|
||||
$buckets1[$index] += $a->answer1;
|
||||
$count1[$index]++;
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$buckets2[$index] += $a->answer2;
|
||||
$count2[$index]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -591,14 +620,16 @@
|
||||
}
|
||||
|
||||
foreach ($aaa as $a) {
|
||||
$index = $indexof[$a->question];
|
||||
if ($a->answer1) {
|
||||
$difference = (float) ($a->answer1 - $buckets1[$index]);
|
||||
$stdev1[$index] += ($difference * $difference);
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$difference = (float) ($a->answer2 - $buckets2[$index]);
|
||||
$stdev2[$index] += ($difference * $difference);
|
||||
if (!$group or isset($users[$a->userid])) {
|
||||
$index = $indexof[$a->question];
|
||||
if ($a->answer1) {
|
||||
$difference = (float) ($a->answer1 - $buckets1[$index]);
|
||||
$stdev1[$index] += ($difference * $difference);
|
||||
}
|
||||
if ($a->answer2) {
|
||||
$difference = (float) ($a->answer2 - $buckets2[$index]);
|
||||
$stdev2[$index] += ($difference * $difference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,15 +185,23 @@ function survey_log_info($log) {
|
||||
AND u.id = '$log->userid'");
|
||||
}
|
||||
|
||||
function survey_get_responses($survey) {
|
||||
function survey_get_responses($surveyid, $groupid) {
|
||||
global $CFG;
|
||||
|
||||
if ($groupid) {
|
||||
$groupsql = "AND gm.groupid = $groupid AND u.id = gm.userid";
|
||||
} else {
|
||||
$groupsql = "";
|
||||
}
|
||||
|
||||
return get_records_sql("SELECT MAX(a.time) as time,
|
||||
count(*) as numanswers,
|
||||
u.id, u.firstname, u.lastname, u.picture
|
||||
FROM {$CFG->prefix}survey_answers AS a,
|
||||
{$CFG->prefix}user AS u
|
||||
WHERE a.survey = $survey
|
||||
AND a.userid = u.id
|
||||
{$CFG->prefix}user AS u,
|
||||
{$CFG->prefix}groups_members AS gm
|
||||
WHERE a.survey = $surveyid
|
||||
AND a.userid = u.id $groupsql
|
||||
GROUP BY u.id, u.firstname, u.lastname
|
||||
ORDER BY time ASC");
|
||||
}
|
||||
@ -217,15 +225,22 @@ function survey_update_analysis($survey, $user, $notes) {
|
||||
}
|
||||
|
||||
|
||||
function survey_get_user_answers($surveyid, $questionid, $sort="sa.answer1,sa.answer2 ASC") {
|
||||
function survey_get_user_answers($surveyid, $questionid, $groupid, $sort="sa.answer1,sa.answer2 ASC") {
|
||||
global $CFG;
|
||||
|
||||
if ($groupid) {
|
||||
$groupsql = "AND gm.groupid = $groupid AND u.id = gm.userid";
|
||||
} else {
|
||||
$groupsql = "";
|
||||
}
|
||||
|
||||
return get_records_sql("SELECT sa.*,u.firstname,u.lastname,u.picture
|
||||
FROM {$CFG->prefix}survey_answers sa,
|
||||
{$CFG->prefix}user u
|
||||
{$CFG->prefix}user u,
|
||||
{$CFG->prefix}groups_members gm
|
||||
WHERE sa.survey = '$surveyid'
|
||||
AND sa.question = $questionid
|
||||
AND u.id = sa.userid
|
||||
AND u.id = sa.userid $groupsql
|
||||
ORDER BY $sort");
|
||||
}
|
||||
|
||||
@ -255,8 +270,8 @@ function survey_already_done($survey, $user) {
|
||||
return record_exists("survey_answers", "survey", $survey, "userid", $user);
|
||||
}
|
||||
|
||||
function survey_count_responses($survey) {
|
||||
if ($responses = survey_get_responses($survey)) {
|
||||
function survey_count_responses($surveyid, $groupid) {
|
||||
if ($responses = survey_get_responses($surveyid, $groupid)) {
|
||||
return count($responses);
|
||||
} else {
|
||||
return 0;
|
||||
@ -439,8 +454,8 @@ function survey_print_graph($url) {
|
||||
echo "(".get_string("gdneed").")";
|
||||
|
||||
} else {
|
||||
echo "<IMG HEIGHT=\"$SURVEY_GHEIGHT\" WIDTH=\"$SURVEY_GWIDTH\" BORDER=1".
|
||||
" SRC=\"$CFG->wwwroot/mod/survey/graph.php?$url\">";
|
||||
echo "<img height=\"$survey_gheight\" width=\"$survey_gwidth\" border=\"1\"".
|
||||
" src=\"$CFG->wwwroot/mod/survey/graph.php?$url\">";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,9 @@
|
||||
|
||||
// Check that all the parameters have been provided.
|
||||
|
||||
require_variable($id); // Course Module ID
|
||||
optional_variable($action, "students"); // What to look at
|
||||
require_variable($id); // Course Module ID
|
||||
optional_variable($action, ""); // What to look at
|
||||
optional_variable($qid, "0"); // Question id
|
||||
|
||||
if (! $cm = get_record("course_modules", "id", $id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
@ -62,6 +63,20 @@
|
||||
"", "", true,
|
||||
update_module_button($cm->id, $course->id, $strsurvey), navmenu($course, $cm));
|
||||
|
||||
/// Check to see if groups are being used in this survey
|
||||
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
|
||||
$currentgroup = setup_and_print_groups($course, $groupmode,
|
||||
"report.php?id=$cm->id&action=$action&qid=$qid");
|
||||
} else {
|
||||
$currentgroup = 0;
|
||||
}
|
||||
|
||||
if ($currentgroup) {
|
||||
$users = get_users_in_group($currentgroup);
|
||||
} else {
|
||||
$users = get_course_users($course->id);
|
||||
}
|
||||
|
||||
print_simple_box_start("center");
|
||||
if ($showscales) {
|
||||
echo "<a href=\"report.php?action=summary&id=$id\">$strsummary</a>";
|
||||
@ -69,10 +84,16 @@
|
||||
echo " <a href=\"report.php?action=questions&id=$id\">$strquestions</a>";
|
||||
echo " <a href=\"report.php?action=students&id=$id\">$course->students</a>";
|
||||
echo " <a href=\"report.php?action=download&id=$id\">$strdownload</a>";
|
||||
if (empty($action)) {
|
||||
$action = "summary";
|
||||
}
|
||||
} else {
|
||||
echo "<a href=\"report.php?action=questions&id=$id\">$strquestions</a>";
|
||||
echo " <a href=\"report.php?action=students&id=$id\">$course->students</a>";
|
||||
echo " <a href=\"report.php?action=download&id=$id\">$strdownload</a>";
|
||||
if (empty($action)) {
|
||||
$action = "questions";
|
||||
}
|
||||
}
|
||||
print_simple_box_end();
|
||||
|
||||
@ -86,9 +107,9 @@
|
||||
case "summary":
|
||||
print_heading($strsummary);
|
||||
|
||||
if (survey_count_responses($survey->id)) {
|
||||
if (survey_count_responses($survey->id, $currentgroup)) {
|
||||
echo "<p align=center><a href=\"report.php?action=scales&id=$id\">";
|
||||
survey_print_graph("id=$id&type=overall.png");
|
||||
survey_print_graph("id=$id&group=$currentgroup&type=overall.png");
|
||||
echo "</a>";
|
||||
} else {
|
||||
echo "<p align=center>".get_string("nobodyyet","survey")."</p>";
|
||||
@ -116,7 +137,7 @@
|
||||
continue;
|
||||
}
|
||||
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");
|
||||
survey_print_graph("id=$id&qid=$question->id&group=$currentgroup&type=multiquestion.png");
|
||||
echo "</a></p><br>";
|
||||
}
|
||||
}
|
||||
@ -169,14 +190,14 @@
|
||||
if ($subquestion->type > 0) {
|
||||
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");
|
||||
survey_print_graph("id=$id&qid=$subquestion->id&group=$currentgroup&type=question.png");
|
||||
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\">";
|
||||
survey_print_graph("id=$id&qid=$question->id&type=question.png");
|
||||
survey_print_graph("id=$id&qid=$question->id&group=$currentgroup&type=question.png");
|
||||
echo "</a></p>";
|
||||
|
||||
} else {
|
||||
@ -186,7 +207,7 @@
|
||||
|
||||
$contents = '<table cellpadding="15" width="100%">';
|
||||
|
||||
if ($aaa = survey_get_user_answers($survey->id, $question->id, "sa.time ASC")) {
|
||||
if ($aaa = survey_get_user_answers($survey->id, $question->id, $currentgroup, "sa.time ASC")) {
|
||||
foreach ($aaa as $a) {
|
||||
$contents .= "<tr>";
|
||||
$contents .= '<td nowrap="nowrap" width="10%" valign="top">'.fullname($a).'</td>';
|
||||
@ -227,7 +248,7 @@
|
||||
$table->align = array ("left", "left", "left", "left", "right");
|
||||
$table->size = array (35, "", "", "", "");
|
||||
|
||||
if ($aaa = survey_get_user_answers($survey->id, $question->id)) {
|
||||
if ($aaa = survey_get_user_answers($survey->id, $question->id, $currentgroup)) {
|
||||
foreach ($aaa as $a) {
|
||||
if ($a->answer1) {
|
||||
$answer1 = "$a->answer1 - ".$answers[$a->answer1 - 1];
|
||||
@ -257,7 +278,7 @@
|
||||
|
||||
print_heading(get_string("analysisof", "survey", "$course->students"));
|
||||
|
||||
if (! $results = survey_get_responses($survey->id) ) {
|
||||
if (! $results = survey_get_responses($survey->id, $currentgroup) ) {
|
||||
notify(get_string("nobodyyet","survey"));
|
||||
} else {
|
||||
survey_print_all_responses($cm->id, $results, $course->id);
|
||||
@ -373,6 +394,7 @@
|
||||
echo '<center>';
|
||||
$options["id"] = "$cm->id";
|
||||
$options["type"] = "xls";
|
||||
$options["group"] = $currentgroup;
|
||||
print_single_button("download.php", $options, get_string("downloadexcel", "survey"));
|
||||
|
||||
$options["type"] = "txt";
|
||||
|
@ -90,8 +90,8 @@
|
||||
$strsurveysaved = get_string("surveysaved", "survey");
|
||||
|
||||
print_header("$course->shortname: $strsurveysaved", "$course->fullname",
|
||||
"<A HREF=/course/view.php?id=$course->id>$course->shortname</A> ->
|
||||
<A HREF=index.php?id=$course->id>$strsurveys</A> -> $survey->name -> $strsurveysaved", "");
|
||||
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
|
||||
<a href=\"index.php?id=$course->id\">$strsurveys</a> -> $survey->name -> $strsurveysaved", "");
|
||||
|
||||
|
||||
notice(get_string("thanksforanswers","survey", $USER->firstname), "$CFG->wwwroot/course/view.php?id=$course->id");
|
||||
|
@ -5,7 +5,7 @@
|
||||
// This fragment is called by /admin/index.php
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$module->version = 2004021602;
|
||||
$module->version = 2004021900;
|
||||
$module->requires = 2004013101; // Requires this Moodle version
|
||||
$module->cron = 0;
|
||||
|
||||
|
@ -36,8 +36,19 @@
|
||||
"$navigation <A HREF=index.php?id=$course->id>$strsurveys</A> -> $survey->name", "", "", true,
|
||||
update_module_button($cm->id, $course->id, $strsurvey), navmenu($course, $cm));
|
||||
|
||||
/// Check to see if groups are being used in this survey
|
||||
if ($groupmode = groupmode($course, $cm)) { // Groups are being used
|
||||
$currentgroup = get_current_group($course->id);
|
||||
} else {
|
||||
$currentgroup = 0;
|
||||
}
|
||||
|
||||
if (isteacheredit($course->id) or ($groupmode == VISIBLEGROUPS)) {
|
||||
$currentgroup = 0;
|
||||
}
|
||||
|
||||
if (isteacher($course->id)) {
|
||||
$numusers = survey_count_responses($survey->id);
|
||||
$numusers = survey_count_responses($survey->id, $currentgroup);
|
||||
echo "<p align=right><a href=\"report.php?id=$cm->id\">".
|
||||
get_string("viewsurveyresponses", "survey", $numusers)."</A></P>";
|
||||
} else if (!$cm->visible) {
|
||||
@ -54,13 +65,13 @@
|
||||
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);
|
||||
$numusers = survey_count_responses($survey->id);
|
||||
$numusers = survey_count_responses($survey->id, $currentgroup);
|
||||
|
||||
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");
|
||||
survey_print_graph("id=$cm->id&sid=$USER->id&group=$currentgroup&type=student.png");
|
||||
echo "</center>";
|
||||
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user