Right now it is very difficult to support multiple grading of a single activity.
For example, you cannot easily add support to both grade a user's entire contribution to a forum and their individual posts without duplicating much of the work done in the standard_grading_coursemodule_elements function. In addition, Moodle currently assumes that all grading features supported by an activity are supported by all gradable areas.
In reality there are times where you will want to have multiple graded things, with each thing having different support.
For example the rating of individual forum posts obviously only support ratings and not more advanced grading features like Advanced grading and outcomes. Meanwhile a secondary grading thing to grading a users involvement via a Rubric or other advanced grading feature needs to support advanced grading too.
I feel that the best way to support this is to move away from whole-activity feature flags for grading (FEATURE_GRADE_HAS_GRADE, FEATURE_GRADE_OUTCOMES, FEATURE_ADVANCED_GRADING, FEATURE_RATE, and potentially FEATURE_PLAGIARISM) to the creation of an API whereby an activity defines each of the potential grading things, and which features that particular thing supports.
This needs to replace the existing grading mechanisms, but we will need to continue supporting the legacy way for the deprecation period.
I would suggest:
- a new Interface in core_course\grades\graded_activity_area
- implementations of the Interface in mod_[modname]\core_course\grades\graded_activity_areas[areaname]
- a new manager class and/or factory to fetch the relevant items
- a new function in \moodleform_mod which allows activities to add an individual graded thing to the form in the order and location preferred. This will replace all uses of the existing standard_grading_coursemodule_elements function. It will also need to be married with any calls to definition_after_data and validation
- deprecation of standard_grading_coursemodule_elements
- support for different grade categories per item
In reality this is pretty feasible. I started on a branch doing this for
MDL-66079 but have had to revert to doing it by hand for now in the interest of expediency. We should however attempt to do this for 3.8 time allowing.
As far as I'm aware, the only other place which currently has multiple graded things is Workshop so I'll cc David Mudrák (@mudrd8mz) for his interest here too. There are other areas which would benefit from such a change - for example pretty much anything that uses ratings to allow students to rate an item and then staff to grade the contributions separately.