Note:

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

Improved Question Bank Tags: Difference between revisions

From MoodleDocs
Line 92: Line 92:
These images are mockups '''for illustration only''' and are not to be taken as the final UI design.
These images are mockups '''for illustration only''' and are not to be taken as the final UI design.


[[File:RandomQuestionFromListMenu.png|frame|center|Random question from list added to quiz structure menu]]
[[File:RandomQuestionFromListMenu.png|frame|center|Add a random question from a category + tag]]


[[File:RandomQuestionPopup.png|frame|center|Dialog to edit the list of random questions]]
[[File:RandomQuestionInQuiz.png|frame|center|Random question from category + tag added to a quiz]]
 
[[File:RandomQuestionPicker.png|frame|center|Question picker to add questions to the random list]]
 
[[File:RandomQuestionInQuiz.png|frame|center|Random question from list added to a quiz]]


==== Upgrade Steps Required ====
==== Upgrade Steps Required ====

Revision as of 08:52, 16 November 2017

Overview

This document is the technical design for a set of features proposed by the Moodle Users Association for Moodle 3.5.

The project proposal is here: https://moodleassociation.org/mod/page/view.php?id=465

The requirements / user stories have been written by the MUA - a copy is included here for clarity

User Stories / Requirements

Must:

  • As a teacher, I can add tag(s) to a question bank question for use in my course for organizational and search/filtering of questions.
  • As a teacher, I can filter my questions in courses based on tags.
  • As a teacher, I can see tags on questions at higher category assigned by Question sharer role holder.
  • As another teacher in the same course, I have access to the question tags on the questions in that course context.
  • As a teacher in a course, I do not see tags of other in contexts I do not have access to. (Instructor 1’s “midterm 1” question set would not be relevant to Instructor 2)
  • As a teacher, I am able to add/modify/remove tags on questions.
  • As a teacher, I should not have to copy a question into my course from higher category contexts to include it in a ‘random question from question set’ question type.
  • As a teacher, I can add a 'random question from question set' question type to my quiz where the question set is a selectable list of questions. These questions can be searched for and filtered by tag but the set itself is not defined by specifying a tag.

Nice to have:

  • Tags can contain any visible ASCII characters including characters such as apostrophes, slashes, and colons. Exception of Comma.
  • As a teacher, when searching for questions to add to a ‘random question from question set’ I see the question with its context clearly visible.
  • As a teacher, I can export/import questions with their tags.
  • As a Question sharer role holder, I can add a tag(s) to a question bank questions that exist at the category context.
  • As a Question sharer role holder, I can search/filter all the questions I have access to and see them along with their context.

Updates

16th Nov 2017

It was discussed that the "random question from a set of questions" is not ideal because it is hard to "manage" the set of questions, e.g. adding or deleting questions from a set would have to be done individually for every question instance using the set. Adding 10 random questions from a set would create 10 individual questions with the list of question ids stored in each (and each would then require updating individually). It also becomes more difficult to prevent a student from seeing the same random question in the same quiz more than once.

Initially "random question from a tag" was discarded earlier because there are problems when users with different permissions are editing the question. If we add the questioncategory (context) to the information that would solve the ambiguity. So we would have only one random question type, which could be further restricted by specifying a tag. We also need to meet the use case where we want to use questions from different question categories.

This impacts one of the user requirements for the project:

"As a teacher, I can add a 'random question from question set' question type to my quiz where the question set is a selectable list of questions. These questions can be searched for and filtered by tag but the set itself is not defined by specifying a tag."

would have to be modified to:

"As a teacher, I can add a 'random question' to my quiz where the question is taken from multiple question categories with optional filtering by tags."

Note for Tim: We discussed having all the data in the slots table, but that's not really possible because the MUA requires the ability to pull random questions from multiple categories. So it needs to be stored as a list of question categories, and optional tags.

Design

The requirements listed above can be met by implementing the following changes (which are described in detail further down):

  • New question type "Random question from a question category + tag"
  • Enhanced question search allowing search/filter by tag everywhere
  • Allow adding course level tags to questions that exist in a category

Random question from a question category + tag

Architecture

Currently the quiz_slots DB table has a questionid column that directly links to the question for that slot. We will make this field optional (allow null). The slot type can be determined by the presence or absence of the questionid field.

The slot type can be determined from the fields in the quiz_slots table. After these changes there will only be 2 possible slot types (single question, or random question). The random question will require a new table storing a list of questioncategoryid and an optional tag.

Classes could go in a new namespace corresponding to mod/quiz/classes/local/structure/. Should rpobalby move the existing classes/structure.php & repaginate.php in there. We will introduce a new abstract class "mod_quiz\local\structure\slot_type".

The slot_type subclass will be responsible for:

  • Determining a specific question id from a quizid + slotid + userid. A new question id is only queried when a new attempt is started, or a question is re-attempted.
  • Display of UI to configure this slot type (JS and non-JS).

When the slottype is "single" - the \mod_quiz\local\structure\slot_single class is loaded directly from the quiz (not a sub-plugin). When the slottype is "random" the \mod_quiz\local\structure\slot_random class is loaded directly from the quiz (also not a sub-plugin).

Other related code improvements

Tim has requested to move the classes from classes/structure.php and classes/repaginate.php to the mod_quiz\local\structure namespace and combine them.

Before modifying the existing quiz editing UI, Tim has requested that we move it from YUI + custom ajax to AMD + Templates and webservices.

DB changes

Update the quiz_slots table to change questionid to allow null.

quiz_slots(id, slot, quizid, page, requireprevious, question, maxmark, category, tagid)

Introduce 1 new table to store a list of questioncategoryid + optional tagid for each random question slot.

quiz_randomslot(id, quizslotid, category, tagid *allow null*)

DB structure changes

UI changes

These images are mockups for illustration only and are not to be taken as the final UI design.

Add a random question from a category + tag
Random question from category + tag added to a quiz

Upgrade Steps Required

  • We will need to change the questionid column of the quiz_slots table to allow null. (Quick DB update, no conflicts to resolve).
  • We will need to add columns to the quiz_slots table for questioncategoryid and tagid. (Quick update, columns will be initially null).
  • We will need to search for all "random" questions in the question bank and for each one - move the configuration data to the quiz_slots table. This will be the slow part of the upgrade and will require a progress bar. Although it should not happen we need to allow for the same random question instance being used by 2 quizzes.
  • We will then need to delete all "random" questions.

Search for question by tag

Architecture

We should be able to search for questions by tag from the tag management page. This work has been started on https://tracker.moodle.org/browse/MDL-59781, all that remains to complete it is to create a moodle page that can show a single question from a question bank (so the tag search results page can link to the question).

UI Changes

Search for questions from global tag search

Course level tags for questions

Architecture

This will be implemented by defining a new "tag area" for "course questions". The itemtype will be question and the component will be core_course. We will still have to implement the UI for adding and deleting "course question tags", and make sure that searching for questions by tags returns results from both the question tags, and the course question tags. We will add this new tag area to the backup/restore and ensure questions tagged in a course are included in the course backup file. Viewing the coursetags for a question will be controlled by a new capability: "moodle/course:viewquestiontags". Changing the course tags for a question will be controlled by a new capability "moodle/course:managequestiontags".

UI Changes

Question bank shows course tags icon
Edit the course tags for a question