MDL-10549 fixed outcoems appearing in assingment when not used
This commit is contained in:
+4
-2
@@ -306,7 +306,7 @@ function grade_is_locked($courseid, $itemtype, $itemmodule, $iteminstance, $item
|
||||
* @param int $userid ID of the graded user
|
||||
* @return array of outcome information objects (scaleid, name, grade and locked status) indexed with itemnumbers
|
||||
*/
|
||||
function grade_get_outcomes($courseid, $itemtype, $itemmodule, $iteminstance, $userid) {
|
||||
function grade_get_outcomes($courseid, $itemtype, $itemmodule, $iteminstance, $userid=0) {
|
||||
$result = array();
|
||||
if ($items = grade_item::fetch_all(array('itemtype'=>$itemtype, 'itemmodule'=>$itemmodule, 'iteminstance'=>$iteminstance, 'courseid'=>$courseid))) {
|
||||
foreach ($items as $item) {
|
||||
@@ -322,7 +322,9 @@ function grade_get_outcomes($courseid, $itemtype, $itemmodule, $iteminstance, $u
|
||||
$o->scaleid = $outcome->scaleid;
|
||||
$o->name = $outcome->fullname;
|
||||
|
||||
if ($grade = $item->get_grade($userid,false)) {
|
||||
if (empty($userid)) {
|
||||
//no user info
|
||||
} if ($grade = $item->get_grade($userid,false)) {
|
||||
$o->grade = $grade->finalgrade;
|
||||
$o->locked = $grade->is_locked();
|
||||
} else {
|
||||
|
||||
+14
-7
@@ -988,6 +988,12 @@ class assignment_base {
|
||||
$quickgrade = get_user_preferences('assignment_quickgrade', 0);
|
||||
}
|
||||
|
||||
if (!empty($CFG->enableoutcomes) and grade_get_outcomes($this->course->id, 'mod', 'assignment', $this->assignment->id)) {
|
||||
$uses_outcomes = true;
|
||||
} else {
|
||||
$uses_outcomes = false;
|
||||
}
|
||||
|
||||
$teacherattempts = true; /// Temporary measure
|
||||
$page = optional_param('page', 0, PARAM_INT);
|
||||
$strsaveallfeedback = get_string('saveallfeedback', 'assignment');
|
||||
@@ -1023,7 +1029,7 @@ class assignment_base {
|
||||
$users = get_users_by_capability($context, 'mod/assignment:submit', '', '', '', '', $currentgroup, '', false);
|
||||
|
||||
$tablecolumns = array('picture', 'fullname', 'grade', 'submissioncomment', 'timemodified', 'timemarked', 'status');
|
||||
if (!empty($CFG->enableoutcomes)) {
|
||||
if ($uses_outcomes) {
|
||||
$tablecolumns[] = ''; // no sorting based on outcomes column
|
||||
}
|
||||
|
||||
@@ -1034,7 +1040,7 @@ class assignment_base {
|
||||
get_string('lastmodified').' ('.$course->student.')',
|
||||
get_string('lastmodified').' ('.$course->teacher.')',
|
||||
get_string('status'));
|
||||
if (!empty($CFG->enableoutcomes)) {
|
||||
if ($uses_outcomes) {
|
||||
$tableheaders[] = get_string('outcomes', 'grades');
|
||||
}
|
||||
|
||||
@@ -1059,7 +1065,7 @@ class assignment_base {
|
||||
$table->column_class('timemodified', 'timemodified');
|
||||
$table->column_class('timemarked', 'timemarked');
|
||||
$table->column_class('status', 'status');
|
||||
if (!empty($CFG->enableoutcomes)) {
|
||||
if ($uses_outcomes) {
|
||||
$table->column_class('outcomes', 'outcomes');
|
||||
}
|
||||
|
||||
@@ -1214,16 +1220,17 @@ class assignment_base {
|
||||
|
||||
$outcomes = '';
|
||||
|
||||
if (!empty($CFG->enableoutcomes) and $outcomes_data = grade_get_outcomes($this->course->id, 'mod', 'assignment', $this->assignment->id, $auser->id)) {
|
||||
if ($uses_outcomes and $outcomes_data = grade_get_outcomes($this->course->id, 'mod', 'assignment', $this->assignment->id, $auser->id)) {
|
||||
|
||||
foreach($outcomes_data as $n=>$data) {
|
||||
$outcomes .= '<div class="outcome"><label>'.format_string($data->name).'</label> ';
|
||||
$outcomes .= '<div class="outcome"><label>'.format_string($data->name).'</label>';
|
||||
$options = make_grades_menu(-$data->scaleid);
|
||||
|
||||
if ($data->locked or !$quickgrade) {
|
||||
$options[0] = get_string('nooutcome', 'grades');
|
||||
$outcomes .= ':<span id="outcome_'.$n.'_'.$auser->id.'">'.$options[$data->grade].'</span>';
|
||||
$outcomes .= ': <span id="outcome_'.$n.'_'.$auser->id.'">'.$options[$data->grade].'</span>';
|
||||
} else {
|
||||
$outcomes .= ' ';
|
||||
$outcomes .= choose_from_menu($options, 'outcome_'.$n.'['.$auser->id.']',
|
||||
$data->grade, get_string('nooutcome', 'grades'), '', 0, true, false, 0, 'outcome_'.$n.'_'.$auser->id);
|
||||
}
|
||||
@@ -1233,7 +1240,7 @@ class assignment_base {
|
||||
|
||||
|
||||
$row = array($picture, fullname($auser), $grade, $comment, $studentmodified, $teachermodified, $status);
|
||||
if (!empty($CFG->enableoutcomes)) {
|
||||
if ($uses_outcomes) {
|
||||
$row[] = $outcomes;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user