mirror of
https://github.com/moodle/moodle.git
synced 2025-02-01 05:18:06 +01:00
MDL-32322 quiz reports: edit to increase duplication, before refactoring.
This commit is contained in:
parent
768a758854
commit
4747c788c0
@ -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 '-';
|
||||
|
@ -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']) {
|
||||
|
@ -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 '<div class="quizattemptcounts">' . $strattemptnum . '</div>';
|
||||
}
|
||||
@ -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, ';
|
||||
|
@ -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');
|
||||
|
@ -15,7 +15,7 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file defines the quiz responses report class.
|
||||
* This file defines the quiz responses table.
|
||||
*
|
||||
* @package quiz_responses
|
||||
* @copyright 2008 Jean-Michel Vedrine
|
||||
@ -45,11 +45,13 @@ class quiz_responses_table extends quiz_attempt_report_table {
|
||||
}
|
||||
|
||||
public function build_table() {
|
||||
if ($this->rawdata) {
|
||||
if (!$this->rawdata) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->strtimeformat = str_replace(',', ' ', get_string('strftimedatetime'));
|
||||
parent::build_table();
|
||||
}
|
||||
}
|
||||
|
||||
public function col_sumgrades($attempt) {
|
||||
if (!$attempt->timefinish) {
|
||||
|
@ -71,7 +71,7 @@ class quiz_responses_settings_form extends moodleform {
|
||||
get_string('show', 'quiz_overview'), $options);
|
||||
|
||||
if ($this->_customdata['qmsubselect']) {
|
||||
$gm = '<span class="gradedattempt">' .
|
||||
$gm = '<span class="highlight">' .
|
||||
quiz_get_grading_option_name($this->_customdata['quiz']->grademethod) .
|
||||
'</span>';
|
||||
$mform->addElement('advcheckbox', 'qmfilter',
|
||||
|
Loading…
x
Reference in New Issue
Block a user