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 9e18742b authored by David Beniamine's avatar David Beniamine
Browse files

Retrieve teamconfig and mission id in edit form

parent 660443f0
......@@ -34,6 +34,14 @@ class user extends moodlefetcher
return $this->fetch('GET', '/v1/mission')->data;
}
/**
* @return object teamconfig
*/
public function getTeamconfig($teamconfigId)
{
return $this->fetch('GET', '/v1/teamconfig/'.$teamconfigId);
}
/**
* Give a teacher a tutor access to these LnB missions and classes, if it does not exist yet.
*
......
......@@ -91,6 +91,9 @@ function refreshMissions() {
e.innerText = '[' + m.code + '] ' + m.name;
container.appendChild(e);
}
if (typeof(window.missionid) != 'undefined') {
document.querySelector('select[name="labnbook_missionid"]').value = window.missionid;
}
}).catch(() => {
refreshLock = 0;
document.querySelector('#labnbook-missions-loading').remove();
......@@ -175,6 +178,28 @@ EOJS
$this->add_action_buttons();
}
/**
* Allows module to modify data returned by get_moduleinfo_data() or prepare_new_moduleinfo_data() before calling set_data()
* This method is also called in the bulk activity completion form.
*
* Only available on moodleform_mod.
*
* @param array $default_values passed by reference
*/
public function data_preprocessing(&$default_values){
parent::data_preprocessing($default_values);
// The labnbook missionid will not be correctly set as option list is retrieved by ajax
// Thus we store the id and let the ajax use it later
echo '<script>window.missionid='.$default_values['labnbook_missionid'].';</script>';
// Retrieve teamconfig data
$fetcher = new fetch\User();
$teamconfig = $fetcher->getTeamconfig($default_values['labnbook_teamconfigid']);
foreach (['method', 'size_min', 'size_max', 'size_opt', 'teams_max'] as $field) {
$default_values[$field]= $teamconfig->$field;
}
}
/**
* Hook called once the form data has been loaded into the elements.
*/
......
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