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

The H5P check_updates_since callback should return H5P attempts information

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.9
    • 3.9
    • H5P
    • MOODLE_39_STABLE
    • MOODLE_39_STABLE
    • MDL-68451-master
    • Hide

      Notice: You need to be able to use CURL in a console.

      Setup

      1. Login as admin.
      2. Create a course "Course 1" and a new H5P activity with the attached file (question-set-616.h5p).
      3. Create a teacher t1 user and enrolled in the Course 1.
      4. Create two students s1 and s2 and enrolled in the Course 1.
      5. Enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      6. Click on Site administration ► Plugins ► Web services ► Manage tokens
      7. Create two tokens, one for the teacher t1 and other for the student s1  to service (Mobile Service).
      8. Calculate the current timestamp https://www.unixtimestamp.com/. This timestamp will be used in the following scenarios (always the same).

      Testing Scenario 0: No updates in the h5pactivity.

      1. Do a CURL REST call simulating a WS client with the user.
        • You need to replace the WSTOKENSTUDENT (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance

          curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck[0][contextlevel]=module&tocheck[0][id]=CMID&tocheck[0][since]=TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENSTUDENT' | python -m "json.tool"

      1. Expected result: Check that you don't receive updates. "instances" and "warnings" should be empty.
      2. Do a CURL REST call simulating a WS client with the user.
        • You need to replace the WSTOKENTEACHER (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance

          curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck[0][contextlevel]=module&tocheck[0][id]=CMID&tocheck[0][since]=TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENTEACHER' | python -m "json.tool"

      1. Expected result: Check that you don't receive updates. "instances" and "warnings" should be empty.

      Testing Scenario 1: Updates in the h5pactivity title.

      1. Edit the H5P activity, change the name and save changes.
      2. Do a CURL REST call simulating a WS client with the user.
        • You need to replace the WSTOKENSTUDENT (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance

          curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck[0][contextlevel]=module&tocheck[0][id]=CMID&tocheck[0][since]=TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENSTUDENT' | python -m "json.tool"

      1. Expected result: Check that you don't receive updates about tracks, only about "name": "configuration" with "timeupdated" and "itemids" with a value and "name": "packagefiles" 
      2. Do a CURL REST call simulating a WS client with the user.
        • You need to replace the WSTOKENTEACHER (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance

          curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck[0][contextlevel]=module&tocheck[0][id]=CMID&tocheck[0][since]=TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENTEACHER' | python -m "json.tool"

      1. Expected result: Check that you don't receive updates about usertracks, only about "name": "configuration" with "timeupdated" and "itemids" with a value and "name": "packagefiles" 

      Testing Scenario 2: New updates in the h5pactivity.

      1. Go to the "Course 1".
      2. Login as s1.
      3. Go to the course and do the H5P activity twice. Just, when you finish your first attempt click on retry button to do it again.
      4. Logout.
      5. Login as s2.
      6. Go to the course and do the H5P activity once.
      7. Do a CURL REST call simulating a WS client with the user.
        • You need to replace the WSTOKENSTUDENT (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance

          curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck[0][contextlevel]=module&tocheck[0][id]=CMID&tocheck[0][since]=TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENSTUDENT' | python -m "json.tool"

      1. Expected result: Check that you receive updates about tracks, but not about usertracks. You should see two itemsid belong to tracks field. There are two attempts of the s1.
      2. Do a CURL REST call simulating a WS client with the user.
        • You need to replace the WSTOKENTEACHER (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance

          curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck[0][contextlevel]=module&tocheck[0][id]=CMID&tocheck[0][since]=TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENTEACHER' | python -m "json.tool"

      1. Expected result: Check that you receive updates about usertracks, but not about tracks. You should see three itemsid belong to usertracks field. There are all the attempts of the students.

      Testing Scenario 3: Check updates when h5pactivity is defined as separate groups.

      1. Login as an admin.
      2. Go to the "Course 1".
      3. Create two groups in the course, g1 and g2.
      4. Enrol the student s1 in g1 and s2 in g2.
      5. Edit the new H5P activity and set the Group Mode to Separate groups in Common module settings section.
      6. Do a CURL REST call simulating a WS client with the user.
        • You need to replace the WSTOKENTEACHER (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance

          curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck[0][contextlevel]=module&tocheck[0][id]=CMID&tocheck[0][since]=TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENTEACHER' | python -m "json.tool"

      1. Expected result: Check that you receive updates about usertracks, but not about tracks. You should see three itemsid belong to usertracks field. There are all the attempts of the students.
      2. Now, unassign (prohibit) the moodle/site:accessallgroups capability in the course for the teacher role.
      3. Do a CURL REST call simulating a WS client with the user.
        • You need to replace the WSTOKENTEACHER (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance

          curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck[0][contextlevel]=module&tocheck[0][id]=CMID&tocheck[0][since]=TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENTEACHER' | python -m "json.tool"

      1. Expected result: Check that you no receive updates about usertracks. You shouldn't see itemsid belong to usertracks field. 
      2. Now, assign the teacher to the group g1.
      3. Do a CURL REST call simulating a WS client with the user.
        • You need to replace the WSTOKENTEACHER (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance

          curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck[0][contextlevel]=module&tocheck[0][id]=CMID&tocheck[0][since]=TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENTEACHER' | python -m "json.tool"

      1. Expected result: Check that you receive updates about usertracks. You should see two itemsid belong to usertracks field. This items belong to the user s1.
      Show
      Notice: You need to be able to use CURL in a console. Setup Login as admin. Create a course "Course 1" and a new H5P activity with the attached file (question-set-616.h5p). Create a teacher t1 user and enrolled in the Course 1. Create two students s1 and s2 and enrolled in the Course 1. Enable "Mobile services": Site administration ► Mobile app ► Mobile settings Click on Site administration ► Plugins ► Web services ► Manage tokens Create two tokens, one for the teacher t1 and other for the student s1  to service (Mobile Service). Calculate the current timestamp  https://www.unixtimestamp.com/ . This timestamp will be used in the following scenarios (always the same). Testing Scenario 0: No updates in the h5pactivity. Do a CURL REST call simulating a WS client with the user. You need to replace the WSTOKENSTUDENT (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck [0] [contextlevel] =module&tocheck [0] [id] =CMID&tocheck [0] [since] =TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENSTUDENT' | python -m "json.tool" Expected result: Check that you don't receive updates. "instances" and "warnings" should be empty. Do a CURL REST call simulating a WS client with the user. You need to replace the WSTOKENTEACHER (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck [0] [contextlevel] =module&tocheck [0] [id] =CMID&tocheck [0] [since] =TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENTEACHER' | python -m "json.tool" Expected result : Check that you don't receive updates. "instances" and "warnings" should be empty. Testing Scenario 1: Updates in the h5pactivity title. Edit the H5P activity, change the name and save changes. Do a CURL REST call simulating a WS client with the user. You need to replace the WSTOKENSTUDENT (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck [0] [contextlevel] =module&tocheck [0] [id] =CMID&tocheck [0] [since] =TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENSTUDENT' | python -m "json.tool" Expected result: Check that you don't receive updates about tracks, only about "name": "configuration" with "timeupdated" and "itemids" with a value and "name": "packagefiles"  Do a CURL REST call simulating a WS client with the user. You need to replace the WSTOKENTEACHER (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck [0] [contextlevel] =module&tocheck [0] [id] =CMID&tocheck [0] [since] =TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENTEACHER' | python -m "json.tool" Expected result: Check that you don't receive updates about usertracks, only about "name": "configuration" with "timeupdated" and "itemids" with a value and "name": "packagefiles"  Testing Scenario 2: New updates in the h5pactivity. Go to the "Course 1". Login as s1. Go to the course and do the H5P activity twice. Just, when you finish your first attempt click on retry button to do it again. Logout. Login as s2. Go to the course and do the H5P activity once. Do a CURL REST call simulating a WS client with the user. You need to replace the WSTOKENSTUDENT (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck [0] [contextlevel] =module&tocheck [0] [id] =CMID&tocheck [0] [since] =TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENSTUDENT' | python -m "json.tool" Expected result: Check that you receive updates about tracks, but not about usertracks. You should see two itemsid belong to tracks field. There are two attempts of the s1. Do a CURL REST call simulating a WS client with the user. You need to replace the WSTOKENTEACHER (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck [0] [contextlevel] =module&tocheck [0] [id] =CMID&tocheck [0] [since] =TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENTEACHER' | python -m "json.tool" Expected result: Check that you receive updates about usertracks, but not about tracks. You should see three itemsid belong to usertracks field. There are all the attempts of the students. Testing Scenario 3: Check updates when h5pactivity is defined as separate groups. Login as an admin. Go to the "Course 1". Create two groups in the course, g1 and g2. Enrol the student s1 in g1 and s2 in g2. Edit the new H5P activity and set the Group Mode to Separate groups in Common module settings section. Do a CURL REST call simulating a WS client with the user. You need to replace the WSTOKENTEACHER (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck [0] [contextlevel] =module&tocheck [0] [id] =CMID&tocheck [0] [since] =TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENTEACHER' | python -m "json.tool" Expected result: Check that you receive updates about usertracks, but not about tracks. You should see three itemsid belong to usertracks field. There are all the attempts of the students. Now, unassign (prohibit) the moodle/site:accessallgroups capability in the course for the teacher role. Do a CURL REST call simulating a WS client with the user. You need to replace the WSTOKENTEACHER (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck [0] [contextlevel] =module&tocheck [0] [id] =CMID&tocheck [0] [since] =TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENTEACHER' | python -m "json.tool" Expected result: Check that you no receive updates about usertracks. You shouldn't see itemsid belong to usertracks field.  Now, assign the teacher to the group g1. Do a CURL REST call simulating a WS client with the user. You need to replace the WSTOKENTEACHER (with the token for Student 1), COURSEID with the id of the course, the TIMESTAMP parameter (with the timestamp you calculated in setup area), the CMID with the h5pactivity cmid and the YOURMOODLESITE of your moodle instance curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=COURSEID&tocheck [0] [contextlevel] =module&tocheck [0] [id] =CMID&tocheck [0] [since] =TIMESTAMP&wsfunction=core_course_check_updates&wstoken=WSTOKENTEACHER' | python -m "json.tool" Expected result: Check that you receive updates about usertracks. You should see two itemsid belong to usertracks field. This items belong to the user s1.

      The check_updates_since callback checks if the module has any update that affects the current user for a given time.

      This function is used by the Moodle app to update the "downloaded" status of offline activities so we can let our users know that there are updates in the Moodle site that need to be synchronised in the app.

      The callback is missing updates information related to attempts (h5pactivity_attempts table) because they may affect the user or the information displayed in the app.

      A reference implementation can be found in mod/scorm/lib.php

        1. question-set-616.h5p
          2.92 MB
        2. Screenshot_1.png
          Screenshot_1.png
          276 kB
        3. Screenshot_2.png
          Screenshot_2.png
          59 kB
        4. Screenshot_3.png
          Screenshot_3.png
          84 kB

            cescobedo Carlos Escobedo
            jleyva Juan Leyva
            Juan Leyva Juan Leyva
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Janelle Barcega Janelle Barcega
            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 - 1 day, 1 hour
                1d 1h

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