diff --git a/grade/report/grader/edit_grade.php b/grade/report/grader/edit_grade.php index beef3575b6b..5052c7660f6 100644 --- a/grade/report/grader/edit_grade.php +++ b/grade/report/grader/edit_grade.php @@ -20,14 +20,19 @@ require_capability('gradereport/grader:manage', $context); // default return url $returnurl = $CFG->wwwroot.'/grade/report.php?report=grader&id='.$course->id; -$mform = new edit_grade_form(qualified_me(), array('id'=>$id)); +$grade_grades = get_record('grade_grades', 'id', $id); +$gradeitem = get_record('grade_items', 'id', $grade_grades->itemid); + +$mform = new edit_grade_form(qualified_me(), array('gradeitem'=>$gradeitem)); if ($grade_grades = get_record('grade_grades', 'id', $id)) { if ($grade_text = get_record('grade_grades_text', 'gradeid', $id)) { $mform->set_data($grade_text); - } + } + $grade_grades->locked = $grade_grades->locked > 0 ? 1:0; $grade_grades->courseid = $courseid; $mform->set_data($grade_grades); + } else { $mform->set_data(array('courseid'=>$course->id, 'id' => $id)); } diff --git a/grade/report/grader/edit_grade_form.php b/grade/report/grader/edit_grade_form.php index 31d2f637dd5..17088e59204 100755 --- a/grade/report/grader/edit_grade_form.php +++ b/grade/report/grader/edit_grade_form.php @@ -4,12 +4,11 @@ require_once $CFG->libdir.'/formslib.php'; class edit_grade_form extends moodleform { function definition() { + global $CFG, $USER; $mform =& $this->_form; - $id = $this->_customdata['id']; - $grade_grades = get_record('grade_grades', 'id', $id); - $gradeitem = get_record('grade_items', 'id', $grade_grades->itemid); + $gradeitem = $this->_customdata['gradeitem']; /// actual grade - numeric or scale if ($gradeitem->gradetype == 1) { @@ -29,13 +28,12 @@ class edit_grade_form extends moodleform { $mform->addElement('select', 'finalgrade', get_string('finalgrade', 'grades'), $scaleopt); } - /// hidden /// hidden $mform->addElement('advcheckbox', 'hidden', get_string('hidden', 'grades')); /// locked - $mform->addElement('advcheckbox', 'locked', get_string('locked', 'grades'),'','',$grade_grades->locked); + $mform->addElement('advcheckbox', 'locked', get_string('locked', 'grades')); /// locktime $mform->addElement('date_time_selector', 'locktime', get_string('locktime', 'grades'), array('optional'=>true)); @@ -49,7 +47,7 @@ class edit_grade_form extends moodleform { // User preference determines the format if ($CFG->htmleditor && $USER->htmleditor && $feedbackformat == GRADER_REPORT_FEEDBACK_FORMAT_HTML) { $mform->addElement('htmleditor', 'feedback', get_string('feedback', 'grades'), - array('rows'=> '15', 'course' => optional_param('courseid', PARAM_INT), 'cols'=>'45')); + array('rows'=> '15', 'course' => $gradeitem->courseid, 'cols'=>'45')); } else { $mform->addElement('textarea', 'feedback', get_string('feedback', 'grades')); } @@ -69,4 +67,4 @@ class edit_grade_form extends moodleform { } } -?> +?> \ No newline at end of file