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

Too complicated way to retrieve modules ids in badges

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5.1
    • Fix Version/s: 2.5.3
    • Component/s: Badges
    • Labels:
    • Testing Instructions:
      Hide

      To test, you need course badges enabled, a course with several activities, completion criteria set on at least one of these activities (manual completion is the easiest to test), and a user enrolled in the course.

      1. As an admin, create a course badge.
      2. Add activity completion criteria for a badge.
      3. Pick an activity for the badge criteria.
      4. Enable badge access.
      5. Log in as an enrolled user.
      6. Mark activity that is required by the course badge as completed.
      7. Go to "CourseName > Badges > Course badges" navigation menu.
      8. Make sure that you earned a badge. It is shown in the "Issued to me" column.

      If you selected more than one activity for completion, you will need to make sure that you complete all/any of them depending on your badge criteria ALL/ANY rule.

      Show
      To test, you need course badges enabled, a course with several activities, completion criteria set on at least one of these activities (manual completion is the easiest to test), and a user enrolled in the course. 1. As an admin, create a course badge. 2. Add activity completion criteria for a badge. 3. Pick an activity for the badge criteria. 4. Enable badge access. 5. Log in as an enrolled user. 6. Mark activity that is required by the course badge as completed. 7. Go to "CourseName > Badges > Course badges" navigation menu. 8. Make sure that you earned a badge. It is shown in the "Issued to me" column. If you selected more than one activity for completion, you will need to make sure that you complete all/any of them depending on your badge criteria ALL/ANY rule.
    • Affected Branches:
      MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_25_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-41637_master

      Description

      Function completion_info::get_activities() already returns modules indexed by their ids

      diff --git a/badges/criteria/award_criteria_activity.php b/badges/criteria/award_criteria_activity.php
      index 3a14e6b..ff9b92e 100644
      --- a/badges/criteria/award_criteria_activity.php
      +++ b/badges/criteria/award_criteria_activity.php
      @@ -120,7 +120,7 @@ class award_criteria_activity extends award_criteria {
               $course = $DB->get_record('course', array('id' => $this->courseid));
               $info = new completion_info($course);
               $mods = $info->get_activities();
      -        $mids = array_map(create_function('$o', 'return $o->id;'), $mods);
      +        $mids = array_keys($mods);
       
               if ($this->id !== 0) {
                   $existing = array_keys($this->params);
      

        Gliffy Diagrams

          Activity

          Hide
          poltawski Dan Poltawski added a comment -

          +1, thanks Marina/Yuliya

          Show
          poltawski Dan Poltawski added a comment - +1, thanks Marina/Yuliya
          Hide
          samhemelryk Sam Hemelryk added a comment -

          Thanks girls, nice improvement!

          Show
          samhemelryk Sam Hemelryk added a comment - Thanks girls, nice improvement!
          Hide
          rwijaya Rossiani Wijaya added a comment -

          This is working as expected.

          Tested for 2.5 and master.

          Test passed.

          Show
          rwijaya Rossiani Wijaya added a comment - This is working as expected. Tested for 2.5 and master. Test passed.
          Hide
          samhemelryk Sam Hemelryk added a comment -

          Yarrr me 'arties, good job done. Yer code 'as landed and the weeklies ave been released with your contributions in tow.
          The brethren thank ya for yer 'ard work and if there'd been treasure to ave ya would ave got yer cut.

          Thanks for the effort everyone, another successful weekly release has been rolled.
          Please keep in mind code freeze is just around the corner now, get your new features and improvements in ASAP.

          Many thanks
          Sam

          Show
          samhemelryk Sam Hemelryk added a comment - Yarrr me 'arties, good job done. Yer code 'as landed and the weeklies ave been released with your contributions in tow. The brethren thank ya for yer 'ard work and if there'd been treasure to ave ya would ave got yer cut. Thanks for the effort everyone, another successful weekly release has been rolled. Please keep in mind code freeze is just around the corner now, get your new features and improvements in ASAP. Many thanks Sam

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Nov/13