Skip to content

Commit

Permalink
MDL-52309 gradereport_history: require user to submit parameters
Browse files Browse the repository at this point in the history
Prevent a timely full report from loading when need is exceedingly
rare. Only execute the report when the user has submitted the form.
  • Loading branch information
smbader committed Jan 11, 2016
1 parent 2b11b94 commit 1dabeb8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
24 changes: 14 additions & 10 deletions grade/report/history/index.php
Expand Up @@ -30,9 +30,10 @@
$download = optional_param('download', '', PARAM_ALPHA);
$courseid = required_param('id', PARAM_INT); // Course id.
$page = optional_param('page', 0, PARAM_INT); // Active page.
$showreport = optional_param('showreport', 0, PARAM_INT);

$PAGE->set_pagelayout('report');
$url = new moodle_url('/grade/report/history/index.php', array('id' => $courseid));
$url = new moodle_url('/grade/report/history/index.php', array('id' => $courseid, 'showreport' => 1));
$PAGE->set_url($url);

$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
Expand Down Expand Up @@ -105,15 +106,18 @@
print_grade_page_head($COURSE->id, 'report', 'history', get_string('pluginname', 'gradereport_history'), false, '');
$mform->display();

// Render table.
echo $output->render($table);
// MDL-52309: Display report after form has been submitted.
if ($showreport) {
// Render table.
echo $output->render($table);

$event = \gradereport_history\event\grade_report_viewed::create(
array(
'context' => $context,
'courseid' => $courseid
)
);
$event->trigger();
$event = \gradereport_history\event\grade_report_viewed::create(
array(
'context' => $context,
'courseid' => $courseid
)
);
$event->trigger();
}

echo $OUTPUT->footer();
3 changes: 2 additions & 1 deletion grade/report/history/tests/behat/basic_functionality.feature
Expand Up @@ -47,7 +47,8 @@ Feature: A teacher checks the grade history report in a course
And I give the grade "70.00" to the user "Student 2" for the grade item "The greatest assignment ever"
And I give the grade "80.00" to the user "Student 2" for the grade item "Rewarding assignment"
And I press "Save changes"
When I follow "Grade history"
And I follow "Grade history"
When I press "Submit"
Then the following should exist in the "gradereport_history" table:
| First name/Surname | Grade item | Original grade | Revised grade | Grader |
| Student 1 | The greatest assignment ever | | 50.00 | Teacher 1 |
Expand Down

0 comments on commit 1dabeb8

Please sign in to comment.