-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
3.5, 4.2.11, 4.1.9, 4.1.15, 4.2.6, 4.3, 4.3.9, 4.5.1
-
MOODLE_35_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE, MOODLE_405_STABLE
-
MDL-61267-master
Update, February 2024: finally, the Moodle 4.x question bank changed got rid of qtype_random, as proposed below.
Unfortunately, while a huge amount of work was done, it seems that people still have rows in the mdl_question their database with qtype = 'random'. See this discussion in the quiz forum. Those should not exist any more. So, I am taking over this issue to use to investigate that. The things to address are:
- Where are these rows coming from? (Guesses include: upgrade never removed them, and/or restoring old backups creates more.)
- Whatever it is, we need to prevent more of these rows from being created.
- Then, we need to code a DB upgrade to clean up the rows that should not exist. (Suitable clean-up queries are given in the forum thread.)
Update: it is restore of old backups: we need to stop that creating qtype randoms, since they are not required. And, it seems that at the moment, qtype random in the backup is creating rows in all of mdl_question, mdl_question_versions and mdl_question_bank_entries.
------
The ability to select questions at random from the question bank is an important feature. However, the way it is currently implemented, with instances of a fake question type sort-of present in the question bank but hidden, causes no end of problems, particularly with backup and restore. There are better ways to store what is going on.
For example, in the quiz, the quiz_slots DB table has a questionid column that directly links to the question for non-random questions, and it has columns categoryid + tag + include subcategories, for randomly selected questions. That is the good way to handle this, and does not require qtype_random at all.
So, qtype_random should be removed (except, possibly, for a stub to support restore of old backups). And all the code simplification that follows from that should be made.