mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 20:50:21 +01:00
Merge branch 'MDL-47893-master' of git://github.com/zbdd/moodle
This commit is contained in:
commit
f61619597b
@ -333,6 +333,9 @@ class grade extends tablelike implements selectable_items, filterable_items {
|
||||
}
|
||||
|
||||
foreach ($data as $varname => $value) {
|
||||
if (preg_match('/override_(\d+)_(\d+)/', $varname, $matches)) {
|
||||
$data->$matches[0] = '1';
|
||||
}
|
||||
if (!preg_match('/^finalgrade_(\d+)_/', $varname, $matches)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -255,7 +255,17 @@ abstract class screen {
|
||||
|
||||
$fields = $this->definition();
|
||||
|
||||
// Avoiding execution timeouts when updating
|
||||
// a large amount of grades.
|
||||
$progress = 0;
|
||||
$progressbar = new \core\progress\display_if_slow();
|
||||
$progressbar->start_html();
|
||||
$progressbar->start_progress(get_string('savegrades', 'gradereport_singleview'), count((array) $data) - 1);
|
||||
$changecount = array();
|
||||
|
||||
foreach ($data as $varname => $throw) {
|
||||
$progressbar->progress($progress);
|
||||
$progress++;
|
||||
if (preg_match("/(\w+)_(\d+)_(\d+)/", $varname, $matches)) {
|
||||
$itemid = $matches[2];
|
||||
$userid = $matches[3];
|
||||
@ -270,6 +280,9 @@ abstract class screen {
|
||||
if (preg_match('/^old[oe]{1}/', $varname)) {
|
||||
$elementname = preg_replace('/^old/', '', $varname);
|
||||
if (!isset($data->$elementname)) {
|
||||
// Decrease the progress because we've increased the
|
||||
// size of the array we are iterating through.
|
||||
$progress--;
|
||||
$data->$elementname = false;
|
||||
}
|
||||
}
|
||||
@ -309,6 +322,9 @@ abstract class screen {
|
||||
if (!empty($msg)) {
|
||||
$warnings[] = $msg;
|
||||
}
|
||||
if (preg_match('/_(\d+)_(\d+)/', $varname, $matchelement)) {
|
||||
$changecount[$matchelement[0]] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Some post-processing.
|
||||
@ -316,8 +332,11 @@ abstract class screen {
|
||||
$eventdata->warnings = $warnings;
|
||||
$eventdata->post_data = $data;
|
||||
$eventdata->instance = $this;
|
||||
$eventdata->changecount = $changecount;
|
||||
|
||||
return $eventdata->warnings;
|
||||
$progressbar->end_html();
|
||||
|
||||
return $eventdata;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -337,7 +337,6 @@ class user extends tablelike implements selectable_items {
|
||||
if ($bulk->is_applied($data)) {
|
||||
$filter = $bulk->get_type($data);
|
||||
$insertvalue = $bulk->get_insert_value($data);
|
||||
// Appropriately massage data that may not exist.
|
||||
|
||||
$userid = $this->item->id;
|
||||
foreach ($this->items as $gradeitemid => $gradeitem) {
|
||||
@ -357,6 +356,9 @@ class user extends tablelike implements selectable_items {
|
||||
}
|
||||
|
||||
foreach ($data as $varname => $value) {
|
||||
if (preg_match('/override_(\d+)_(\d+)/', $varname, $matches)) {
|
||||
$data->$matches[0] = '1';
|
||||
}
|
||||
if (!preg_match('/^finalgrade_(\d+)_/', $varname, $matches)) {
|
||||
continue;
|
||||
}
|
||||
@ -376,7 +378,6 @@ class user extends tablelike implements selectable_items {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return parent::process($data);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,6 @@ if (!$course = $DB->get_record('course', $courseparams)) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$PAGE->set_pagelayout('report');
|
||||
|
||||
if (!in_array($itemtype, gradereport_singleview::valid_screens())) {
|
||||
print_error('notvalid', 'gradereport_singleview', '', $itemtype);
|
||||
@ -99,15 +98,25 @@ $pageparams = array(
|
||||
$currentpage = new moodle_url('/grade/report/singleview/index.php', $pageparams);
|
||||
|
||||
if ($data = data_submitted()) {
|
||||
require_sesskey(); // Must have a sesskey for all actions.
|
||||
$warnings = $report->process_data($data);
|
||||
$PAGE->set_pagelayout('redirect');
|
||||
$PAGE->set_title(get_string('savegrades', 'gradereport_singleview'));
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (empty($warnings)) {
|
||||
redirect($currentpage);
|
||||
require_sesskey(); // Must have a sesskey for all actions.
|
||||
$result = $report->process_data($data);
|
||||
|
||||
if (!empty($result->warnings)) {
|
||||
foreach ($result->warnings as $warning) {
|
||||
echo $OUTPUT->notification($warning);
|
||||
}
|
||||
}
|
||||
echo $OUTPUT->notification(get_string('savegradessuccess', 'gradereport_singleview', count ((array)$result->changecount)));
|
||||
echo $OUTPUT->continue_button($currentpage);
|
||||
echo $OUTPUT->footer();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
$PAGE->set_pagelayout('report');
|
||||
print_grade_page_head($course->id, 'report', 'singleview', $reportname);
|
||||
|
||||
$graderrightnav = $graderleftnav = null;
|
||||
@ -157,12 +166,6 @@ if ($report->screen->display_group_selector()) {
|
||||
echo $report->group_selector;
|
||||
}
|
||||
|
||||
if (!empty($warnings)) {
|
||||
foreach ($warnings as $warning) {
|
||||
echo $OUTPUT->notification($warning);
|
||||
}
|
||||
}
|
||||
|
||||
echo $report->output();
|
||||
|
||||
if ($report->screen->supports_paging()) {
|
||||
|
@ -45,6 +45,8 @@ $string['overrideall'] = 'Override all grades';
|
||||
$string['overridefor'] = 'Override for {$a}';
|
||||
$string['overridenone'] = 'Override no grades';
|
||||
$string['pluginname'] = 'Single view';
|
||||
$string['savegrades'] = 'Saving grades';
|
||||
$string['savegradessuccess'] = 'Grades were set for {$a} items';
|
||||
$string['singleview:view'] = 'View report';
|
||||
$string['summarygrade'] = 'A table of users, with columns for range, grade, feedback, and whether to override or exclude a particular grade.';
|
||||
$string['summaryuser'] = 'A table of grade items, with columns for grade category, range, grade, feedback, and whether to override or exclude a particular grade.';
|
||||
|
@ -58,7 +58,9 @@ Feature: We can use Single view
|
||||
| Feedback for Test assignment one | test data |
|
||||
And I click on "Exclude for Test assignment four" "checkbox"
|
||||
And I press "Update"
|
||||
Then the following should exist in the "generaltable" table:
|
||||
Then I should see "Grades were set for 2 items"
|
||||
And I press "Continue"
|
||||
And the following should exist in the "generaltable" table:
|
||||
| Test assignment four |
|
||||
| excluded |
|
||||
And the following should exist in the "generaltable" table:
|
||||
@ -71,6 +73,8 @@ Feature: We can use Single view
|
||||
| Feedback for james (Student) 1 | test data2 |
|
||||
And I click on "Exclude for holly (Student) 2" "checkbox"
|
||||
And I press "Update"
|
||||
Then I should see "Grades were set for 2 items"
|
||||
And I press "Continue"
|
||||
And the following should exist in the "generaltable" table:
|
||||
| Test assignment three |
|
||||
| 12.05 |
|
||||
@ -79,6 +83,8 @@ Feature: We can use Single view
|
||||
And I click on "new grade item 1" "option"
|
||||
And I click on "Very good" "option"
|
||||
And I press "Update"
|
||||
Then I should see "Grades were set for 1 items"
|
||||
And I press "Continue"
|
||||
And the following should exist in the "generaltable" table:
|
||||
| Grade for james (Student) 1 | "Very good" |
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user