mwithheld / moodle-block_integrityadvocate

0 stars 0 forks source link

Use new activity status endpoint #4

Closed mwithheld closed 2 days ago

mwithheld commented 3 days ago

For activity status, there's a much simpler endpoint available:https://ca.integrityadvocateserver.com/api/2-0/participantstatusFound in our dev docs:https://www.integrityadvocateserver.com/developers#apiendpointsIt uses the same auth as the old endpoints, so you should be able to easily swap.

mwithheld commented 3 days ago

One use of this starts in the IA availability condition with

\block_integrityadvocate\Api::is_status_valid()
\block_integrityadvocate\Api::is_status_invalid()

These go through an excessive number of functions to get the info

\block_integrityadvocate\Api::is_status_valid($othercm->context, $userid);
// self = \block_integrityadvocate\Api
self::get_module_status($modulecontext, $userid);
self::get_module_session_latest($modulecontext, $userid);
self::get_participantsessions_activity(
            $blockinstance->config->apikey,
            $blockinstance->config->appid,
            $modulecontext->get_course_context()->instanceid,
            $modulecontext->instanceid,
            $userid,
            1
        );
// This next one is recursive.
self::get_participantsessions_activity_data($apikey, $appid, $params);
self::get(self::ENDPOINT_PARTICIPANTSESSIONS_ACTIVITY, $apikey, $appid, $params);
mwithheld commented 3 days ago

Done in this commit https://github.com/mwithheld/moodle-block_integrityadvocate/commit/763c1baa539112a64d153a87f957e9a591a2bc37