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

External function get_course_contents doesn't return the module instance when it should

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.7.4, 2.8.2, 2.9
    • Fix Version/s: 2.7.6, 2.8.4
    • Component/s: Web Services
    • Labels:
    • Testing Instructions:
      Hide
      1. Create a course with some activities and resources, enrol a user as student or teacher
      2. Enable "Mobile services": Plugins ► Web Services ► External services
      3. Create a Token for the Mobile app service (for the user you enrolled in the course):
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      4. Next, you can do a CURL REST call simulating a WS client:
        • Replace the courseid value with the if of the course you created
        • You also need to replace the wstoken and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4,nb;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Cookie: MoodleSession=879vus9eleqakm580n28efeuk3' -H 'Connection: keep-alive' --data 'options%5B0%5D%5Bname%5D=&options%5B0%5D%5Bvalue%5D=&courseid=3&wsfunction=core_course_get_contents&wstoken=1b9b8bd8d01acbf452c2bd77ca0d2925' --compressed
          

      5. Confirm that:
        • The command returns a list of course sections, every section listing the course activities or resources (modules), and every modules has an instance id value correctly filled

      You should use jsonlint.com for validating and formatting the json response

      Show
      Create a course with some activities and resources, enrol a user as student or teacher Enable "Mobile services": Plugins ► Web Services ► External services Create a Token for the Mobile app service (for the user you enrolled in the course): Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client: Replace the courseid value with the if of the course you created You also need to replace the wstoken and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4,nb;q=0.2' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Cookie: MoodleSession=879vus9eleqakm580n28efeuk3' -H 'Connection: keep-alive' --data 'options%5B0%5D%5Bname%5D=&options%5B0%5D%5Bvalue%5D=&courseid=3&wsfunction=core_course_get_contents&wstoken=1b9b8bd8d01acbf452c2bd77ca0d2925' --compressed Confirm that: The command returns a list of course sections, every section listing the course activities or resources (modules), and every modules has an instance id value correctly filled You should use jsonlint.com for validating and formatting the json response
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-48357-master

      Description

      The module instance is stored in the array to be returned by the Web Service as response but it's never returned because the returns parameter definition is incorrect.
      The return parameters definition misses the "instance" attribute (that is defined in the structure)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Adrian Greeve
              Integrator:
              Eloy Lafuente (stronk7)
              Tester:
              Andrew Nicols
              Participants:
              Component watchers:
              Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                9/Mar/15