Development:Grade settings modules: Difference between revisions
Andrew Davis (talk | contribs) |
Andrew Davis (talk | contribs) |
||
Line 47: | Line 47: | ||
| int(4) | | int(4) | ||
| | | | ||
| The grading method the module instance uses | | The grading method the module instance uses. For example highest grade, average grade, last attempt, first attempt. These are currently hard coded. Should these be moved into a table? | ||
|- | |||
| decimalpoints | |||
| int(4) | |||
| | |||
| How many decimal points should be displayed | |||
|- | |||
| applypenalties | |||
| int(4) | |||
| | |||
| Used by quiz module. Should students be penalized for incorrect answers. | |||
|} | |} | ||
Revision as of 08:00, 28 January 2010
Note: This page is a work-in-progress. Feedback and suggested improvements are welcome. Please join the discussion on moodle.org or use the page comments.
Executive Summary
Module grade settings should be provided and stored in a central location rather than being handled by each individual module. In the UI, grade settings should appear in their own section provided by grade library.
- Reduce duplicate code - Requiring each module to be aware of grading settings leads to unnecessary duplication of grading code.
- Allow centralized grading - Shifting all grade related settings into the grade tables makes it easier to provide a centralized marking UI.
Interface
Database structures
New tables to be created
grade_modules_settings
Holds the grade related settings for all modules. Additional columns, course id etc, may be required/desirable to make getting and setting of the settings easier.
Field | Type | Default | Info |
---|---|---|---|
id | int(10) | auto-incrementing | The unique ID for this setting. |
coursemoduleid | int(10) | The PK of the associated record in course_modules - identifies the instance of module associated with the settings. | |
grade | int(10) | The grade | |
grademethod | int(4) | The grading method the module instance uses. For example highest grade, average grade, last attempt, first attempt. These are currently hard coded. Should these be moved into a table? | |
decimalpoints | int(4) | How many decimal points should be displayed | |
applypenalties | int(4) | Used by quiz module. Should students be penalized for incorrect answers. |
The following columns need to be migrated to the new system then removed.
- assignment - grade
- quiz - grade, grademethod
Code Alterations
Class moodleform_mod()
in course/moodleform_mod.php
the following new method will be added
coursemodule_grading_elements()
Similar to standard_coursemodule_elements(). Adds elements to a private instance of moodle form. A new method is being added rather than adding grading elements to those already output by standard_coursemodule_elements() to allow the grading elements to appear near the top of page, just below the General section. Standard elements are usually added at the bottom of the settings. The assignment and quiz modules in 1.9 have their grade settings at the top and shifting them to the bottom would be unexpected.
It will determine whether to include a grade and grading method element by calling plugin_supports() found in lib/moodlelib.php like this...
if (plugin_supports('mod', $mod, FEATURE_GRADE_HAS_GRADE, false)) {
//include grade element
}
Module Enhancements
Each module's mod_form.php definition() method, for example in mod/assignment/mod_form.php, will then call $this->coursemodule_grading_elements() to insert the grading elements.
Another constant like FEATURE_GRADE_HAS_GRADE called FEATURE_GRADE_HAS_GRADING_METHOD will be needed for modules like quiz that have a variable grading method.
Each module's %modname%_supports() method, for example assignment_supports() in the assignment modules, will need to be checked and possibly altered to specify the modules support for a grade and grading method.
Outstanding Issues
Where is the code that actually makes use of the module instance grade setting?