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

Create H5P activity WebService to get the list of students that attempted an activity

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Integration review in progress
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.9.1
    • Fix Version/s: None
    • Component/s: H5P
    • Testing Instructions:
      Hide
      1. Enable webservices in site advanced features
      2. create external webservice and enable it
      3. add mod_h5pactivity_get_user_attempts function to it
      4. create webservice user
      5. create a token
      6. create a course
      7. add h5pactivity to a course
      8. enroll 3 users (with names Jake A, Bake B, Cake C)
      9. Add 2 attempts for user 1, 1 attempt for user 2 for h5pactivity
      10. Call a webservice:

        curl 'http://YOURMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=WSTOKEN&wsfunction=mod_h5pactivity_get_user_attempts&h5pactivityid=H5PACTIVITYID' | python -m "json.tool"
        

      11. Ensure result has following structure

        {
            "activityid": 4,
            "usersattempts": [
                {
                    "userid": 5,
                    "attempts": [
                        {
                            "id": 3,
                            "h5pactivityid": 4,
                            "userid": 5,
                            "timecreated": 1608124755,
                            "timemodified": 1608124755,
                            "attempt": 1,
                            "rawscore": 0,
                            "maxscore": 13,
                            "duration": 4,
                            "completion": 1,
                            "success": 0,
                            "scaled": 0
                        }
                    ],
                    "scored": {
                        "title": "Highest score attempt",
                        "grademethod": "1",
                        "attempts": [
                            {
                                "id": 3,
                                "h5pactivityid": 4,
                                "userid": 5,
                                "timecreated": 1608124755,
                                "timemodified": 1608124755,
                                "attempt": 1,
                                "rawscore": 0,
                                "maxscore": 13,
                                "duration": 4,
                                "completion": 1,
                                "success": 0,
                                "scaled": 0
                            }
                        ]
                    }
                },
                {
                    "userid": 19,
                    "attempts": []
                },
                {
                    "userid": 42,
                    "attempts": [
                        {
                            "id": 1,
                            "h5pactivityid": 4,
                            "userid": 42,
                            "timecreated": 1608124674,
                            "timemodified": 1608124674,
                            "attempt": 1,
                            "rawscore": 0,
                            "maxscore": 13,
                            "duration": 8,
                            "completion": 1,
                            "success": 0,
                            "scaled": 0
                        },
                        {
                            "id": 2,
                            "h5pactivityid": 4,
                            "userid": 42,
                            "timecreated": 1608124724,
                            "timemodified": 1608124725,
                            "attempt": 2,
                            "rawscore": 0,
                            "maxscore": 13,
                            "duration": 4,
                            "completion": 1,
                            "success": 0,
                            "scaled": 0
                        }
                    ],
                    "scored": {
                        "title": "Highest score attempt",
                        "grademethod": "1",
                        "attempts": [
                            {
                                "id": 2,
                                "h5pactivityid": 4,
                                "userid": 42,
                                "timecreated": 1608124724,
                                "timemodified": 1608124725,
                                "attempt": 2,
                                "rawscore": 0,
                                "maxscore": 13,
                                "duration": 4,
                                "completion": 1,
                                "success": 0,
                                "scaled": 0
                            }
                        ]
                    }
                }
            ],
            "warnings": []
        }

      12. Ensure it returns info for 3 users (you can see all userids)
      13. Ensure User 1 has 2 attempts, User 2 has 1 attempt and User 3 has no attempts returned
      14. Call a webservice with firstname filter:

        curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=YOURTOKEN&wsfunction=mod_h5pactivity_get_user_attempts&h5pactivityid=H5PACTIVITYID&firstinitial=L' | python -m "json.tool"
        
        

      15. Ensure only user 1 is returned
      16. Ensure result has following structure

        {
            "activityid": 4,
            "usersattempts": [
                {
                    "userid": 42,
                    "attempts": [
                        {
                            "id": 1,
                            "h5pactivityid": 4,
                            "userid": 42,
                            "timecreated": 1608124674,
                            "timemodified": 1608124674,
                            "attempt": 1,
                            "rawscore": 0,
                            "maxscore": 13,
                            "duration": 8,
                            "completion": 1,
                            "success": 0,
                            "scaled": 0
                        },
                        {
                            "id": 2,
                            "h5pactivityid": 4,
                            "userid": 42,
                            "timecreated": 1608124724,
                            "timemodified": 1608124725,
                            "attempt": 2,
                            "rawscore": 0,
                            "maxscore": 13,
                            "duration": 4,
                            "completion": 1,
                            "success": 0,
                            "scaled": 0
                        }
                    ],
                    "scored": {
                        "title": "Highest score attempt",
                        "grademethod": "1",
                        "attempts": [
                            {
                                "id": 2,
                                "h5pactivityid": 4,
                                "userid": 42,
                                "timecreated": 1608124724,
                                "timemodified": 1608124725,
                                "attempt": 2,
                                "rawscore": 0,
                                "maxscore": 13,
                                "duration": 4,
                                "completion": 1,
                                "success": 0,
                                "scaled": 0
                            }
                        ]
                    }
                }
            ],
            "warnings": []
        }
        

      Show
      Enable webservices in site advanced features create external webservice and enable it add mod_h5pactivity_get_user_attempts function to it create webservice user create a token create a course add h5pactivity to a course enroll 3 users (with names Jake A, Bake B, Cake C) Add 2 attempts for user 1, 1 attempt for user 2 for h5pactivity Call a webservice: curl 'http://YOURMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=WSTOKEN&wsfunction=mod_h5pactivity_get_user_attempts&h5pactivityid=H5PACTIVITYID' | python -m "json.tool" Ensure result has following structure { "activityid" : 4 , "usersattempts" : [ { "userid" : 5 , "attempts" : [ { "id" : 3 , "h5pactivityid" : 4 , "userid" : 5 , "timecreated" : 1608124755 , "timemodified" : 1608124755 , "attempt" : 1 , "rawscore" : 0 , "maxscore" : 13 , "duration" : 4 , "completion" : 1 , "success" : 0 , "scaled" : 0 } ], "scored" : { "title" : "Highest score attempt" , "grademethod" : "1" , "attempts" : [ { "id" : 3 , "h5pactivityid" : 4 , "userid" : 5 , "timecreated" : 1608124755 , "timemodified" : 1608124755 , "attempt" : 1 , "rawscore" : 0 , "maxscore" : 13 , "duration" : 4 , "completion" : 1 , "success" : 0 , "scaled" : 0 } ] } }, { "userid" : 19 , "attempts" : [] }, { "userid" : 42 , "attempts" : [ { "id" : 1 , "h5pactivityid" : 4 , "userid" : 42 , "timecreated" : 1608124674 , "timemodified" : 1608124674 , "attempt" : 1 , "rawscore" : 0 , "maxscore" : 13 , "duration" : 8 , "completion" : 1 , "success" : 0 , "scaled" : 0 }, { "id" : 2 , "h5pactivityid" : 4 , "userid" : 42 , "timecreated" : 1608124724 , "timemodified" : 1608124725 , "attempt" : 2 , "rawscore" : 0 , "maxscore" : 13 , "duration" : 4 , "completion" : 1 , "success" : 0 , "scaled" : 0 } ], "scored" : { "title" : "Highest score attempt" , "grademethod" : "1" , "attempts" : [ { "id" : 2 , "h5pactivityid" : 4 , "userid" : 42 , "timecreated" : 1608124724 , "timemodified" : 1608124725 , "attempt" : 2 , "rawscore" : 0 , "maxscore" : 13 , "duration" : 4 , "completion" : 1 , "success" : 0 , "scaled" : 0 } ] } } ], "warnings" : [] } Ensure it returns info for 3 users (you can see all userids) Ensure User 1 has 2 attempts, User 2 has 1 attempt and User 3 has no attempts returned Call a webservice with firstname filter: curl 'http://YOURMOODLESITE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=YOURTOKEN&wsfunction=mod_h5pactivity_get_user_attempts&h5pactivityid=H5PACTIVITYID&firstinitial=L' | python -m "json.tool" Ensure only user 1 is returned Ensure result has following structure { "activityid" : 4 , "usersattempts" : [ { "userid" : 42 , "attempts" : [ { "id" : 1 , "h5pactivityid" : 4 , "userid" : 42 , "timecreated" : 1608124674 , "timemodified" : 1608124674 , "attempt" : 1 , "rawscore" : 0 , "maxscore" : 13 , "duration" : 8 , "completion" : 1 , "success" : 0 , "scaled" : 0 }, { "id" : 2 , "h5pactivityid" : 4 , "userid" : 42 , "timecreated" : 1608124724 , "timemodified" : 1608124725 , "attempt" : 2 , "rawscore" : 0 , "maxscore" : 13 , "duration" : 4 , "completion" : 1 , "success" : 0 , "scaled" : 0 } ], "scored" : { "title" : "Highest score attempt" , "grademethod" : "1" , "attempts" : [ { "id" : 2 , "h5pactivityid" : 4 , "userid" : 42 , "timecreated" : 1608124724 , "timemodified" : 1608124725 , "attempt" : 2 , "rawscore" : 0 , "maxscore" : 13 , "duration" : 4 , "completion" : 1 , "success" : 0 , "scaled" : 0 } ] } } ], "warnings" : [] }
    • Affected Branches:
      MOODLE_39_STABLE
    • Pull 3.11 Branch:
      MDL-69259-311
    • Pull Master Branch:
      MDL-69259-master
    • Sprint:
      Moppies Kanban

      Description

      We need a WS for the teacher to get the list of students that attempted an H5P activity similar to what they can view in the web interface.

        Attachments

          Activity

            People

            Assignee:
            ilyatregubov Ilya Tregubov
            Reporter:
            dpalou Dani Palou
            Peer reviewer:
            Carlos Escobedo
            Integrator:
            Jake Dallimore
            Participants:
            Component watchers:
            Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 6 hours
                1d 6h