private $returnparams = array();
/** @var string modulename prevents excessive calls to get_string */
- private static $modulename = '';
+ private static $modulename = null;
/** @var string modulenameplural prevents excessive calls to get_string */
- private static $modulenameplural = '';
+ private static $modulenameplural = null;
/**
* Constructor for the base assign class
global $CFG;
$posthtml = '<p><font face="sans-serif">'.
'<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.format_string($course->shortname, true, array('context' => $context->get_course_context())).'</a> ->'.
- '<a href="'.$CFG->wwwroot.'/mod/assignment/index.php?id='.$course->id.'">'.$modulename.'</a> ->'.
- '<a href="'.$CFG->wwwroot.'/mod/assignment/view.php?id='.$coursemodule->id.'">'.format_string($assignmentname, true, array('context' => $context)).'</a></font></p>';
+ '<a href="'.$CFG->wwwroot.'/mod/assign/index.php?id='.$course->id.'">'.$modulename.'</a> ->'.
+ '<a href="'.$CFG->wwwroot.'/mod/assign/view.php?id='.$coursemodule->id.'">'.format_string($assignmentname, true, array('context' => $context)).'</a></font></p>';
$posthtml .= '<hr /><font face="sans-serif">';
$posthtml .= '<p>'.get_string($messagetype . 'html', 'assign', $info).'</p>';
$posthtml .= '</font><hr />';
$users = array();
// first check all the last modified values
- // Using POST is really unfortunate. A better solution needs to be found here. As we are looking for grades students we could
+ $currentgroup = groups_get_activity_group($this->get_course_module(), true);
+ $participants = $this->list_participants($currentgroup, true);
+
// gets a list of possible users and look for values based upon that.
- foreach ($_POST as $key => $value) {
- if (preg_match('#^grademodified_(\d+)$#', $key, $matches)) {
+ foreach ($participants as $userid => $unused) {
+ $modified = optional_param('grademodified_' . $userid, -1, PARAM_INT);
+ if ($modified >= 0) {
// gather the userid, updated grade and last modified value
$record = new stdClass();
- $record->userid = (int)$matches[1];
- $record->grade = required_param('quickgrade_' . $record->userid, PARAM_INT);
- $record->lastmodified = clean_param($value, PARAM_INT);
- $record->gradinginfo = grade_get_grades($this->get_course()->id, 'mod', 'assign', $this->get_instance()->id, array($record->userid));
- $users[$record->userid] = $record;
+ $record->userid = $userid;
+ $record->grade = required_param('quickgrade_' . $userid, PARAM_INT);
+ $record->lastmodified = $modified;
+ $record->gradinginfo = grade_get_grades($this->get_course()->id, 'mod', 'assign', $this->get_instance()->id, array($userid));
+ $users[$userid] = $record;
}
}
if (empty($users)) {
$modifiedusers = array();
foreach ($currentgrades as $current) {
$modified = $users[(int)$current->userid];
+ $grade = $this->get_user_grade($userid, false);
// check to see if the outcomes were modified
if ($CFG->enableoutcomes) {
}
}
+ // let plugins participate
+ foreach ($this->feedbackplugins as $plugin) {
+ if ($plugin->is_visible() && $plugin->is_enabled() && $plugin->supports_quickgrading()) {
+ if ($plugin->is_quickgrading_modified($modified->userid, $grade)) {
+ if ((int)$current->lastmodified > (int)$modified->lastmodified) {
+ return get_string('errorrecordmodified', 'assign');
+ } else {
+ $modifiedusers[$modified->userid] = $modified;
+ continue;
+ }
+ }
+ }
+ }
+
if (($current->grade < 0 || $current->grade === NULL) &&
($modified->grade < 0 || $modified->grade === NULL)) {
$this->update_grade($grade);
+ // save plugins data
+ foreach ($this->feedbackplugins as $plugin) {
+ if ($plugin->is_visible() && $plugin->is_enabled() && $plugin->supports_quickgrading()) {
+ $plugin->save_quickgrading_changes($userid, $grade);
+ }
+ }
+
// save outcomes
if ($CFG->enableoutcomes) {
$data = array();