mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 10:56:56 +02:00
MDL-32322 quiz reports: edit to increase duplication, before refactoring.
This commit is contained in:
parent
768a758854
commit
4747c788c0
6 changed files with 46 additions and 37 deletions
|
@ -54,7 +54,7 @@ class quiz_overview_table extends quiz_attempt_report_table {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->strtimeformat = str_replace(',', '', get_string('strftimedatetime'));
|
$this->strtimeformat = str_replace(',', ' ', get_string('strftimedatetime'));
|
||||||
parent::build_table();
|
parent::build_table();
|
||||||
|
|
||||||
// End of adding the data from attempts. Now add averages at bottom.
|
// 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;
|
return null;
|
||||||
}
|
}
|
||||||
$slot = $matches[1];
|
$slot = $matches[1];
|
||||||
|
|
||||||
$question = $this->questions[$slot];
|
$question = $this->questions[$slot];
|
||||||
if (!isset($this->lateststeps[$attempt->usageid][$slot])) {
|
if (!isset($this->lateststeps[$attempt->usageid][$slot])) {
|
||||||
return '-';
|
return '-';
|
||||||
|
|
|
@ -67,7 +67,8 @@ class quiz_overview_settings_form extends moodleform {
|
||||||
$options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO] =
|
$options[QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO] =
|
||||||
get_string('optnoattemptsonly', 'quiz_overview', $studentsstring);
|
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();
|
$showattemptsgrp = array();
|
||||||
if ($this->_customdata['qmsubselect']) {
|
if ($this->_customdata['qmsubselect']) {
|
||||||
|
|
|
@ -174,14 +174,15 @@ class quiz_overview_report extends quiz_attempt_report {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($groupmode = groups_get_activity_groupmode($cm)) {
|
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()) {
|
if (!$table->is_downloading()) {
|
||||||
groups_print_activity_menu($cm, $reporturl->out(true, $displayoptions));
|
groups_print_activity_menu($cm, $reporturl->out(true, $displayoptions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print information on the number of existing attempts.
|
// 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)) {
|
if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm, true, $currentgroup)) {
|
||||||
echo '<div class="quizattemptcounts">' . $strattemptnum . '</div>';
|
echo '<div class="quizattemptcounts">' . $strattemptnum . '</div>';
|
||||||
}
|
}
|
||||||
|
@ -197,12 +198,12 @@ class quiz_overview_report extends quiz_attempt_report {
|
||||||
echo $OUTPUT->notification(get_string('nostudentsingroup'));
|
echo $OUTPUT->notification(get_string('nostudentsingroup'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print display options.
|
// Print the display options.
|
||||||
$mform->display();
|
$mform->display();
|
||||||
}
|
}
|
||||||
|
|
||||||
$hasstudents = $students && (!$currentgroup || $groupstudents);
|
$hasstudents = $students && (!$currentgroup || $groupstudents);
|
||||||
if ($hasquestions && ($hasstudents || ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL))) {
|
if ($hasquestions && ($hasstudents || $attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL)) {
|
||||||
// Construct the SQL.
|
// Construct the SQL.
|
||||||
$fields = $DB->sql_concat('u.id', "'#'", 'COALESCE(quiza.attempt, 0)') .
|
$fields = $DB->sql_concat('u.id', "'#'", 'COALESCE(quiza.attempt, 0)') .
|
||||||
' AS uniqueid, ';
|
' 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 {
|
class quiz_responses_report extends quiz_attempt_report {
|
||||||
|
|
||||||
public function display($quiz, $cm, $course) {
|
public function display($quiz, $cm, $course) {
|
||||||
global $CFG, $DB, $PAGE, $OUTPUT;
|
global $CFG, $DB, $OUTPUT;
|
||||||
|
|
||||||
$this->context = context_module::instance($cm->id);
|
$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);
|
$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) {
|
if (!$includeqtext && !$includeresp && !$includeright) {
|
||||||
$includeresp = 1;
|
$includeresp = 1;
|
||||||
set_user_preference('quiz_report_responses_resp', 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)
|
$includecheckboxes = has_capability('mod/quiz:deleteattempts', $this->context)
|
||||||
&& ($attemptsmode != QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO);
|
&& ($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) {
|
if ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL) {
|
||||||
// This option is only available to users who can access all groups in
|
// 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
|
// 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();
|
$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 (empty($currentgroup) || $groupstudents) {
|
||||||
if (optional_param('delete', 0, PARAM_BOOL) && confirm_sesskey()) {
|
if (optional_param('delete', 0, PARAM_BOOL) && confirm_sesskey()) {
|
||||||
if ($attemptids = optional_param_array('attemptid', array(), PARAM_INT)) {
|
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.
|
// Start output.
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$table->is_downloading()) {
|
if (!$table->is_downloading()) {
|
||||||
// Only print headers if not asked to download data.
|
// Only print headers if not asked to download data.
|
||||||
$this->print_header_and_tabs($cm, $course, $quiz, 'responses');
|
$this->print_header_and_tabs($cm, $course, $quiz, 'responses');
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
// 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
|
* @package quiz_responses
|
||||||
* @copyright 2008 Jean-Michel Vedrine
|
* @copyright 2008 Jean-Michel Vedrine
|
||||||
|
@ -45,10 +45,12 @@ class quiz_responses_table extends quiz_attempt_report_table {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function build_table() {
|
public function build_table() {
|
||||||
if ($this->rawdata) {
|
if (!$this->rawdata) {
|
||||||
$this->strtimeformat = str_replace(',', ' ', get_string('strftimedatetime'));
|
return;
|
||||||
parent::build_table();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->strtimeformat = str_replace(',', ' ', get_string('strftimedatetime'));
|
||||||
|
parent::build_table();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function col_sumgrades($attempt) {
|
public function col_sumgrades($attempt) {
|
||||||
|
|
|
@ -71,7 +71,7 @@ class quiz_responses_settings_form extends moodleform {
|
||||||
get_string('show', 'quiz_overview'), $options);
|
get_string('show', 'quiz_overview'), $options);
|
||||||
|
|
||||||
if ($this->_customdata['qmsubselect']) {
|
if ($this->_customdata['qmsubselect']) {
|
||||||
$gm = '<span class="gradedattempt">' .
|
$gm = '<span class="highlight">' .
|
||||||
quiz_get_grading_option_name($this->_customdata['quiz']->grademethod) .
|
quiz_get_grading_option_name($this->_customdata['quiz']->grademethod) .
|
||||||
'</span>';
|
'</span>';
|
||||||
$mform->addElement('advcheckbox', 'qmfilter',
|
$mform->addElement('advcheckbox', 'qmfilter',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue