Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LabNbook
LabNbook-Moodle
Commits
9e18742b
Verified
Commit
9e18742b
authored
May 07, 2020
by
David Beniamine
Browse files
Retrieve teamconfig and mission id in edit form
parent
660443f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
classes/fetch/user.php
View file @
9e18742b
...
...
@@ -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.
*
...
...
mod_form.php
View file @
9e18742b
...
...
@@ -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.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment