Verified Commit 14852059 authored by David Beniamine's avatar David Beniamine
Browse files

WIP : add new calls

+ Delete teamconfig
+ Get number of started reports
parent 15b43120
......@@ -42,6 +42,23 @@ class user extends moodlefetcher
return $this->fetch('GET', '/v1/teamconfig/'.$teamconfigId);
}
/**
* @return int
*/
public function getNumStartedReports($teamconfigId)
{
return $this->fetch('GET', '/v1/teamconfig/'.$teamconfigId.'/countStartedReports');
}
/**
* deletes a teamconfig
* @return boolean
*/
public function deleteTeamconfig($teamconfigId)
{
return $this->fetch('POST', '/v1/teamconfig/'.$teamconfigId.'/delete');
}
/**
* Give a teacher a tutor access to these LnB missions and classes, if it does not exist yet.
*
......
......@@ -141,13 +141,17 @@ function labnbook_delete_instance($id)
{
global $DB;
$exists = $DB->get_record(LABNBOOK_TABLE, ['id' => $id]);
if (!$exists) {
$record = $DB->get_record(LABNBOOK_TABLE, ['id' => $id]);
if (!$record) {
return false;
}
$fetcher = new fetch\user();
if (!$fetcher->deleteTeamconfig($record->labnbook_teamconfigid)) {
throw new moodle_exception("Cannot delete teamconfig : some students have started to work.");
return false;
}
$DB->delete_records(LABNBOOK_TABLE, ['id' => $id]);
return true;
}
/**
......
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