Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LabNbook
LabNbook-Moodle
Commits
f08494eb
Commit
f08494eb
authored
Feb 22, 2019
by
Francois Gannaz
Browse files
Activity form: mission selector updates name+descr
parent
8a5dd7dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
mod_form.php
View file @
f08494eb
...
...
@@ -46,19 +46,33 @@ class mod_labnbook_mod_form extends moodleform_mod {
$mform
=
$this
->
_form
;
$missions
=
session
::
load
()
->
getMissions
();
$mform
->
addElement
(
'html'
,
'<script>var missions = '
.
json_encode
(
$missions
)
.
';</script>'
);
$missionsList
=
array_map
(
function
(
$x
)
{
return
"[
{
$x
->
code
}
]
{
$x
->
name
}
"
;
},
$missions
);
$mform
->
addElement
(
'header'
,
'general'
,
"LabNbook"
);
$mform
->
addElement
(
'select'
,
'missionid'
,
get_string
(
'mission'
,
'mod_labnbook'
),
array_merge
([
''
=>
"-"
],
$missionsList
));
$mform
->
addElement
(
'header'
,
'external'
,
"LabNbook"
);
$mform
->
addElement
(
'select'
,
'missionid'
,
get_string
(
'mission'
,
'mod_labnbook'
),
array_merge
([
''
=>
"-"
],
$missionsList
),
[
'onchange'
=>
'javascript: '
.
'document.querySelector("#id_name").value = missions[this.value].name;'
// try to update the Atto text, but Atto is undocumented stuff (wiki pages are all dead)
.
'document.querySelector("#id_introeditor").innerHTML = missions[this.value].description;'
.
'document.querySelector("#id_introeditoreditable").innerHTML = missions[this.value].description;'
]
);
$mform
->
addRule
(
'missionid'
,
null
,
'required'
,
null
,
'client'
);
// Adding the "general" fieldset, where all the common settings are showed.
$mform
->
addElement
(
'header'
,
'general'
,
get_string
(
'general'
,
'form'
));
// Adding the standard "name" field.
$mform
->
addElement
(
'text'
,
'name'
,
get_string
(
'instancename'
,
'mod_labnbook'
),
array
(
'size'
=>
'64'
)
);
$mform
->
addElement
(
'text'
,
'name'
,
get_string
(
'instancename'
,
'mod_labnbook'
),
[
'size'
=>
'64'
]
);
if
(
!
empty
(
$CFG
->
formatstringstriptags
))
{
$mform
->
setType
(
'name'
,
PARAM_TEXT
);
...
...
Write
Preview
Supports
Markdown
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