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

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.7.4, 2.8.2, 2.9
    • 2.7.6, 2.8.4
    • Web Services
    • MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • MDL-48357-master
    • 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

    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

              jleyva Juan Leyva
              jleyva Juan Leyva
              Adrian Greeve Adrian Greeve
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Andrew Lyons Andrew Lyons
              Juan Leyva, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                9/Mar/15