Moodle

get_my_courses does not properly obey the limit parameter

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9.5
  • Fix Version/s: 1.9.6
  • Component/s: Course, Libraries, My Moodle
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

get_my_courses always returns 2 more courses than specified in $limit (if available).

This is because of the way that it applied the limit.

It does it using a counter as it steps through the courses. In this process, there are two off by one error.

I have attached a diff that simplifies it somewhat (to read), and removes the two off by one errors.

  1. accesslib.diff
    08/Oct/09 12:45 AM
    0.5 kB
    Eric Merrill
  2. datalib.diff
    08/Oct/09 12:38 AM
    0.5 kB
    Eric Merrill

Issue Links

Activity

Hide
Eric Merrill added a comment -

get_user_courses_bycap appears to suffer by the same off by 2 problem. Attaching patch for accesslib.

Show
Eric Merrill added a comment - get_user_courses_bycap appears to suffer by the same off by 2 problem. Attaching patch for accesslib.
Hide
Martin Dougiamas added a comment -

Good catch! +1 from me! Thanks!

Show
Martin Dougiamas added a comment - Good catch! +1 from me! Thanks!
Hide
Eric Merrill added a comment -

I have committed the changes to get_user_courses_bycap and get_my_courses to 19_STABLE and HEAD - Resolving ticket.

Show
Eric Merrill added a comment - I have committed the changes to get_user_courses_bycap and get_my_courses to 19_STABLE and HEAD - Resolving ticket.
Hide
Andrew Davis added a comment -

Looks good. Closing.

Show
Andrew Davis added a comment - Looks good. Closing.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: