I think what might be easily misunderstood in Mike's post above is that he is proposing to just develope functionality to report the portion of the grades for different areas of a quiz in both the overview report and in the feedback at the end of the quiz for the student. He doesn't I think intend to modify the quiz grading itself. The bit about the student having to get 40 % in each section is just background information he is not intending to implement this programmatically.
Yep you're spot on Jamie, we're not intending to develop anything to do with threshhold scores for individual categories. Lecturers would just need to communicate the grade boundaries to students, possibly manually overriding grades if they want to.
We're not looking to write anything back to the db (if possible). The summary columns would represent a calculation based on the questions which were used to form the attempt and the source question bank category they originated from.
Tim I take your point about questions being moved to other categories after an attempt. The only way I can see round this would be to have an extra table which would store attempt question ids against source category ids at the point of the attempt. Effectively a snapshot of the quiz contents at the time of attempt for each user (to accomodate random question addition functionality). Not sure if this is efficient though - we're open to suggestions.
I think the conclusion is that you can get what you want relatively easily by using question bank categories, and that is probably your best bet.
However, that is not good enough to get into standard Moodle. A development that is good enough to get into standard Moodle would be a lot more work, and so is unlikely to happen for the forseeable future.
Since what you are developing will not go into standard Moodle, you might want to consider making a Quiz access rule plug-in to hold most of the code. That is really an abuse of that plugin type, but it will let you do the settings on the quiz form with no core changes.
For the places where you do need to change core Moodle code, you could put the code in your plugin, and then make minimal changes in Moodle core to call the new code instead of the old code.
For the view.php display changes, you could use this technique: http://docs.moodle.org/dev/Themes_2.0_overriding_a_renderer to avoid changing core code.
Sadly, the quiz reports have not yet been upgraded to user renderers, so that approach is not yet available.
Anyway, I feel that you should be able to get what you want as an access rule plugins plus a small core patch.
You say "Anyway, I feel that you should be able to get what you want as an access rule plugins plus a small core patch."
Are you suggesting then it would be better to put the overridden renderer in the Quiz access plug in and then make some changes to have the view.php page use that rather than putting the overridden code in the theme?
I am guessing you mean to put the new renderer in the theme. I can't see a mechanism to override a renderer outside the theme, although I expect it would be possible to assign a new renderer factory or the renderer itself before it is used. Would be nice to get all this code in one place althought overriding the renderer outside the theme would certainly mean at least a line or two of extra code added to the core code.
Methods on the accessmanager class are called between the fetching of the renderer and the use of the renderer in view.php I bet we could delve into the global variables $THEME or some other global and reassign the renderer which is referenced by the local variable but that would be quite ugly and an abuse too far I think even if it did then mean we would have shoe horned the code into the access rule plug in.
I am not suggesting that.
If you want to change something that is controlled by a renderer, override that renderer in your custom theme.
If the bit you want to change is not controlled by a renderer, then plan B is to put most of the code in some sort of plugin, and make a minimal change in core to call your code instead of the standard code. A local_ plugin is good if there is nothing more appropriate, but in this cases there is a better plugin type.
I implemented this as a local plug in with the minimum of changes to Moodle core code. Here is the code : https://github.com/jamiepratt/moodle-mod_quiz_accessrule_gradebycategory
See the README at the bottom of the page for detailled instructions of how to install. This should work with Moodle 2.3 and upwards. Tested on Moodle 2.3 and 2.4.
That is crazy! Brilliant, but a crazy abuse of what accessrule plugins were intended for.
Do you have any thought about simple changes to the quiz code, to add more hooks, that would reduce the number of core code changes required to install this?
For example MDL-39050.
If we could add admin menu items using settings.php in the accessrule plug in and we converted lib/tablelib and all the places it is used to use renderers then we wouldn't need to modify core code at all to implement this.
I installed and can see all the options and have enabled by category.... but it doesn't show on the report, am I looking in the wrong place or being stupid!?
For those having trouble with the above, we will have an alternative available within about 60 days that does not require any core changes. We will be coding for Moodle 2.7. It might work back to 2.3 or so, but we'll be testing on 2.7 and above. Keep an eye on this forum for future updates.