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 8f657647 authored by Francois Gannaz's avatar Francois Gannaz
Browse files

update API calls to /mission/*

parent 9e288081
......@@ -57,36 +57,49 @@ class user extends moodlefetcher
*
* @param int $missionId
* @param int $courseId
* @param string $coursename
* @param int|null $groupId
* @param array $teamconfig
* @return object teamconfig
*/
public function useMission(int $missionId, int $courseId, int $groupId = null) {
public function useMission(int $missionId, int $courseId, string $coursename, ?int $groupId = null, array $teamconfig) {
return $this
->fetch(
'POST',
"/v1/mission/$missionId/use",
['courseid' => $courseId, 'groupid' => $groupId]
[
'courseid' => $courseId,
'coursename' => $coursename,
'groupid' => $groupId,
'team_config' => $teamconfig,
]
)
->data->team_config;
->team_config;
}
/**
* Update the team config of a Moodle-LnB activity.
*
* @param int $missionId
* @param int $teamconfigId
* @param int $courseId
* @param string $coursename
* @param int|null $groupId
* @param array $teamconfig
* @return object teamconfig
*/
public function updateMissionUse(int $missionId, int $teamconfigId, int $courseId, int $groupId = null) {
public function updateMissionUse(int $missionId, int $courseId, string $coursename, ?int $groupId = null, array $teamconfig) {
return $this
->fetch(
'POST',
"/v1/mission/$missionId/use",
['team_config_id' => $teamconfigId, 'courseid' => $courseId, 'groupid' => $groupId]
"/v1/mission/$missionId/update",
[
'courseid' => $courseId,
'coursename' => $coursename,
'groupid' => $groupId,
'team_config' => $teamconfig,
],
)
->data->team_config;
->team_config;
}
/**
......
......@@ -49,10 +49,24 @@ function labnbook_add_instance($moduleinstance, $mform = null) {
global $DB;
$fetcher = new fetch\user();
$courseid = (int) $moduleinstance->course;
$groupid = (int) $moduleinstance->groupmode === 0 ? null : (int) $moduleinstance->group;
$teamconfig = [
'method' => $moduleinstance->method,
'teams_max' => $moduleinstance->teams_max,
'size_opt' => $moduleinstance->size_opt,
'size_max' => $moduleinstance->size_max,
'size_min' => $moduleinstance->size_min,
'start_datetime' => isset ($moduleinstance->startdate) ? date('Y-m-d H:i:s', $moduleinstance->startdate) : null,
'end_datetime' => isset($moduleinstance->enddate) ? date('Y-m-d H:i:s', $moduleinstance->enddate) : null,
];
try {
$teamConfig = $fetcher->useMission($moduleinstance->labnbook_missionid, $courseid, $groupid);
$teamConfig = $fetcher->useMission(
(int) $moduleinstance->labnbook_missionid,
(int) $moduleinstance->course,
$mform->get_course()->shortname,
$groupid,
$teamconfig
);
} catch (\Exception $e) {
die("fatal error: " . $e->getMessage()); // TODO
}
......@@ -81,14 +95,24 @@ function labnbook_update_instance($moduleinstance, $mform = null) {
$moduleinstance->id = $moduleinstance->instance;
$fetcher = new fetch\user();
$courseid = (int) $moduleinstance->course;
$groupid = (int) $moduleinstance->groupmode === 0 ? null : (int) $moduleinstance->group;
$teamconfig = [
'id_team_config' => $moduleinstance->labnbook_teamconfigid,
'method' => $moduleinstance->method,
'teams_max' => $moduleinstance->teams_max,
'size_opt' => $moduleinstance->size_opt,
'size_max' => $moduleinstance->size_max,
'size_min' => $moduleinstance->size_min,
'start_datetime' => isset ($moduleinstance->startdate) ? date('Y-m-d H:i:s', $moduleinstance->startdate) : null,
'end_datetime' => isset($moduleinstance->enddate) ? date('Y-m-d H:i:s', $moduleinstance->enddate) : null,
];
try {
$fetcher->updateMissionUse(
$moduleinstance->labnbook_missionid,
$moduleinstance->labnbook_teamconfigid,
$courseid,
$groupid
(int) $moduleinstance->labnbook_missionid,
(int) $moduleinstance->course,
$mform->get_course()->shortname,
$groupid,
$teamconfig
);
} catch (\Exception $e) {
die("fatal error: " . $e->getMessage()); // TODO
......
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