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/

Verified Commit 15b43120 authored by David Beniamine's avatar David Beniamine
Browse files

Handle failure on teamconfig creation

parent 9a1ddc90
......@@ -35,6 +35,11 @@ abstract class moodlefetcher
return \rtrim($CFG->labnbook_api_url, '/') . '/v1/redirect';
}
public function getLastError(): ?\Stdclass
{
return $this->fetcher->getLastError();
}
protected function getEnvironment(): environment
{
global $CFG, $USER;
......
......@@ -66,3 +66,4 @@ $string['external_reports_descr'] = "Acccess to the students' reports, with the
// view as student
$string['gotoreport'] = "Access to the report";
$string['error_duplicate_teaming'] = "This mission is already attributed to this class. If you've just removed a similar activity, please wait a few minutes then retry";
......@@ -66,3 +66,4 @@ $string['external_reports_descr'] = "Accéder aux rapports produits par les étu
// view as student
$string['gotoreport'] = "Accéder au rapport";
$string['error_duplicate_teaming'] = "Cette mission est déjà attribuée à cette classe. Si vous venez de supprimer une activité identique, veuillez patienter quelques minutes et recommencer";
......@@ -68,7 +68,12 @@ function labnbook_add_instance($moduleinstance, $mform = null)
$teamconfig
);
} catch (\Exception $e) {
die("fatal error: " . $e->getMessage()); // TODO
$error = $fetcher->getLastError();
if ($error->code == 409) {
print_error(get_string('error_duplicate_teaming', 'labnbook'));
} else {
die("fatal error: " . $error->message);
}
}
if ($teamConfig->id_team_config) {
$moduleinstance->labnbook_teamconfigid = (int) $teamConfig->id_team_config;
......
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