mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-3030 quiz overdue handling: show the attempt state in the reports.
This commit is contained in:
parent
2cdd2df92d
commit
863872e3e7
@ -508,7 +508,7 @@ $string['overrideuser'] = 'Override user';
|
||||
$string['overrideusereventname'] = '{$a->quiz} - Override';
|
||||
$string['page-mod-quiz-x'] = 'Any quiz module page';
|
||||
$string['page-mod-quiz-edit'] = 'Edit quiz page';
|
||||
$string['pagesize'] = 'Attempts shown per page:';
|
||||
$string['pagesize'] = 'Page size';
|
||||
$string['parent'] = 'Parent';
|
||||
$string['parentcategory'] = 'Parent category';
|
||||
$string['parsingquestions'] = 'Parsing questions from import file.';
|
||||
@ -628,16 +628,26 @@ $string['replace'] = 'Replace';
|
||||
$string['replacementoptions'] = 'Replacement options';
|
||||
$string['report'] = 'Reports';
|
||||
$string['reportanalysis'] = 'Item analysis';
|
||||
$string['reportattemptsfrom'] = 'Attempts from';
|
||||
$string['reportattemptsthatare'] = 'Attempts that are';
|
||||
$string['reportdisplayoptions'] = 'Display options';
|
||||
$string['reportfullstat'] = 'Detailed statistics';
|
||||
$string['reportmulti_percent'] = 'Multi-percentages';
|
||||
$string['reportmulti_q_x_student'] = 'Multi-student choices';
|
||||
$string['reportmulti_resp'] = 'Individual responses';
|
||||
$string['reportmustselectstate'] = 'You must select at least one state.';
|
||||
$string['reportnotfound'] = 'Report not known ({$a})';
|
||||
$string['reportoverview'] = 'Overview';
|
||||
$string['reportregrade'] = 'Regrade attempts';
|
||||
$string['reportresponses'] = 'Detailed responses';
|
||||
$string['reports'] = 'Reports';
|
||||
$string['reportshowonly'] = 'Show only attempts';
|
||||
$string['reportsimplestat'] = 'Simple statistics';
|
||||
$string['reportusersall'] = 'all users who have attempted the quiz';
|
||||
$string['reportuserswith'] = 'enrolled users who have attempted the quiz';
|
||||
$string['reportuserswithorwithout'] = 'enrolled users who have, or have not, attempted the quiz';
|
||||
$string['reportuserswithout'] = 'enrolled users who have not attempted the quiz';
|
||||
$string['reportwhattoinclude'] = 'What to include in the report';
|
||||
$string['requirepassword'] = 'Require password';
|
||||
$string['requirepassword_help'] = 'If a password is specified, a student must enter it in order to attempt the quiz.';
|
||||
$string['requiresubnet'] = 'Require network address';
|
||||
@ -721,6 +731,7 @@ $string['showfeedback'] = 'After answering, show feedback?';
|
||||
$string['showinsecurepopup'] = 'Use a \'secure\' popup window for attempts';
|
||||
$string['shownoattempts'] = 'Show students with no attempts';
|
||||
$string['shownoattemptsonly'] = 'Show only students with no attempts';
|
||||
$string['showreport'] = 'Show report';
|
||||
$string['showteacherattempts'] = 'Show teacher attempts';
|
||||
$string['showuserpicture'] = 'Show the user\'s picture';
|
||||
$string['showuserpicture_help'] = 'If enabled, the student\'s name and picture will be shown on-screen during the attempt, and on the review screen, making it easier to check that the student is logged in as themself in an invigilated (proctored) exam.';
|
||||
|
@ -39,14 +39,14 @@ abstract class quiz_attempts_report extends quiz_default_report {
|
||||
/** @var int default page size for reports. */
|
||||
const DEFAULT_PAGE_SIZE = 30;
|
||||
|
||||
/** @var int include all attempts. */
|
||||
const ALL_ATTEMPTS = 0;
|
||||
/** @var int include just enroled users who have not attempted the quiz. */
|
||||
const STUDENTS_WITH_NO = 1;
|
||||
/** @var int include just enroled users who have attempted the quiz. */
|
||||
const STUDENTS_WITH = 2;
|
||||
/** @var int include all enroled users. */
|
||||
const ALL_STUDENTS = 3;
|
||||
/** @var string constant used for the options, means all users with attempts. */
|
||||
const ALL_WITH = 'all_with';
|
||||
/** @var string constant used for the options, means only enrolled users with attempts. */
|
||||
const ENROLLED_WITH = 'enrolled_with';
|
||||
/** @var string constant used for the options, means only enrolled users without attempts. */
|
||||
const ENROLLED_WITHOUT = 'enrolled_without';
|
||||
/** @var string constant used for the options, means all enrolled users. */
|
||||
const ENROLLED_ALL = 'enrolled_any';
|
||||
|
||||
/** @var string the mode this report is. */
|
||||
protected $mode;
|
||||
|
@ -40,65 +40,81 @@ abstract class mod_quiz_attempts_report_form extends moodleform {
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', 'preferencespage',
|
||||
get_string('preferencespage', 'quiz_overview'));
|
||||
get_string('reportwhattoinclude', 'quiz'));
|
||||
|
||||
if (!$this->_customdata['currentgroup']) {
|
||||
$studentsstring = get_string('participants');
|
||||
} else {
|
||||
$a = new stdClass();
|
||||
$a->coursestudent = get_string('participants');
|
||||
$a->groupname = groups_get_group_name($this->_customdata['currentgroup']);
|
||||
if (20 < strlen($a->groupname)) {
|
||||
$studentsstring = get_string('studentingrouplong', 'quiz_overview', $a);
|
||||
} else {
|
||||
$studentsstring = get_string('studentingroup', 'quiz_overview', $a);
|
||||
}
|
||||
}
|
||||
$options = array();
|
||||
if (!$this->_customdata['currentgroup']) {
|
||||
$options[quiz_attempts_report::ALL_ATTEMPTS] = get_string('optallattempts', 'quiz_overview');
|
||||
}
|
||||
if ($this->_customdata['currentgroup'] ||
|
||||
!is_inside_frontpage($this->_customdata['context'])) {
|
||||
$options[quiz_attempts_report::ALL_STUDENTS] =
|
||||
get_string('optallstudents', 'quiz_overview', $studentsstring);
|
||||
$options[quiz_attempts_report::STUDENTS_WITH] =
|
||||
get_string('optattemptsonly', 'quiz_overview', $studentsstring);
|
||||
$options[quiz_attempts_report::STUDENTS_WITH_NO] =
|
||||
get_string('optnoattemptsonly', 'quiz_overview', $studentsstring);
|
||||
}
|
||||
$mform->addElement('select', 'attemptsmode',
|
||||
get_string('show', 'quiz_overview'), $options);
|
||||
|
||||
$this->definition_inner($mform);
|
||||
$this->standard_attempt_fields($mform);
|
||||
$this->other_attempt_fields($mform);
|
||||
|
||||
$mform->addElement('header', 'preferencesuser',
|
||||
get_string('preferencesuser', 'quiz_overview'));
|
||||
get_string('reportdisplayoptions', 'quiz'));
|
||||
|
||||
$mform->addElement('text', 'pagesize', get_string('pagesize', 'quiz_overview'));
|
||||
$mform->setType('pagesize', PARAM_INT);
|
||||
$this->standard_preference_fields($mform);
|
||||
$this->other_preference_fields($mform);
|
||||
|
||||
$mform->addElement('submit', 'submitbutton',
|
||||
get_string('preferencessave', 'quiz_overview'));
|
||||
get_string('showreport', 'quiz'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add any report-specific options to the form.
|
||||
*
|
||||
* @param MoodleQuickForm $mform the form we are building.
|
||||
*/
|
||||
protected abstract function definition_inner(MoodleQuickForm $mform);
|
||||
protected function standard_attempt_fields(MoodleQuickForm $mform) {
|
||||
|
||||
/**
|
||||
* Create the standard checkbox for the 'include highest graded only' option.
|
||||
*
|
||||
* @param MoodleQuickForm $mform the form we are building.
|
||||
*/
|
||||
protected function create_qmfilter_checkbox(MoodleQuickForm $mform) {
|
||||
$gm = html_writer::tag('span', quiz_get_grading_option_name(
|
||||
$this->_customdata['quiz']->grademethod), array('class' => 'highlight'));
|
||||
return $mform->createElement('advcheckbox', 'qmfilter',
|
||||
get_string('showattempts', 'quiz_overview'),
|
||||
get_string('optonlygradedattempts', 'quiz_overview', $gm), null, array(0, 1));
|
||||
$mform->addElement('select', 'attempts', get_string('reportattemptsfrom', 'quiz'), array(
|
||||
quiz_attempts_report::ENROLLED_WITH => get_string('reportuserswith', 'quiz'),
|
||||
quiz_attempts_report::ENROLLED_WITHOUT => get_string('reportuserswithout', 'quiz'),
|
||||
quiz_attempts_report::ENROLLED_ALL => get_string('reportuserswithorwithout', 'quiz'),
|
||||
quiz_attempts_report::ALL_WITH => get_string('reportusersall', 'quiz'),
|
||||
));
|
||||
|
||||
$stategroup = array(
|
||||
$mform->createElement('advcheckbox', 'stateinprogress', '',
|
||||
get_string('stateinprogress', 'quiz')),
|
||||
$mform->createElement('advcheckbox', 'stateoverdue', '',
|
||||
get_string('stateoverdue', 'quiz')),
|
||||
$mform->createElement('advcheckbox', 'statefinished', '',
|
||||
get_string('statefinished', 'quiz')),
|
||||
$mform->createElement('advcheckbox', 'stateabandoned', '',
|
||||
get_string('stateabandoned', 'quiz')),
|
||||
);
|
||||
$mform->addGroup($stategroup, 'stateoptions',
|
||||
get_string('reportattemptsthatare', 'quiz'), array(' '), false);
|
||||
$mform->setDefault('stateinprogress', 1);
|
||||
$mform->setDefault('stateoverdue', 1);
|
||||
$mform->setDefault('statefinished', 1);
|
||||
$mform->setDefault('stateabandoned', 1);
|
||||
$mform->disabledIf('stateinprogress', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
|
||||
$mform->disabledIf('stateoverdue', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
|
||||
$mform->disabledIf('statefinished', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
|
||||
$mform->disabledIf('stateabandoned', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
|
||||
|
||||
if (quiz_report_can_filter_only_graded($this->_customdata['quiz'])) {
|
||||
$gm = html_writer::tag('span',
|
||||
quiz_get_grading_option_name($this->_customdata['quiz']->grademethod),
|
||||
array('class' => 'highlight'));
|
||||
$mform->addElement('advcheckbox', 'onlygraded', get_string('reportshowonly', 'quiz'),
|
||||
get_string('optonlygradedattempts', 'quiz_overview', $gm));
|
||||
$mform->disabledIf('onlygraded', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
|
||||
$mform->disabledIf('onlygraded', 'statefinished', 'notchecked');
|
||||
}
|
||||
}
|
||||
|
||||
protected function other_attempt_fields(MoodleQuickForm $mform) {
|
||||
}
|
||||
|
||||
protected function standard_preference_fields(MoodleQuickForm $mform) {
|
||||
$mform->addElement('text', 'pagesize', get_string('pagesize', 'quiz'));
|
||||
$mform->setType('pagesize', PARAM_INT);
|
||||
}
|
||||
|
||||
protected function other_preference_fields(MoodleQuickForm $mform) {
|
||||
}
|
||||
|
||||
public function validation($data, $files) {
|
||||
$errors = parent::validation($data, $files);
|
||||
|
||||
if ($data['attempts'] != quiz_attempts_report::ENROLLED_WITHOUT && !(
|
||||
$data['stateinprogress'] || $data['stateoverdue'] || $data['statefinished'] || $data['stateabandoned'])) {
|
||||
$errors['stateoptions'] = get_string('reportmustselectstate', 'quiz');
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
@ -48,12 +48,32 @@ class mod_quiz_attempts_report_options {
|
||||
/** @var object the course settings for the course the quiz is in. */
|
||||
public $course;
|
||||
|
||||
/** @var string quiz_attempts_report:: constants. */
|
||||
public $attempts = quiz_attempts_report::STUDENTS_WITH;
|
||||
/**
|
||||
* @var array form field name => corresponding quiz_attempt:: state constant.
|
||||
*/
|
||||
protected static $statefields = array(
|
||||
'stateinprogress' => quiz_attempt::IN_PROGRESS,
|
||||
'stateoverdue' => quiz_attempt::OVERDUE,
|
||||
'statefinished' => quiz_attempt::FINISHED,
|
||||
'stateabandoned' => quiz_attempt::ABANDONED,
|
||||
);
|
||||
|
||||
/**
|
||||
* @var string quiz_attempts_report::ALL_WITH or quiz_attempts_report::ENROLLED_WITH
|
||||
* quiz_attempts_report::ENROLLED_WITHOUT or quiz_attempts_report::ENROLLED_ALL
|
||||
*/
|
||||
public $attempts = quiz_attempts_report::ENROLLED_WITH;
|
||||
|
||||
/** @var int the currently selected group. 0 if no group is selected. */
|
||||
public $group = 0;
|
||||
|
||||
/**
|
||||
* @var array|null of quiz_attempt::IN_PROGRESS, etc. constants. null means
|
||||
* no restriction.
|
||||
*/
|
||||
public $states = array(quiz_attempt::IN_PROGRESS, quiz_attempt::OVERDUE,
|
||||
quiz_attempt::FINISHED, quiz_attempt::ABANDONED);
|
||||
|
||||
/**
|
||||
* @var bool whether to show all finished attmepts, or just the one that gave
|
||||
* the final grade for the user.
|
||||
@ -94,10 +114,10 @@ class mod_quiz_attempts_report_options {
|
||||
*/
|
||||
protected function get_url_params() {
|
||||
return array(
|
||||
'id' => $this->cm->id,
|
||||
'mode' => $this->mode,
|
||||
'attemptsmode' => $this->attempts,
|
||||
'qmfilter' => $this->onlygraded,
|
||||
'id' => $this->cm->id,
|
||||
'mode' => $this->mode,
|
||||
'attempts' => $this->attempts,
|
||||
'onlygraded' => $this->onlygraded,
|
||||
);
|
||||
}
|
||||
|
||||
@ -136,9 +156,9 @@ class mod_quiz_attempts_report_options {
|
||||
*/
|
||||
public function get_initial_form_data() {
|
||||
$toform = new stdClass();
|
||||
$toform->attemptsmode = $this->attempts;
|
||||
$toform->qmfilter = $this->onlygraded;
|
||||
$toform->pagesize = $this->pagesize;
|
||||
$toform->attempts = $this->attempts;
|
||||
$toform->onlygraded = $this->onlygraded;
|
||||
$toform->pagesize = $this->pagesize;
|
||||
|
||||
return $toform;
|
||||
}
|
||||
@ -148,21 +168,31 @@ class mod_quiz_attempts_report_options {
|
||||
* @param object $fromform The data from $mform->get_data() from the settings form.
|
||||
*/
|
||||
public function setup_from_form_data($fromform) {
|
||||
$this->attempts = $fromform->attemptsmode;
|
||||
$this->attempts = $fromform->attempts;
|
||||
$this->group = groups_get_activity_group($this->cm, true);
|
||||
$this->onlygraded = !empty($fromform->qmfilter);
|
||||
$this->onlygraded = !empty($fromform->onlygraded);
|
||||
$this->pagesize = $fromform->pagesize;
|
||||
|
||||
$this->states = array();
|
||||
foreach (self::$statefields as $field => $state) {
|
||||
if (!empty($fromform->$field)) {
|
||||
$this->states[] = $state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fields of this object from the user's preferences.
|
||||
*/
|
||||
public function setup_from_params() {
|
||||
$this->attempts = optional_param('attemptsmode', $this->attempts, PARAM_ALPHAEXT);
|
||||
$this->attempts = optional_param('attempts', $this->attempts, PARAM_ALPHAEXT);
|
||||
$this->group = groups_get_activity_group($this->cm, true);
|
||||
$this->onlygraded = optional_param('qmfilter', $this->onlygraded, PARAM_BOOL);
|
||||
$this->onlygraded = optional_param('onlygraded', $this->onlygraded, PARAM_BOOL);
|
||||
$this->pagesize = optional_param('pagesize', $this->pagesize, PARAM_INT);
|
||||
|
||||
$this->states = explode('-', optional_param('states',
|
||||
implode('-', $this->states), PARAM_ALPHAEXT));
|
||||
|
||||
$this->download = optional_param('download', $this->download, PARAM_ALPHA);
|
||||
}
|
||||
|
||||
@ -188,30 +218,49 @@ class mod_quiz_attempts_report_options {
|
||||
public function resolve_dependencies() {
|
||||
if ($this->group) {
|
||||
// Default for when a group is selected.
|
||||
if ($this->attempts === null || $this->attempts == quiz_attempts_report::ALL_ATTEMPTS) {
|
||||
$this->attempts = quiz_attempts_report::STUDENTS_WITH;
|
||||
if ($this->attempts === null || $this->attempts == quiz_attempts_report::ALL_WITH) {
|
||||
$this->attempts = quiz_attempts_report::ENROLLED_WITH;
|
||||
}
|
||||
|
||||
} else if (!$this->group && $this->course->id == SITEID) {
|
||||
// Force report on front page to show all, unless a group is selected.
|
||||
$this->attempts = quiz_attempts_report::ALL_ATTEMPTS;
|
||||
$this->attempts = quiz_attempts_report::ALL_WITH;
|
||||
|
||||
} else if ($this->attempts === null) {
|
||||
$this->attempts = quiz_attempts_report::ALL_ATTEMPTS;
|
||||
} else if (!in_array($this->attempts, array(quiz_attempts_report::ALL_WITH, quiz_attempts_report::ENROLLED_WITH,
|
||||
quiz_attempts_report::ENROLLED_WITHOUT, quiz_attempts_report::ENROLLED_ALL))) {
|
||||
$this->attempts = quiz_attempts_report::ENROLLED_WITH;
|
||||
}
|
||||
|
||||
if ($this->pagesize < 1) {
|
||||
$this->pagesize = quiz_attempts_report::DEFAULT_PAGE_SIZE;
|
||||
$cleanstates = array();
|
||||
foreach (self::$statefields as $state) {
|
||||
if (in_array($state, $this->states)) {
|
||||
$cleanstates[] = $state;
|
||||
}
|
||||
}
|
||||
$this->states = $cleanstates;
|
||||
if (count($this->states) == count(self::$statefields)) {
|
||||
// If all states have been selected, then there is no constraint
|
||||
// required in the SQL, so clear the array.
|
||||
$this->states = null;
|
||||
}
|
||||
|
||||
if (!quiz_report_qm_filter_select($this->quiz)) {
|
||||
if (!quiz_report_can_filter_only_graded($this->quiz)) {
|
||||
// A grading mode like 'average' has been selected, so we cannot do
|
||||
// the show the attempt that gave the final grade thing.
|
||||
$this->onlygraded = false;
|
||||
}
|
||||
|
||||
if ($this->attempts == quiz_attempts_report::STUDENTS_WITH_NO) {
|
||||
if ($this->attempts == quiz_attempts_report::ENROLLED_WITHOUT) {
|
||||
$this->states = null;
|
||||
$this->onlygraded = false;
|
||||
}
|
||||
|
||||
if ($this->onlygraded) {
|
||||
$this->states = array(quiz_attempt::FINISHED);
|
||||
}
|
||||
|
||||
if ($this->pagesize < 1) {
|
||||
$this->pagesize = quiz_attempts_report::DEFAULT_PAGE_SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,12 +61,6 @@ abstract class quiz_attempts_report_table extends table_sql {
|
||||
/** @var object mod_quiz_attempts_report_options the options affecting this report. */
|
||||
protected $options;
|
||||
|
||||
/** @var bool whether to only display the first/best/last attempt for each student. */
|
||||
protected $qmfilter;
|
||||
|
||||
/** @var int which attempts/students to include in the report.. */
|
||||
protected $attemptsmode;
|
||||
|
||||
/** @var object the ids of the students in the currently selected group, if applicable. */
|
||||
protected $groupstudents;
|
||||
|
||||
@ -98,8 +92,6 @@ abstract class quiz_attempts_report_table extends table_sql {
|
||||
$this->quiz = $quiz;
|
||||
$this->context = $context;
|
||||
$this->qmsubselect = $qmsubselect;
|
||||
$this->qmfilter = $options->onlygraded;
|
||||
$this->attemptsmode = $options->attempts;
|
||||
$this->groupstudents = $groupstudents;
|
||||
$this->students = $students;
|
||||
$this->questions = $questions;
|
||||
@ -392,29 +384,30 @@ abstract class quiz_attempts_report_table extends table_sql {
|
||||
quiza.userid = u.id AND quiza.quiz = :quizid";
|
||||
$params = array('quizid' => $this->quiz->id);
|
||||
|
||||
if ($this->qmsubselect && $this->qmfilter) {
|
||||
if ($this->qmsubselect && $this->options->onlygraded) {
|
||||
$from .= " AND $this->qmsubselect";
|
||||
}
|
||||
switch ($this->attemptsmode) {
|
||||
case quiz_attempts_report::ALL_ATTEMPTS:
|
||||
|
||||
switch ($this->options->attempts) {
|
||||
case quiz_attempts_report::ALL_WITH:
|
||||
// Show all attempts, including students who are no longer in the course.
|
||||
$where = 'quiza.id IS NOT NULL AND quiza.preview = 0';
|
||||
break;
|
||||
case quiz_attempts_report::STUDENTS_WITH:
|
||||
case quiz_attempts_report::ENROLLED_WITH:
|
||||
// Show only students with attempts.
|
||||
list($usql, $uparams) = $DB->get_in_or_equal(
|
||||
$reportstudents, SQL_PARAMS_NAMED, 'u');
|
||||
$params += $uparams;
|
||||
$where = "u.id $usql AND quiza.preview = 0 AND quiza.id IS NOT NULL";
|
||||
break;
|
||||
case quiz_attempts_report::STUDENTS_WITH_NO:
|
||||
case quiz_attempts_report::ENROLLED_WITHOUT:
|
||||
// Show only students without attempts.
|
||||
list($usql, $uparams) = $DB->get_in_or_equal(
|
||||
$reportstudents, SQL_PARAMS_NAMED, 'u');
|
||||
$params += $uparams;
|
||||
$where = "u.id $usql AND quiza.id IS NULL";
|
||||
break;
|
||||
case quiz_attempts_report::ALL_STUDENTS:
|
||||
case quiz_attempts_report::ENROLLED_ALL:
|
||||
// Show all students with or without attempts.
|
||||
list($usql, $uparams) = $DB->get_in_or_equal(
|
||||
$reportstudents, SQL_PARAMS_NAMED, 'u');
|
||||
@ -423,6 +416,13 @@ abstract class quiz_attempts_report_table extends table_sql {
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->options->states) {
|
||||
list($statesql, $stateparams) = $DB->get_in_or_equal($this->options->states,
|
||||
SQL_PARAMS_NAMED, 'state');
|
||||
$params += $stateparams;
|
||||
$where .= " AND (quiza.state $statesql OR quiza.state IS NULL)";
|
||||
}
|
||||
|
||||
return array($fields, $from, $where, $params);
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ $string['regradeheader'] = 'Regrading';
|
||||
$string['regradeselected'] = 'Regrade selected attempts';
|
||||
$string['show'] = 'Show / download';
|
||||
$string['showattempts'] = 'Only show / download attempts';
|
||||
$string['showdetailedmarks'] = 'Show / download marks for each question';
|
||||
$string['showdetailedmarks'] = 'Marks for each question';
|
||||
$string['showinggraded'] = 'Showing only the attempt graded for each user.';
|
||||
$string['showinggradedandungraded'] = 'Showing graded and ungraded attempts for each user. The one attempt for each user that is graded is highlighted. The grading method for this quiz is {$a}.';
|
||||
$string['studentingroup'] = '\'{$a->coursestudent}\' in group \'{$a->groupname}\'';
|
||||
|
@ -35,22 +35,21 @@ require_once($CFG->dirroot . '/mod/quiz/report/attemptsreport_form.php');
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class quiz_overview_settings_form extends mod_quiz_attempts_report_form {
|
||||
protected function definition_inner(MoodleQuickForm $mform) {
|
||||
$showattemptsgrp = array();
|
||||
if ($this->_customdata['qmsubselect']) {
|
||||
$showattemptsgrp[] = $this->create_qmfilter_checkbox($mform);
|
||||
}
|
||||
if (has_capability('mod/quiz:regrade', $this->_customdata['context'])) {
|
||||
$showattemptsgrp[] = $mform->createElement('advcheckbox', 'regradefilter',
|
||||
get_string('showattempts', 'quiz_overview'),
|
||||
get_string('optonlyregradedattempts', 'quiz_overview'), null, array(0, 1));
|
||||
}
|
||||
if ($showattemptsgrp) {
|
||||
$mform->addGroup($showattemptsgrp, null,
|
||||
get_string('showattempts', 'quiz_overview'), '<br />', false);
|
||||
}
|
||||
|
||||
$mform->addElement('selectyesno', 'detailedmarks',
|
||||
get_string('showdetailedmarks', 'quiz_overview'));
|
||||
protected function other_attempt_fields(MoodleQuickForm $mform) {
|
||||
if (has_capability('mod/quiz:regrade', $this->_customdata['context'])) {
|
||||
$mform->addElement('advcheckbox', 'onlyregraded', '',
|
||||
get_string('optonlyregradedattempts', 'quiz_overview'));
|
||||
$mform->disabledIf('onlyregraded', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
|
||||
}
|
||||
}
|
||||
|
||||
protected function other_preference_fields(MoodleQuickForm $mform) {
|
||||
if (quiz_has_grades($this->_customdata['quiz'])) {
|
||||
$mform->addElement('selectyesno', 'slotmarks',
|
||||
get_string('showdetailedmarks', 'quiz_overview'));
|
||||
} else {
|
||||
$mform->addElement('hidden', 'slotmarks', 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,15 +44,15 @@ class quiz_overview_options extends mod_quiz_attempts_report_options {
|
||||
|
||||
protected function get_url_params() {
|
||||
$params = parent::get_url_params();
|
||||
$params['regradefilter'] = $this->onlyregraded;
|
||||
$params['detailedmarks'] = $this->slotmarks;
|
||||
$params['onlyregraded'] = $this->onlyregraded;
|
||||
$params['slotmarks'] = $this->slotmarks;
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function get_initial_form_data() {
|
||||
$toform = parent::get_initial_form_data();
|
||||
$toform->regradefilter = $this->onlyregraded;
|
||||
$toform->detailedmarks = $this->slotmarks;
|
||||
$toform->onlyregraded = $this->onlyregraded;
|
||||
$toform->slotmarks = $this->slotmarks;
|
||||
|
||||
return $toform;
|
||||
}
|
||||
@ -60,15 +60,15 @@ class quiz_overview_options extends mod_quiz_attempts_report_options {
|
||||
public function setup_from_form_data($fromform) {
|
||||
parent::setup_from_form_data($fromform);
|
||||
|
||||
$this->onlyregraded = !empty($fromform->regradefilter);
|
||||
$this->slotmarks = $fromform->detailedmarks;
|
||||
$this->onlyregraded = !empty($fromform->onlyregraded);
|
||||
$this->slotmarks = $fromform->slotmarks;
|
||||
}
|
||||
|
||||
public function setup_from_params() {
|
||||
parent::setup_from_params();
|
||||
|
||||
$this->onlyregraded = optional_param('regradefilter', $this->onlyregraded, PARAM_BOOL);
|
||||
$this->slotmarks = optional_param('detailedmarks', $this->slotmarks, PARAM_BOOL);
|
||||
$this->onlyregraded = optional_param('onlyregraded', $this->onlyregraded, PARAM_BOOL);
|
||||
$this->slotmarks = optional_param('slotmarks', $this->slotmarks, PARAM_BOOL);
|
||||
}
|
||||
|
||||
public function setup_from_user_preferences() {
|
||||
@ -80,7 +80,9 @@ class quiz_overview_options extends mod_quiz_attempts_report_options {
|
||||
public function update_user_preferences() {
|
||||
parent::update_user_preferences();
|
||||
|
||||
set_user_preference('quiz_overview_slotmarks', $this->slotmarks);
|
||||
if (quiz_has_grades($this->quiz)) {
|
||||
set_user_preference('quiz_overview_slotmarks', $this->slotmarks);
|
||||
}
|
||||
}
|
||||
|
||||
public function resolve_dependencies() {
|
||||
@ -94,6 +96,6 @@ class quiz_overview_options extends mod_quiz_attempts_report_options {
|
||||
// if the user has permissions and if the report mode is showing attempts.
|
||||
$this->checkboxcolumn = has_any_capability(
|
||||
array('mod/quiz:regrade', 'mod/quiz:deleteattempts'), context_module::instance($this->cm->id))
|
||||
&& ($this->attempts != quiz_attempts_report::STUDENTS_WITH_NO);
|
||||
&& ($this->attempts != quiz_attempts_report::ENROLLED_WITHOUT);
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ class quiz_overview_table extends quiz_attempts_report_table {
|
||||
quiz_overview_options $options, $groupstudents, $students, $questions, $reporturl) {
|
||||
parent::__construct('mod-quiz-report-overview-report', $quiz , $context,
|
||||
$qmsubselect, $options, $groupstudents, $students, $questions, $reporturl);
|
||||
$this->detailedmarks = $options->slotmarks;
|
||||
}
|
||||
|
||||
public function build_table() {
|
||||
@ -105,7 +104,7 @@ class quiz_overview_table extends quiz_attempts_report_table {
|
||||
$record->grade, $this->quiz->id, $this->context))
|
||||
);
|
||||
|
||||
if ($this->detailedmarks) {
|
||||
if ($this->options->slotmarks) {
|
||||
$dm = new question_engine_data_mapper();
|
||||
$qubaids = new qubaid_join($from, 'quiza.uniqueid', $where, $params);
|
||||
$avggradebyq = $dm->load_average_marks($qubaids, array_keys($this->questions));
|
||||
@ -281,7 +280,7 @@ class quiz_overview_table extends quiz_attempts_report_table {
|
||||
}
|
||||
|
||||
protected function requires_latest_steps_loaded() {
|
||||
return $this->detailedmarks;
|
||||
return $this->options->slotmarks;
|
||||
}
|
||||
|
||||
protected function is_latest_step_column($column) {
|
||||
@ -298,7 +297,7 @@ class quiz_overview_table extends quiz_attempts_report_table {
|
||||
public function query_db($pagesize, $useinitialsbar = true) {
|
||||
parent::query_db($pagesize, $useinitialsbar);
|
||||
|
||||
if ($this->detailedmarks && has_capability('mod/quiz:regrade', $this->context)) {
|
||||
if ($this->options->slotmarks && has_capability('mod/quiz:regrade', $this->context)) {
|
||||
$this->regradedqs = $this->get_regraded_questions();
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class quiz_overview_report extends quiz_attempts_report {
|
||||
|
||||
$this->form->set_data($options->get_initial_form_data());
|
||||
|
||||
if ($options->attempts == self::ALL_ATTEMPTS) {
|
||||
if ($options->attempts == self::ALL_WITH) {
|
||||
// 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
|
||||
// are accessible, is not a security porblem.
|
||||
@ -116,7 +116,7 @@ class quiz_overview_report extends quiz_attempts_report {
|
||||
}
|
||||
|
||||
$hasstudents = $students && (!$currentgroup || $groupstudents);
|
||||
if ($hasquestions && ($hasstudents || $options->attempts == self::ALL_ATTEMPTS)) {
|
||||
if ($hasquestions && ($hasstudents || $options->attempts == self::ALL_WITH)) {
|
||||
// Construct the SQL.
|
||||
$fields = $DB->sql_concat('u.id', "'#'", 'COALESCE(quiza.attempt, 0)') .
|
||||
' AS uniqueid, ';
|
||||
|
@ -127,6 +127,15 @@ WHERE
|
||||
return $qsbyslot;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $quiz the quiz settings.
|
||||
* @return bool whether, for this quiz, it is possible to filter attempts to show
|
||||
* only those that gave the final grade.
|
||||
*/
|
||||
function quiz_report_can_filter_only_graded($quiz) {
|
||||
return $quiz->attempts != 1 && $quiz->grademethod != QUIZ_GRADEAVERAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the quiz grading method return sub select sql to find the id of the
|
||||
* one attempt that will be graded for each user. Or return
|
||||
|
@ -23,10 +23,13 @@
|
||||
*/
|
||||
|
||||
$string['cannotloadoptions'] = 'Could not load question options';
|
||||
$string['include'] = 'Include';
|
||||
$string['include'] = 'Include the';
|
||||
$string['mustselectcols'] = 'You must include something.';
|
||||
$string['pagesize'] = 'Page size';
|
||||
$string['pluginname'] = 'Responses';
|
||||
$string['questiontext'] = 'question text';
|
||||
$string['reportresponses'] = 'Responses';
|
||||
$string['response'] = 'response';
|
||||
$string['responses'] = 'Responses';
|
||||
$string['responsesdownload'] = 'Responses download';
|
||||
$string['responsesfilename'] = 'responses';
|
||||
@ -34,8 +37,10 @@ $string['responsesoptions'] = 'Responses options';
|
||||
$string['responsesreport'] = 'Responses report';
|
||||
$string['responsestitle'] = 'Responses';
|
||||
$string['responsex'] = 'Response {$a}';
|
||||
$string['rightanswer'] = 'right answer';
|
||||
$string['rightanswerx'] = 'Right answer {$a}';
|
||||
$string['showattempts'] = 'Only show / download attempts';
|
||||
$string['showthe'] = 'Show the';
|
||||
$string['summaryofquestiontext'] = 'Summary of the question';
|
||||
$string['summaryofresponse'] = 'Summary of the response given';
|
||||
$string['summaryofrightanswer'] = 'Summary of the right answer';
|
||||
|
@ -63,7 +63,7 @@ class quiz_responses_report extends quiz_attempts_report {
|
||||
|
||||
$this->form->set_data($options->get_initial_form_data());
|
||||
|
||||
if ($options->attempts == self::ALL_ATTEMPTS) {
|
||||
if ($options->attempts == self::ALL_WITH) {
|
||||
// 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
|
||||
// are accessible, is not a security porblem.
|
||||
@ -124,7 +124,7 @@ class quiz_responses_report extends quiz_attempts_report {
|
||||
}
|
||||
|
||||
$hasstudents = $students && (!$currentgroup || $groupstudents);
|
||||
if ($hasquestions && ($hasstudents || $options->attempts == self::ALL_ATTEMPTS)) {
|
||||
if ($hasquestions && ($hasstudents || $options->attempts == self::ALL_WITH)) {
|
||||
|
||||
list($fields, $from, $where, $params) = $table->base_sql($allowed);
|
||||
|
||||
|
@ -35,19 +35,29 @@ require_once($CFG->dirroot . '/mod/quiz/report/attemptsreport_form.php');
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class quiz_responses_settings_form extends mod_quiz_attempts_report_form {
|
||||
protected function definition_inner(MoodleQuickForm $mform) {
|
||||
if ($this->_customdata['qmsubselect']) {
|
||||
$mform->addElement($this->create_qmfilter_checkbox($mform));
|
||||
|
||||
protected function other_preference_fields(MoodleQuickForm $mform) {
|
||||
$mform->addGroup(array(
|
||||
$mform->createElement('advcheckbox', 'qtext', '',
|
||||
get_string('questiontext', 'quiz_responses')),
|
||||
$mform->createElement('advcheckbox', 'resp', '',
|
||||
get_string('response', 'quiz_responses')),
|
||||
$mform->createElement('advcheckbox', 'right', '',
|
||||
get_string('rightanswer', 'quiz_responses')),
|
||||
), 'coloptions', get_string('showthe', 'quiz_responses'), array(' '), false);
|
||||
$mform->disabledIf('qtext', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
|
||||
$mform->disabledIf('resp', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
|
||||
$mform->disabledIf('right', 'attempts', 'eq', quiz_attempts_report::ENROLLED_WITHOUT);
|
||||
}
|
||||
|
||||
public function validation($data, $files) {
|
||||
$errors = parent::validation($data, $files);
|
||||
|
||||
if ($data['attempts'] != quiz_attempts_report::ENROLLED_WITHOUT && !(
|
||||
$data['qtext'] || $data['resp'] || $data['right'])) {
|
||||
$errors['coloptions'] = get_string('reportmustselectstate', 'quiz');
|
||||
}
|
||||
|
||||
$colsgroup = array();
|
||||
$colsgroup[] = $mform->createElement('advcheckbox', 'qtext', '',
|
||||
get_string('summaryofquestiontext', 'quiz_responses'));
|
||||
$colsgroup[] = $mform->createElement('advcheckbox', 'resp', '',
|
||||
get_string('summaryofresponse', 'quiz_responses'));
|
||||
$colsgroup[] = $mform->createElement('advcheckbox', 'right', '',
|
||||
get_string('summaryofrightanswer', 'quiz_responses'));
|
||||
$mform->addGroup($colsgroup, null,
|
||||
get_string('include', 'quiz_responses'), '<br />', false);
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +105,6 @@ class quiz_responses_options extends mod_quiz_attempts_report_options {
|
||||
// We only want to show the checkbox to delete attempts
|
||||
// if the user has permissions and if the report mode is showing attempts.
|
||||
$this->checkboxcolumn = has_capability('mod/quiz:deleteattempts', context_module::instance($this->cm->id))
|
||||
&& ($this->attempts != quiz_attempts_report::STUDENTS_WITH_NO);
|
||||
&& ($this->attempts != quiz_attempts_report::ENROLLED_WITHOUT);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user