diff --git a/mod/quiz/report/overview/overview_table.php b/mod/quiz/report/overview/overview_table.php
index 13061a4be89..386aaeda468 100644
--- a/mod/quiz/report/overview/overview_table.php
+++ b/mod/quiz/report/overview/overview_table.php
@@ -54,7 +54,7 @@ class quiz_overview_table extends quiz_attempt_report_table {
return;
}
- $this->strtimeformat = str_replace(',', '', get_string('strftimedatetime'));
+ $this->strtimeformat = str_replace(',', ' ', get_string('strftimedatetime'));
parent::build_table();
// End of adding the data from attempts. Now add averages at bottom.
@@ -219,6 +219,7 @@ class quiz_overview_table extends quiz_attempt_report_table {
return null;
}
$slot = $matches[1];
+
$question = $this->questions[$slot];
if (!isset($this->lateststeps[$attempt->usageid][$slot])) {
return '-';
diff --git a/mod/quiz/report/overview/overviewsettings_form.php b/mod/quiz/report/overview/overviewsettings_form.php
index ac656b63378..b51cc9091c9 100644
--- a/mod/quiz/report/overview/overviewsettings_form.php
+++ b/mod/quiz/report/overview/overviewsettings_form.php
@@ -67,7 +67,8 @@ class quiz_overview_settings_form extends moodleform {
$options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO] =
get_string('optnoattemptsonly', 'quiz_overview', $studentsstring);
}
- $mform->addElement('select', 'attemptsmode', get_string('show', 'quiz_overview'), $options);
+ $mform->addElement('select', 'attemptsmode',
+ get_string('show', 'quiz_overview'), $options);
$showattemptsgrp = array();
if ($this->_customdata['qmsubselect']) {
diff --git a/mod/quiz/report/overview/report.php b/mod/quiz/report/overview/report.php
index 87a4282c0fb..bdb49ed2ec1 100644
--- a/mod/quiz/report/overview/report.php
+++ b/mod/quiz/report/overview/report.php
@@ -174,14 +174,15 @@ class quiz_overview_report extends quiz_attempt_report {
}
if ($groupmode = groups_get_activity_groupmode($cm)) {
- // Groups are being used, output the group selector if we are not downloading.
+ // Groups are being used, so output the group selector if we are not downloading.
if (!$table->is_downloading()) {
groups_print_activity_menu($cm, $reporturl->out(true, $displayoptions));
}
}
// Print information on the number of existing attempts.
- if (!$table->is_downloading()) { // Do not print notices when downloading.
+ if (!$table->is_downloading()) {
+ // Do not print notices when downloading.
if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm, true, $currentgroup)) {
echo '
' . $strattemptnum . '
';
}
@@ -197,12 +198,12 @@ class quiz_overview_report extends quiz_attempt_report {
echo $OUTPUT->notification(get_string('nostudentsingroup'));
}
- // Print display options.
+ // Print the display options.
$mform->display();
}
$hasstudents = $students && (!$currentgroup || $groupstudents);
- if ($hasquestions && ($hasstudents || ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL))) {
+ if ($hasquestions && ($hasstudents || $attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL)) {
// Construct the SQL.
$fields = $DB->sql_concat('u.id', "'#'", 'COALESCE(quiza.attempt, 0)') .
' AS uniqueid, ';
diff --git a/mod/quiz/report/responses/report.php b/mod/quiz/report/responses/report.php
index 160201544f2..09fa0dc0124 100644
--- a/mod/quiz/report/responses/report.php
+++ b/mod/quiz/report/responses/report.php
@@ -47,7 +47,7 @@ require_once($CFG->dirroot . '/mod/quiz/report/responses/responses_table.php');
class quiz_responses_report extends quiz_attempt_report {
public function display($quiz, $cm, $course) {
- global $CFG, $DB, $PAGE, $OUTPUT;
+ global $CFG, $DB, $OUTPUT;
$this->context = context_module::instance($cm->id);
@@ -97,6 +97,16 @@ class quiz_responses_report extends quiz_attempt_report {
}
$this->validate_common_options($attemptsmode, $pagesize, $course, $currentgroup);
+ $displayoptions = array();
+ $displayoptions['attemptsmode'] = $attemptsmode;
+ $displayoptions['qmfilter'] = $qmfilter;
+ $displayoptions['qtext'] = $includeqtext;
+ $displayoptions['resp'] = $includeresp;
+ $displayoptions['right'] = $includeright;
+
+ $mform->set_data($displayoptions +
+ array('pagesize' => $pagesize));
+
if (!$includeqtext && !$includeresp && !$includeright) {
$includeresp = 1;
set_user_preference('quiz_report_responses_resp', 1);
@@ -107,15 +117,6 @@ class quiz_responses_report extends quiz_attempt_report {
$includecheckboxes = has_capability('mod/quiz:deleteattempts', $this->context)
&& ($attemptsmode != QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO);
- $displayoptions = array();
- $displayoptions['attemptsmode'] = $attemptsmode;
- $displayoptions['qmfilter'] = $qmfilter;
- $displayoptions['qtext'] = $includeqtext;
- $displayoptions['resp'] = $includeresp;
- $displayoptions['right'] = $includeright;
-
- $mform->set_data($displayoptions + array('pagesize' => $pagesize));
-
if ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL) {
// This option is only available to users who can access all groups in
// groups mode, so setting allowed to empty (which means all quiz attempts
@@ -123,6 +124,24 @@ class quiz_responses_report extends quiz_attempt_report {
$allowed = array();
}
+ // Load the required questions.
+ $questions = quiz_report_get_significant_questions($quiz);
+
+ // Prepare for downloading, if applicable.
+ $courseshortname = format_string($course->shortname, true,
+ array('context' => context_course::instance($course->id)));
+ $table = new quiz_responses_table($quiz, $this->context, $qmsubselect,
+ $qmfilter, $attemptsmode, $groupstudents, $students,
+ $questions, $includecheckboxes, $reporturl, $displayoptions);
+ $filename = quiz_report_download_filename(get_string('responsesfilename', 'quiz_responses'),
+ $courseshortname, $quiz->name);
+ $table->is_downloading($download, $filename,
+ $courseshortname . ' ' . format_string($quiz->name, true));
+ if ($table->is_downloading()) {
+ raise_memory_limit(MEMORY_EXTRA);
+ }
+
+ // Process actions.
if (empty($currentgroup) || $groupstudents) {
if (optional_param('delete', 0, PARAM_BOOL) && confirm_sesskey()) {
if ($attemptids = optional_param_array('attemptid', array(), PARAM_INT)) {
@@ -133,22 +152,7 @@ class quiz_responses_report extends quiz_attempt_report {
}
}
- // Load the required questions.
- $questions = quiz_report_get_significant_questions($quiz);
-
- $courseshortname = format_string($course->shortname, true,
- array('context' => context_course::instance($course->id)));
- $table = new quiz_responses_table($quiz, $this->context, $qmsubselect,
- $qmfilter, $attemptsmode, $groupstudents, $students, $questions,
- $includecheckboxes, $reporturl, $displayoptions);
- $filename = quiz_report_download_filename(get_string('responsesfilename', 'quiz_responses'),
- $courseshortname, $quiz->name);
- $table->is_downloading($download, $filename,
- $courseshortname . ' ' . format_string($quiz->name, true));
- if ($table->is_downloading()) {
- raise_memory_limit(MEMORY_EXTRA);
- }
-
+ // Start output.
if (!$table->is_downloading()) {
// Only print headers if not asked to download data.
$this->print_header_and_tabs($cm, $course, $quiz, 'responses');
diff --git a/mod/quiz/report/responses/responses_table.php b/mod/quiz/report/responses/responses_table.php
index b3d0ed64ba5..88ba7dcdfd9 100644
--- a/mod/quiz/report/responses/responses_table.php
+++ b/mod/quiz/report/responses/responses_table.php
@@ -15,7 +15,7 @@
// along with Moodle. If not, see .
/**
- * This file defines the quiz responses report class.
+ * This file defines the quiz responses table.
*
* @package quiz_responses
* @copyright 2008 Jean-Michel Vedrine
@@ -45,10 +45,12 @@ class quiz_responses_table extends quiz_attempt_report_table {
}
public function build_table() {
- if ($this->rawdata) {
- $this->strtimeformat = str_replace(',', ' ', get_string('strftimedatetime'));
- parent::build_table();
+ if (!$this->rawdata) {
+ return;
}
+
+ $this->strtimeformat = str_replace(',', ' ', get_string('strftimedatetime'));
+ parent::build_table();
}
public function col_sumgrades($attempt) {
diff --git a/mod/quiz/report/responses/responsessettings_form.php b/mod/quiz/report/responses/responsessettings_form.php
index e100c042d67..71eb2255185 100644
--- a/mod/quiz/report/responses/responsessettings_form.php
+++ b/mod/quiz/report/responses/responsessettings_form.php
@@ -71,7 +71,7 @@ class quiz_responses_settings_form extends moodleform {
get_string('show', 'quiz_overview'), $options);
if ($this->_customdata['qmsubselect']) {
- $gm = '' .
+ $gm = '' .
quiz_get_grading_option_name($this->_customdata['quiz']->grademethod) .
'';
$mform->addElement('advcheckbox', 'qmfilter',