Permalink
Browse files

Merge branch 'MDL-37635-24' of git://github.com/damyon/moodle into MO…

…ODLE_24_STABLE
  • Loading branch information...
2 parents ecd6063 + 5c15ab2 commit 3e0ddd4cfd302cc281e8fc9bdf70e7bae3d5e7aa @danpoltawski danpoltawski committed Feb 4, 2013
Showing with 60 additions and 32 deletions.
  1. +46 −22 mod/assign/locallib.php
  2. +14 −10 mod/assign/renderer.php
View
@@ -1766,7 +1766,8 @@ private function view_course_index() {
}
}
$grading_info = grade_get_grades($course->id, 'mod', 'assign', $cm->instance, $USER->id);
- if (isset($grading_info->items[0]) && !$grading_info->items[0]->grades[$USER->id]->hidden ) {
+ if (isset($grading_info->items[0]->grades[$USER->id]) &&
+ !$grading_info->items[0]->grades[$USER->id]->hidden ) {
$grade = $grading_info->items[0]->grades[$USER->id]->str_grade;
} else {
$grade = '-';
@@ -2910,8 +2911,12 @@ public function view_student_summary($user, $showlinks) {
$this->get_instance()->id,
$user->id);
- $gradingitem = $gradinginfo->items[0];
- $gradebookgrade = $gradingitem->grades[$user->id];
+ $gradingitem = null;
+ $gradebookgrade = null;
+ if (isset($gradinginfo->items[0])) {
+ $gradingitem = $gradinginfo->items[0];
+ $gradebookgrade = $gradingitem->grades[$user->id];
+ }
// check to see if all feedback plugins are empty
$emptyplugins = true;
@@ -2925,25 +2930,34 @@ public function view_student_summary($user, $showlinks) {
}
}
+ $cangrade = has_capability('mod/assign:grade', $this->get_context());
+ // If there is feedback or a visible grade, show the summary.
+ if ((!empty($gradebookgrade->grade) && ($cangrade || !$gradebookgrade->hidden)) ||
+ !$emptyplugins) {
- if (!($gradebookgrade->hidden) && ($gradebookgrade->grade !== null || !$emptyplugins)) {
-
- $gradefordisplay = '';
+ $gradefordisplay = null;
+ $gradeddate = null;
+ $grader = null;
$gradingmanager = get_grading_manager($this->get_context(), 'mod_assign', 'submissions');
- if ($controller = $gradingmanager->get_active_controller()) {
- $controller->set_grade_range(make_grades_menu($this->get_instance()->grade));
- $gradefordisplay = $controller->render_grade($PAGE,
- $grade->id,
- $gradingitem,
- $gradebookgrade->str_long_grade,
- has_capability('mod/assign:grade', $this->get_context()));
- } else {
- $gradefordisplay = $this->display_grade($gradebookgrade->grade, false);
+ // Only show the grade if it is not hidden in gradebook.
+ if (!empty($gradebookgrade->grade) && ($cangrade || !$gradebookgrade->hidden)) {
+ if ($controller = $gradingmanager->get_active_controller()) {
+ $controller->set_grade_range(make_grades_menu($this->get_instance()->grade));
+ $gradefordisplay = $controller->render_grade($PAGE,
+ $grade->id,
+ $gradingitem,
+ $gradebookgrade->str_long_grade,
+ $cangrade);
+ } else {
+ $gradefordisplay = $this->display_grade($gradebookgrade->grade, false);
+ }
+ $gradeddate = $gradebookgrade->dategraded;
+ if (isset($grade->grader)) {
+ $grader = $DB->get_record('user', array('id'=>$grade->grader));
+ }
}
- $gradeddate = $gradebookgrade->dategraded;
- $grader = $DB->get_record('user', array('id'=>$grade->grader));
$feedbackstatus = new assign_feedback_status($gradefordisplay,
$gradeddate,
@@ -4154,12 +4168,22 @@ public function add_grade_form_elements(MoodleQuickForm $mform, stdClass $data,
}
}
- if (has_all_capabilities(array('gradereport/grader:view', 'moodle/grade:viewall'), $this->get_course_context())) {
- $gradestring = $this->get_renderer()->action_link(new moodle_url('/grade/report/grader/index.php',
- array('id'=>$this->get_course()->id)),
- $gradinginfo->items[0]->grades[$userid]->str_grade);
+ $capabilitylist = array('gradereport/grader:view', 'moodle/grade:viewall');
+ if (has_all_capabilities($capabilitylist, $this->get_course_context())) {
+ $urlparams = array('id'=>$this->get_course()->id);
+ $url = new moodle_url('/grade/report/grader/index.php', $urlparams);
+ $usergrade = '-';
+ if (isset($gradinginfo->items[0]->grades[$userid]->str_grade)) {
+ $usergrade = $gradinginfo->items[0]->grades[$userid]->str_grade;
+ }
+ $gradestring = $this->get_renderer()->action_link($url, $usergrade);
} else {
- $gradestring = $gradinginfo->items[0]->grades[$userid]->str_grade;
+ $usergrade = '-';
+ if (isset($gradinginfo->items[0]->grades[$userid]) &&
+ !$grading_info->items[0]->grades[$userid]->hidden) {
+ $usergrade = $gradinginfo->items[0]->grades[$userid]->str_grade;
+ }
+ $gradestring = $usergrade;
}
$mform->addElement('static', 'finalgrade', get_string('currentgrade', 'assign').':', $gradestring);
View
@@ -324,17 +324,21 @@ public function render_assign_feedback_status(assign_feedback_status $status) {
$o .= $this->output->box_start('boxaligncenter feedbacktable');
$t = new html_table();
- $row = new html_table_row();
- $cell1 = new html_table_cell(get_string('grade'));
- $cell2 = new html_table_cell($status->gradefordisplay);
- $row->cells = array($cell1, $cell2);
- $t->data[] = $row;
+ // Grade.
+ if (isset($status->gradefordisplay)) {
+ $row = new html_table_row();
+ $cell1 = new html_table_cell(get_string('grade'));
+ $cell2 = new html_table_cell($status->gradefordisplay);
+ $row->cells = array($cell1, $cell2);
+ $t->data[] = $row;
- $row = new html_table_row();
- $cell1 = new html_table_cell(get_string('gradedon', 'assign'));
- $cell2 = new html_table_cell(userdate($status->gradeddate));
- $row->cells = array($cell1, $cell2);
- $t->data[] = $row;
+ // Grade date.
+ $row = new html_table_row();
+ $cell1 = new html_table_cell(get_string('gradedon', 'assign'));
+ $cell2 = new html_table_cell(userdate($status->gradeddate));
+ $row->cells = array($cell1, $cell2);
+ $t->data[] = $row;
+ }
if ($status->grader) {
$row = new html_table_row();

0 comments on commit 3e0ddd4

Please sign in to comment.