Moodle
  1. Moodle
  2. MDL-34085

Fix the backup options names in core_course_duplicate_course

    Details

    • Testing Instructions:
      Hide
      1. Create a course with 2 students enrolled
      2. enable actvity completion in course and site settings
      3. Create an assignment and a page resource
      4. Enable manual (student smarks as complete) activity completion on the page resource
      5. For the assignment, set the activity as completed when the students submits the assignment and the teacher grades it.
      6. As a student manually mark the page as completed
      7. As a student submit an assignment
      8. As a teaher grade the assignment
      9. Enable webservices, providing access to the core_course_duplicate_course webservice.
        #
        Use this client:
        https://github.com/moodlehq/sample-ws-clients/blob/master/PHP-REST/client.php
        functionname
        core_course_duplicate_course
        /// PARAMETERS
        $params = array(
        'courseid' => 4, // CHANGE TO THE COURSE you created above
        'fullname' => 'core_course_duplicate_course test', // New course full name
        'shortname' => 'core_course_duplicate_course', // New course shortname
        'categoryid' => 1, // New course category id
        'visible' => 1, // Make the course visible after duplicating
        'options' => array(array('name'=>'blocks', 'value'=>1), array('name'=>'activities', 'value'=>1), array('name'=>'users', 'value'=>1), array('name'=>'userscompletion', 'value'=>1), array('name'=>'grade_histories', 'value'=>1), ) // Backup options
        );
      1. VERIFY: that the course has been duplicated correctly
      2. VERIFY: that the student has been enrolled correctly into the new course
      3. VERIFY: that you can login as the student and see the completion information is restored in the new coruse
      4. VERFIY: that the grade history has been retained in the new course
      Show
      Create a course with 2 students enrolled enable actvity completion in course and site settings Create an assignment and a page resource Enable manual (student smarks as complete) activity completion on the page resource For the assignment, set the activity as completed when the students submits the assignment and the teacher grades it. As a student manually mark the page as completed As a student submit an assignment As a teaher grade the assignment Enable webservices, providing access to the core_course_duplicate_course webservice. # Use this client: https://github.com/moodlehq/sample-ws-clients/blob/master/PHP-REST/client.php functionname core_course_duplicate_course /// PARAMETERS $params = array( 'courseid' => 4, // CHANGE TO THE COURSE you created above 'fullname' => 'core_course_duplicate_course test', // New course full name 'shortname' => 'core_course_duplicate_course', // New course shortname 'categoryid' => 1, // New course category id 'visible' => 1, // Make the course visible after duplicating 'options' => array(array('name'=>'blocks', 'value'=>1), array('name'=>'activities', 'value'=>1), array('name'=>'users', 'value'=>1), array('name'=>'userscompletion', 'value'=>1), array('name'=>'grade_histories', 'value'=>1), ) // Backup options ); VERIFY: that the course has been duplicated correctly VERIFY: that the student has been enrolled correctly into the new course VERIFY: that you can login as the student and see the completion information is restored in the new coruse VERFIY: that the grade history has been retained in the new course
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Pull 2.4 Branch:
      wip_24_mdl-34085
    • Pull 2.5 Branch:
      wip_25_mdl-34085
    • Pull Master Branch:
      wip_master_mdl-34085
    • Rank:
      42392

      Description

      Some backup options name are incorrect:

      "completion_information" (int) Include user course completion information (default to 0 that is equal to
      "histories" (int) Include histories (default to 0 that is equal to no)'

      Correct ones are:

      anonymize is missing

      "anonymize" (int) Anonymize backup (default to 0 that is equal to no),
      "userscompletion" (int) Include user course completion information (default to 0 that is equal to no),
      "grade_histories" (int) Include grade histories (default to 0 that is equal to no)'

        Issue Links

          Activity

          Hide
          Brian King added a comment -

          Please also note that in 2.3.1, the external_value for 'options' is wrong; it should be PARAM_ALPHAEXT, not PARAM_ALPHA (otherwise things like 'role_assignments' fail validation).

          diff --git a/course/externallib.php b/course/externallib.php
          index 41c5ab4..41f3eaa 100644
          --- a/course/externallib.php
          +++ b/course/externallib.php
          @@ -668,7 +668,7 @@ class core_course_external extends external_api {
                           'options' => new external_multiple_structure(
                               new external_single_structure(
                                   array(
          -                                'name' => new external_value(PARAM_ALPHA, 'The backup option name:
          +                                'name' => new external_value(PARAM_ALPHAEXT, 'The backup option name:
                                                       "activities" (int) Include course activites (default to 1 that is equal to yes),
                                                       "blocks" (int) Include course blocks (default to 1 that is equal to yes),
                                                       "filters" (int) Include course filters  (default to 1 that is equal to yes),
          
          Show
          Brian King added a comment - Please also note that in 2.3.1, the external_value for 'options' is wrong; it should be PARAM_ALPHAEXT, not PARAM_ALPHA (otherwise things like 'role_assignments' fail validation). diff --git a/course/externallib.php b/course/externallib.php index 41c5ab4..41f3eaa 100644 --- a/course/externallib.php +++ b/course/externallib.php @@ -668,7 +668,7 @@ class core_course_external extends external_api { 'options' => new external_multiple_structure( new external_single_structure( array( - 'name' => new external_value(PARAM_ALPHA, 'The backup option name: + 'name' => new external_value(PARAM_ALPHAEXT, 'The backup option name: "activities" (int) Include course activites (default to 1 that is equal to yes), "blocks" (int) Include course blocks (default to 1 that is equal to yes), "filters" (int) Include course filters (default to 1 that is equal to yes),
          Hide
          Dan Poltawski added a comment -

          Looks like this is your issue Iñaki

          Show
          Dan Poltawski added a comment - Looks like this is your issue Iñaki
          Hide
          Dan Poltawski added a comment -

          Hi Brian King,

          Looks like the issue you mentioned was fixed in MDL-34083,

          thanks!

          Show
          Dan Poltawski added a comment - Hi Brian King , Looks like the issue you mentioned was fixed in MDL-34083 , thanks!
          Hide
          Dan Poltawski added a comment -

          Hi Iñaki,

          The issue was missing testing instructions, so i've created some to save sending this back.

          If you have some time, please could you verify that the instructions are correct and/or improve them to be more accurate. Thanks

          Show
          Dan Poltawski added a comment - Hi Iñaki, The issue was missing testing instructions, so i've created some to save sending this back. If you have some time, please could you verify that the instructions are correct and/or improve them to be more accurate. Thanks
          Hide
          Dan Poltawski added a comment -

          Oh, I just noticed that "anonymize" (int) Anonymize backup (default to 0 that is equal to no), was not addressed from issue description, will create an issue for that.

          Show
          Dan Poltawski added a comment - Oh, I just noticed that "anonymize" (int) Anonymize backup (default to 0 that is equal to no), was not addressed from issue description, will create an issue for that.
          Hide
          Dan Poltawski added a comment -

          Thanks, i've integrated this to master, 25, 24 and 23.

          I noticed the anonymize issue to late and so have created MDL-40007

          Show
          Dan Poltawski added a comment - Thanks, i've integrated this to master, 25, 24 and 23. I noticed the anonymize issue to late and so have created MDL-40007
          Hide
          Iñaki Arenaza added a comment -

          Hi Dan,

          I left anonymize out intentionally. I added the option in the first place, but when testing the patch, it threw an exception inside the backup/restore code (saying the option name was unkown). So I left it out for this patch.

          Saludos.
          Iñaki.

          Show
          Iñaki Arenaza added a comment - Hi Dan, I left anonymize out intentionally. I added the option in the first place, but when testing the patch, it threw an exception inside the backup/restore code (saying the option name was unkown). So I left it out for this patch. Saludos. Iñaki.
          Hide
          Petr Škoda added a comment -

          Hmm, is restore of grade histories already implemented? I searched the codebase and I could not find anything apart from the settings.

          Show
          Petr Škoda added a comment - Hmm, is restore of grade histories already implemented? I searched the codebase and I could not find anything apart from the settings.
          Hide
          Petr Škoda added a comment - - edited

          This kind of works, sorry for the noise, I am going to create new issues for:
          1/ weird function name - core_course_duplicate_course Duplicate an existing course (creating a new one) without user data - it restores user data now it seems
          2/ the marking guide and rubric data is not restored.

          The grade_grades_history restore seems not implemented...

          Thanks

          Show
          Petr Škoda added a comment - - edited This kind of works, sorry for the noise, I am going to create new issues for: 1/ weird function name - core_course_duplicate_course Duplicate an existing course (creating a new one) without user data - it restores user data now it seems 2/ the marking guide and rubric data is not restored. The grade_grades_history restore seems not implemented... Thanks
          Hide
          Dan Poltawski added a comment -
          Feature: Thanks to our superb contributors
            In order to make Moodle better
            As an integrator
            I need to thank all our contributors
          
            Scenario: Dan thanks you all
              Given I log in as "dan"
              And I see "lots of fixed issues"
              When I follow "Close integrated issues"
              Then I should see "Lots of thanks to all our contributors"
          

          Your changes are upstream

          Show
          Dan Poltawski added a comment - Feature: Thanks to our superb contributors In order to make Moodle better As an integrator I need to thank all our contributors Scenario: Dan thanks you all Given I log in as "dan" And I see "lots of fixed issues" When I follow "Close integrated issues" Then I should see "Lots of thanks to all our contributors" Your changes are upstream

            People

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

              Dates

              • Created:
                Updated:
                Resolved: