Moodle
  1. Moodle
  2. MDL-12403

backup or import of single quiz includes all questions in database

    Details

    • Database:
      MySQL
    • Testing Instructions:
      Hide

      To tester: Note that the original issue has been divided in two. This issue addresses a setting to include questions in the course backup and MDL-41924 minimizes the number of questions included in each activity.

      COURSE SETUP:

      1. Add a course QUIZCOURSE with a number of different modules including a quiz
      2. Add a course NOQUESTIONCOURSE without a quiz or questions, and some other activities
      3. Add a course QUESTIONONLYCOURSE with questions added to the question bank, but no quiz and some other activities

      A1. BACKUP QUIZCOURSE TEST:

      1. Backup QUIZCOURSE with default settings, question bank enabled
      2. VERIFY: Backup backs up correctly
      3. VERIFY: Course can be restored into a another Moodle correctly.
      4. Backup QUIZCOURSE without question bank unselected
      5. VERIFY: The quizes in the course can not be selected for backup
      6. VERIFY: Backup completes correctly
      7. VERIFY: if the backup is unzipped, no questions are included in the backup
      8. VERIFY: Course can be restored into a another Moodle correctly, without the quiz or questions

      A2. BACKUP NOQUESTIONCOURSE TEST:

      1. Backup NOQUESTIONCOURSE with default settings, question bank enabled
      2. VERIFY: Backup backs up correctly
      3. VERIFY: Course can be restored into a another Moodle correctly.
      4. Backup NOQUESTIONCOURSE without question bank unselected
      5. VERIFY: All activities are able to be backed up
      6. VERIFY: Backup completes correctly

      A3. BACKUP QUESTIONONLYCOURSE TEST:

      1. Backup QUESTIONONLYCOURSE with default settings, question bank enabled
      2. VERIFY: Backup backs up correctly
      3. VERIFY: Course can be restored into a another Moodle correctly.
      4. VERIFY: question bank is restored into new course
      5. Backup NOQUESTIONCOURSE without question bank unselected
      6. VERIFY: All activities are able to be backed up
      7. VERIFY: Backup completes correctly
      8. VERIFY: if the backup is unzipped, no questions are included in the backup
      9. VERIFY: Course can be restored into a another Moodle correctly, without questions

      B: Automated backups:

      1. Setup automated backups:
        1. Enable backup_auto_active
        2. Specify a directory in your automated backup setting
        3. Set backup_auto_skip_modif_days to Never
        4. Disable backup_auto_skip_modif_prev
      2. Now you need to run the automated backups with the 'Include question bank set to enabled in automated backup settings
        1. Enable backup_auto_questionbank
        2. Run the automated backups CLI tool: admin/cli/automated_backups.php
        3. VERIFY: the state of the backup files is the same as created in steps A1-A3 with question bank setting enabled
      3. Now run automated backups with 'Include question bank' set to enabled
        1. Disable backup_auto_questionbank
        2. Run the automated backups CLI tool: admin/cli/automated_backups.php
        3. VERIFY: the state of the backup files is the same as created in steps A1-A3 with question bank setting disabled.

      C: Import

      1. Create an empty course
      2. Go to course import
      3. Select the QUIZCOURSE to import frm
      4. Unselect 'include question bank'
      5. VERIFY: that you can't choose the quiz activity to import frm
      6. Select an activity which isn't the quiz to import
      7. VERIFY: that the activity imports correctly
      8. VERIFY: that the question bank remains empty
      9. Run the import again, this time selecting the question bank in settings
      10. Choose the quiz to import
      11. VERIFY: the quiz imports succesfully
      12. VERIFY: the questions are imported into the question bank

      D: Default settings

      1. In general backup default settings, disable question bank from the defaults
      2. Go to a course backup
      3. VERIFY: that 'include question bank' is default disabled
      4. [Note that if you try and enable it and backup that course it doens't work.. that is existing prob MDL-41923]

      E: Backup settings test

      1. Upgrade to lastest version
      2. Go to a course
      3. In your database: DELETE FROM mdl_config_plugins WHERE plugin = 'backup' and name like '%questionbank%';
      4. Purge caches
      5. Go to backup a course (don't let moodle try and get you to set the config settings)
      6. VERIFY: that question bank is ticked in the settings
      7. Run automated backups cli script
      8. VERIFY: no errors are experienced
      Show
      To tester: Note that the original issue has been divided in two. This issue addresses a setting to include questions in the course backup and MDL-41924 minimizes the number of questions included in each activity. COURSE SETUP: Add a course QUIZCOURSE with a number of different modules including a quiz Add a course NOQUESTIONCOURSE without a quiz or questions, and some other activities Add a course QUESTIONONLYCOURSE with questions added to the question bank, but no quiz and some other activities A1. BACKUP QUIZCOURSE TEST: Backup QUIZCOURSE with default settings, question bank enabled VERIFY: Backup backs up correctly VERIFY: Course can be restored into a another Moodle correctly. Backup QUIZCOURSE without question bank unselected VERIFY: The quizes in the course can not be selected for backup VERIFY: Backup completes correctly VERIFY: if the backup is unzipped, no questions are included in the backup VERIFY: Course can be restored into a another Moodle correctly, without the quiz or questions A2. BACKUP NOQUESTIONCOURSE TEST: Backup NOQUESTIONCOURSE with default settings, question bank enabled VERIFY: Backup backs up correctly VERIFY: Course can be restored into a another Moodle correctly. Backup NOQUESTIONCOURSE without question bank unselected VERIFY: All activities are able to be backed up VERIFY: Backup completes correctly A3. BACKUP QUESTIONONLYCOURSE TEST: Backup QUESTIONONLYCOURSE with default settings, question bank enabled VERIFY: Backup backs up correctly VERIFY: Course can be restored into a another Moodle correctly. VERIFY: question bank is restored into new course Backup NOQUESTIONCOURSE without question bank unselected VERIFY: All activities are able to be backed up VERIFY: Backup completes correctly VERIFY: if the backup is unzipped, no questions are included in the backup VERIFY: Course can be restored into a another Moodle correctly, without questions B: Automated backups: Setup automated backups: Enable backup_auto_active Specify a directory in your automated backup setting Set backup_auto_skip_modif_days to Never Disable backup_auto_skip_modif_prev Now you need to run the automated backups with the 'Include question bank set to enabled in automated backup settings Enable backup_auto_questionbank Run the automated backups CLI tool: admin/cli/automated_backups.php VERIFY: the state of the backup files is the same as created in steps A1-A3 with question bank setting enabled Now run automated backups with 'Include question bank' set to enabled Disable backup_auto_questionbank Run the automated backups CLI tool: admin/cli/automated_backups.php VERIFY: the state of the backup files is the same as created in steps A1-A3 with question bank setting disabled. C: Import Create an empty course Go to course import Select the QUIZCOURSE to import frm Unselect 'include question bank' VERIFY: that you can't choose the quiz activity to import frm Select an activity which isn't the quiz to import VERIFY: that the activity imports correctly VERIFY: that the question bank remains empty Run the import again, this time selecting the question bank in settings Choose the quiz to import VERIFY: the quiz imports succesfully VERIFY: the questions are imported into the question bank D: Default settings In general backup default settings, disable question bank from the defaults Go to a course backup VERIFY: that 'include question bank' is default disabled [Note that if you try and enable it and backup that course it doens't work.. that is existing prob MDL-41923] E: Backup settings test Upgrade to lastest version Go to a course In your database: DELETE FROM mdl_config_plugins WHERE plugin = 'backup' and name like '%questionbank%'; Purge caches Go to backup a course (don't let moodle try and get you to set the config settings) VERIFY: that question bank is ticked in the settings Run automated backups cli script VERIFY: no errors are experienced
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_22_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_26_STABLE
    • Pull Master Branch:
      MDL-12403-master
    • Story Points:
      100
    • Rank:
      52640
    • Sprint:
      BACKEND Sprint 5

      Description

      When making a backup of individual quizzes, no matter how many (or how few) quizzes I back up, the backup includes all questions from the question bank, not only those used in the quiz which I'm backing up. So, in an extreme case, if I back up a single quiz, and then restore it to another course, I unintentionally transfer hundreds of questions along with this quiz.

      The same happens when importing a quiz to another course.

        Issue Links

          Activity

          Hide
          Anthony Borrow added a comment -

          This is a challenging issue. Obviously you do not want to have extraneous data; however, random questions makes it challenging. I think that the questions that should be backed up are the categories that are used in the quiz. It seems worth looking at to see if it can be improved but I think it is important that it remain a complete backup of the quizzes in question. Anything less would be a loss of functionality (IMHO). Peace - Anthony

          Show
          Anthony Borrow added a comment - This is a challenging issue. Obviously you do not want to have extraneous data; however, random questions makes it challenging. I think that the questions that should be backed up are the categories that are used in the quiz. It seems worth looking at to see if it can be improved but I think it is important that it remain a complete backup of the quizzes in question. Anything less would be a loss of functionality (IMHO). Peace - Anthony
          Hide
          Morten Brydensholt added a comment -

          See also http://moodle.org/mod/forum/discuss.php?d=80779 which is related to this issue.

          Show
          Morten Brydensholt added a comment - See also http://moodle.org/mod/forum/discuss.php?d=80779 which is related to this issue.
          Hide
          Anthony Borrow added a comment -

          I would also like to see us go back and look at the code in Moodle 1.8 to see if we might clean things up a little; however, this is a bit of a lower priority. Peace - Anthony

          Show
          Anthony Borrow added a comment - I would also like to see us go back and look at the code in Moodle 1.8 to see if we might clean things up a little; however, this is a bit of a lower priority. Peace - Anthony
          Hide
          Jamie Pratt added a comment -

          What would probably be good here is to have a select box on the backup preferences screen to select whether to backup all questions in a course, only questions used by module instances or no questions in which case you wouldn't be able to back up module instances that depend on questions such as the quiz module but you would be able to backup modules that use questions but don't depend on them such as the contrib question creation module.

          Show
          Jamie Pratt added a comment - What would probably be good here is to have a select box on the backup preferences screen to select whether to backup all questions in a course, only questions used by module instances or no questions in which case you wouldn't be able to back up module instances that depend on questions such as the quiz module but you would be able to backup modules that use questions but don't depend on them such as the contrib question creation module.
          Hide
          Przemyslaw Stencel added a comment -

          Yes, but the issue remains what to do if you select the option to backup "only questions used by module instances". What to do if there are any random questions in some of the quizzes? (as I understand, this is the main reason why backup behaves as it does now)

          In the discussion mentioned by Morten (above) someone suggested that it should work like this:

          • if a quiz doesn't have any random questions, backup should include only questions used in this quiz
          • if a quiz includes some random questions, backup should include the question categories from which these random questions are drawn (but not the whole question bank)
          Show
          Przemyslaw Stencel added a comment - Yes, but the issue remains what to do if you select the option to backup "only questions used by module instances". What to do if there are any random questions in some of the quizzes? (as I understand, this is the main reason why backup behaves as it does now) In the discussion mentioned by Morten (above) someone suggested that it should work like this: if a quiz doesn't have any random questions, backup should include only questions used in this quiz if a quiz includes some random questions, backup should include the question categories from which these random questions are drawn (but not the whole question bank)
          Hide
          Jamie Pratt added a comment -

          Oops. Was trying to edit the link to mark this issue as linked to MDL-13034 because 13034 'will HELP to resolve this issue' but accidentally added an extra link. Seems like I can't edit or delete links.

          Show
          Jamie Pratt added a comment - Oops. Was trying to edit the link to mark this issue as linked to MDL-13034 because 13034 'will HELP to resolve this issue' but accidentally added an extra link. Seems like I can't edit or delete links.
          Hide
          UMass Amherst Instructional Media Lab added a comment -

          +1 from us on this too – we use question banks to construct quizzes that we then export to specific courses. The question banks contain over a thousand questions, whereas the quizzes themselves each contain at most a hundred questions. And the questions need to be compartmentalized so that instructors in one course don't see the questions used by instructors in another course.

          A side note: should the "Affects Version(s)" field on this issue be updated to include Moodle 2.0 and 2.1? Having it set to only 1.9 seems a little misleading to us users, as this issue does indeed affect 2.0 and 2.1, but I don't know what the developers use as their protocol for tracking issues by version.

          Thanks!

          Show
          UMass Amherst Instructional Media Lab added a comment - +1 from us on this too – we use question banks to construct quizzes that we then export to specific courses. The question banks contain over a thousand questions, whereas the quizzes themselves each contain at most a hundred questions. And the questions need to be compartmentalized so that instructors in one course don't see the questions used by instructors in another course. A side note: should the "Affects Version(s)" field on this issue be updated to include Moodle 2.0 and 2.1? Having it set to only 1.9 seems a little misleading to us users, as this issue does indeed affect 2.0 and 2.1, but I don't know what the developers use as their protocol for tracking issues by version. Thanks!
          Hide
          Tim Hunt added a comment -

          I think it will be really hard to solve this well without making some moderately big changes to the question bank to make it clearly which questions are used by which quiz. The real problem is random questions. Doing this is moving to the top of my todo list, but I still don't have a design that solves all the problems.

          Getting Affects Version(s) right is not very important, I hardly ever look at it. However, if you want to know what is 'right' then the rules is to list the latest version from each sable branch where you have verified the problem occurs. So, the correct affects version for this issue is problably 1.9.12, 2.0.3 and 2.1

          Show
          Tim Hunt added a comment - I think it will be really hard to solve this well without making some moderately big changes to the question bank to make it clearly which questions are used by which quiz. The real problem is random questions. Doing this is moving to the top of my todo list, but I still don't have a design that solves all the problems. Getting Affects Version(s) right is not very important, I hardly ever look at it. However, if you want to know what is 'right' then the rules is to list the latest version from each sable branch where you have verified the problem occurs. So, the correct affects version for this issue is problably 1.9.12, 2.0.3 and 2.1
          Hide
          Oleg Sychev added a comment -

          Tim, maybe not "which questions are used by which quiz" but "which categories are used by which module"? The categories should be easier to handle, since random is always related to some category. And I think not many people will object with "if quiz use one question, all category with it will be backuped".

          As a small (and modest) hint to design - random tells us that question should be able report a category on which it rely. That's just one function. Than it will be not hard to get all question/categories for given module (quiz, but there may be more...). (I hope random is (or could be) safeguarded from selecting another random, if it at all possible).

          Show
          Oleg Sychev added a comment - Tim, maybe not "which questions are used by which quiz" but "which categories are used by which module"? The categories should be easier to handle, since random is always related to some category. And I think not many people will object with "if quiz use one question, all category with it will be backuped". As a small (and modest) hint to design - random tells us that question should be able report a category on which it rely. That's just one function. Than it will be not hard to get all question/categories for given module (quiz, but there may be more...). (I hope random is (or could be) safeguarded from selecting another random, if it at all possible).
          Hide
          Rick Houghton added a comment - - edited

          This makes the practice of importing activities from other courses impossible as it takes longer to delete out all the unwanted questions than the import is worth.

          Show
          Rick Houghton added a comment - - edited This makes the practice of importing activities from other courses impossible as it takes longer to delete out all the unwanted questions than the import is worth.
          Hide
          Tim Lock added a comment -

          Hi Tim H,

          Any progress on this issue? Can we help out in some way?

          Regards,
          Tim L

          Show
          Tim Lock added a comment - Hi Tim H, Any progress on this issue? Can we help out in some way? Regards, Tim L
          Hide
          Tim Hunt added a comment -

          It is genuinely a hard problem. The underlying cause is the sharing model in the question bank, which is not right. The trouble is that I don't yet have a proposed new design that solves all the problems, though I have been thinking about it for ages.

          Short of changing the question bank, it might be possible to make backup and restore more intelligent about what questions it includes, but that is another hard problem, and if I am going to solve a hard problem, then I want to solve the first one.

          The second problem is probably attackable: You need to work on the place where the backup system annotates (I think that is the word) the questions that should be included in the backup file.

          If you change the behaviour a lot, we may have to introduce an option for this in the backup settings: Include all questions from the course / include only question categories used by the quiz / include only the specific questions used by the quiz.

          Show
          Tim Hunt added a comment - It is genuinely a hard problem. The underlying cause is the sharing model in the question bank, which is not right. The trouble is that I don't yet have a proposed new design that solves all the problems, though I have been thinking about it for ages. Short of changing the question bank, it might be possible to make backup and restore more intelligent about what questions it includes, but that is another hard problem, and if I am going to solve a hard problem, then I want to solve the first one. The second problem is probably attackable: You need to work on the place where the backup system annotates (I think that is the word) the questions that should be included in the backup file. If you change the behaviour a lot, we may have to introduce an option for this in the backup settings: Include all questions from the course / include only question categories used by the quiz / include only the specific questions used by the quiz.
          Hide
          Paolo Oprandi added a comment -

          I have just written an import function so it doesn't use the backup and restore functionality and simply copies the db record into the new course. I agree that that the sharing model for questions is not right, but I have managed to write it so it imports only the questions in the quiz you wish to get.

          I create a new question category and add all questions to the new "import" category.

          If the quiz uses an "embedded answers (cloze)" I also copy all the questions that have a parent id of the embedded answer question.

          And if I use a "random short answer matching" question type I also copy the questions in the category that are non-allocated short answer questions.

          The code is being tested but I can distribute once this is done if it is helpful. The code is for Moodle 1.9.

          Show
          Paolo Oprandi added a comment - I have just written an import function so it doesn't use the backup and restore functionality and simply copies the db record into the new course. I agree that that the sharing model for questions is not right, but I have managed to write it so it imports only the questions in the quiz you wish to get. I create a new question category and add all questions to the new "import" category. If the quiz uses an "embedded answers (cloze)" I also copy all the questions that have a parent id of the embedded answer question. And if I use a "random short answer matching" question type I also copy the questions in the category that are non-allocated short answer questions. The code is being tested but I can distribute once this is done if it is helpful. The code is for Moodle 1.9.
          Hide
          Tim Hunt added a comment -

          Code for 1.9 is not very helpful.

          Does your code work correctly for random questions?

          Show
          Tim Hunt added a comment - Code for 1.9 is not very helpful. Does your code work correctly for random questions?
          Hide
          Paolo Oprandi added a comment -

          Hi Tim,

          If a random question exists in a quiz I import all non-allocated questions in the category.

          Cheers,

          Paolo

          Show
          Paolo Oprandi added a comment - Hi Tim, If a random question exists in a quiz I import all non-allocated questions in the category. Cheers, Paolo
          Hide
          Tim Hunt added a comment -

          What about sub-categories of that category? (whether or not subcategories are included depends on questiontext = 0 or 1).

          Show
          Tim Hunt added a comment - What about sub-categories of that category? (whether or not subcategories are included depends on questiontext = 0 or 1).
          Hide
          Paolo Oprandi added a comment -

          It takes the questions of subcategories and puts it in the new category. It does not attempt to recreate the category hierarchy. Is there any point in doing so that I have missed?

          Thanks
          Paolo

          Show
          Paolo Oprandi added a comment - It takes the questions of subcategories and puts it in the new category. It does not attempt to recreate the category hierarchy. Is there any point in doing so that I have missed? Thanks Paolo
          Hide
          Tim Hunt added a comment -

          Well, there are theoretical scenarios like

          • Cat
            • Sub
              • Sub-sub

          With one random question picking from Cat, and another from Sub-sub. With your code, you might get repeated questions in the quiz.

          Show
          Tim Hunt added a comment - Well, there are theoretical scenarios like Cat Sub Sub-sub With one random question picking from Cat, and another from Sub-sub. With your code, you might get repeated questions in the quiz.
          Hide
          Paolo Oprandi added a comment -

          Okay - good point. I can quite easily extend my code not to repeat questions.

          Anything else I should watch out for?

          Cheers
          Paolo

          Show
          Paolo Oprandi added a comment - Okay - good point. I can quite easily extend my code not to repeat questions. Anything else I should watch out for? Cheers Paolo
          Hide
          Tim Hunt added a comment -

          I can't think of anything else at the moment.

          Show
          Tim Hunt added a comment - I can't think of anything else at the moment.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          U P S T R E A M I Z E D !

          Many thanks, this is now available in all the repos (git & cvs).

          Closing, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - U P S T R E A M I Z E D ! Many thanks, this is now available in all the repos (git & cvs). Closing, ciao
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Doh,

          somehow this issue was closed incorrectly when processing all the integrated issues this week. (sort of most voted and current in integration filters mix). Apologies for the confusion, reseting to previous status!

          Ciao, Eloy

          Show
          Eloy Lafuente (stronk7) added a comment - Doh, somehow this issue was closed incorrectly when processing all the integrated issues this week. (sort of most voted and current in integration filters mix). Apologies for the confusion, reseting to previous status! Ciao, Eloy
          Hide
          Przemyslaw Stencel added a comment - - edited

          > It takes the questions of subcategories and puts it in the new category. It does not attempt to recreate the category hierarchy.
          > I can quite easily extend my code not to repeat questions.
          > Anything else I should watch out for?

          Another possible scenario:

          • Cat
            • Sub1
            • Sub2

          The quiz picks 3 questions from Sub1 and 3 questions from Sub2.
          If your code put all the questions in Cat, the quiz will simply have 6 questions picked from Cat and they may happen to all come from only one of the Subs (while the teacher wanted it to have specifically 3 questions from Sub1 and 3 questions from Sub2).

          Yet another scenario:

          • Cat
            • Sub1
            • Sub2

          Quiz A picks some questions from Cat (and subcategories), quiz B picks questions from Sub1 only, quiz C picks questions from Sub2 only.

          I suppose there might be some more scenarios. If a teacher has created a hierarchical structure, it probably has a purpose, even if it's only to keep stuff organized I don't think the script should "flatten" the hierarchy.

          Show
          Przemyslaw Stencel added a comment - - edited > It takes the questions of subcategories and puts it in the new category. It does not attempt to recreate the category hierarchy. > I can quite easily extend my code not to repeat questions. > Anything else I should watch out for? Another possible scenario: Cat Sub1 Sub2 The quiz picks 3 questions from Sub1 and 3 questions from Sub2. If your code put all the questions in Cat, the quiz will simply have 6 questions picked from Cat and they may happen to all come from only one of the Subs (while the teacher wanted it to have specifically 3 questions from Sub1 and 3 questions from Sub2). Yet another scenario: Cat Sub1 Sub2 Quiz A picks some questions from Cat (and subcategories), quiz B picks questions from Sub1 only, quiz C picks questions from Sub2 only. I suppose there might be some more scenarios. If a teacher has created a hierarchical structure, it probably has a purpose, even if it's only to keep stuff organized I don't think the script should "flatten" the hierarchy.
          Hide
          Paolo Oprandi added a comment -

          Thanks for your comments, Przemek. Absolutely right.

          Talking to users more extensively and seeing how they actually use categories put me right about this.

          The import now recreates the categories of the questions included in the quiz including those accessible from random question types.

          The quiz categories are created at module level rather than course level so that they do not compete with other question categories already in the course.

          For the future I propose:

          • question records in quizzes do not belong to categories
          • question records in categories do not belong to quizzes
          • when a question from a category is used in a quiz a new instance of the question is created

          In this way categories are more like question banks.

          Would this work?

          Show
          Paolo Oprandi added a comment - Thanks for your comments, Przemek. Absolutely right. Talking to users more extensively and seeing how they actually use categories put me right about this. The import now recreates the categories of the questions included in the quiz including those accessible from random question types. The quiz categories are created at module level rather than course level so that they do not compete with other question categories already in the course. For the future I propose: question records in quizzes do not belong to categories question records in categories do not belong to quizzes when a question from a category is used in a quiz a new instance of the question is created In this way categories are more like question banks. Would this work?
          Hide
          Nadav Kavalerchik added a comment -

          We "fixed" it (more or less) only recently.

          A while back, we fixed the issue in which the backup process was looking for images that are part of the questions, and that are originally stored inside the course, on the site level (course = 1)
          http://pegasus1.weizmann.ac.il/git/?p=moodle/.git;a=commitdiff;h=2c47a06d255fde7b62f9a20d9369690417adbada
          ( peleas refer to last diff on the above commit )

          And this following "work in progress" (which is working. and tested over several courses):
          http://pegasus1.weizmann.ac.il/git/?p=moodle/.git;a=commitdiff;h=e2b219f759838d6ebeb40aad7a70495e6da385cb
          ( Please ignore all the echo and debug remarks in the comments )

          Hope it helps

          Show
          Nadav Kavalerchik added a comment - We "fixed" it (more or less) only recently. A while back, we fixed the issue in which the backup process was looking for images that are part of the questions, and that are originally stored inside the course, on the site level (course = 1) http://pegasus1.weizmann.ac.il/git/?p=moodle/.git;a=commitdiff;h=2c47a06d255fde7b62f9a20d9369690417adbada ( peleas refer to last diff on the above commit ) And this following "work in progress" (which is working. and tested over several courses): http://pegasus1.weizmann.ac.il/git/?p=moodle/.git;a=commitdiff;h=e2b219f759838d6ebeb40aad7a70495e6da385cb ( Please ignore all the echo and debug remarks in the comments ) Hope it helps
          Hide
          Paolo Oprandi added a comment -

          Hi Nadav,

          So you only backup categories if they contain questions relating to the quiz? Nice work.

          Do you create the parents of used question categories if the parents themselves are empty or contain unused questions?

          Do you backup question categories if they are used in random or random shortanswer matching questions?

          Best wishes, Paolo

          Show
          Paolo Oprandi added a comment - Hi Nadav, So you only backup categories if they contain questions relating to the quiz? Nice work. Do you create the parents of used question categories if the parents themselves are empty or contain unused questions? Do you backup question categories if they are used in random or random shortanswer matching questions? Best wishes, Paolo
          Hide
          Nadav Kavalerchik added a comment -

          "So you only backup categories if they contain questions relating to the quiz?"
          Yes.

          "Do you create the parents of used question categories if the parents themselves are empty or contain unused questions?"
          Actually, no. That might be a good idea! (so far we do not have issues with this one since we have a one sub level of categories in those courses, on that specific server Moodle 1.9.5)

          Do you backup question categories if they are used in random or random shortanswer matching questions?
          Yes.

          BTW, We are on the last stages of moving to Moodle 2.3. And I hope to leave all this mess behind
          Tim has done a lot of beautiful work with the Quiz and Questions and all the extra plugins you can extend the Quiz with , in Moodle 2+ (Obviously, in Moodle 1.9.x too!) which inspire us to quicken our move, asap.
          So, see you all in Moodle 2 soon

          Show
          Nadav Kavalerchik added a comment - "So you only backup categories if they contain questions relating to the quiz?" Yes. "Do you create the parents of used question categories if the parents themselves are empty or contain unused questions?" Actually, no. That might be a good idea! (so far we do not have issues with this one since we have a one sub level of categories in those courses, on that specific server Moodle 1.9.5) Do you backup question categories if they are used in random or random shortanswer matching questions? Yes. — BTW, We are on the last stages of moving to Moodle 2.3. And I hope to leave all this mess behind Tim has done a lot of beautiful work with the Quiz and Questions and all the extra plugins you can extend the Quiz with , in Moodle 2+ (Obviously, in Moodle 1.9.x too!) which inspire us to quicken our move, asap. So, see you all in Moodle 2 soon
          Hide
          Brian King added a comment - - edited

          I've been looking at this on a Moodle 2.3.3.

          Tim, could you check if my thoughts about this are right? My thoughts:

          • There should be an option when making a course backup to include the whole question bank
          • If a course is backed up without the whole-question-bank option, or if a few quizzes are imported into another course, only the questions associated with the selected quizzes should be backed up (and their associated files)
          • The questions associated with selected quizzes are:
            • The questions from the selected quizzes; let's call these toplevel-questions
              • All toplevel-questions children (the questions which have a parent among the toplevel-questions)
            • All questions from the category (possibly including subcategories) of any random questions among the toplevel-questions
              • All children of these questions from the categories
          • Assumptions:
            • Random questions will never have random questions as children
            • There are no questions which have more than one level of descendant (e.g. a question with a parent will never have a child)

          I did a bit of hacking based on these assumptions, and got as far as reducing the number of question categories included in the backup for a course with > 1000 questions in many categories. When I then restored the course as a new course, the restore time was reduced from 379 seconds (without my hacks) to 77 seconds on a computer with quad core cpu and ssd.

          Are you or someone else already working on something like this (with the goal to significantly reduce backup/restore time for courses with many questions)? Or is my approach nonsense? I'd like to help improve performance, but don't want to waste my time.

          Show
          Brian King added a comment - - edited I've been looking at this on a Moodle 2.3.3. Tim, could you check if my thoughts about this are right? My thoughts: There should be an option when making a course backup to include the whole question bank If a course is backed up without the whole-question-bank option, or if a few quizzes are imported into another course, only the questions associated with the selected quizzes should be backed up (and their associated files) The questions associated with selected quizzes are: The questions from the selected quizzes; let's call these toplevel-questions All toplevel-questions children (the questions which have a parent among the toplevel-questions) All questions from the category (possibly including subcategories) of any random questions among the toplevel-questions All children of these questions from the categories Assumptions: Random questions will never have random questions as children There are no questions which have more than one level of descendant (e.g. a question with a parent will never have a child) I did a bit of hacking based on these assumptions, and got as far as reducing the number of question categories included in the backup for a course with > 1000 questions in many categories. When I then restored the course as a new course, the restore time was reduced from 379 seconds (without my hacks) to 77 seconds on a computer with quad core cpu and ssd. Are you or someone else already working on something like this (with the goal to significantly reduce backup/restore time for courses with many questions)? Or is my approach nonsense? I'd like to help improve performance, but don't want to waste my time.
          Hide
          Tim Hunt added a comment -

          You are almost entirely right.

          The bit I am not sure about is: "There should be an option when making a course backup to include the whole question bank."

          I think that if you are backing up a course, then it should include the whole course questionbank. If you are just backing up one activity, then it should just include the questions for that activity. We don't need a new UI option.

          What you are proposing: just fixing backup and restore for the existing question bank structure, is something that needs to be done, but no-one is working on it. In the longer term, we really need to fix the question bank structure, to make it less complex. There are no immediate plans to do that either.

          Show
          Tim Hunt added a comment - You are almost entirely right. The bit I am not sure about is: "There should be an option when making a course backup to include the whole question bank." I think that if you are backing up a course, then it should include the whole course questionbank. If you are just backing up one activity, then it should just include the questions for that activity. We don't need a new UI option. What you are proposing: just fixing backup and restore for the existing question bank structure, is something that needs to be done, but no-one is working on it. In the longer term, we really need to fix the question bank structure, to make it less complex. There are no immediate plans to do that either.
          Hide
          Don Hinkelman added a comment -

          On our 2.3.3 site, it appears all questions in the site are backed up whenever we do import, duplicate, backup or sharing cart moves. Since we have thousands of questions, every backup includes the 350mb of Question Bank questions. Our school does intensive sharing of quizzes among 20 teachers so this has become a great irritant, and recently a blocker, because when there is a corrupted question type, every backup fails with red error messages. We have identified the corrupted question type, Drag-and-drop matching, and fixed it. However, the large backup/import/duplicate files persist, making a ballooning problem of huge files all over the site. Why is it necessary to backup the whole QB for a quiz with even a single t/f question in it? I read the above and do not quite understand, but since this issue began in 2007, it must be a complex issue. I agree with Tim's statement: "I think that if you are backing up a course, then it should include the whole course questionbank. If you are just backing up one activity, then it should just include the questions for that activity." However, that is not happening. The whole QB is being backed up in any backup-related operation. I asked our programmer to investigate and he reported the following when we got the red error messages:

          > Mysteriously, I could restore it successfully on my debug environment. But I found standard Moodle core issues:
          > - If a quiz contains a system category question, quiz backup function always backups WHOLE question bank of system category. This is the reason why your backup mbzs are same big size, 346MB.
          > - And quiz restore function tries to restore entire question bank. So if there is a broken question, restore function fails even if the quiz uses only one true/false question.
          > - When I restore more than one quizzes (they have the same big question bank backup), a debugging message says that there are some database inconsistencies. First one shows no error.
          > It seems to be very difficult to fix. And maybe we need Moodle core modification.

          Another of my programmer colleagues suggested we give up using System categories, because we are using System categories throughout our courses (see also this issue: MDL-26442). System categories enable us to share among teachers. For example, five teachers are using the same textbook, and each one creates ten questions for a test each week. These 50 questions are collected in one System category and listed chapter by chapter. We repeat this process monthly and even weekly. Collaborative materials writing is very powerful and if we cannot use System categories, we feel like Moodle is forcing us to abandon collaboration. By forcing course-level categories, the classic pedagogic model of each teacher teaching in isolation of their own course returns. Yes, there is a lot to solve to make Moodle truly collaborative, but a small step would be to make System categories easy to use, and avoid the bloated backup of the whole question bank. Is there a way to do that?

          Show
          Don Hinkelman added a comment - On our 2.3.3 site, it appears all questions in the site are backed up whenever we do import, duplicate, backup or sharing cart moves. Since we have thousands of questions, every backup includes the 350mb of Question Bank questions. Our school does intensive sharing of quizzes among 20 teachers so this has become a great irritant, and recently a blocker, because when there is a corrupted question type, every backup fails with red error messages. We have identified the corrupted question type, Drag-and-drop matching, and fixed it. However, the large backup/import/duplicate files persist, making a ballooning problem of huge files all over the site. Why is it necessary to backup the whole QB for a quiz with even a single t/f question in it? I read the above and do not quite understand, but since this issue began in 2007, it must be a complex issue. I agree with Tim's statement: "I think that if you are backing up a course, then it should include the whole course questionbank. If you are just backing up one activity, then it should just include the questions for that activity." However, that is not happening. The whole QB is being backed up in any backup-related operation. I asked our programmer to investigate and he reported the following when we got the red error messages: > Mysteriously, I could restore it successfully on my debug environment. But I found standard Moodle core issues: > - If a quiz contains a system category question, quiz backup function always backups WHOLE question bank of system category. This is the reason why your backup mbzs are same big size, 346MB. > - And quiz restore function tries to restore entire question bank. So if there is a broken question, restore function fails even if the quiz uses only one true/false question. > - When I restore more than one quizzes (they have the same big question bank backup), a debugging message says that there are some database inconsistencies. First one shows no error. > It seems to be very difficult to fix. And maybe we need Moodle core modification. Another of my programmer colleagues suggested we give up using System categories, because we are using System categories throughout our courses (see also this issue: MDL-26442 ). System categories enable us to share among teachers. For example, five teachers are using the same textbook, and each one creates ten questions for a test each week. These 50 questions are collected in one System category and listed chapter by chapter. We repeat this process monthly and even weekly. Collaborative materials writing is very powerful and if we cannot use System categories, we feel like Moodle is forcing us to abandon collaboration. By forcing course-level categories, the classic pedagogic model of each teacher teaching in isolation of their own course returns. Yes, there is a lot to solve to make Moodle truly collaborative, but a small step would be to make System categories easy to use, and avoid the bloated backup of the whole question bank. Is there a way to do that?
          Hide
          Tim Hunt added a comment -

          Backup is not supposed to include all system-level questions just because you have used one in your quiz.

          The logic is that it will only include those question categories that you have used a question from. However, if it include a given category, it will also include all the subcategories (I think). Therefore, you may be able to improve matters by splitting your system question bank into more smaller categories.

          I agree that sharing and collaboration between teachers on questions is something that should be encouraged, and Moodle does not currently support that as well as it should.

          Show
          Tim Hunt added a comment - Backup is not supposed to include all system-level questions just because you have used one in your quiz. The logic is that it will only include those question categories that you have used a question from. However, if it include a given category, it will also include all the subcategories (I think). Therefore, you may be able to improve matters by splitting your system question bank into more smaller categories. I agree that sharing and collaboration between teachers on questions is something that should be encouraged, and Moodle does not currently support that as well as it should.
          Hide
          Paolo Oprandi added a comment -

          Hi Don,

          Re your first point, as I said above, I have rewritten the Moodle import of resources and activities in v1.9. Import has a completely different use case to backup and restore, but the code bases overlap massively (too much) hence the problem. In any case I resolved the categories issue and it wasn't as hard as I thought it would be, so perhaps if one of your developers or even Tim put his great mind to it they could do the same, even using the existing backup and restore.

          However I think there is a better solution to both your problems and I have proposed it on the forums. Tim and others have been discussing the proposal, but I'd like to get more interested parties to consider it and contribute their ideas.

          In essence here it is. The quiz module could be relatively easily redesigned so questions belong to categories or a quiz, but not to both as they can now. And when a question from a category is used in a quiz it is copied. This will mean when backup-ing up and restoring or importing a quiz you only get the questions used. If you want to import or backup a question category that would be a separate option.

          If you have time to consider this redevelopment, which is in part a solution to this issue but also other problems, please contribute to the discussion I have started about it.

          https://moodle.org/mod/forum/discuss.php?d=214136

          Show
          Paolo Oprandi added a comment - Hi Don, Re your first point, as I said above, I have rewritten the Moodle import of resources and activities in v1.9. Import has a completely different use case to backup and restore, but the code bases overlap massively (too much) hence the problem. In any case I resolved the categories issue and it wasn't as hard as I thought it would be, so perhaps if one of your developers or even Tim put his great mind to it they could do the same, even using the existing backup and restore. However I think there is a better solution to both your problems and I have proposed it on the forums. Tim and others have been discussing the proposal, but I'd like to get more interested parties to consider it and contribute their ideas. In essence here it is. The quiz module could be relatively easily redesigned so questions belong to categories or a quiz, but not to both as they can now. And when a question from a category is used in a quiz it is copied. This will mean when backup-ing up and restoring or importing a quiz you only get the questions used. If you want to import or backup a question category that would be a separate option. If you have time to consider this redevelopment, which is in part a solution to this issue but also other problems, please contribute to the discussion I have started about it. https://moodle.org/mod/forum/discuss.php?d=214136
          Hide
          Richard Bitgood added a comment - - edited

          We have massive headaches with this as well. Because we have developed very deep random banks, we often have 5,000-10,000 questions per course.

          Obviously these courses often fail to back up. The system just takes too long. If it does back up, it will never restore, as this takes even longer.

          When backing up a course like this, we need an option to not include these test banks. Or, at the very least, if we backup a course, but de-select all of the quizzes (as in there are no quizzes included at all in the backup) it should not still include the test bank, which it currently does.

          We used to have no issue with 1.9, but with 2.2 and 2.3, this is a huge issue. It means we have to recreate these courses manually.

          Also to clarify, these are course-level questions... not system level.

          Show
          Richard Bitgood added a comment - - edited We have massive headaches with this as well. Because we have developed very deep random banks, we often have 5,000-10,000 questions per course. Obviously these courses often fail to back up. The system just takes too long. If it does back up, it will never restore, as this takes even longer. When backing up a course like this, we need an option to not include these test banks. Or, at the very least, if we backup a course, but de-select all of the quizzes (as in there are no quizzes included at all in the backup) it should not still include the test bank, which it currently does. We used to have no issue with 1.9, but with 2.2 and 2.3, this is a huge issue. It means we have to recreate these courses manually. Also to clarify, these are course-level questions... not system level.
          Hide
          Emma Richardson added a comment -

          This has also had the effect of making sharing cart so slow that it times out on quiz copies. I tried removing my subcategories but it is still restoring the entire question bank. I am getting an error for each question and one for each hint.

          Show
          Emma Richardson added a comment - This has also had the effect of making sharing cart so slow that it times out on quiz copies. I tried removing my subcategories but it is still restoring the entire question bank. I am getting an error for each question and one for each hint.
          Hide
          Emma Richardson added a comment -

          Is this related? With full developer debugging turned on, this is what I get when I try to copy a quiz. Pretty sure I am getting an entry for every question in the database and then a similar error for every hint (but webpage crashed on me before I could copy that one over). The quiz will copy but takes several minutes.

          Error: mdb->get_record() found more than one record!

          line 1394 of /lib/dml/moodle_database.php: call to debugging()
          line 1354 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
          line 1333 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
          line 621 of /backup/util/dbops/restore_dbops.class.php: call to moodle_database->get_record()
          line 485 of /backup/util/dbops/restore_dbops.class.php: call to restore_dbops::prechek_precheck_qbanks_by_level()
          line 135 of /backup/util/helper/restore_prechecks_helper.class.php: call to restore_dbops::precheck_categories_and_questions()
          line 338 of /backup/controller/restore_controller.class.php: call to restore_prechecks_helper::execute_prechecks()
          line 85 of /course/modduplicate.php: call to restore_controller->execute_precheck()

          Show
          Emma Richardson added a comment - Is this related? With full developer debugging turned on, this is what I get when I try to copy a quiz. Pretty sure I am getting an entry for every question in the database and then a similar error for every hint (but webpage crashed on me before I could copy that one over). The quiz will copy but takes several minutes. Error: mdb->get_record() found more than one record! line 1394 of /lib/dml/moodle_database.php: call to debugging() line 1354 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql() line 1333 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select() line 621 of /backup/util/dbops/restore_dbops.class.php: call to moodle_database->get_record() line 485 of /backup/util/dbops/restore_dbops.class.php: call to restore_dbops::prechek_precheck_qbanks_by_level() line 135 of /backup/util/helper/restore_prechecks_helper.class.php: call to restore_dbops::precheck_categories_and_questions() line 338 of /backup/controller/restore_controller.class.php: call to restore_prechecks_helper::execute_prechecks() line 85 of /course/modduplicate.php: call to restore_controller->execute_precheck()
          Hide
          Michael de Raadt added a comment -

          This issue has been around for a while.

          It would be good to see it resolved.

          Show
          Michael de Raadt added a comment - This issue has been around for a while. It would be good to see it resolved.
          Hide
          Tim Hunt added a comment -

          Yes, it would be good to see it resolved. Are you volunteering?

          Show
          Tim Hunt added a comment - Yes, it would be good to see it resolved. Are you volunteering?
          Hide
          Don Hinkelman added a comment - - edited

          Referring to my post of November 29, we found a workaround that solved the immediate backup/import issue in quizzes. After removing 100% of our 10,000 quiz questions that had been in the System Category and placing them in Course level categories, the problem disappeared. Backup/restore became fast and easy. Apparently, if a quiz has any question that is in a System level category, the quiz will copy the whole System Level Question Bank. In our case, that was over 500mb, which caused timeouts, stalled backups, or extremely long backups (over one hour to backup a single quiz). Despite finding this solution, we created a new problem: now teachers cannot see the question bank categories and cannot share questions well. Therefore, we now rely on verbal exchange to know where to go to get questions we want. I think everyone agrees this is a long-standing, difficult to resolve issue. Until it is handled, it would recommend installing warning messages when unsuspecting users put questions into the System level. The message should explain the dangers. Also, Moodle Docs should explicitly warn teachers and admins to never (or almost never) use the System Level.

          Show
          Don Hinkelman added a comment - - edited Referring to my post of November 29, we found a workaround that solved the immediate backup/import issue in quizzes. After removing 100% of our 10,000 quiz questions that had been in the System Category and placing them in Course level categories, the problem disappeared. Backup/restore became fast and easy. Apparently, if a quiz has any question that is in a System level category, the quiz will copy the whole System Level Question Bank. In our case, that was over 500mb, which caused timeouts, stalled backups, or extremely long backups (over one hour to backup a single quiz). Despite finding this solution, we created a new problem: now teachers cannot see the question bank categories and cannot share questions well. Therefore, we now rely on verbal exchange to know where to go to get questions we want. I think everyone agrees this is a long-standing, difficult to resolve issue. Until it is handled, it would recommend installing warning messages when unsuspecting users put questions into the System level. The message should explain the dangers. Also, Moodle Docs should explicitly warn teachers and admins to never (or almost never) use the System Level.
          Hide
          Emma Richardson added a comment -

          The problem with that solution is that it removes the ability to share questions between teachers unless they communicate regularly - I have teachers from multiple states in the same system and they do not know each other. I purposely keep all mine at the system level so that all teachers can access them. I have had to tell them to not use Sharing Cart for quizzes to avoid the issue for now. Really need a fix to this..

          Show
          Emma Richardson added a comment - The problem with that solution is that it removes the ability to share questions between teachers unless they communicate regularly - I have teachers from multiple states in the same system and they do not know each other. I purposely keep all mine at the system level so that all teachers can access them. I have had to tell them to not use Sharing Cart for quizzes to avoid the issue for now. Really need a fix to this..
          Hide
          Michael Penney added a comment -

          "This issue has been around for a while.
          It would be good to see it resolved."

          Agreed - this issue is a serious core problem affecting any Moodle user who uses system level categories and the core team should fix it as part of the usual course of business.

          Show
          Michael Penney added a comment - "This issue has been around for a while. It would be good to see it resolved." Agreed - this issue is a serious core problem affecting any Moodle user who uses system level categories and the core team should fix it as part of the usual course of business.
          Hide
          Tim Hunt added a comment -

          Alternatively, those of us who believe in open source might thing that those who are pained by this might want to scratch their own itch, and work on a fix themselves.

          Anway, assigning to Moodle HQ as suggested.

          Show
          Tim Hunt added a comment - Alternatively, those of us who believe in open source might thing that those who are pained by this might want to scratch their own itch, and work on a fix themselves. Anway, assigning to Moodle HQ as suggested.
          Hide
          Michael Penney added a comment -

          Thanks! This one looks like one of those that will take extensive review before being integrated, if contributed. Probably that will take about the same amount of core personhours and the whole thing get done sooner if core writes it the way they want it to be to begin with.

          Show
          Michael Penney added a comment - Thanks! This one looks like one of those that will take extensive review before being integrated, if contributed. Probably that will take about the same amount of core personhours and the whole thing get done sooner if core writes it the way they want it to be to begin with .
          Hide
          Nadav Kavalerchik added a comment -

          Since it is a major itch for us at the Davidson Institute (http://pegasus1.weizmann.ac.il/moodle2/?lang=en) because we are also sharing a lot of questions between courses and teachers and since we are moving our courses from Moodle 19 servers to Moodle 2+ and since we "worked around" it on Moodle 19... I guess we will be fixing it at some point. It is on our internal todo list. When we start to work on it, I will post an update on this issue.

          Tim, I would LOVE some pointers and ideas for what you would have done if you had to fix it
          (changes in: UI, DB schema, workflow, settings...)

          Show
          Nadav Kavalerchik added a comment - Since it is a major itch for us at the Davidson Institute ( http://pegasus1.weizmann.ac.il/moodle2/?lang=en ) because we are also sharing a lot of questions between courses and teachers and since we are moving our courses from Moodle 19 servers to Moodle 2+ and since we "worked around" it on Moodle 19... I guess we will be fixing it at some point. It is on our internal todo list. When we start to work on it, I will post an update on this issue. Tim, I would LOVE some pointers and ideas for what you would have done if you had to fix it (changes in: UI, DB schema, workflow, settings...)
          Hide
          Russell Smith added a comment -

          I've linked the issue of slow question restore as it relates to the comments about not being able to restore large question banks. MDL-39726 will focus on restore speedup, while this issue will cover the backup component.

          Show
          Russell Smith added a comment - I've linked the issue of slow question restore as it relates to the comments about not being able to restore large question banks. MDL-39726 will focus on restore speedup, while this issue will cover the backup component.
          Hide
          HEFT Moodle Administrator added a comment -

          Thanks for looking into this one everyone.

          As with Nadav and many other administrators, it's a major issue which does need to be resolved shortly. In our organisation, we have over 100+ courses and many of those have multiple quizzes. There are many automated backups which will either take a significant amount of time to complete, or not complete at all, because of this issue, and we've also had to block Teachers from using the Import feature due to source Question Banks being copied over to destination course question banks without them knowing.

          A huge issue which affects many organisations, definitely a very important one to fix! Hopefully it can be resolved in time for 2.5.

          Show
          HEFT Moodle Administrator added a comment - Thanks for looking into this one everyone. As with Nadav and many other administrators, it's a major issue which does need to be resolved shortly. In our organisation, we have over 100+ courses and many of those have multiple quizzes. There are many automated backups which will either take a significant amount of time to complete, or not complete at all, because of this issue, and we've also had to block Teachers from using the Import feature due to source Question Banks being copied over to destination course question banks without them knowing. A huge issue which affects many organisations, definitely a very important one to fix! Hopefully it can be resolved in time for 2.5.
          Hide
          Louise Kelly (UNE) added a comment -

          This has also affected all versions we have had (2.0, 2.1 and now 2.3). Importing a single file resource is enough to import a whole question bank. Will a fix implemented for 2.5 be back-portable for 2.3/2.4 do you think?

          Show
          Louise Kelly (UNE) added a comment - This has also affected all versions we have had (2.0, 2.1 and now 2.3). Importing a single file resource is enough to import a whole question bank. Will a fix implemented for 2.5 be back-portable for 2.3/2.4 do you think?
          Hide
          Russell Smith added a comment -

          @Louise Kelly (UNE): Given Moodle 2.3 bug fix support ends with the July release of 2.3.8, I don't expect this fix will be in mainstream 2.3 unless somebody is really fast to develop a fix. The back-patching of other branches will depend on the complexity of the patch and the safety of porting it. If we (La Trobe University) develop or implement a developed fix we will be back-porting it to 2.3. I can post the results of that on this bug. However we do not have global context quizzes so this has not been an issue for us as yet. The restore component a much greater problem.

          You should be able the encourage your Partner to invest in this issue if it is critical for you. It would be great for you and the whole community if they were able to develop a fix and contribute it back to the community.

          Show
          Russell Smith added a comment - @ Louise Kelly (UNE) : Given Moodle 2.3 bug fix support ends with the July release of 2.3.8, I don't expect this fix will be in mainstream 2.3 unless somebody is really fast to develop a fix. The back-patching of other branches will depend on the complexity of the patch and the safety of porting it. If we (La Trobe University) develop or implement a developed fix we will be back-porting it to 2.3. I can post the results of that on this bug. However we do not have global context quizzes so this has not been an issue for us as yet. The restore component a much greater problem. You should be able the encourage your Partner to invest in this issue if it is critical for you. It would be great for you and the whole community if they were able to develop a fix and contribute it back to the community.
          Hide
          Russell Smith added a comment -

          I've updated the assignee, affected versions and fix versions in line with the new tracker policies.

          Show
          Russell Smith added a comment - I've updated the assignee, affected versions and fix versions in line with the new tracker policies.
          Hide
          Martin Dougiamas added a comment -

          Sorry for the noise, I just saw this is not really a quiz issue, Tim.

          Show
          Martin Dougiamas added a comment - Sorry for the noise, I just saw this is not really a quiz issue, Tim.
          Hide
          Martin Dougiamas added a comment -

          Can I suggest that instead of going for complete redesign in questions, which sounds incredibly complex, that we perhaps go for the basic case first (which probably covers most of the people annoyed with this):

          1) Add a backup checkbox like: "Minimise questions included with quizzes"

          2) If this option is checked, AND a given quiz does not use any random questions, then only include questions that are used in that quiz.

          This would really help people share quizzes to moodle.net, for example.

          Show
          Martin Dougiamas added a comment - Can I suggest that instead of going for complete redesign in questions, which sounds incredibly complex, that we perhaps go for the basic case first (which probably covers most of the people annoyed with this): 1) Add a backup checkbox like: "Minimise questions included with quizzes" 2) If this option is checked, AND a given quiz does not use any random questions, then only include questions that are used in that quiz. This would really help people share quizzes to moodle.net, for example.
          Hide
          Don Hinkelman added a comment - - edited

          I agree with Martin that handling the basic case would cover the constant problems we face in backup/restore. And as a user/developer of the Hub (Moodle.net), I can say this fix will go a long way to enabling smoother sharing of quizzes and courses.

          I believe minimization of questions should be the default, because most users will assume that. Therefore, by unchecking a default minimization checkbox, then all parent category questions AND system level questions are included. Of course, non-parent category questions will never be included.

          Show
          Don Hinkelman added a comment - - edited I agree with Martin that handling the basic case would cover the constant problems we face in backup/restore. And as a user/developer of the Hub (Moodle.net), I can say this fix will go a long way to enabling smoother sharing of quizzes and courses. I believe minimization of questions should be the default, because most users will assume that. Therefore, by unchecking a default minimization checkbox, then all parent category questions AND system level questions are included. Of course, non-parent category questions will never be included.
          Hide
          Dan Poltawski added a comment -

          Alright, i'm pretty unfamiliar with questions, backup and everything in this domain. What can possibly go wrong with looking at this issue?

          Show
          Dan Poltawski added a comment - Alright, i'm pretty unfamiliar with questions, backup and everything in this domain. What can possibly go wrong with looking at this issue?
          Hide
          Joseph Rézeau added a comment -

          Totally agree with Martin D.'s suggestion dated 17/Sep/13 7:29 AM.
          For quizzes that do NOT use random questions, then only include questions that are used in that quiz.

          Show
          Joseph Rézeau added a comment - Totally agree with Martin D.'s suggestion dated 17/Sep/13 7:29 AM. For quizzes that do NOT use random questions, then only include questions that are used in that quiz.
          Hide
          Don Hinkelman added a comment -

          Dan, like you I am not familiar with the issues deeply, but I think a more detailed testing instruction pattern may be needed. Let me explain. In our school, we put all 5000+ of our questions in the System level category to enable sharing among teachers/courses. As I reported, our course backups ballooned to 1gb because all System questions were included (with associated media files). So we moved the questions to sub-categories and it worked a little better, but still we had to finally move all questions into Course level categories to keep backup sizes manageable. I think to enable sharing and to enable a Random question bank, we may want to encourage Question Bank administrators to divide questions into non-Course, non-System, mid-level categories. In these cateqories, then Random questions can be drawn from. But it is important that not all of these mid-level categories be duplicated, just the parent one. So could you make a testing scenario with two parent sub-categories and see that the just the immediate parent question bank is duplicated when the default "minimize questions" is unchecked? I hope those of you who understand the Question Bank better than I, can comment more intelligently or confirm what I just suggested.

          Show
          Don Hinkelman added a comment - Dan, like you I am not familiar with the issues deeply, but I think a more detailed testing instruction pattern may be needed. Let me explain. In our school, we put all 5000+ of our questions in the System level category to enable sharing among teachers/courses. As I reported, our course backups ballooned to 1gb because all System questions were included (with associated media files). So we moved the questions to sub-categories and it worked a little better, but still we had to finally move all questions into Course level categories to keep backup sizes manageable. I think to enable sharing and to enable a Random question bank, we may want to encourage Question Bank administrators to divide questions into non-Course, non-System, mid-level categories. In these cateqories, then Random questions can be drawn from. But it is important that not all of these mid-level categories be duplicated, just the parent one. So could you make a testing scenario with two parent sub-categories and see that the just the immediate parent question bank is duplicated when the default "minimize questions" is unchecked? I hope those of you who understand the Question Bank better than I, can comment more intelligently or confirm what I just suggested.
          Hide
          Dan Poltawski added a comment -

          Hi Don,

          Yes - sorry, i'm just writing testing instructions as I go, please don't see me edits as a final version of what I think is required until I send the issue for review

          Show
          Dan Poltawski added a comment - Hi Don, Yes - sorry, i'm just writing testing instructions as I go, please don't see me edits as a final version of what I think is required until I send the issue for review
          Hide
          Tim Hunt added a comment -

          Well, it is a combined questions/backup issue. However, it was a bit presumptive of you Martin Dougiamas to assign it to me without discussing it first. It is a big job and I don't have time to work on it.

          Great that Dan is taking a look. The "Minimise questions included with quizzes" setting sounds sensible (but not easy to implement). If you need any help Dan, please just shout, though from the start of the testing instructions you have written, it seems that you have a good grip of the issues.

          Well, one case that is not there yet. If you have

          • Category Parent (1 question, not in quiz)
            • Cateory sub, not in quiz (1 question)
            • Cateory sub, in quiz (1 question)

          How much of that do you expect to go into the backup file. I think ideally it would be:

          • Category Parent (0 questions)
            • Cateory sub, in quiz (1 question)

          Also note that the backup code is currently written on the assumption that you will backup all the questions in one question_category - and changing that is one half of why this is a big job.

          Show
          Tim Hunt added a comment - Well, it is a combined questions/backup issue. However, it was a bit presumptive of you Martin Dougiamas to assign it to me without discussing it first. It is a big job and I don't have time to work on it. Great that Dan is taking a look. The "Minimise questions included with quizzes" setting sounds sensible (but not easy to implement). If you need any help Dan, please just shout, though from the start of the testing instructions you have written, it seems that you have a good grip of the issues. Well, one case that is not there yet. If you have Category Parent (1 question, not in quiz) Cateory sub, not in quiz (1 question) Cateory sub, in quiz (1 question) How much of that do you expect to go into the backup file. I think ideally it would be: Category Parent (0 questions) Cateory sub, in quiz (1 question) Also note that the backup code is currently written on the assumption that you will backup all the questions in one question_category - and changing that is one half of why this is a big job.
          Hide
          Louise Kelly (UNE) added a comment -

          Martin Dougiamas wrote:
          > 1) Add a backup checkbox like: "Minimise questions included with quizzes"

          I like this idea, and I appreciate the work that would have to go into it. Some of our academics have been asking for a checkbox option to "not include question bank" at all when importing content from one course to another, simply because as it is now all course-level questions are included in the import even when no quizzes are selected. How achievable is it to have an option to not include questions at all?

          Show
          Louise Kelly (UNE) added a comment - Martin Dougiamas wrote: > 1) Add a backup checkbox like: "Minimise questions included with quizzes" I like this idea, and I appreciate the work that would have to go into it. Some of our academics have been asking for a checkbox option to "not include question bank" at all when importing content from one course to another, simply because as it is now all course-level questions are included in the import even when no quizzes are selected. How achievable is it to have an option to not include questions at all?
          Hide
          HEFT Moodle Administrator added a comment -

          I agree with Kelly. For our Moodle website, we'd want to make use of the export and import functions for individual elements of courses, but as it is because Moodle doesn't allow you to deselect the question bank, then every time you want to move a few resources or labels or whatever from a course, an entire question bank will come with the import. If it is achievable to implement a way to not import any of the question bank if you so choose, then this would be fantastic.

          Show
          HEFT Moodle Administrator added a comment - I agree with Kelly. For our Moodle website, we'd want to make use of the export and import functions for individual elements of courses, but as it is because Moodle doesn't allow you to deselect the question bank, then every time you want to move a few resources or labels or whatever from a course, an entire question bank will come with the import. If it is achievable to implement a way to not import any of the question bank if you so choose, then this would be fantastic.
          Hide
          Eloy Lafuente (stronk7) added a comment - - edited

          My personal opinion:

          I don't think solutions like "minimize questions" are correct. That will lead to partial question banks that, apart from leading to problems with "connected" questions (random and potentially others) will make the process really slower, because we'll need to go down and check every question use along all the attempts.

          Instead I'd create a new setting "include questions", enabled by default (current approach) and, if disabled, it automatically will disable the backup of all quizzes in the course and of, course, will prevent the export of ANY question_bank in the operation.

          That solution sounds fair enough to me to achieve the goal of smaller/quicker backups and, at the same time, we don't break the "question bank is the atom" principle which consequences are, indeed, unknown.

          My 2 cents. Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - - edited My personal opinion: I don't think solutions like "minimize questions" are correct. That will lead to partial question banks that, apart from leading to problems with "connected" questions (random and potentially others) will make the process really slower, because we'll need to go down and check every question use along all the attempts. Instead I'd create a new setting "include questions", enabled by default (current approach) and, if disabled, it automatically will disable the backup of all quizzes in the course and of, course, will prevent the export of ANY question_bank in the operation. That solution sounds fair enough to me to achieve the goal of smaller/quicker backups and, at the same time, we don't break the "question bank is the atom" principle which consequences are, indeed, unknown. My 2 cents. Ciao
          Hide
          Don Hinkelman added a comment - - edited

          Eloy wrote: "Instead I'd create a new setting "include questions", enabled by default (current approach) and, if disabled, it automatically will disable the backup of all quizzes in the course"

          This is already implemented in the current backup process. I can easily uncheck all quizzes in a course.

          What I hear everyone asking for is a way to include just the relevant questions in a backup--a way to exclude or include System Level, and Sub-System level portions of the Question Bank. Why should I have to have the Math Dept. questions when I only need my French Dept questions? If you are saying that is too difficult using Martin's minimize strategy, then we really do need to devote a complete rewrite of the Question Bank, Quiz module and Backup. This has been a demon for over five years, and I commend efforts to deal with it. Remember the goal is not merely smaller backups, it is about moving and sharing questions.

          Show
          Don Hinkelman added a comment - - edited Eloy wrote: "Instead I'd create a new setting "include questions", enabled by default (current approach) and, if disabled, it automatically will disable the backup of all quizzes in the course" This is already implemented in the current backup process. I can easily uncheck all quizzes in a course. What I hear everyone asking for is a way to include just the relevant questions in a backup--a way to exclude or include System Level, and Sub-System level portions of the Question Bank. Why should I have to have the Math Dept. questions when I only need my French Dept questions? If you are saying that is too difficult using Martin's minimize strategy, then we really do need to devote a complete rewrite of the Question Bank, Quiz module and Backup. This has been a demon for over five years, and I commend efforts to deal with it. Remember the goal is not merely smaller backups, it is about moving and sharing questions.
          Hide
          Emma Richardson added a comment -

          As another user of a large system bank, I would also like to see something happen here. In response to the concern about random questions, I think that in that case, you just have to include the category that the questions are being selected from. However, you should not have to include the entire question bank. I like the minimize questions approach if it is workable. Happy to help test if we get that far.

          Show
          Emma Richardson added a comment - As another user of a large system bank, I would also like to see something happen here. In response to the concern about random questions, I think that in that case, you just have to include the category that the questions are being selected from. However, you should not have to include the entire question bank. I like the minimize questions approach if it is workable. Happy to help test if we get that far.
          Hide
          Richard Bitgood added a comment -

          @Don Hinkelman...

          Hi Don, unfortunately, even if you deselect all quizzes, the question bank still comes in the backup. We do need a setting to exclude questions from a backup, because deselecting all quizzes does not work. We create some advanced random question banks with sometimes thousands of questions per course. Without the option to exclude the question bank (because unchecking all the quizzes doesn't work) it renders backups of courses essentially useless.

          Show
          Richard Bitgood added a comment - @Don Hinkelman... Hi Don, unfortunately, even if you deselect all quizzes, the question bank still comes in the backup. We do need a setting to exclude questions from a backup, because deselecting all quizzes does not work. We create some advanced random question banks with sometimes thousands of questions per course. Without the option to exclude the question bank (because unchecking all the quizzes doesn't work) it renders backups of courses essentially useless.
          Hide
          Jean-Michel Vedrine added a comment - - edited

          I think everybody understand that this issue is complex.
          Why not fix an easy goal witch could be reached rapidly and easily ?
          The fact that when you don't include any activity that use the question bank (there is not only quiz but also qcreate, qpractice, ...) questions are sometime still included in the backup seems to me like a bug.
          Why not begin by studying and fixing this bug ? It would already make life of a lot of people easier

          Show
          Jean-Michel Vedrine added a comment - - edited I think everybody understand that this issue is complex. Why not fix an easy goal witch could be reached rapidly and easily ? The fact that when you don't include any activity that use the question bank (there is not only quiz but also qcreate, qpractice, ...) questions are sometime still included in the backup seems to me like a bug . Why not begin by studying and fixing this bug ? It would already make life of a lot of people easier
          Hide
          Tim Hunt added a comment -

          Ideally, I think it would work like this:

          For each context that would be included in the backup (so course and module contexts as applicable) where there is something in the question bank (so coures, quiz, qpractice, ... contexts) then there should be a separate checkbox 'include question bank'. If that is ticked, all questions for those context are included. If not ticked, then just the minimum number of questions are included from those contexts, given which activities are being included in the backup, and which questions they might use. This includes correctly processing things like random questions and working out the minimum number of questions to include. Good luck if you want to try to do that

          Show
          Tim Hunt added a comment - Ideally, I think it would work like this: For each context that would be included in the backup (so course and module contexts as applicable) where there is something in the question bank (so coures, quiz, qpractice, ... contexts) then there should be a separate checkbox 'include question bank'. If that is ticked, all questions for those context are included. If not ticked, then just the minimum number of questions are included from those contexts, given which activities are being included in the backup, and which questions they might use. This includes correctly processing things like random questions and working out the minimum number of questions to include. Good luck if you want to try to do that
          Hide
          Dan Poltawski added a comment -

          Well, lots of conflicting options

          The fact that when you don't include any activity that use the question bank (there is not only quiz but also qcreate, qpractice, ...) questions are sometime still included in the backup seems to me like a bug.

          What is the circumstance which causes this?

          Show
          Dan Poltawski added a comment - Well, lots of conflicting options The fact that when you don't include any activity that use the question bank (there is not only quiz but also qcreate, qpractice, ...) questions are sometime still included in the backup seems to me like a bug. What is the circumstance which causes this?
          Hide
          Louise Kelly (UNE) added a comment - - edited

          To test what happens to question bank when importing content:

          • create a new course to import into
          • select a course to import from that does contain questions in the question bank and a PDF resource or a label.
          • Begin your import process and select only the PDF resource or label to import to the new course. Do not select any other content.
          • When the import is complete, the new site contains the single resource you imported, and the whole question bank from the source course.

          That is what our Moodle does and others have the same issue by the look of it. Now here is the nightmare scenario this causes:

          • I have a clean course to set up for a new teaching period.
          • I want to bring over a few resources from several other sites and the other sites all have quizzes (hence question banks).
          • I select some PDF resources from one, several book resource from another, and some audiovisual and URLs from a third (No quizzes or anything else that use questions)
          • When I complete my imports my new course now contains the complete question banks from three other sites.

          Imagine what happens when someone imports a label or PDF from my new site now? This problem snowballs. I need an option now to simply "exclude question bank" from my import (although I suppose there is nothing simple about that).

          Later it would be nice, if I did want to import a single quiz from another course that has thousands of questions, to have an option to "minimise question import" as the default option.

          Show
          Louise Kelly (UNE) added a comment - - edited To test what happens to question bank when importing content: create a new course to import into select a course to import from that does contain questions in the question bank and a PDF resource or a label. Begin your import process and select only the PDF resource or label to import to the new course. Do not select any other content. When the import is complete, the new site contains the single resource you imported, and the whole question bank from the source course. That is what our Moodle does and others have the same issue by the look of it. Now here is the nightmare scenario this causes: I have a clean course to set up for a new teaching period. I want to bring over a few resources from several other sites and the other sites all have quizzes (hence question banks). I select some PDF resources from one, several book resource from another, and some audiovisual and URLs from a third (No quizzes or anything else that use questions) When I complete my imports my new course now contains the complete question banks from three other sites. Imagine what happens when someone imports a label or PDF from my new site now? This problem snowballs. I need an option now to simply "exclude question bank" from my import (although I suppose there is nothing simple about that). Later it would be nice, if I did want to import a single quiz from another course that has thousands of questions, to have an option to "minimise question import" as the default option.
          Hide
          Dan Poltawski added a comment -

          Thanks Louise, that helps.

          As Tim and Eloy have alluded to, the logic of working out what questions to include seems like it will be very tricky to work out. I am not confident in achieving this and this bug has not been open for so long because that is easy to achieve.

          So the conclusion I am coming to is that the 'minimise question import' is something for another issue. Instead I will aim to tackle the 'include question bank' option. If no question bank using activities are included in a backup then we don't need to include all the questions.

          It looks like one of the problems here is that we don't have any callbacks in modules to let us know if the activity is using the question bank.

          Show
          Dan Poltawski added a comment - Thanks Louise, that helps. As Tim and Eloy have alluded to, the logic of working out what questions to include seems like it will be very tricky to work out. I am not confident in achieving this and this bug has not been open for so long because that is easy to achieve. So the conclusion I am coming to is that the 'minimise question import' is something for another issue. Instead I will aim to tackle the 'include question bank' option. If no question bank using activities are included in a backup then we don't need to include all the questions. It looks like one of the problems here is that we don't have any callbacks in modules to let us know if the activity is using the question bank.
          Hide
          Tim Hunt added a comment -

          Dan, there are two callbacks that an activity using questions will probably override, to use quiz as an example:

          • quiz_extend_settings_navigation
          • quiz_get_extra_capabilities

          You can also tell because we implement functions like

          • quiz_questions_in_use
          • quiz_question_pluginfile

          However, you probably don't want to rely on any of that here

          I suggest you add this to ..._supports. A new FEATURE_USES_QUESTION_BANK.

          Then, if you want to make the API nice for developers, you could make Moodle core do automatically what is currently done manually in quiz_extend_settings_navigation and quiz_get_extra_capabilities, with debugging output to tell people they no longer need to do it manually core detects that they have done so.

          Show
          Tim Hunt added a comment - Dan, there are two callbacks that an activity using questions will probably override, to use quiz as an example: quiz_extend_settings_navigation quiz_get_extra_capabilities You can also tell because we implement functions like quiz_questions_in_use quiz_question_pluginfile However, you probably don't want to rely on any of that here I suggest you add this to ..._supports. A new FEATURE_USES_QUESTION_BANK. Then, if you want to make the API nice for developers, you could make Moodle core do automatically what is currently done manually in quiz_extend_settings_navigation and quiz_get_extra_capabilities, with debugging output to tell people they no longer need to do it manually core detects that they have done so.
          Hide
          Dan Poltawski added a comment - - edited

          Amazingly (and pleasing to me, because i have spent most of today reading and looking at this problem, and maybe 30mins coding) I have a patch which seems to work for the idea which Eloy spoke about (a simple 'include the question bank' setting), which undoubtedly will solve a lot of the problems. But it won't solve the quiz/question sharing problem.

          Now to go further and start to look at the 'minimise questions' suggestion will be much riskier and concerning for performance.

          So I guess I am thinking out loud if there would be strong objections proceeding this here to get the 'question bank included' setting integrated.

          PS. I think we could also backport this one (perhaps with a temporary hacky harcoding of know question engine using modules.

          Show
          Dan Poltawski added a comment - - edited Amazingly (and pleasing to me, because i have spent most of today reading and looking at this problem, and maybe 30mins coding) I have a patch which seems to work for the idea which Eloy spoke about (a simple 'include the question bank' setting), which undoubtedly will solve a lot of the problems. But it won't solve the quiz/question sharing problem. Now to go further and start to look at the 'minimise questions' suggestion will be much riskier and concerning for performance. So I guess I am thinking out loud if there would be strong objections proceeding this here to get the 'question bank included' setting integrated. PS. I think we could also backport this one (perhaps with a temporary hacky harcoding of know question engine using modules.
          Hide
          Tim Hunt added a comment -

          Pleasingly little code to achieve that. Nice one Dan. A vague +1 so far. I agree with backporting. This is backwards compatible and a big win for users.

          One thing I don't understand from reading the patch: Do you have a separate "Include questoin bank" setting, or do you ahve one settings for each course/relevant activity?

          I also wonder if you should break this down into separate subtasks and commits:

          • New FEATURE_USES_QUESTION_BANK
          • New backup setting implementations
          • minimise questions option

          Please can you also mention FEATURE_USES_QUESTION_BANK in an appropriate upgrade.txt file, and in the release notes.

          Show
          Tim Hunt added a comment - Pleasingly little code to achieve that. Nice one Dan. A vague +1 so far. I agree with backporting. This is backwards compatible and a big win for users. One thing I don't understand from reading the patch: Do you have a separate "Include questoin bank" setting, or do you ahve one settings for each course/relevant activity? I also wonder if you should break this down into separate subtasks and commits: New FEATURE_USES_QUESTION_BANK New backup setting implementations minimise questions option Please can you also mention FEATURE_USES_QUESTION_BANK in an appropriate upgrade.txt file, and in the release notes.
          Hide
          Dan Poltawski added a comment -

          Do you have a separate "Include questoin bank" setting, or do you ahve one settings for each course/relevant activity?

          This is just the course level setting (same as 'include logs', 'include blocks' etc). If you choose to not select it then it prevents the quizzes from being selected to be backed up.

          It doesn't do anything clever like not including the question bank if you don't choose any question using activities in your backup. But actually I think there is a certain elegance in it behaving like that. It gives the impression that the question bank is something like user data that can either be chosen for a course or omitted and if you choose it, it always comes with the backup.

          I also wonder if you should break this down into separate subtasks and commits

          Yep, I will break it down, was just putting the code up for show

          Please can you also mention FEATURE_USES_QUESTION_BANK in an appropriate upgrade.txt file, and in the release notes.

          Yes, again if this is the way to go. Actually I was just about to write the upgrade.txt, but wondered where it should go.. question was my first thought, but actually its probably mod/, but maybe even mod/quiz if people are doing crazy things extending quiz..

          Show
          Dan Poltawski added a comment - Do you have a separate "Include questoin bank" setting, or do you ahve one settings for each course/relevant activity? This is just the course level setting (same as 'include logs', 'include blocks' etc). If you choose to not select it then it prevents the quizzes from being selected to be backed up. It doesn't do anything clever like not including the question bank if you don't choose any question using activities in your backup. But actually I think there is a certain elegance in it behaving like that. It gives the impression that the question bank is something like user data that can either be chosen for a course or omitted and if you choose it, it always comes with the backup. I also wonder if you should break this down into separate subtasks and commits Yep, I will break it down, was just putting the code up for show Please can you also mention FEATURE_USES_QUESTION_BANK in an appropriate upgrade.txt file, and in the release notes. Yes, again if this is the way to go. Actually I was just about to write the upgrade.txt, but wondered where it should go.. question was my first thought, but actually its probably mod/, but maybe even mod/quiz if people are doing crazy things extending quiz..
          Hide
          Dan Poltawski added a comment -

          Tim: on the backwards compatibility question.. I wonder what you would think the best approach would be to working out question engine usage?

          1. Try and call one of the existing callbacks
            • _question_pluginfile is the only one which qpractice uses
            • Annoyingly we don't have a component_callback_exists type function for that, so it'd be a bit ugly
          2. Hardcoded list of plugins to count as question engine usage, with TODO to remove..
          3. Some other approach?
          Show
          Dan Poltawski added a comment - Tim: on the backwards compatibility question.. I wonder what you would think the best approach would be to working out question engine usage? Try and call one of the existing callbacks _question_pluginfile is the only one which qpractice uses Annoyingly we don't have a component_callback_exists type function for that, so it'd be a bit ugly Hardcoded list of plugins to count as question engine usage, with TODO to remove.. Some other approach?
          Hide
          Tim Hunt added a comment -

          I can't think of a better option than looking for _question_pluginfile. And it makes sense to do that by implementing component_callback_exists in core_compoenent.

          Sorry I don't have a better idea.

          I assume you will add a debugging message when we find that FEATURE_USES_QUESTION_BANK is missing.

          Show
          Tim Hunt added a comment - I can't think of a better option than looking for _question_pluginfile. And it makes sense to do that by implementing component_callback_exists in core_compoenent. Sorry I don't have a better idea. I assume you will add a debugging message when we find that FEATURE_USES_QUESTION_BANK is missing.
          Hide
          Dan Poltawski added a comment - - edited

          Alright, sending for a round of peer review.

          Notes:

          1. I've split the commits up for review only , the backup ones should all be squashed.
          2. I have added the configuration for the question bank to the automated and general settings as this seems to be the correct thing to do. But, those settings concern me a bit, so I forced the default of the config.
          3. I thought about unit testing of component_callback_exists/component_callback/question_module_uses_questions but I can't think of a particularly non-ugly way to do it.
          4. Needs extensive testing instructions, I know
          Show
          Dan Poltawski added a comment - - edited Alright, sending for a round of peer review. Notes: I've split the commits up for review only , the backup ones should all be squashed. I have added the configuration for the question bank to the automated and general settings as this seems to be the correct thing to do. But, those settings concern me a bit, so I forced the default of the config. I thought about unit testing of component_callback_exists/component_callback/question_module_uses_questions but I can't think of a particularly non-ugly way to do it. Needs extensive testing instructions, I know
          Hide
          Tim Hunt added a comment -

          Some comments:

          A. I would write https://github.com/danpoltawski/moodle/commit/c3977caecf3f56b4c5bb0b8b8799576e56c9598d#L0R7229 as a guard clause. That is if (!$functionname)

          { return; }

          rather than a long nested if, but that is probably just personal style.

          +1 Looks good to me, assuming you will address your notes.

          Show
          Tim Hunt added a comment - Some comments: A. I would write https://github.com/danpoltawski/moodle/commit/c3977caecf3f56b4c5bb0b8b8799576e56c9598d#L0R7229 as a guard clause. That is if (!$functionname) { return; } rather than a long nested if, but that is probably just personal style. +1 Looks good to me, assuming you will address your notes.
          Hide
          Dan Poltawski added a comment -

          To everyone interested in 'minimise questions' discussed at length on this issue, i've created a new issue for it: MDL-41924

          Show
          Dan Poltawski added a comment - To everyone interested in 'minimise questions' discussed at length on this issue, i've created a new issue for it: MDL-41924
          Hide
          Dan Poltawski added a comment -

          Regarding A: I prefer that style a bit too, but that was the existing code and so i'm leaving it for now. Will see if I can get another peer reviewer and decide to change it based on what they say.

          Show
          Dan Poltawski added a comment - Regarding A: I prefer that style a bit too, but that was the existing code and so i'm leaving it for now. Will see if I can get another peer reviewer and decide to change it based on what they say.
          Hide
          Don Hinkelman added a comment -

          Hi Dan, Thank you for working on this, but it seems everything we needed done was scoped out of the project. I don't see why the minimize question is so difficult, because whenever random questions are included in a quiz, the whole category can be copied as a default operation, but not the whole question bank. And whenever random questions are not included in a quiz, just the questions used can be copied or optionally the immediate parent category can be included. There was a concern raised that partial question banks might be a problem, but I do not see becoming a problem in our site. When we share questions, we keep a master template that all of our teachers update. From there we can create quizzes based on a sub-System Level Question Bank Category.

          I suppose you would rather we continue the discussion elsewhere, but in MDL-41924, the issue has been surprisingly downgraded to "minor" and only 3 people are watching compared to 61 here. I think a majority of those watching here in MDL-12403 are interested in the minimize questions strategy. This issue is over five years old and does not need to "continue".

          Show
          Don Hinkelman added a comment - Hi Dan, Thank you for working on this, but it seems everything we needed done was scoped out of the project. I don't see why the minimize question is so difficult, because whenever random questions are included in a quiz, the whole category can be copied as a default operation, but not the whole question bank. And whenever random questions are not included in a quiz, just the questions used can be copied or optionally the immediate parent category can be included. There was a concern raised that partial question banks might be a problem, but I do not see becoming a problem in our site. When we share questions, we keep a master template that all of our teachers update. From there we can create quizzes based on a sub-System Level Question Bank Category. I suppose you would rather we continue the discussion elsewhere, but in MDL-41924 , the issue has been surprisingly downgraded to "minor" and only 3 people are watching compared to 61 here. I think a majority of those watching here in MDL-12403 are interested in the minimize questions strategy. This issue is over five years old and does not need to "continue".
          Hide
          Don Hinkelman added a comment -

          If we go back two years ago, Oleg said this similarly: "I think not many people will object with "if quiz use one question, all category with it will be backuped". As a small (and modest) hint to design - random tells us that question should be able report a category on which it rely. That's just one function. Than it will be not hard to get all question/categories for given module (quiz, but there may be more...). (I hope random is (or could be) safeguarded from selecting another random, if it at all possible).

          In other words, for random questions, instead of the default backup setting being the whole question bank, the default setting could be the immediate parent category of the questions being used. In the rare case of a quiz creator using multiple high level categories for random questions (I know of no one doing this), they could be either warned of proper question bank organization or provided an option to "backup entire question bank".

          Show
          Don Hinkelman added a comment - If we go back two years ago, Oleg said this similarly: "I think not many people will object with "if quiz use one question, all category with it will be backuped". As a small (and modest) hint to design - random tells us that question should be able report a category on which it rely. That's just one function. Than it will be not hard to get all question/categories for given module (quiz, but there may be more...). (I hope random is (or could be) safeguarded from selecting another random, if it at all possible). In other words, for random questions, instead of the default backup setting being the whole question bank, the default setting could be the immediate parent category of the questions being used. In the rare case of a quiz creator using multiple high level categories for random questions (I know of no one doing this), they could be either warned of proper question bank organization or provided an option to "backup entire question bank".
          Hide
          Dan Poltawski added a comment -

          Hi Don,

          Well, it seems there is agreement about this backup enhancement being the first step, which is why I decided to carry it forward in this issue.

          While I think everyone wants something like the minimise solution, myself included, I am concerned that this is a goal that we will never reach. (Its been 5 years already..) And its hard to tell how many people watching this issue will have a 'good enough' improvement to class this as a major priority.

          So, perhaps this is de-scoped, but at least we are making some progress and we can find out from all the people who need the minimise solution on the other issue.

          Show
          Dan Poltawski added a comment - Hi Don, Well, it seems there is agreement about this backup enhancement being the first step, which is why I decided to carry it forward in this issue. While I think everyone wants something like the minimise solution, myself included, I am concerned that this is a goal that we will never reach. (Its been 5 years already..) And its hard to tell how many people watching this issue will have a 'good enough' improvement to class this as a major priority. So, perhaps this is de-scoped, but at least we are making some progress and we can find out from all the people who need the minimise solution on the other issue.
          Hide
          Dan Poltawski added a comment -

          I'm afraid, I don't find speculating how 'easy' this issue is to resolve to be a very helpful contribution, just look at the discussion on this issue to indicate its not.

          Show
          Dan Poltawski added a comment - I'm afraid, I don't find speculating how 'easy' this issue is to resolve to be a very helpful contribution, just look at the discussion on this issue to indicate its not.
          Hide
          Don Hinkelman added a comment -

          I think we can speculate, because this issue is not just a coding bug. It is also about making question bank management policy decisions. We can make strategic policy recommendations which will allow question bank managers to handle the great majority of cases easily with proper defaults. The minor cases can be warned against, and we need not be paralyzed in hope of handling every possible case with code.

          Show
          Don Hinkelman added a comment - I think we can speculate, because this issue is not just a coding bug. It is also about making question bank management policy decisions. We can make strategic policy recommendations which will allow question bank managers to handle the great majority of cases easily with proper defaults. The minor cases can be warned against, and we need not be paralyzed in hope of handling every possible case with code.
          Hide
          Frédéric Massart added a comment -

          Hi Dan,

          This seems pretty good, and I don't have much things to mention here.

          1. I know it's part of the blocking issue, but question_module_uses_questions() would be easier to read as question_module_uses_question_bank().
          2. Instead of forcing the setting to be set during upgrade, perhaps you could alter the logic of the backup to only set the setting value if the config setting is defined and not null. It is wrong to assume that it is set anyway.
          3. I had a quick look at backup_calculate_question_categories(), and I agree that it doesn't seem easy to easily filter the questions to be backed up. Perhaps we should define a new backup_step for questions only. Anyway... the discussion will happen on the related issue.

          Cheers,
          Fred

          Show
          Frédéric Massart added a comment - Hi Dan, This seems pretty good, and I don't have much things to mention here. I know it's part of the blocking issue, but question_module_uses_questions() would be easier to read as question_module_uses_question_bank() . Instead of forcing the setting to be set during upgrade, perhaps you could alter the logic of the backup to only set the setting value if the config setting is defined and not null. It is wrong to assume that it is set anyway. I had a quick look at backup_calculate_question_categories(), and I agree that it doesn't seem easy to easily filter the questions to be backed up. Perhaps we should define a new backup_step for questions only. Anyway... the discussion will happen on the related issue. Cheers, Fred
          Hide
          Dan Poltawski added a comment - - edited

          Hi Fred,

          1. I've commented in the issue.
          2. Yes, that does seem sensible, i've adjusted the branch, and this patch: https://github.com/danpoltawski/moodle/commit/c0d7c95b7a6c6e8b9df7622214644cbfa8902e9b

          I've discoverd a few backup related setting issues, so I will take a look at hose.

          Show
          Dan Poltawski added a comment - - edited Hi Fred, 1. I've commented in the issue. 2. Yes, that does seem sensible, i've adjusted the branch, and this patch: https://github.com/danpoltawski/moodle/commit/c0d7c95b7a6c6e8b9df7622214644cbfa8902e9b I've discoverd a few backup related setting issues, so I will take a look at hose.
          Hide
          Dan Poltawski added a comment -

          Sending this back for another review

          Show
          Dan Poltawski added a comment - Sending this back for another review
          Hide
          Tim Hunt added a comment -

          I reviewed this again, and am happy to give it my +1. I will leave official peer review with Fred, however, unless he wishes me to do it.

          Show
          Tim Hunt added a comment - I reviewed this again, and am happy to give it my +1. I will leave official peer review with Fred, however, unless he wishes me to do it.
          Hide
          Frédéric Massart added a comment -

          Looks good to me, thanks!

          Show
          Frédéric Massart added a comment - Looks good to me, thanks!
          Hide
          Marina Glancy added a comment -

          Thanks Dan, this was integrated in master.

          ... but unittests would be really great here together with massive testing instructions

          Show
          Marina Glancy added a comment - Thanks Dan, this was integrated in master. ... but unittests would be really great here together with massive testing instructions
          Hide
          Damyon Wiese added a comment -

          Finished all tests - no errors found.

          Thanks Tim - all good!

          Show
          Damyon Wiese added a comment - Finished all tests - no errors found. Thanks Tim - all good!
          Hide
          Dan Poltawski added a comment -

          It was me!

          Show
          Dan Poltawski added a comment - It was me!
          Hide
          Damyon Wiese added a comment -

          Sorry Dan. Thanks!

          Show
          Damyon Wiese added a comment - Sorry Dan. Thanks!
          Hide
          Marina Glancy added a comment -

          lol, if the issue name has word "quiz" it's automatically "thanks Tim"

          Show
          Marina Glancy added a comment - lol, if the issue name has word "quiz" it's automatically "thanks Tim"
          Hide
          Tim Hunt added a comment -

          Yes. don't thank me. I am not crazy enough to try to fix something this difficult Dan P is a hero.

          Show
          Tim Hunt added a comment - Yes. don't thank me. I am not crazy enough to try to fix something this difficult Dan P is a hero.
          Hide
          Oleg Sychev added a comment -

          I'm against closing this issue after partial solution and moving elsewhere. This issue contains many votes, viewers and useful discussion, not limited to the scope of the fix done. IMHO
          it is better to create and close separate sub-task for the created code, leaving this issue open.

          Show
          Oleg Sychev added a comment - I'm against closing this issue after partial solution and moving elsewhere. This issue contains many votes, viewers and useful discussion, not limited to the scope of the fix done. IMHO it is better to create and close separate sub-task for the created code, leaving this issue open.
          Hide
          Dan Poltawski added a comment -

          You did it!

          Thanks for your contribution, this change has been merged upstream and is now available on your local git mirror and on download sites shortly.

          Show
          Dan Poltawski added a comment - You did it! Thanks for your contribution, this change has been merged upstream and is now available on your local git mirror and on download sites shortly.
          Hide
          Gary Harris added a comment - - edited

          Many thanks for this development effort! I think it will be highly beneficial for everyone going forward.

          I have a few questions:

          1) If I do not select "Include question bank," are the quiz checkboxes supposed to be disabled on the next page of the backup process?
          2) Are there plans to backport the patch to Moodle 2.3 (or any other previous version)?

          Thanks again!

          Show
          Gary Harris added a comment - - edited Many thanks for this development effort! I think it will be highly beneficial for everyone going forward. I have a few questions: 1) If I do not select "Include question bank," are the quiz checkboxes supposed to be disabled on the next page of the backup process? 2) Are there plans to backport the patch to Moodle 2.3 (or any other previous version)? Thanks again!

            Dates

            • Created:
              Updated:
              Resolved:

              Agile