Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-45927

Replace qtype_random with quiz-specific code, and helper methods in the question bank

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Major Major
    • None
    • 2.7
    • Questions, Quiz
    • MOODLE_27_STABLE

      On 9th April 2003, Martin Dougiamas introduced the random question type (https://github.com/moodle/moodle/commit/34d52ad7d29675bc1f1c6275bddf896e262145be) as a clever application of the adaptor pattern to allow questions to be added randomly to the quiz. With the benefit of 11.25 year's hind-sight, we can say this was probably a mistake. Maybe

      The implementation was already greatly simplified as part of the question engine rewrite (MDL-20636, e.g. https://github.com/moodle/moodle/commit/f9b0500f7fc461365303338181c33920a7b2c2c1).

      However, we should probably completely remove qtype_random eventually, since overall it is more trouble than it is worth. Signs that there is a problem:

      • mod/quiz/startattempt.php already has to have some code the manually detect random questions and handle them differently from other questions.
      • special case code when question categories and quizzes are deleted, to clean up unused random questions (see MDL-20154).
      • some of the complexity in question backup and restore.

      What we should do instead:

      1. Change mdl_quiz_slots to allow either a questionid or a categoryid, to mean that either that slot holds a specific question, or one picked at random from a category. (In future this would be more extensible when we want to allow random selection of question by tag, not category.)
      2. Deprecate qtype_random, but leave it in place, to handle restoring old backups, and converting the data to the new DB structure.
      3. Move the useful helper methods (e.g. select a question from this category) from inside qtype_random to core_question question bank library code.
      4. Update the quiz code to work with the new DB structure.
      5. Write the DB upgrade code.

            timhunt Tim Hunt
            timhunt Tim Hunt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.