Here is a method to extract subscores from Quiz (or any other Moodle activity that allows you to set different point values per question), without requiring any changes to Moodle code. It is a bit complex, but it does work. However, this method is only useful if you don't plan to use or display the final Quiz score, but you only want to display and use the subscores.
Step 1: Create Quiz and set values of Questions
Start by creating a quiz as usual. However, for each subscore you want to extract, you will need to set the values of questions for that subscore to an order of magnitude matching that subscore. This is easiest to understand with an example. Suppose you are creating a test that will contain questions from three areas: Mathematics, Language, and History. In this example, Mathematics is Topic 1, Language is Topic 2, and History is Topic 3.
For each topic, use a different point value for each question in that topic. For Topic 1 (Mathematics), each question is worth 1 point. For Topic 2 (Language), each question is worth 10 points. For Topic 3 (History), each question is worth 100 points. (Note that this is going to make your final quiz score meaningless.)
Important: set the total points of the quiz to the same as the total of all the questions. Otherwise, the Quiz will change its scores based on whatever you set as the maximum number of points for the Quiz, and your calculations in later steps won't work correctly.
You also need to give the Quiz activity an ID number that you will be able to remember later. In this example we will use "Pretest".
Step 2: Create Grade Items for each topic
Next, create one new Manual Grade Item for each of your Topics. Important: put these Grade Items into a separate category that does NOT have Natural Weighting as the grade aggregation method. After saving each Grade Item, you will edit the Calculation for the item directly in the item's Edit menu.
The calculation looks like this (where [[Pretest]] is the ID of the quiz score you are breaking into subscores):
where "topicvalue" is the same as the number of points each question in the topic is worth in step 1. So for Topic 1, the calculation is:
For Topic 2, the calculation is:
For Topic 3, the calculation is:
mod(dividend, divisor): Calculates the remainder of a division
floor(number): Maps a real number to the largest previous integer
What this does is extract the digit from the quiz grade. So Topic 1 gets the "ones" digit, topic 2 gets the "tens" digit, etc. Note that this means you can only have up to 9 quiz questions per topic (not 10, otherwise you could not tell the difference between 10 correct answers at 1 point each and 1 correct answer at 10 points each).
The maximum number of topics depends on the number of questions per topic and is limited by both the maximum allowable values of Maximum grade and Total of marks for the quiz. With 9 questions per topic, these limits allow a maximum of 4 sections. See below for larger numbers of topics or questions per topic.
At this point, you may want to test your quiz with some sample students so you can see how this looks in the Gradebook.
Note: you can aggregate these subscores at the level of the category you created for them by using any of the available aggregation methods (sum, mean, min, max, etc.) and show the result in place of the original Quiz score, if needed.
Use your Subscores
Now, you have manual grade items for each topic, and they have values you can use in controlling visibility/access to activities. For example, set some labels to display or not display based on subscores from the first quiz. These labels can contain advisory text to students, letting them know whether they should complete a section of the course. You could also hide the section if the student has done well enough on the pretest, or show a section that is normally hidden if the student did poorly enough to need remedial material.
Larger numbers of topics or questions per topic
With n questions per topic, you must use calculations in base of at least n+1. For example, with 10 questions per topic, you must use base-11 calculations. If you have 4 questions per topic, you could use base-5 calculations.
With 10 questions per topic and base-11 calculations, the mark for the questions in the first topic is 1, the mark for the questions in the second topic is 11, third topic 121, fourth topic 1331, etc. For topic 1 the calculation is
, for section 2 the calculation is
, for section 3 the calculation is
In general, we have:
Number of questions per topic : n
Base for calculations : b = n + 1
Value for topic t (t = 1, 2,...) : topicvalue(t) = bᵗ⁻¹
Calculation for topic t : =mod(floor([[Pretest]]/topicvalue(t)),b)
Maximum grade for the quiz : = n*[ b⁰ + b¹ + b² + ... + b**(number of topics - 1) ]
Total of marks = Maximum grade for the quiz
Both Maximum grade and Total of marks for the quiz must be less than or equal to their maximum allowable values which are respectively 90 909 and 99 999 by default. For example, with 4 questions per topic and base-5 calculations, the maximum number of topics is 7 with the Maximum grade and Total of marks set at 78 124 (less than or equal to 90 909). Mishael Ogochukwu reported that he got around the limits for Maximum grade and Total Marks by adjusting the datatype for "sumgrades", "maxmark", "grade", "finalgrade", "rawgrademax" and "rawgrade" in the Moodle database to allow for a higher grade number.
Detailed examples can be found at MoodleFormulas.org.