Uploaded image for project: 'Moodle QA'
  1. Moodle QA
  2. MDLQA-9827 Moodle 3.2 QA
  3. MDLQA-10287

CLONE - Test core_course_get_contents webservice


    • Icon: Functional Test Functional Test
    • Icon: Minor Minor
    • Moodle 3.2
    • Moodle 3.2
    • Web Services
    • None

      For testing this issue:

      1. You need to have access to console on your system
      2. Curl and python should be installed on your system.
      3. Have basic understanding of Json


      1. Login as admin
      2. Enable web services (Site administration ▶︎ Advanced features)
      3. Enable Rest protocol (Site administration ▶︎ Plugins ▶︎ Web services ▶︎ Manage protocols)
      4. Add an external service (Site administration ▶︎ Plugins ▶︎ Web services ▶︎ External services)
      5. Add function with core_course_get_contents
      6. Create a token for student (Sam student) (Site administration ▶︎ Plugins ▶︎ Web services ▶︎ Manage tokens)
      7. Save token and use it to replace d49d1fac7125d9fd515c374be8d37c34 in the web service below.


      1. Run following command on your console

        curl 'https://qa.moodle.net/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 'Connection: keep-alive' --data 'courseid=3&wsfunction=core_course_get_contents&wstoken=d49d1fac7125d9fd515c374be8d37c34' --compressed | python -m json.tool

      2. Ensure you receive a list of course modules including all the activities in "Activity examples" course on qa.moodle.net
      3. Now replace the --data value to tests the different options:
        • You should see course topics list but not activity modules

          --data 'options%5B0%5D%5Bname%5D=excludemodules&options%5B0%5D%5Bvalue%5D=1&courseid=3&wsfunction=core_course_get_contents&wstoken=d49d1fac7125d9fd515c374be8d37c34'

        • You should see the course topics list, including activities and resources. The resources must have an empty contents attribute

          --data 'options%5B0%5D%5Bname%5D=excludecontents&options%5B0%5D%5Bvalue%5D=4&courseid=3&wsfunction=core_course_get_contents&wstoken=d49d1fac7125d9fd515c374be8d37c34'

        • In this case you will be a single section with resources without contents

          --data 'options%5B0%5D%5Bname%5D=sectionnumber&options%5B0%5D%5Bvalue%5D=10&options%5B1%5D%5Bname%5D=excludecontents&options%5B1%5D%5Bvalue%5D=4&courseid=3&wsfunction=core_course_get_contents&wstoken=d49d1fac7125d9fd515c374be8d37c34'

            fred Frédéric Massart
            0 Vote for this issue
            1 Start watching this issue


                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.