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

Too complicated way to retrieve modules ids in badges

    XMLWordPrintable

    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);
      

        Attachments

          Activity

            People

            • Assignee:
              ybozhko Yuliya Bozhko
              Reporter:
              marina Marina Glancy
              Peer reviewer:
              Dan Poltawski
              Integrator:
              Sam Hemelryk
              Tester:
              Rossiani Wijaya
              Participants:
              Component watchers:
              Yuliya Bozhko, Amaia Anabitarte, Bas Brands, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

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