Details
-
New Feature
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.9.1
-
MOODLE_39_STABLE
-
MOODLE_311_STABLE
-
MDL-69259-311 -
MDL-69259-master -
Hide
- Create a new user
- Navigate to site administration -> Users -> Permissions -> Define roles
- Create a new role with:
- No archetyle
- Contexts: System
- Capabilities: mod/h5pactivity:reviewattempts
- Navigate to site administration -> Users -> Permissions -> Assign system roles
- Assign the new user to the role
- Enable webservices in site advanced features
- create a new external webservice
- Edit the web service
- Ensure that the "Enable" checkbox is ticked
- Save changes
- Click on the "Functions" link for the service
- add mod_h5pactivity_get_user_attempts function to it
- Save changes
- Navigate to site administration -> Plugins -> Web services -> External tokens
- Create a new token for the user against the new service
- 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
- Open the database and find the new activityid:
select id from mdl_h5pactivity order by id desc limit 1;
- Call the 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": []
}
ShowCreate a new user Navigate to site administration -> Users -> Permissions -> Define roles Create a new role with: No archetyle Contexts: System Capabilities: mod/h5pactivity:reviewattempts Navigate to site administration -> Users -> Permissions -> Assign system roles Assign the new user to the role Enable webservices in site advanced features create a new external webservice Edit the web service Ensure that the "Enable" checkbox is ticked Save changes Click on the "Functions" link for the service add mod_h5pactivity_get_user_attempts function to it Save changes Navigate to site administration -> Plugins -> Web services -> External tokens Create a new token for the user against the new service 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 Open the database and find the new activityid: select id from mdl_h5pactivity order by id desc limit 1; Call the 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" : [] }
-
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.