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

Return new h5pactivity save state settings in WebServices so external clients can implement the save state feature

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.2
    • 4.1.2
    • H5P
    • MOODLE_401_STABLE
    • MOODLE_402_STABLE
    • MDL-77701-master
    • Hide
      1. Login as admin.
      2. Go to Site administration ► Plugins ► Activity modules ► H5P.
      3. Enable "Save state" and set any number in "Save state frequency".
      4. Go to "Site administration ► Users ► Add a new user" and create a new user.
      5. Go to "Site administration ► Courses ► Add a new course" and create a course.
      6. Enrol the user in the course as a student.
      7. Enable "Mobile services": via Site administration ► Advanced users
      8. Create a Token for the mobile app service for any user on the site (but not an admin)
        Click on Site administration ► Plugins ► Web services ► Manage tokens
      9. Next, you can do a CURL REST call simulating a WS client with the user token. You need to replace the WSTOKEN with the student token, the COURSEID with the id of the course you created in step 5, and the MOODLE_URL with the URL of your moodle instance

        curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_h5pactivity_get_h5pactivities_by_courses&wstoken=WSTOKEN&courseids%5B0%5D=COURSEID' | python -m json.tool

      1. Confirm that: you receive a property named h5pglobalsettings that includes:
        1. enablesavestate=true
        2. savestatefreq should be the value you entered in step 3.
      2. Go to Site administration ► Plugins ► Activity modules ► H5P.
      3. Disable "Save state".
      4. Perform the CURL request from step 9 again.
      5. Confirm that: you receive a property named h5pglobalsettings that includes enablesavestate=false and it does not include savestatefreq.
      Show
      Login as admin. Go to Site administration ► Plugins ► Activity modules ► H5P. Enable "Save state" and set any number in "Save state frequency". Go to "Site administration ► Users ► Add a new user" and create a new user. Go to "Site administration ► Courses ► Add a new course" and create a course. Enrol the user in the course as a student. Enable "Mobile services": via Site administration ► Advanced users Create a Token for the mobile app service for any user on the site (but not an admin) Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the user token. You need to replace the WSTOKEN with the student token, the COURSEID with the id of the course you created in step 5, and the MOODLE_URL with the URL of your moodle instance curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_h5pactivity_get_h5pactivities_by_courses&wstoken=WSTOKEN&courseids%5B0%5D=COURSEID' | python -m json.tool Confirm that: you receive a property named h5pglobalsettings that includes: enablesavestate=true savestatefreq should be the value you entered in step 3. Go to Site administration ► Plugins ► Activity modules ► H5P. Disable "Save state". Perform the CURL request from step 9 again. Confirm that: you receive a property named h5pglobalsettings that includes enablesavestate=false and it does not include savestatefreq.

      In MDL-67789, 2 new admin settings were added: enablesavestate and savestatefreq. The Moodle app needs these settings to be able to support the feature.

      There are several WebServices where these settings could be returned:

      1. tool_mobile_get_config: this WS is used to return some site settings (mostly tool_mobile settings and $CFG values). Since the new settings are related to the h5pactivity it can look a bit weird to return them here.
      2. mod_h5pactivity_get_h5pactivity_access_information. The main problem is that the settings will be returned for each activity, while they are unique for all activities.
      3. mod_h5pactivity_get_h5pactivities_by_courses. The app usually calls this WS once per course, so it reduces the problem of point 2. We'll still "replicate" the settings for each WS call though.

      There is no perfect solution, but IMO the best one is number 3.

            dpalou Dani Palou
            dpalou Dani Palou
            Juan Leyva Juan Leyva
            Paul Holden Paul Holden
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 52 minutes
                2h 52m

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