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

New Web Service mod_book_view_book

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.9
    • Fix Version/s: 3.0
    • Component/s: Book, Web Services
    • Labels:
    • Testing Instructions:
      Hide

      Note: Version number is bumped because a new web service is added into the Mobile app service and to the mod_book list of external functions.

      1. Create a course with a student, the course must have at least one section.
      2. Enable completion at site level and course level.
      3. Create a mod_book resource, use as completion criteria "Student must view this activity to complete it". Ensure that the book has at least one chapter created.
      4. Log in as the student and visit the book
      5. Log in as teacher and check that the activity is marked as completed by the student and that the student action generated two new entries in the logs (reports -> logs) for the activity (course module viewed and chapter viewed)
      6. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      7. Create a Token for the student user
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      8. Next, you can do a CURL REST call simulating a WS client with the student user .
        • You need to replace the wstoken, bookid (the book instance value) and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'bookid=1&chapterid=0&wsfunction=mod_book_view_book&wstoken=a70d553bbaf6d9b260a9e5c701b3c46e' --compressed

      9. Confirm that
        • You can see new entries in the course log (IMSCP course module viewed) for that course and the user. The origin for the new log entries is "ws"
        • If you access via the web interface you will see the activity marked as completed, if you access the resoure via the web interface with the student you will see log entries with origin "web"
          NOTE: If you don't see the activity marked as completed you should logout and login again, Moodle session cache sometimes does not upgrade the completion status for activities.
      10. Now, from the database retrieve a valid chapter id (table book_chapters) and do the following request (replacing the chapterid parameter with the one you retrieved from the DB):

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'bookid=1&chapterid=1&wsfunction=mod_book_view_book&wstoken=a70d553bbaf6d9b260a9e5c701b3c46e' --compressed

      11. In the course log for the activity you should see a new actiong logged with origin ws "chapter viewed"
      Show
      Note: Version number is bumped because a new web service is added into the Mobile app service and to the mod_book list of external functions. Create a course with a student, the course must have at least one section. Enable completion at site level and course level. Create a mod_book resource, use as completion criteria "Student must view this activity to complete it". Ensure that the book has at least one chapter created. Log in as the student and visit the book Log in as teacher and check that the activity is marked as completed by the student and that the student action generated two new entries in the logs (reports -> logs) for the activity (course module viewed and chapter viewed) As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for the student user Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the student user . You need to replace the wstoken, bookid (the book instance value) and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'bookid=1&chapterid=0&wsfunction=mod_book_view_book&wstoken=a70d553bbaf6d9b260a9e5c701b3c46e' --compressed Confirm that You can see new entries in the course log (IMSCP course module viewed) for that course and the user. The origin for the new log entries is "ws" If you access via the web interface you will see the activity marked as completed, if you access the resoure via the web interface with the student you will see log entries with origin "web" NOTE: If you don't see the activity marked as completed you should logout and login again, Moodle session cache sometimes does not upgrade the completion status for activities. Now, from the database retrieve a valid chapter id (table book_chapters) and do the following request (replacing the chapterid parameter with the one you retrieved from the DB): curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'bookid=1&chapterid=1&wsfunction=mod_book_view_book&wstoken=a70d553bbaf6d9b260a9e5c701b3c46e' --compressed In the course log for the activity you should see a new actiong logged with origin ws "chapter viewed"
    • Affected Branches:
      MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_30_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-50013-master

      Description

      Trigger the module view event.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                16/Nov/15