Skip to content

Commit

Permalink
Merge pull request moodle#24 from marinaglancy/wip-nov08-rubric
Browse files Browse the repository at this point in the history
  • Loading branch information
mudrd8mz committed Nov 8, 2011
2 parents 4e76985 + 48b8a66 commit 35a5c49
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 18 deletions.
3 changes: 2 additions & 1 deletion grade/grading/form/rubric/lib.php
Expand Up @@ -504,7 +504,8 @@ public function get_or_create_instance($instanceid, $raterid, $itemid) {
if ($rs = $DB->get_records('grading_instances', array('raterid' => $raterid, 'itemid' => $itemid), 'timemodified DESC', '*', 0, 1)) {
$record = reset($rs);
$currentinstance = $this->get_current_instance($raterid, $itemid);
if ($record->status == gradingform_rubric_instance::INSTANCE_STATUS_INCOMPLETE && $record->timemodified > $currentinstance->get_data('timemodified')) {
if ($record->status == gradingform_rubric_instance::INSTANCE_STATUS_INCOMPLETE &&
(!$currentinstance || $record->timemodified > $currentinstance->get_data('timemodified'))) {
$record->isrestored = true;
return $this->get_instance($record);
}
Expand Down
8 changes: 6 additions & 2 deletions grade/lib.php
Expand Up @@ -1177,7 +1177,11 @@ private function get_activity_link($element) {

// If module has grade.php, link to that, otherwise view.php
if ($hasgradephp[$itemmodule]) {
return new moodle_url('/mod/' . $itemmodule . '/grade.php', array('id' => $cm->id, 'itemnumber' => $itemnumber));
$args = array('id' => $cm->id, 'itemnumber' => $itemnumber);
if (isset($element['userid'])) {
$args['userid'] = $element['userid'];
}
return new moodle_url('/mod/' . $itemmodule . '/grade.php', $args);
} else {
return new moodle_url('/mod/' . $itemmodule . '/view.php', array('id' => $cm->id));
}
Expand Down Expand Up @@ -1259,7 +1263,7 @@ public function get_grade_analysis_icon(grade_grade $grade) {
return '';
}

return $OUTPUT->action_icon($url, new pix_icon('i/search',
return $OUTPUT->action_icon($url, new pix_icon('t/preview',
get_string('gradeanalysis', 'core_grades')));
}

Expand Down
15 changes: 10 additions & 5 deletions grade/report/grader/lib.php
Expand Up @@ -1007,10 +1007,10 @@ public function get_right_rows() {
if ($item->needsupdate) {
$itemcell->text .= html_writer::tag('span', get_string('error'), array('class'=>"gradingerror$hidden$gradepass"));
} else {
if ($this->get_pref('showanalysisicon') and !is_null($gradeval)) {
$itemcell->text .= html_writer::tag('span', grade_format_gradevalue($gradeval, $item, true, $gradedisplaytype, null), array('class'=>"gradevalue$hidden$gradepass"));
if ($this->get_pref('showanalysisicon')) {
$itemcell->text .= $this->gtree->get_grade_analysis_icon($grade);
}
$itemcell->text .= html_writer::tag('span', grade_format_gradevalue($gradeval, $item, true, $gradedisplaytype, null), array('class'=>"gradevalue$hidden$gradepass"));
}
}

Expand Down Expand Up @@ -1445,7 +1445,7 @@ public function get_right_avg_row($rows=array(), $grouponly=false) {
* figures out the state of the object and builds then returns a div
* with the icons needed for the grader report.
*
* @param object $object
* @param array $object
* @return string HTML
*/
protected function get_icons($element) {
Expand All @@ -1467,7 +1467,6 @@ protected function get_icons($element) {
$lockunlockicon = '';

if (has_capability('moodle/grade:manage', $this->context)) {

if ($this->get_pref('showcalculations')) {
$editcalculationicon = $this->gtree->get_calculation_icon($element, $this->gpr);
}
Expand All @@ -1479,9 +1478,15 @@ protected function get_icons($element) {
if ($this->get_pref('showlocks')) {
$lockunlockicon = $this->gtree->get_locking_icon($element, $this->gpr);
}

}

$gradeanalysisicon = '';
if ($this->get_pref('showanalysisicon') && $element['type'] == 'grade') {
$gradeanalysisicon .= $this->gtree->get_grade_analysis_icon($element['object']);
}

return $OUTPUT->container($editicon.$editcalculationicon.$showhideicon.$lockunlockicon, 'grade_icons');
return $OUTPUT->container($editicon.$editcalculationicon.$showhideicon.$lockunlockicon.$gradeanalysisicon, 'grade_icons');
}

/**
Expand Down
2 changes: 2 additions & 0 deletions grade/report/grader/styles.css
Expand Up @@ -471,6 +471,8 @@ width:2000px;
float:right;
}

.path-grade-report-grader .action-icon {margin-left:0.3em;}

.path-grade-report-grader .gradestable th.user,
.path-grade-report-grader .gradestable th.range,
.path-grade-report-grader .flexible th,
Expand Down
5 changes: 1 addition & 4 deletions grade/report/user/lib.php
Expand Up @@ -304,6 +304,7 @@ private function fill_table_recursive(&$element) {
$depth = $element['depth'];
$grade_object = $element['object'];
$eid = $grade_object->id;
$element['userid'] = $this->user->id;
$fullname = $this->gtree->get_element_header($element, true, true, true);
$data = array();
$hidden = '';
Expand Down Expand Up @@ -393,10 +394,6 @@ private function fill_table_recursive(&$element) {
$data['grade']['class'] = $class;
$gradeval = $this->blank_hidden_total($this->courseid, $grade_grade->grade_item, $gradeval);
$data['grade']['content'] = grade_format_gradevalue($gradeval, $grade_grade->grade_item, true);

if ($this->get_pref('showanalysisicon') and !is_null($gradeval)) {
$data['grade']['content'] = $this->gtree->get_grade_analysis_icon($grade_grade) . $data['grade']['content'];
}
}
}

Expand Down
27 changes: 21 additions & 6 deletions mod/assignment/lib.php
Expand Up @@ -1078,8 +1078,12 @@ function display_submission($offset=-1,$userid =-1, $display=true) {
if (!empty($submission->id)) {
$itemid = $submission->id;
}
$instanceid = optional_param('advancedgradinginstanceid', 0, PARAM_INT);
$mformdata->advancedgradinginstance = $controller->get_or_create_instance($instanceid, $USER->id, $itemid);
if ($gradingdisabled && $itemid) {
$mformdata->advancedgradinginstance = $controller->get_current_instance($USER->id, $itemid);
} else if (!$gradingdisabled) {
$instanceid = optional_param('advancedgradinginstanceid', 0, PARAM_INT);
$mformdata->advancedgradinginstance = $controller->get_or_create_instance($instanceid, $USER->id, $itemid);
}
} else {
$advancedgradingwarning = $controller->form_unavailable_notification();
}
Expand Down Expand Up @@ -1605,12 +1609,18 @@ function display_submissions($message='') {
* If validation passes, preprocess advanced grading (if applicable) and returns true.
*/
function validate_and_preprocess_feedback() {
global $USER;
global $USER, $CFG;
require_once($CFG->libdir.'/gradelib.php');
if (!($feedback = data_submitted()) || !isset($feedback->userid) || !isset($feedback->offset)) {
return true; // No incoming data, nothing to validate
}
$userid = required_param('userid', PARAM_INT);
$offset = required_param('offset', PARAM_INT);
$grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array($userid));
$gradingdisabled = $grading_info->items[0]->grades[$userid]->locked || $grading_info->items[0]->grades[$userid]->overridden;
if ($gradingdisabled) {
return true;
}
$submissiondata = $this->display_submission($offset, $userid, false);
$mform = $submissiondata->mform;
$gradinginstance = $mform->use_advanced_grading();
Expand Down Expand Up @@ -2391,9 +2401,13 @@ function add_grades_section() {

$grademenu = make_grades_menu($this->_customdata->assignment->grade);
if ($gradinginstance = $this->use_advanced_grading()) {
$mform->addElement('hidden', 'advancedgradinginstanceid', $gradinginstance->get_id());
$gradinginstance->get_controller()->set_grade_range($grademenu);
$mform->addElement('grading', 'advancedgrading', get_string('grade').':', array('gradinginstance' => $gradinginstance));
$gradingelement = $mform->addElement('grading', 'advancedgrading', get_string('grade').':', array('gradinginstance' => $gradinginstance));
if ($this->_customdata->gradingdisabled) {
$gradingelement->freeze();
} else {
$mform->addElement('hidden', 'advancedgradinginstanceid', $gradinginstance->get_id());
}
} else {
// use simple direct grading
$grademenu['-1'] = get_string('nograde');
Expand All @@ -2408,7 +2422,8 @@ function add_grades_section() {
$options = make_grades_menu(-$outcome->scaleid);
if ($outcome->grades[$this->_customdata->submission->userid]->locked) {
$options[0] = get_string('nooutcome', 'grades');
echo $options[$outcome->grades[$this->_customdata->submission->userid]->grade];
$mform->addElement('static', 'outcome_'.$n.'['.$this->_customdata->userid.']', $outcome->name.':',
$options[$outcome->grades[$this->_customdata->submission->userid]->grade]);
} else {
$options[''] = get_string('nooutcome', 'grades');
$attributes = array('id' => 'menuoutcome_'.$n );
Expand Down

0 comments on commit 35a5c49

Please sign in to comment.