Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 73534e1a authored by Francois Gannaz's avatar Francois Gannaz
Browse files

labnbook_update_instance() calls LnB

parent 507e9990
......@@ -50,6 +50,8 @@ class user extends moodlefetcher
}
/**
* Use a LnB mission in a Moodle activity.
*
* @param int $missionId
* @param int $courseId
* @param int|null $groupId
......@@ -65,6 +67,25 @@ class user extends moodlefetcher
->data->team_config;
}
/**
* Update the team config of a Moodle-LnB activity.
*
* @param int $missionId
* @param int $teamconfigId
* @param int $courseId
* @param int|null $groupId
* @return object teamconfig
*/
public function updateMissionUse(int $missionId, int $teamconfigId, int $courseId, int $groupId = null) {
return $this
->fetch(
'POST',
"/v1/mission/$missionId/use",
['team_config_id' => $teamconfigId, 'courseid' => $courseId, 'groupid' => $groupId]
)
->data->team_config;
}
/**
* Return the JS code that fetches the missions.
*
......
......@@ -80,6 +80,15 @@ function labnbook_update_instance($moduleinstance, $mform = null) {
$moduleinstance->timemodified = time();
$moduleinstance->id = $moduleinstance->instance;
$fetcher = new fetch\user();
$courseid = (int) $moduleinstance->course;
$groupid = (int) $moduleinstance->groupmode === 0 ? null : (int) $moduleinstance->group;
try {
$fetcher->updateMissionUse($moduleinstance->labnbook_missionid, $moduleinstance->labnbook_teamconfigid, $courseid, $groupid);
} catch (\Exception $e) {
die("fatal error: " . $e->getMessage()); // TODO
}
return $DB->update_record(LABNBOOK_TABLE, $moduleinstance);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment