Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Moodle 2.0 question bank improvements

From MoodleDocs

Moodle 2.0


Moodle 1.9 introduced the tagging infrastructure. In Moodle 2.0 we should support tagging questions.

With this added metadata, we should provide enhanced facilities for searching the question bank.

In addition, we need to find a way to display all of this extra information. It will not all fit when viewing the question bank on the quiz editing page, so we need to start separating the question bank display that is used to add questions to a quiz, and the stand-alone question bank interface.

This is MDL-16345.

Design

Database changes

New column in the question table, allquestiontext. This is a concatenation of the questiontext, generalfeedback, and any question type specific text fields, with tags stripped. Used for full-text searching. Then change all the places where the question table is queried, to not return this column by default.

To generate this column, we need a get_extra_question_text method in question types, to be called from the save_question method.

New capability

I used to thing that a separate moodle/question:tag capability would be a good idea. I now think it is an unnecessary complication. We will just rely on the standard moodle/question:edit.

UI for tagging questions

There will be a new field on the question editing page for editing the tags.

Question bank display changes

The code for rendering the question bank will be converting into a class. We will either have a abstract base class, and two sub-classes for viewing the question bank along, and within the quiz editing page; or the base class will be used for displaying the question bank alone, with one subclass for display within the quiz editing page.

The code will be structured in such a way it is easy for subclasses (or people who want to customise the code) to control which columns are visible. Probably we will have a little class for each column (type) that controls rendering the heading and the data for a question, and generating the right sort clause and field names in the query. Then we will define the table as an array of column-class instances.

Need to support 'columns' that take a whole extra row, like question text, as well as ones that fit into a <td>.

The compact view will look almost exactly as it does in Olli's new editing interface.

In the full view, there will be new columns "Creator", "Created", "Modified" and "Tags" in addition to what we have now.

We also need methods to customise exactly what appears at the top and bottom of the question bank display, and to control the new filtering UI.

Ways of filtering the question bank

Sorting

Currently, you can sort the question bank by type, name, or age, using a non-standard interface - a drop-down menu of choices.

Instead, make the question bank sortable by any column, using the standard click the column heading mechanism.

Searching

At the moment you can search by

  • question category, optionally including sub-categories
  • including hidden questions (deleted questions that were kept because they are still in use)

Add searching by the following conditions:

  • question type
  • tags
  • creator
  • dates
  • full text search of the question

To facilitate this, we will make a new question_bank_filter base class, with sub-classes for each filter type. These will encapsulate generating where clauses, providing a description of the condition for display to users, and generating interface for the advanced search form.

Question bank advanced search interface

A form for setting the search options. With JavaScript on, this will appear as a pop-up form like the repository file-picker, although when it is submitted, it will have to reload the whole page.

See also