mirror of
https://github.com/moodle/moodle.git
synced 2025-02-01 05:18:06 +01:00
MDL-32322 quiz_reports: move some more options into the options class.
This commit is contained in:
parent
ac4d91575a
commit
9e67e357eb
@ -218,12 +218,13 @@ abstract class quiz_attempts_report extends quiz_default_report {
|
|||||||
* Add all the grade and feedback columns, if applicable, to the $columns
|
* Add all the grade and feedback columns, if applicable, to the $columns
|
||||||
* and $headers arrays.
|
* and $headers arrays.
|
||||||
* @param object $quiz the quiz settings.
|
* @param object $quiz the quiz settings.
|
||||||
|
* @param bool $usercanseegrades whether the user is allowed to see grades for this quiz.
|
||||||
* @param array $columns the list of columns. Added to.
|
* @param array $columns the list of columns. Added to.
|
||||||
* @param array $headers the columns headings. Added to.
|
* @param array $headers the columns headings. Added to.
|
||||||
* @param bool $includefeedback whether to include the feedbacktext columns
|
* @param bool $includefeedback whether to include the feedbacktext columns
|
||||||
*/
|
*/
|
||||||
protected function add_grade_columns($quiz, &$columns, &$headers, $includefeedback = true) {
|
protected function add_grade_columns($quiz, $usercanseegrades, &$columns, &$headers, $includefeedback = true) {
|
||||||
if (quiz_report_should_show_grades($quiz)) {
|
if ($usercanseegrades) {
|
||||||
$columns[] = 'sumgrades';
|
$columns[] = 'sumgrades';
|
||||||
$headers[] = get_string('grade', 'quiz') . '/' .
|
$headers[] = get_string('grade', 'quiz') . '/' .
|
||||||
quiz_format_grade($quiz, $quiz->grade);
|
quiz_format_grade($quiz, $quiz->grade);
|
||||||
|
@ -45,32 +45,30 @@ class mod_quiz_attempts_report_options {
|
|||||||
/** @var object the course settings for the course the quiz is in. */
|
/** @var object the course settings for the course the quiz is in. */
|
||||||
public $course;
|
public $course;
|
||||||
|
|
||||||
/**
|
/** @var string quiz_attempts_report:: constants. */
|
||||||
* @var string quiz_attempts_report:: constants.
|
|
||||||
*/
|
|
||||||
public $attempts = quiz_attempts_report::STUDENTS_WITH;
|
public $attempts = quiz_attempts_report::STUDENTS_WITH;
|
||||||
|
|
||||||
/**
|
/** @var int the currently selected group. 0 if no group is selected. */
|
||||||
* @var int the currently selected group. 0 if no group is selected.
|
|
||||||
*/
|
|
||||||
public $group = 0;
|
public $group = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool wether to show all finished attmepts, or just the one that gave
|
* @var bool whether to show all finished attmepts, or just the one that gave
|
||||||
* the final grade for the user.
|
* the final grade for the user.
|
||||||
*/
|
*/
|
||||||
public $onlygraded = false;
|
public $onlygraded = false;
|
||||||
|
|
||||||
/**
|
/** @var int Number of attempts to show per page. */
|
||||||
* @var int Number of attempts to show per page.
|
|
||||||
*/
|
|
||||||
public $pagesize = quiz_attempts_report::DEFAULT_PAGE_SIZE;
|
public $pagesize = quiz_attempts_report::DEFAULT_PAGE_SIZE;
|
||||||
|
|
||||||
/**
|
/** @var string whether the data should be downloaded in some format, or '' to display it. */
|
||||||
* @var string whether the data should be downloaded in some format, or '' to display it.
|
|
||||||
*/
|
|
||||||
public $download = '';
|
public $download = '';
|
||||||
|
|
||||||
|
/** @var bool whether the current user has permission to see grades. */
|
||||||
|
public $usercanseegrades;
|
||||||
|
|
||||||
|
/** @var bool whether the report table should have a column of checkboxes. */
|
||||||
|
public $checkboxcolumn = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
* @param object $quiz the settings for the quiz being reported on.
|
* @param object $quiz the settings for the quiz being reported on.
|
||||||
@ -80,6 +78,8 @@ class mod_quiz_attempts_report_options {
|
|||||||
$this->quiz = $quiz;
|
$this->quiz = $quiz;
|
||||||
$this->cm = $cm;
|
$this->cm = $cm;
|
||||||
$this->course = $course;
|
$this->course = $course;
|
||||||
|
|
||||||
|
$this->usercanseegrades = quiz_report_should_show_grades($quiz);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,8 +79,14 @@ class quiz_overview_options extends mod_quiz_attempts_report_options {
|
|||||||
public function resolve_dependencies() {
|
public function resolve_dependencies() {
|
||||||
parent::resolve_dependencies();
|
parent::resolve_dependencies();
|
||||||
|
|
||||||
if (!quiz_report_should_show_grades($this->quiz)) {
|
if (!$this->usercanseegrades) {
|
||||||
$this->slotmarks = false;
|
$this->slotmarks = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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_any_capability(
|
||||||
|
array('mod/quiz:regrade', 'mod/quiz:deleteattempts'), context_module::instance($this->cm->id))
|
||||||
|
&& ($this->attempts != quiz_attempts_report::STUDENTS_WITH_NO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,12 +60,6 @@ class quiz_overview_report extends quiz_attempts_report {
|
|||||||
|
|
||||||
$this->form->set_data($options->get_initial_form_data());
|
$this->form->set_data($options->get_initial_form_data());
|
||||||
|
|
||||||
// We only want to show the checkbox to delete attempts
|
|
||||||
// if the user has permissions and if the report mode is showing attempts.
|
|
||||||
$includecheckboxes = has_any_capability(
|
|
||||||
array('mod/quiz:regrade', 'mod/quiz:deleteattempts'), $this->context)
|
|
||||||
&& ($options->attempts != self::STUDENTS_WITH_NO);
|
|
||||||
|
|
||||||
if ($options->attempts == self::ALL_ATTEMPTS) {
|
if ($options->attempts == self::ALL_ATTEMPTS) {
|
||||||
// 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
|
||||||
@ -81,7 +75,7 @@ class quiz_overview_report extends quiz_attempts_report {
|
|||||||
array('context' => context_course::instance($course->id)));
|
array('context' => context_course::instance($course->id)));
|
||||||
$table = new quiz_overview_table($quiz, $this->context, $this->qmsubselect,
|
$table = new quiz_overview_table($quiz, $this->context, $this->qmsubselect,
|
||||||
$options->onlygraded, $options->attempts, $groupstudents, $students, $options->slotmarks,
|
$options->onlygraded, $options->attempts, $groupstudents, $students, $options->slotmarks,
|
||||||
$questions, $includecheckboxes, $this->get_base_url(), $displayoptions);
|
$questions, $options->checkboxcolumn, $this->get_base_url(), $displayoptions);
|
||||||
$filename = quiz_report_download_filename(get_string('overviewfilename', 'quiz_overview'),
|
$filename = quiz_report_download_filename(get_string('overviewfilename', 'quiz_overview'),
|
||||||
$courseshortname, $quiz->name);
|
$courseshortname, $quiz->name);
|
||||||
$table->is_downloading($options->download, $filename,
|
$table->is_downloading($options->download, $filename,
|
||||||
@ -246,7 +240,7 @@ class quiz_overview_report extends quiz_attempts_report {
|
|||||||
$columns = array();
|
$columns = array();
|
||||||
$headers = array();
|
$headers = array();
|
||||||
|
|
||||||
if (!$table->is_downloading() && $includecheckboxes) {
|
if (!$table->is_downloading() && $options->checkboxcolumn) {
|
||||||
$columns[] = 'checkbox';
|
$columns[] = 'checkbox';
|
||||||
$headers[] = null;
|
$headers[] = null;
|
||||||
}
|
}
|
||||||
@ -276,7 +270,7 @@ class quiz_overview_report extends quiz_attempts_report {
|
|||||||
$headers[] = get_string('regrade', 'quiz_overview');
|
$headers[] = get_string('regrade', 'quiz_overview');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->add_grade_columns($quiz, $columns, $headers, false);
|
$this->add_grade_columns($quiz, $options->usercanseegrades, $columns, $headers, false);
|
||||||
|
|
||||||
$this->set_up_table_columns(
|
$this->set_up_table_columns(
|
||||||
$table, $columns, $headers, $this->get_base_url(), $displayoptions, false);
|
$table, $columns, $headers, $this->get_base_url(), $displayoptions, false);
|
||||||
@ -285,7 +279,7 @@ class quiz_overview_report extends quiz_attempts_report {
|
|||||||
$table->out($options->pagesize, true);
|
$table->out($options->pagesize, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$table->is_downloading() && quiz_report_should_show_grades($quiz)) {
|
if (!$table->is_downloading() && $options->usercanseegrades) {
|
||||||
if ($currentgroup && $groupstudents) {
|
if ($currentgroup && $groupstudents) {
|
||||||
list($usql, $params) = $DB->get_in_or_equal($groupstudents);
|
list($usql, $params) = $DB->get_in_or_equal($groupstudents);
|
||||||
$params[] = $quiz->id;
|
$params[] = $quiz->id;
|
||||||
|
@ -70,11 +70,6 @@ class quiz_responses_report extends quiz_attempts_report {
|
|||||||
|
|
||||||
$this->form->set_data($options->get_initial_form_data());
|
$this->form->set_data($options->get_initial_form_data());
|
||||||
|
|
||||||
// We only want to show the checkbox to delete attempts
|
|
||||||
// if the user has permissions and if the report mode is showing attempts.
|
|
||||||
$includecheckboxes = has_capability('mod/quiz:deleteattempts', $this->context)
|
|
||||||
&& ($options->attempts != self::STUDENTS_WITH_NO);
|
|
||||||
|
|
||||||
if ($options->attempts == self::ALL_ATTEMPTS) {
|
if ($options->attempts == self::ALL_ATTEMPTS) {
|
||||||
// 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
|
||||||
@ -90,10 +85,10 @@ class quiz_responses_report extends quiz_attempts_report {
|
|||||||
array('context' => context_course::instance($course->id)));
|
array('context' => context_course::instance($course->id)));
|
||||||
$table = new quiz_responses_table($quiz, $this->context, $this->qmsubselect,
|
$table = new quiz_responses_table($quiz, $this->context, $this->qmsubselect,
|
||||||
$options->onlygraded, $options->attempts, $groupstudents, $students,
|
$options->onlygraded, $options->attempts, $groupstudents, $students,
|
||||||
$questions, $includecheckboxes, $this->get_base_url(), $displayoptions);
|
$questions, $options->checkboxcolumn, $this->get_base_url(), $displayoptions);
|
||||||
$filename = quiz_report_download_filename(get_string('responsesfilename', 'quiz_responses'),
|
$filename = quiz_report_download_filename(get_string('responsesfilename', 'quiz_responses'),
|
||||||
$courseshortname, $quiz->name);
|
$courseshortname, $quiz->name);
|
||||||
$table->is_downloading(optional_param('download', '', PARAM_ALPHA), $filename,
|
$table->is_downloading($options->download, $filename,
|
||||||
$courseshortname . ' ' . format_string($quiz->name, true));
|
$courseshortname . ' ' . format_string($quiz->name, true));
|
||||||
if ($table->is_downloading()) {
|
if ($table->is_downloading()) {
|
||||||
raise_memory_limit(MEMORY_EXTRA);
|
raise_memory_limit(MEMORY_EXTRA);
|
||||||
@ -166,7 +161,7 @@ class quiz_responses_report extends quiz_attempts_report {
|
|||||||
$columns = array();
|
$columns = array();
|
||||||
$headers = array();
|
$headers = array();
|
||||||
|
|
||||||
if (!$table->is_downloading() && $includecheckboxes) {
|
if (!$table->is_downloading() && $options->checkboxcolumn) {
|
||||||
$columns[] = 'checkbox';
|
$columns[] = 'checkbox';
|
||||||
$headers[] = null;
|
$headers[] = null;
|
||||||
}
|
}
|
||||||
@ -177,7 +172,7 @@ class quiz_responses_report extends quiz_attempts_report {
|
|||||||
$this->add_time_columns($columns, $headers);
|
$this->add_time_columns($columns, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->add_grade_columns($quiz, $columns, $headers);
|
$this->add_grade_columns($quiz, $options->usercanseegrades, $columns, $headers);
|
||||||
|
|
||||||
foreach ($questions as $id => $question) {
|
foreach ($questions as $id => $question) {
|
||||||
if ($options->showqtext) {
|
if ($options->showqtext) {
|
||||||
|
@ -93,5 +93,10 @@ class quiz_responses_options extends mod_quiz_attempts_report_options {
|
|||||||
// We have to show at least something.
|
// We have to show at least something.
|
||||||
$this->showresponses = true;
|
$this->showresponses = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user