Plan to Convert question bank to activity module

Jump to: navigation, search
Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable.

This plan was scrapped

This plan was scrapped (see 'Plan for the conversion of the question bank into an activity module' discussion on General Developer Forums for reasons)! And I'm now working on a new plan Plan to Improve Flexibility of Question Category Sharing and Permissions also discussed in the same forum discussion here with new heading 'Plan to Improve Flexibility of Question Category Sharing and Permissions'.

Convert question bank

Making the question bank an activity module allows us :

  • to have more than one question bank in a course and
  • to use activity module roles and permissions and restore and backup framework for question banks rather than special case code.

Code changes

  • move files in /question to mod/qb directory
    • rename edit.php to mod/qb/view.php
    • mod/qb/index.php will list available question banks.
  • implement mod/ hooks to question bank and remove special case code for question roles
    • activity visibility.
      • activity will be visible or invisible as normal in course view. (chosen when setting up new question bank)
      • But need to check that mod is visible if students are allowed to edit / create questions.
  • new {prefix}qb table for question bank
  • prefix qb_ to all tables of question bank. To comply to the convention that all module tables are prefixed with the module name
  • new field in {prefix}qb_question_categories table to point to {prefix}qb table
  • When more than one question banks is available add available question bank names as a replacement for TOP in parent drop down box when creating a category and add it to drop down box when creating a question.
    • Available question banks depend on the permissions of the current user.


Test operation of question bank adding questions.

Make Question Bank Work with Quizzes

  • fix urls and include paths and anything else that has been broken in quiz module


  • Test quiz set up to see it works as normal.

Conversion of Existing Question Data in db

  • On conversion questions default invisible question bank in first topic of course created with permissions the same as old question bank (only if there are existing questions - no default qb created otherwise).
  • All existing questions added to this question bank.
  • modify roles in db to use new mod/qb roles.


Test update of existing questions in database to work with mod/qb banks.

Check for Breakage in Log Messages

Check existing log messages. See that they're not affected by db changes and question bank API changes.

Backup and Restore

Implement Restore of Old Question Bank Backup to New db structure

Implement restore of existing question banks backups to new db structure. User will be asked to se

Implement Backup of New db structure to New Question Bank Backup Format

Implement Backup of db structure after conversion to new question bank backup format. Format same as other activity modules new top level xml tag <qb> with module name <questions> nested within <qb>

Implement Restore of New db structure from New Question Bank Backup Format

Will be able to restore new and old question bank backup format.

Backup Dependencies

  • Add hook in mod/qb/backuplib.php for modules to tell moodle what other module instances are necessary.
  • Call it so that we can make sure that when a quiz is selected that all question banks required are also selected.
  • Throw a warning if somehow a user selects a module but has not selected the module dependencies, and then go ahead and backup the dependencies anyway.
  • Make sure that the code works as expected for shared questions from other courses. See :

More sophisticated Permissions for Question Bank

This needs more thinking about but I'd like to see more sophisticated permissions for each question bank. Something along these lines.

Seperate permissions for :

  • read all questions
  • create own question permission
  • edit own question permission
  • delete own question permission.
  • edit others question permission
  • delete others question permission.

Need to add a user id to question record for question creator and last editor.

Need a follow of the different authors to limit somewhat plagiarism like this wiki page. A comma separated list of id could be useful. However if we allow import and export (and the import/export is working for this question_type...) the identification list is less useful against plagiarism.

User id defaults to NULL or 0 when updating old database.

Further Work Needed

Hopefully the conversion of question banks into activity modules will then make the problem of access to media from shared questions easier to handle. Petr's modfile.php patch might help with this see