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

Add idnumbers to question and question category

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      As a teacher on a course, navigate to the question bank and create two new question categories with idnumbers.

      Check that when creating the second question category that if the idnumber is the same as the first one then the form validation shows a warning, and if the idnumber is changed to something different then the new category does save.

      Within one of these categories, create two new questions (I suggest true/false as these are quick and simple; use the minimum of information as we will not be actually using the question). Again try to use the same idnumber on the second question, and check that form validation prevents saving.

      Within the other category create one new question using the same idnumber as one of the previous question idnumbers. Next move that question into the other category. Check the moved question's idnumber; it should have an _1 appended indicating that the idnumber is similar to another in that category.

      Backup this course, then restore it to a new course and check the questions and question categories have transferred properly and that the idnumbers are correct.

      Check an export (Moodle XML only) of one category of questions can be made, and that if it is imported again to the same course, the question categories and questions are imported correctly and that there are no clashes of idnumbers. (Where there is an idnumber being imported that would clash with an existing idnumber then the new imported idnumber should be nulled.)

      Show
      As a teacher on a course, navigate to the question bank and create two new question categories with idnumbers. Check that when creating the second question category that if the idnumber is the same as the first one then the form validation shows a warning, and if the idnumber is changed to something different then the new category does save. Within one of these categories, create two new questions (I suggest true/false as these are quick and simple; use the minimum of information as we will not be actually using the question). Again try to use the same idnumber on the second question, and check that form validation prevents saving. Within the other category create one new question using the same idnumber as one of the previous question idnumbers. Next move that question into the other category. Check the moved question's idnumber; it should have an _1 appended indicating that the idnumber is similar to another in that category. Backup this course, then restore it to a new course and check the questions and question categories have transferred properly and that the idnumbers are correct. Check an export (Moodle XML only) of one category of questions can be made, and that if it is imported again to the same course, the question categories and questions are imported correctly and that there are no clashes of idnumbers. (Where there is an idnumber being imported that would clash with an existing idnumber then the new imported idnumber should be nulled.)
    • Affected Branches:
      MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_36_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      wip-MDL-62708-master

      Description

      Many entities in Moodle have a field called idnumber, including users, courses, course_categories, cohorts, groups, groupings, course_modules, grade_items, competencies, .... (For a full list, search for idnumber in lib/db/install.xml.)

      Until now, questions and question_categories have not had idnumbers, but for a project we are working on at the Open University, it would be extremely helpful if we could add them. Hence, we are raising this issue, and the related forum thread: https://moodle.org/mod/forum/discuss.php?d=372096, to discuss doing so.

      Techical details:

      1. Add a new column, idnumber CHAR(100) to the question and question_categories tables.
      2. Add unique indexes on question (category, idnumber) and question_categories (contextid, idnumber).
      3. Add that field (PARAM_RAW) to the edit question and edit question_categories form.
      4. Form validation to avoid unique index errors when editing.
      5. Add the new fields to backup/restore.
      6. Add the new fields to Moodle XML import/export in the question bank.
      7. Code in restore & import, so that if the idnumber would cause a unique index violation, we nullify the new items idnumber - this seems to be what is done for other idnumbers in restore.
      8. Code when moving a question between categories - add an integer suffix _N (like course restore does).
      9. Ditto when moving question categories to a new context.
      10. Obviously, all the unique index issues will need careful tests to verify.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                8 Vote for this issue
                Watchers:
                13 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  3/Dec/18