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

Badge cron task checks badges of invisible courses

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.4, 3.6
    • Fix Version/s: 3.5.6, 3.6.4
    • Component/s: Badges
    • Labels:
    • Testing Instructions:
      Hide
      1. Create a course with the setting 'Course visibility' set to 'Hide' and the 'Course start date' set to a few days in the past.
      2. Visit the course.
      3. Click 'Badges' on the left.
      4. Click 'Add a new badge'.
      5. Create a badge, filling in the necessary fields (any image will do) (remember the name of the badge).
      6. Add a 'Manual issue by role' criteria (choose any role).
      7. Click on the button 'Enable access' and confirm.
      8. Visit 'Site administration' > 'Badges' > 'Manage badges'.
      9. Click 'Add a new badge'.
      10. Create a badge, filling in the necessary fields (any image will do) (remember the name of the badge).
      11. Add a 'Manual issue by role' criteria (choose any role).
      12. Click on the button 'Enable access' and confirm.
      13. Run php admin/tool/task/cli/schedule_task.php --execute="\core\task\badges_cron_task".
      14. Verify in the cron log (The text following the execution of the cron task) that the badge you created in the course has not been reviewed but the site badge has.
      15. Unhide the course.
      16. Run php admin/tool/task/cli/schedule_task.php --execute="\core\task\badges_cron_task".
      17. Verify in the cron log that both badges you created have been verified.
      Show
      Create a course with the setting 'Course visibility' set to 'Hide' and the 'Course start date' set to a few days in the past. Visit the course. Click 'Badges' on the left. Click 'Add a new badge'. Create a badge, filling in the necessary fields (any image will do) (remember the name of the badge). Add a 'Manual issue by role' criteria (choose any role). Click on the button 'Enable access' and confirm. Visit 'Site administration' > 'Badges' > 'Manage badges'. Click 'Add a new badge'. Create a badge, filling in the necessary fields (any image will do) (remember the name of the badge). Add a 'Manual issue by role' criteria (choose any role). Click on the button 'Enable access' and confirm. Run php admin/tool/task/cli/schedule_task.php --execute="\core\task\badges_cron_task" . Verify in the cron log (The text following the execution of the cron task) that the badge you created in the course has not been reviewed but the site badge has. Unhide the course. Run php admin/tool/task/cli/schedule_task.php --execute="\core\task\badges_cron_task" . Verify in the cron log that both badges you created have been verified.
    • Affected Branches:
      MOODLE_35_STABLE, MOODLE_36_STABLE
    • Fixed Branches:
      MOODLE_35_STABLE, MOODLE_36_STABLE
    • Pull 3.5 Branch:
    • Pull 3.6 Branch:
    • Pull Master Branch:
      MDL-64851-master

      Description

      In our Moodle 3.5 installation we have about 120 course badges. Many of them are related to invisible courses, but cron still checks them.

      The problem seems to be in the query that select badges to review. (https://github.com/moodle/moodle/blob/MOODLE_35_STABLE/badges/cron.php#L53)

      This part of the SQL query OR EXISTS (SELECT id FROM {course} WHERE visible = :visible AND startdate < :current) '; doesn’t seem to filter anything because is always true.

       

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                13/May/19

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 55 minutes
                1h 55m