Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Component/s: Backup
    • Labels:
      None
    • Difficulty:
      Difficult
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      Implement restore UI 90% equivalent to the backup one (MDL-22142) but with some differences. Just quick-enumerating them here for further details/discussion.

      A) We need support for date (day/month/year) setting. To be added to course settings, it's missing right now.

      B) A lot of settings become decided by the backup file contents. For example, the root->users setting will be "No" if the backup was generated without users. In that case, it should display a simply label (dependencies of course, will continue being enforced but NOTHING will change that value). I've somehow configured the default values and the list of options of the current select ui elements. But I'm not sure if that's the way. Needs discussion.

      C) Here it's one minimalistic restore API. Follow this steps in order to get it working:

      – Set $CFG->keeptempdirectoriesonbackup = true; in your config.php files
      – Execute one backup if one course containing at least one choice activity.
      – Go to $CFG->dataroot/temp/backup and you will see one xxxxxxx directory. Copy that xxxxxxx
      – Create one script with these contents:

      require_once('config.php');
      require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
       
      $tempdir = 'xxxxxxx'; // Put here the name of the temp directory.
      $course_to_restore_to = xx; // Target course where backup will be restored
      $user_doing_the_restore = xx; // ID of the user executing the restore
       
      $rc = new restore_controller($tempdir, $course_to_restore_to, backup::INTERACTIVE_YES, backup::MODE_GENERAL, $user_doing_the_restore
      , backup::TARGET_NEW_COURSE);
       
      if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) {
          echo "format: {$rc->get_format()} detected. Conversion needed";
          $rc->convert();
      }
       
      $rc->finish_ui();
       
      if (!$rc->execute_precheck()) {
          $rc->get_precheck_results();
      } else {
          $rc->execute_plan();
      }

      As you can see, API is really similar to the backup one, but have two exceptions, both optional (don't happen always), but cause new request to happen:

      C1 - If the backup format doesn't correspond to one moodle2 format, status will be STATUS_REQUIRE_CONV and conversion must be performed, surely with one page showing the situation (with continue button) and another to show the conversion process.

      C2 - If the execution of the prechecks returns false, that means that something is preventing restore to be executed. The results returned by get_precheck_results() will be an array of warnings and/or errors. warnings will allow to continue with execute_plan() but errors wont. Note there is one new status STATUS_NEED_PRECHECK enforcing the execution of the prechecks.

      Both these C1 and C2 mean that, apart from the "typical" settings pages... we'll need to be able to show (conditionally) other pages (stages) "in the middle" of the restore API. Needs discussion, for sure.

      D - Note we have still pending which information we are going to output while execute_plan() is in action (see, related MDL-22144 and MDL-22143, they apply both to backup and restore).

      E - Tiny detail, once execute_plan() has finished ok, it should show one button to go to the restored course.

      F - I'm sure that there was one F, grrr (and important!). But I've forgotten it. Sure it appears when implementing the whole thing.

      Ciao

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    24/Nov/10