Reputation: 1792
I want to get a list of all assignments along with their completion status under all courses. Basically what is shown under the timeline in the dashboard.
The WS function core_course_get_enrolled_courses_by_timeline_classification
, gives me all the current courses the student is enrolled in when I use the parameter ?classification=inprogress
.
Using the course ids from the above function, I pass them as parameters to the function mod_assign_get_assignments
, but there's just one tiny problem, it doesn't give any information on whether that assignment has been marked as complete by the student (completion status).
The function core_course_get_contents
is a lot more than what I need since it provides every single module in that course and all activities under each module, moreover it gives all this only for one course at a time, however it does give the completion status for each activity.
Also, it would help me out a lot if you provide the required and optional query parameters since the API docs are quite terrible and doesn't provide any of that, I had to google each function which was very time consuming.
Upvotes: 1
Views: 1007
Reputation: 10241
The closest function I can see is core_completion_get_activities_completion_status
You can pass the course id and the user id
Which returns with a list of activities including
'cmid' => new external_value(PARAM_INT, 'course module ID'),
'modname' => new external_value(PARAM_PLUGIN, 'activity module name'),
'instance' => new external_value(PARAM_INT, 'instance ID'),
'state' => new external_value(PARAM_INT,
"Completion state value:
0 means incomplete,
1 complete,
2 complete pass,
3 complete fail"
),
'timecompleted' => new external_value(PARAM_INT,
'timestamp for completed activity'),
So in your code, filter the result for modname = 'assign'
The id in the mdl_assign
table is the instance
id
Upvotes: 0