Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.2, 2.3
    • Fix Version/s: 2.1.6, 2.2.3
    • Component/s: Questions
    • Labels:
    • Testing Instructions:
      Hide

      Moodle 1.9 or 2.0 site with quiz attempts.

      Place 2.1, 2.2 or master code in place - but do not run upgrade yet!
      Create admin/tool/qeupgradehelper/partialupgrade.php (2.1 path is local/qeupgradehelper/partialupgrade.php), with the code:

      <?php
      function tool_qeupgradehelper_get_quizzes_to_upgrade() {
          return array();
      }
      

      This will cause the question attempt upgrade to not execute.

      Run the Moodle system upgrade.

      now run (via command line):
      sudo -u www-data /usr/bin/php admin/tool/qeupgradehelper/cli/convert.php -h
      or (for 2.1)
      sudo -u www-data /usr/bin/php local/qeupgradehelper/cli/convert.php -h

      note that www-data is the user of the webprocess on your system - it may be something else, like httpd or apache, the path to php may also vary.

      From there you can try different flags, -t=x to process for x seconds (note it allows the current quiz to finish, so it will likely run longer than x seconds), -c=n to process n quizes, or --quiz=quizid to process quizid.

      -t and -c can be used together, the first to be reached causes a stop.

      No flags will cause the system to complete all remaining quizes.

      Show
      Moodle 1.9 or 2.0 site with quiz attempts. Place 2.1, 2.2 or master code in place - but do not run upgrade yet! Create admin/tool/qeupgradehelper/partialupgrade.php (2.1 path is local/qeupgradehelper/partialupgrade.php), with the code: <?php function tool_qeupgradehelper_get_quizzes_to_upgrade() { return array(); } This will cause the question attempt upgrade to not execute. Run the Moodle system upgrade. now run (via command line): sudo -u www-data /usr/bin/php admin/tool/qeupgradehelper/cli/convert.php -h or (for 2.1) sudo -u www-data /usr/bin/php local/qeupgradehelper/cli/convert.php -h note that www-data is the user of the webprocess on your system - it may be something else, like httpd or apache, the path to php may also vary. From there you can try different flags, -t=x to process for x seconds (note it allows the current quiz to finish, so it will likely run longer than x seconds), -c=n to process n quizes, or --quiz=quizid to process quizid. -t and -c can be used together, the first to be reached causes a stop. No flags will cause the system to complete all remaining quizes.
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull Master Branch:
    • Rank:
      39321

      Description

      We wrote a tool to execute qeupgradehelper, and it allows some options, like only upgrade quiz id x, upgrade x quizes, and run for x seconds.

      I feel this may be pretty helpful to other installs with large attempt upgrade, over the browser based upgrade.

        Issue Links

          Activity

          Hide
          Eric Merrill added a comment -

          Added the patch for master and 2.3

          Don't know (if it were to be included), if the tool should go in admin/tool/qeupgradehelper/* or admin/cli/* - right now I have it in with qeupgradehelper

          Show
          Eric Merrill added a comment - Added the patch for master and 2.3 Don't know (if it were to be included), if the tool should go in admin/tool/qeupgradehelper/* or admin/cli/* - right now I have it in with qeupgradehelper
          Hide
          Tim Hunt added a comment -

          That looks pretty good.

          1. I think it should be in admin/tool/qeupgradehelper/. I don't know if there is a convention like putting it in admin/tool/qeupgradehelper/cli/? I don't think there is, but perhaps there should be. If you can be bothered, discuss it with Petr Skoda but for now it is good where it is.

          2. You seem to have duplicated the line $quiz = tool_qeupgradehelper_get_quiz_for_upgrade(); (lines 91 and 93).

          3. What are the rules about making CLI scripts translatable? Looking in admin/cron.php, it is not clear. This new script is useful as-is. No need to create lots more lang strings.

          4. Getting to the really picky bits: in the PHP comment at the top of the file, it should be @package tool_qeupgradehelper (not separate @subpackage). (At one time I thought it was the other way, which is why all the other files are wrong.) Also, you should change @copyright to by copyright you!

          Thanks, Tim.

          Show
          Tim Hunt added a comment - That looks pretty good. 1. I think it should be in admin/tool/qeupgradehelper/. I don't know if there is a convention like putting it in admin/tool/qeupgradehelper/cli/? I don't think there is, but perhaps there should be. If you can be bothered, discuss it with Petr Skoda but for now it is good where it is. 2. You seem to have duplicated the line $quiz = tool_qeupgradehelper_get_quiz_for_upgrade(); (lines 91 and 93). 3. What are the rules about making CLI scripts translatable? Looking in admin/cron.php, it is not clear. This new script is useful as-is. No need to create lots more lang strings. 4. Getting to the really picky bits: in the PHP comment at the top of the file, it should be @package tool_qeupgradehelper (not separate @subpackage). (At one time I thought it was the other way, which is why all the other files are wrong.) Also, you should change @copyright to by copyright you! Thanks, Tim.
          Hide
          Eric Merrill added a comment -

          Like a chump I committed the wrong (old version). If you could take another peak at it - the now committed version is much better.

          Sorry about that (and I fixed the package label)

          Show
          Eric Merrill added a comment - Like a chump I committed the wrong (old version). If you could take another peak at it - the now committed version is much better. Sorry about that (and I fixed the package label)
          Hide
          Tim Hunt added a comment -

          Yes that is better.

          5. @copyright does need the year, I think.

          6. If you use the latest version of https://github.com/moodlehq/moodle-local_codechecker, it now wants comments to // Start with a capital and end with a full stop. I am not expecting you to fix that here. I just thought I should let you know for future reference.

          If you write some testing instructions, and fix the copyright year, I can submit this for integration.

          Show
          Tim Hunt added a comment - Yes that is better. 5. @copyright does need the year, I think. 6. If you use the latest version of https://github.com/moodlehq/moodle-local_codechecker , it now wants comments to // Start with a capital and end with a full stop. I am not expecting you to fix that here. I just thought I should let you know for future reference. If you write some testing instructions, and fix the copyright year, I can submit this for integration.
          Hide
          Tim Hunt added a comment -

          Sorry. One more thing.

          Please can you add mention of this command-line script to the readme, and on http://docs.moodle.org/21/en/Upgrading_to_Moodle_2.1. We need to let people know this option exists!

          Show
          Tim Hunt added a comment - Sorry. One more thing. Please can you add mention of this command-line script to the readme, and on http://docs.moodle.org/21/en/Upgrading_to_Moodle_2.1 . We need to let people know this option exists!
          Hide
          Eric Merrill added a comment -

          I'll get right on it.

          Speaking of the Upgrading_to_Moodle_2.1, do you also want me to backport it to 2.1? I'm not sure what the protocol is for backporting feature improvements. I'm happy to do it, just whatever you want.

          Show
          Eric Merrill added a comment - I'll get right on it. Speaking of the Upgrading_to_Moodle_2.1, do you also want me to backport it to 2.1? I'm not sure what the protocol is for backporting feature improvements. I'm happy to do it, just whatever you want.
          Hide
          Tim Hunt added a comment -

          I am not bothered one way or the other. It is good to backport, because this is useful functionality, and adding it won't break anything.

          On the other hand, people really ought to be upgrading to 2.2.x, and it is a non-trivial back-port, so you need not bother. Basically, it is up to you.

          Show
          Tim Hunt added a comment - I am not bothered one way or the other. It is good to backport, because this is useful functionality, and adding it won't break anything. On the other hand, people really ought to be upgrading to 2.2.x, and it is a non-trivial back-port, so you need not bother. Basically, it is up to you.
          Hide
          Eric Merrill added a comment -

          I committed some the copyright fix and an addition to the README (not sure if it's the best addition in the world, so please give it a look and let me know if/how I should change it).

          I'll look at 2.1 tonight, if it's not too much of a pain I'll give it a-go. I'll comment here either way.

          Also, should I redo the branches into a single commit, or just leave them as is? All my other patches were done in one go

          Show
          Eric Merrill added a comment - I committed some the copyright fix and an addition to the README (not sure if it's the best addition in the world, so please give it a look and let me know if/how I should change it). I'll look at 2.1 tonight, if it's not too much of a pain I'll give it a-go. I'll comment here either way. Also, should I redo the branches into a single commit, or just leave them as is? All my other patches were done in one go
          Hide
          Tim Hunt added a comment -

          Looking good. I think you should rebase the branch into a single commit.

          Show
          Tim Hunt added a comment - Looking good. I think you should rebase the branch into a single commit.
          Hide
          Eric Merrill added a comment -

          Ok, backported to 2.1, and squashed them all down into single commits, so if you think it looks ready, please send it on for integration.

          Thanks for all the help Tim.

          Show
          Eric Merrill added a comment - Ok, backported to 2.1, and squashed them all down into single commits, so if you think it looks ready, please send it on for integration. Thanks for all the help Tim.
          Hide
          Tim Hunt added a comment -

          Great, thanks Eric!

          To INTEGRATORS, although this is technically a new feature, it is just a new script that cannot possibly break any existing functionality, and it is useful, therefore, please can we back-port it to all the stable branches.

          Show
          Tim Hunt added a comment - Great, thanks Eric! To INTEGRATORS, although this is technically a new feature, it is just a new script that cannot possibly break any existing functionality, and it is useful, therefore, please can we back-port it to all the stable branches.
          Hide
          Dan Poltawski added a comment - - edited

          Hi Eric/Tim,

          This looks and I agree its worth going into the stable branches.

          I have two comments which I wonder if you'd be able to fix before integrating:

          1. I think that this script should go into a cli subdirectory like Tim suggested, its certainly a defacto standard (and I am going to propose we put this into the coding guidelines). See examples:
            admin/cli/ auth/ldap/cli/ auth/db/cli/ enrol/meta/cli enrol/cohort/cli admin/tool/phpunit/cli/ etc
          2. The coding style doc says: ' Our CLI script must not use relative config.php paths.'. So I think that your relative include of config.php should be changed to use dirname instead. (Note that when investigating this I noticed the phpunit tool does use relative includes.. going to investigate that).
          Show
          Dan Poltawski added a comment - - edited Hi Eric/Tim, This looks and I agree its worth going into the stable branches. I have two comments which I wonder if you'd be able to fix before integrating: I think that this script should go into a cli subdirectory like Tim suggested, its certainly a defacto standard (and I am going to propose we put this into the coding guidelines). See examples: admin/cli/ auth/ldap/cli/ auth/db/cli/ enrol/meta/cli enrol/cohort/cli admin/tool/phpunit/cli/ etc The coding style doc says: ' Our CLI script must not use relative config.php paths.'. So I think that your relative include of config.php should be changed to use dirname instead. (Note that when investigating this I noticed the phpunit tool does use relative includes.. going to investigate that).
          Hide
          Eric Merrill added a comment -

          Done. script is now qeupgradehelper/cli/convert.php.

          I had to rebase the braches, so you may have to completely re-pull them.

          Show
          Eric Merrill added a comment - Done. script is now qeupgradehelper/cli/convert.php. I had to rebase the braches, so you may have to completely re-pull them.
          Hide
          Dan Poltawski added a comment -

          Thanks - i've integrated this now.

          I did a commit on top to fix the /afterupgradelib.php and remove some trailing whitespace

          Show
          Dan Poltawski added a comment - Thanks - i've integrated this now. I did a commit on top to fix the /afterupgradelib.php and remove some trailing whitespace
          Hide
          Eric Merrill added a comment -

          D'oh - good catch Dan!

          Show
          Eric Merrill added a comment - D'oh - good catch Dan!
          Hide
          Adrian Greeve added a comment -

          I did an upgrade from 2.0 to 2.2. Everything worked ok.
          Thanks.

          Show
          Adrian Greeve added a comment - I did an upgrade from 2.0 to 2.2. Everything worked ok. Thanks.
          Hide
          Dan Poltawski added a comment -

          Bonza mate!

          Your changes have made it into the Moodle release! Its time to celebrate! Put a shrimp on the barbie and grab a stubby.

          Hooroo

          Show
          Dan Poltawski added a comment - Bonza mate! Your changes have made it into the Moodle release! Its time to celebrate! Put a shrimp on the barbie and grab a stubby. Hooroo

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: