Created
October 5, 2011 08:01
-
-
Save mudrd8mz/1263910 to your computer and use it in GitHub Desktop.
Advanced grading methods support in the Assignment module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/mod/assignment/lib.php b/mod/assignment/lib.php | |
index d247b31..bded4ff 100644 | |
--- a/mod/assignment/lib.php | |
+++ b/mod/assignment/lib.php | |
@@ -922,6 +922,7 @@ class assignment_base { | |
require_once($CFG->libdir.'/gradelib.php'); | |
require_once($CFG->libdir.'/tablelib.php'); | |
require_once("$CFG->dirroot/repository/lib.php"); | |
+ require_once("$CFG->dirroot/grade/grading/lib.php"); | |
if ($userid==-1) { | |
$userid = required_param('userid', PARAM_INT); | |
} | |
@@ -1038,6 +1039,18 @@ class assignment_base { | |
} elseif ($assignment->assignmenttype == 'uploadsingle') { | |
$mformdata->fileui_options = array('subdirs'=>0, 'maxbytes'=>$CFG->userquota, 'maxfiles'=>1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL); | |
} | |
+ $gradingman = get_grading_manager($this->context, 'mod_assignment', 'submission'); | |
+ if ($gradingmethod = $gradingman->get_active_method()) { | |
+ $controller = $gradingman->get_controller($gradingmethod); | |
+ if ($controller->is_form_available()) { | |
+ $gradingrenderer = $controller->prepare_renderer($PAGE); | |
+ $gradingwidget = $controller->make_grading_widget($USER->id, $submission->id); | |
+ if ($gradingwidget instanceof renderable) { | |
+ $mformdata->advancedgradingenabled = true; | |
+ $mformdata->advancedgradingwidget = $gradingrenderer->render($gradingwidget); | |
+ } | |
+ } | |
+ } | |
$submitform = new mod_assignment_grading_form( null, $mformdata ); | |
@@ -2275,13 +2288,20 @@ class mod_assignment_grading_form extends moodleform { | |
$attributes['disabled'] ='disabled'; | |
} | |
- $grademenu = make_grades_menu($this->_customdata->assignment->grade); | |
- $grademenu['-1'] = get_string('nograde'); | |
- | |
$mform->addElement('header', 'Grades', get_string('grades', 'grades')); | |
- $mform->addElement('select', 'xgrade', get_string('grade').':', $grademenu, $attributes); | |
- $mform->setDefault('xgrade', $this->_customdata->submission->grade ); //@fixme some bug when element called 'grade' makes it break | |
- $mform->setType('xgrade', PARAM_INT); | |
+ | |
+ if (!empty($this->_customdata->advancedgradingenabled)) { | |
+ $mform->addElement('static', 'advancedgradingwidget', get_string('grade').':', $this->_customdata->advancedgradingwidget); | |
+ | |
+ } else { | |
+ // use simple direct grading | |
+ $grademenu = make_grades_menu($this->_customdata->assignment->grade); | |
+ $grademenu['-1'] = get_string('nograde'); | |
+ | |
+ $mform->addElement('select', 'xgrade', get_string('grade').':', $grademenu, $attributes); | |
+ $mform->setDefault('xgrade', $this->_customdata->submission->grade ); //@fixme some bug when element called 'grade' makes it break | |
+ $mform->setType('xgrade', PARAM_INT); | |
+ } | |
if (!empty($this->_customdata->enableoutcomes)) { | |
foreach($this->_customdata->grading_info->outcomes as $n=>$outcome) { | |
@@ -3677,6 +3697,7 @@ function assignment_supports($feature) { | |
case FEATURE_GRADE_HAS_GRADE: return true; | |
case FEATURE_BACKUP_MOODLE2: return true; | |
case FEATURE_SHOW_DESCRIPTION: return true; | |
+ case FEATURE_ADVANCED_GRADING: return true; | |
default: return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment