if (!in_array($grade, array('all', 'needsgrading', 'autograded', 'manuallygraded'))) {
$grade = null;
}
- $pagesize = optional_param('pagesize', self::DEFAULT_PAGE_SIZE, PARAM_INT);
+ $pagesize = optional_param('pagesize',
+ get_user_preferences('quiz_grading_pagesize', self::DEFAULT_PAGE_SIZE),
+ PARAM_INT);
$page = optional_param('page', 0, PARAM_INT);
- $order = optional_param('order', self::DEFAULT_ORDER, PARAM_ALPHA);
+ $order = optional_param('order',
+ get_user_preferences('quiz_grading_order', self::DEFAULT_ORDER),
+ PARAM_ALPHA);
// Assemble the options required to reload this page.
$optparams = array('includeauto', 'page');
}
$hasquestions = quiz_has_questions($this->quiz->id);
+ if (!$hasquestions) {
+ $this->print_header_and_tabs($cm, $course, $quiz, 'grading');
+ echo $this->renderer->render_quiz_no_question_notification($quiz, $cm, $this->context);
+ return true;
+ }
+
$counts = null;
if ($slot && $hasquestions) {
// Make sure there is something to do.
}
}
- // Start output.
- $this->print_header_and_tabs($cm, $course, $quiz, 'grading');
-
// What sort of page to display?
- if (!$hasquestions) {
- echo $this->renderer->render_quiz_no_question_notification($quiz, $cm, $this->context);
-
- } else if (!$slot) {
- echo $this->display_index($includeauto);
+ if (!$slot) {
+ $this->display_index($includeauto);
} else {
echo $this->display_grading_interface($slot, $questionid, $grade,
return $result;
}
+ /**
+ * Display the report front page which summarises the number of attempts to grade.
+ *
+ * @param bool $includeauto whether to show automatically-graded questions.
+ */
protected function display_index($includeauto) {
global $PAGE;
- $output = '';
+
+ $this->print_header_and_tabs($this->cm, $this->course, $this->quiz, 'grading');
if ($groupmode = groups_get_activity_groupmode($this->cm)) {
// Groups is being used.
} else {
$linktext = get_string('alsoshowautomaticallygraded', 'quiz_grading');
}
- $output .= $this->renderer->render_display_index_heading($linktext, $this->list_questions_url(!$includeauto));
+ echo $this->renderer->render_display_index_heading($linktext, $this->list_questions_url(!$includeauto));
$data = [];
$header = [];
$data[] = $row;
}
- $output .= $this->renderer->render_questions_table($includeauto, $data, $header);
- return $output;
+ echo $this->renderer->render_questions_table($includeauto, $data, $header);
}
+ /**
+ * Display the UI for grading attempts at one question.
+ *
+ * @param int $slot identifies which question to grade.
+ * @param int $questionid identifies which question to grade.
+ * @param string $grade type of attempts to grade.
+ * @param int $pagesize number of questions to show per page.
+ * @param int $page current page number.
+ * @param bool $shownames whether student names should be shown.
+ * @param bool $showidnumbers wither student idnumbers should be shown.
+ * @param string $order preferred order of attempts.
+ * @param stdClass $counts object that stores the number of each type of attempt.
+ */
protected function display_grading_interface($slot, $questionid, $grade,
$pagesize, $page, $shownames, $showidnumbers, $order, $counts) {
- $output = '';
if ($pagesize * $page >= $counts->$grade) {
$page = 0;
}
- list($qubaids, $count) = $this->get_usage_ids_where_question_in_state(
- $grade, $slot, $questionid, $order, $page, $pagesize);
- $attempts = $this->load_attempts_by_usage_ids($qubaids);
-
- // Prepare the form.
+ // Prepare the options form.
$hidden = [
'id' => $this->cm->id,
'mode' => 'grading',
$settings->order = $order;
$mform->set_data($settings);
+ // If the form was submitted, save the user preferences, and
+ // redirect to a cleaned-up GET URL.
+ if ($mform->get_data()) {
+ set_user_preference('quiz_grading_pagesize', $pagesize);
+ set_user_preference('quiz_grading_order', $order);
+ redirect($this->grade_question_url($slot, $questionid, $grade, $page));
+ }
+
+ list($qubaids, $count) = $this->get_usage_ids_where_question_in_state(
+ $grade, $slot, $questionid, $order, $page, $pagesize);
+ $attempts = $this->load_attempts_by_usage_ids($qubaids);
+
// Question info.
$questioninfo = new stdClass();
$questioninfo->number = $this->questions[$slot]->number;
$paginginfo->of = $count;
$qubaidlist = implode(',', $qubaids);
+ $this->print_header_and_tabs($this->cm, $this->course, $this->quiz, 'grading');
+
$gradequestioncontent = '';
foreach ($qubaids as $qubaid) {
$attempt = $attempts[$qubaid];
'sesskey' => sesskey()
];
- $output .= $this->renderer->render_grading_interface(
+ echo $this->renderer->render_grading_interface(
$questioninfo,
$this->list_questions_url(),
$mform,
$hiddeninputs,
$gradequestioncontent
);
-
- return $output;
}
/**
As a teacher
I need to use the manual grading report
- @javascript
- Scenario: Use the Manual grading report
+ Background:
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | T1 | Teacher1 | teacher1@example.com | T1000 |
| question | page |
| Short answer 001 | 1 |
+ Scenario: Use the Manual grading report
+
# Check report shows nothing when there are no attempts.
- When I log in as "teacher1"
- And I am on "Course 1" course homepage
- And I follow "Quiz 1"
+ When I am on the "Quiz 1" "mod_quiz > View" page logged in as "teacher1"
And I navigate to "Results > Manual grading" in current page administration
Then I should see "Manual grading"
And I should see "Quiz 1"
# Use the manual grading report.
And user "student1" has attempted "Quiz 1" with responses:
| slot | response |
- | 1 | Paris |
+ | 1 | Paris |
And I reload the page
And I should see "Short answer 001"
And "Short answer 001" row "To grade" column of "questionstograde" table should contain "0"
And I should see "All selected attempts have been graded. Returning to the list of questions."
And "Short answer 001" row "To grade" column of "questionstograde" table should contain "0"
And "Short answer 001" row "Already graded" column of "questionstograde" table should contain "1"
+
+ Scenario: Manual grading settings are remembered as user preferences
+ Given user "student1" has attempted "Quiz 1" with responses:
+ | slot | response |
+ | 1 | Paris |
+ When I am on the "Quiz 1" "mod_quiz > Manual grading report" page logged in as "teacher1"
+ And I follow "Also show questions that have been graded automatically"
+ And I click on "update grades" "link" in the "Short answer 001" "table_row"
+ And I set the following fields to these values:
+ | Questions per page | 42 |
+ | Order attempts | By date |
+ And I press "Change options"
+ And I log out
+ And I am on the "Quiz 1" "mod_quiz > Manual grading report" page logged in as "teacher1"
+ And I follow "Also show questions that have been graded automatically"
+ And I click on "update grades" "link" in the "Short answer 001" "table_row"
+ Then the following fields match these values:
+ | Questions per page | 42 |
+ | Order attempts | By date |