Skip to content

Commit

Permalink
MDL-12517 reverting the moving of data processign, returning array of…
Browse files Browse the repository at this point in the history
… warnings instead from function; merged from MOODLE_19_STABLE
  • Loading branch information
skodak committed Dec 18, 2007
1 parent 379ea94 commit 7567447
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
17 changes: 13 additions & 4 deletions grade/report/grader/index.php
Expand Up @@ -121,13 +121,22 @@
// Initialise the grader report object
$report = new grade_report_grader($courseid, $gpr, $context, $page, $sortitemid);


/// processing posted grades & feedback here
if ($data = data_submitted() and confirm_sesskey() and has_capability('moodle/grade:edit', $context)) {
$warnings = $report->process_data($data);
} else {
$warings = array();
}


// Override perpage if set in URL
if ($perpageurl) {
$report->user_prefs['studentsperpage'] = $perpageurl;
}

// final grades MUST be loaded after the processing
$report->load_users();

$numusers = $report->get_numusers();
$report->load_final_grades();

Expand All @@ -146,9 +155,9 @@
echo '<div class="clearer"></div>';
echo $report->get_toggles_html();

/// processing posted grades & feedback here
if ($data = data_submitted() and confirm_sesskey()) {
$report->process_data($data);
//show warnings if any
foreach($warnings as $warning) {
notify($warning);
}

$studentsperpage = $report->get_pref('studentsperpage');
Expand Down
16 changes: 7 additions & 9 deletions grade/report/grader/lib.php
Expand Up @@ -146,14 +146,12 @@ function grade_report_grader($courseid, $gpr, $context, $page=null, $sortitemid=

/**
* Processes the data sent by the form (grades and feedbacks).
* @var array $data
* @return bool Success or Failure (array of errors).
* Caller is reposible for all access control checks
* @param array $data form submission (with magic quotes)
* @return array empty array if success, array of warnings if something fails.
*/
function process_data($data) {

if (!has_capability('moodle/grade:edit', $this->context)) {
return false;
}
$warnings = array();

// always initialize all arrays
$queue = array();
Expand Down Expand Up @@ -209,11 +207,11 @@ function process_data($data) {
$errorstr = 'morethanmax';
}
if ($errorstr) {
$user = get_record('user', 'id', $userid,'','','','','id, firstname, lastname');
$user = get_record('user', 'id', $userid, '', '', '', '', 'id, firstname, lastname');
$gradestr = new object();
$gradestr->username = fullname($user);
$gradestr->itemname = $grade_item->get_name();
notify(get_string($errorstr, 'grades', $gradestr));
$warnings[] = get_string($errorstr, 'grades', $gradestr);
}

} else if ($data_type == 'feedback') {
Expand All @@ -229,7 +227,7 @@ function process_data($data) {
$grade_item->update_final_grade($userid, $finalgrade, 'gradebook', $feedback, FORMAT_MOODLE);
}

return true;
return $warnings;
}


Expand Down

0 comments on commit 7567447

Please sign in to comment.