mirror of
https://github.com/moodle/moodle.git
synced 2025-08-11 03:46:42 +02:00
MDL-70384 mod_data: Format the forms for database activity fields.
This commit is contained in:
parent
c895def59b
commit
38c695cd3a
31 changed files with 1003 additions and 329 deletions
|
@ -1,18 +0,0 @@
|
|||
<table width="100%" cellpadding="5">
|
||||
<tr>
|
||||
<td class="c0"><label for="name"><?php echo get_string('fieldname', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fieldname" type="text" name="name" id="name" value="<?php p($this->field->name); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="required"><?php echo get_string('requiredfield', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="requiredfield" type="checkbox" name="required" id="required" <?php p($this->field->required ? "checked=\"checked\"" : ""); ?>/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0" valign="top"><label for="param1"><?php echo get_string('fieldoptions', 'data'); ?></label></td>
|
||||
<td class="c1"><textarea class="optionstextarea" name="param1" id="param1" cols="80" rows="10"><?php if($this->field->param1) {p($this->field->param1);} ?></textarea></td>
|
||||
</tr>
|
||||
</table>
|
54
mod/data/field/checkbox/templates/checkbox.mustache
Normal file
54
mod/data/field/checkbox/templates/checkbox.mustache
Normal file
|
@ -0,0 +1,54 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template datafield_checkbox/checkbox
|
||||
|
||||
The purpose of this template is to enable the user to define a checkbox field.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* name string The field's name.
|
||||
* description string The field's description.
|
||||
* required bool The field's requiredness.
|
||||
* param1 string The field's options.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "A name",
|
||||
"description": "A description",
|
||||
"required": true,
|
||||
"param1": "One\nTwo\nThree"
|
||||
}
|
||||
}}
|
||||
|
||||
<fieldset>
|
||||
{{> mod_data/fields/basicfields }}
|
||||
{{> mod_data/fields/requiredfield }}
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3 col-form-label d-flex pb-0 pr-md-0">
|
||||
<label for="param1">{{#str}}fieldoptions, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<textarea class="optionstextarea form-control" name="param1" id="param1" cols="80" rows="10">{{param1}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
|
@ -1,10 +0,0 @@
|
|||
<table width="100%" cellpadding="5">
|
||||
<tr>
|
||||
<td class="c0"><label for="name"><?php echo get_string('fieldname', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fieldname" type="text" name="name" id="name" value="<?php p($this->field->name); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description);?>" /></td>
|
||||
</tr>
|
||||
</table>
|
41
mod/data/field/date/templates/date.mustache
Normal file
41
mod/data/field/date/templates/date.mustache
Normal file
|
@ -0,0 +1,41 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template datafield_date/date
|
||||
|
||||
The purpose of this template is to enable the user to define a date field.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* name string The field's name.
|
||||
* description string The field's description.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "A name",
|
||||
"description": "A description"
|
||||
}
|
||||
}}
|
||||
|
||||
<fieldset>
|
||||
{{> mod_data/fields/basicfields }}
|
||||
</fieldset>
|
|
@ -316,4 +316,23 @@ class data_field_file extends data_field_base {
|
|||
}
|
||||
return $configs;
|
||||
}
|
||||
|
||||
public function get_field_params(): array {
|
||||
global $DB, $CFG;
|
||||
|
||||
$data = parent::get_field_params();
|
||||
|
||||
$course = $DB->get_record('course', ['id' => $this->data->course]);
|
||||
$filesizes = get_max_upload_sizes($CFG->maxbytes, $course->maxbytes, 0, $this->field->param3);
|
||||
|
||||
foreach ($filesizes as $value => $name) {
|
||||
if (!((isset($this->field->param3) && $value == $this->field->param3))) {
|
||||
$data['filesizes'][] = ['name' => $name, 'value' => $value, 'selected' => 0];
|
||||
} else {
|
||||
$data['filesizes'][] = ['name' => $name, 'value' => $value, 'selected' => 1];
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
<table width="100%" cellpadding="5">
|
||||
<tr>
|
||||
<td class="c0"><label for="name"><?php echo get_string('fieldname', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fieldname" type="text" name="name" id="name" value="<?php p($this->field->name); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description);?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="required"><?php echo get_string('requiredfield', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="requiredfield" type="checkbox" name="required" id="required" <?php p($this->field->required ? "checked=\"checked\"" : ""); ?>/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="param3">
|
||||
<?php echo get_string('maxsize', 'data'); ?></label></td>
|
||||
<td class="c1">
|
||||
<?php
|
||||
$course = $DB->get_record('course', array('id'=>$this->data->course));
|
||||
$choices = get_max_upload_sizes($CFG->maxbytes, $course->maxbytes, 0, $this->field->param3);
|
||||
echo html_writer::select($choices, 'param3', $this->field->param3, false, array('id' => 'param3'));
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
58
mod/data/field/file/templates/file.mustache
Normal file
58
mod/data/field/file/templates/file.mustache
Normal file
|
@ -0,0 +1,58 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template datafield_file/file
|
||||
|
||||
The purpose of this template is to enable the user to define a file field.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* name string The field's name.
|
||||
* description string The field's description.
|
||||
* required bool The field's requiredness.
|
||||
* filesizes array The field's file sizes.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "A name",
|
||||
"description": "A description",
|
||||
"required": true,
|
||||
"filesizes": [ { "name": "Site upload limit (64MB)", "value": "0", "selected": true },
|
||||
{ "name": "64MB", "value": "67108864", "selected": false } ]
|
||||
}
|
||||
}}
|
||||
|
||||
<fieldset>
|
||||
{{> mod_data/fields/basicfields }}
|
||||
{{> mod_data/fields/requiredfield }}
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3"><label for="param3" class="mb-0">
|
||||
{{#str}}maxsize, data{{/str}}</label></div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<select id="param3" class="select custom-select form-control" name="param3">
|
||||
{{#filesizes}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/filesizes}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
|
@ -339,4 +339,59 @@ class data_field_latlong extends data_field_base {
|
|||
}
|
||||
return $configs;
|
||||
}
|
||||
|
||||
public function get_field_params(): array {
|
||||
global $DB;
|
||||
|
||||
$data = parent::get_field_params();
|
||||
$data['dataid'] = $this->data->id;
|
||||
|
||||
if (isset($this->field->param1)) {
|
||||
$data["param1"] = $this->field->param1;
|
||||
if (isset($this->linkoutservices)) {
|
||||
$serviceschosen = explode(',', htmlspecialchars($this->field->param1));
|
||||
foreach ($this->linkoutservices as $servicename => $serviceurl) {
|
||||
$servicename = htmlspecialchars($servicename);
|
||||
$data['latlonglinkservices'][] = [
|
||||
'name' => $servicename,
|
||||
'selected' => in_array($servicename, $serviceschosen),
|
||||
];
|
||||
unset($serviceschosen[$servicename]);
|
||||
}
|
||||
$data['latlonglinkservicessize'] = count($this->linkoutservices);
|
||||
}
|
||||
}
|
||||
|
||||
$data["otherfields"][] = [
|
||||
'value' => -1,
|
||||
'name' => get_string('entry', 'data') . " #",
|
||||
'selected' => $this->field->param2 == -1,
|
||||
];
|
||||
$data['otherfields'][] = [
|
||||
'value' => -2,
|
||||
'name' => get_string('latitude', 'data') . "/" . get_string('longitude', 'data'),
|
||||
'selected' => $this->field->param2 == -2,
|
||||
];
|
||||
|
||||
// Fetch all "suitable" other fields that exist for this database.
|
||||
$textfields = $DB->get_records('data_fields', ['dataid' => $this->data->id, 'type' => 'text']);
|
||||
if (count($textfields) > 0) {
|
||||
$data['otherfieldsoptgroups']['label'] = get_string('latlongotherfields', 'data') . ":";
|
||||
foreach ($textfields as $textfield) {
|
||||
$data['otherfieldsoptgroups']['options'][] = [
|
||||
'value' => $textfield->id,
|
||||
'name' => $textfield->name,
|
||||
'selected' => $this->field->param2 == $textfield->id,
|
||||
];
|
||||
}
|
||||
}
|
||||
if (isset($data['otherfieldsoptgroups'])) {
|
||||
$data['otherfields'][] = $data['otherfieldsoptgroups'];
|
||||
}
|
||||
if (isset($this->field->id)) {
|
||||
$data['fieldid'] = $this->field->id;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
<table width="100%" cellpadding="5">
|
||||
<tr>
|
||||
<td class="c0"><label for="name"><?php echo get_string('fieldname', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fieldname" type="text" name="name" id="name" value="<?php p($this->field->name); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p ($this->field->description);?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="required"><?php echo get_string('requiredfield', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="requiredfield" type="checkbox" name="required" id="required" <?php p($this->field->required?"checked=\"checked\"":""); ?>/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="param1"><?php echo get_string('latlonglinkservicesdisplayed', 'data'); ?></label></td>
|
||||
<td class="c1">
|
||||
<select class="linkservicesdisplayed" name="param1[]" id="param1" multiple="multiple" size="<?php p(sizeof($this->linkoutservices)); ?>">
|
||||
<?php
|
||||
$serviceschosen = explode(',', htmlspecialchars($this->field->param1));
|
||||
foreach($this->linkoutservices as $servicename=>$serviceurl) {
|
||||
$servicename = htmlspecialchars($servicename);
|
||||
echo "\n <option" . (array_search($servicename, $serviceschosen)===false ? '' : ' selected="selected"') . ">$servicename</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="param2"><?php echo get_string('latlongkmllabelling', 'data'); ?></label></td>
|
||||
<td class="c1">
|
||||
<select class="kmllabelling" name="param2" id="param2">
|
||||
<option value="-1"<?php if($this->field->param2==-1) echo ' selected="selected"' ?>><?php echo get_string('entry', 'data') ?> #</option>
|
||||
<option value="-2"<?php if($this->field->param2==-2) echo ' selected="selected"' ?>><?php echo get_string('latitude', 'data').'/'.get_string('longitude', 'data') ?></option>
|
||||
<?php
|
||||
// Fetch all "suitable" other fields that exist for this database
|
||||
$textfields = $DB->get_records('data_fields', array('dataid'=>$this->data->id, 'type'=>'text'));
|
||||
if(sizeof($textfields)>0) {
|
||||
echo '<optgroup label="'.get_string('latlongotherfields', 'data').':">';
|
||||
foreach($textfields as $textfield) {
|
||||
echo "<option value='$textfield->id'".($this->field->param2==$textfield->id ? ' selected="selected"' : '').">$textfield->name</option>";
|
||||
}
|
||||
echo '</optgroup>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"> </td>
|
||||
<td class="c1"><?php if($this->field->id) {echo "<a href='./field/latlong/kml.php?d=".$this->data->id."&fieldid=".$this->field->id."'>" . get_string('latlongdownloadallhint', 'data') . "</a>"; } ?></td>
|
||||
</tr>
|
||||
</table>
|
105
mod/data/field/latlong/templates/latlong.mustache
Normal file
105
mod/data/field/latlong/templates/latlong.mustache
Normal file
|
@ -0,0 +1,105 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template datafield_latlong/latlong
|
||||
|
||||
The purpose of this template is to enable the user to define a latlong field.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* name string The field's name.
|
||||
* description string The field's description.
|
||||
* required bool The field's requiredness.
|
||||
* latlonglinkservices array The field's Link out services.
|
||||
* otherfields array The field's Other fields.
|
||||
* otherfieldsoptgroups array The field's Other fields optgroups.
|
||||
* dataid int The field's dataid.
|
||||
* fieldid int The field's fieldid.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "A name",
|
||||
"description": "A description",
|
||||
"required": true,
|
||||
"latlonglinkservices": [ { "name": "Google Maps", "selected": true },
|
||||
{ "name": "Google Earth", "selected": false } ],
|
||||
"latlonglinkservicessize": 2,
|
||||
"otherfields": [ { "name": "Entry #", "value": "-1", "selected": false },
|
||||
{ "name": "Latitude/Longitude", "value": "-2", "selected": false } ],
|
||||
"otherfieldsoptgroups": [
|
||||
{
|
||||
"label": "Other fields:",
|
||||
"options": [
|
||||
{ "name": "Field A", "value": "6", "selected": false },
|
||||
{ "name": "Field B", "value": "7", "selected": true }
|
||||
]
|
||||
}
|
||||
],
|
||||
"dataid": 6,
|
||||
"fieldid": 0
|
||||
}
|
||||
}}
|
||||
|
||||
<fieldset>
|
||||
{{> mod_data/fields/basicfields }}
|
||||
{{> mod_data/fields/requiredfield }}
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3">
|
||||
<label for="param1">{{#str}}latlonglinkservicesdisplayed, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<select class="linkservicesdisplayed form-control" name="param1[]" id="param1" multiple="multiple" size="{{latlonglinkservicessize}}">
|
||||
{{#latlonglinkservices}}
|
||||
<option {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/latlonglinkservices}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3">
|
||||
<label for="param2" class="mb-0">{{#str}}latlongkmllabelling, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<select class="kmllabelling select custom-select form-control" name="param2" id="param2">
|
||||
{{#otherfields}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/otherfields}}
|
||||
{{#otherfieldsoptgroups}}
|
||||
<optgroup label="{{label}}">
|
||||
{{#otherfieldsoptgroups}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/otherfieldsoptgroups}}
|
||||
</optgroup>
|
||||
{{/otherfieldsoptgroups}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{{#fieldid}}
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3">
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<a href='./field/latlong/kml.php?d={{dataid}}&fieldid={{fieldid}}'>{{#str}}latlongdownloadallhint, data{{/str}}</a>
|
||||
</div>
|
||||
</div>
|
||||
{{/fieldid}}
|
||||
</fieldset>
|
|
@ -1,18 +0,0 @@
|
|||
<table width="100%" cellpadding="5">
|
||||
<tr>
|
||||
<td class="c0"><label for="name"><?php echo get_string('fieldname', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fieldname" type="text" name="name" id="name" value="<?php p($this->field->name); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description);?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="required"><?php echo get_string('requiredfield', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="requiredfield" type="checkbox" name="required" id="required" <?php p($this->field->required?"checked=\"checked\"":""); ?>/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0" valign="top"><label for="param1"><?php echo get_string('fieldoptions', 'data'); ?></label></td>
|
||||
<td class="c1"><textarea class="optionstextarea" name="param1" id="param1" cols="80" rows="10"><?php if($this->field->param1) {p($this->field->param1);} ?></textarea></td>
|
||||
</tr>
|
||||
</table>
|
54
mod/data/field/menu/templates/menu.mustache
Normal file
54
mod/data/field/menu/templates/menu.mustache
Normal file
|
@ -0,0 +1,54 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template datafield_menu/menu
|
||||
|
||||
The purpose of this template is to enable the user to define a menu field.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* name string The field's name.
|
||||
* description string The field's description.
|
||||
* required bool The field's requiredness.
|
||||
* param1 string The field's options.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "A name",
|
||||
"description": "A description",
|
||||
"required": true,
|
||||
"param1": "One\nTwo\nThree"
|
||||
}
|
||||
}}
|
||||
|
||||
<fieldset>
|
||||
{{> mod_data/fields/basicfields }}
|
||||
{{> mod_data/fields/requiredfield }}
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3 col-form-label d-flex pb-0 pr-md-0">
|
||||
<label for="param1">{{#str}}fieldoptions, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<textarea class="optionstextarea form-control" name="param1" id="param1" cols="80" rows="10">{{param1}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
|
@ -1,18 +0,0 @@
|
|||
<table width="100%" cellpadding="5">
|
||||
<tr>
|
||||
<td class="c0"><label for="name"><?php echo get_string('fieldname', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fieldname" type="text" name="name" id="name" value="<?php p($this->field->name); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="required"><?php echo get_string('requiredfield', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="requiredfield" type="checkbox" name="required" id="required" <?php p($this->field->required?"checked=\"checked\"":""); ?>/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0" valign="top"><label for="param1"><?php echo get_string('fieldoptions', 'data'); ?></label></td>
|
||||
<td class="c1"><textarea class="optionstextarea" name="param1" id="param1" cols="80" rows="10"><?php if($this->field->param1) {p($this->field->param1);} ?></textarea></td>
|
||||
</tr>
|
||||
</table>
|
54
mod/data/field/multimenu/templates/multimenu.mustache
Normal file
54
mod/data/field/multimenu/templates/multimenu.mustache
Normal file
|
@ -0,0 +1,54 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template datafield_multimenu/multimenu
|
||||
|
||||
The purpose of this template is to enable the user to define a multimenu field.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* name string The field's name.
|
||||
* description string The field's description.
|
||||
* required bool The field's requiredness.
|
||||
* param1 string The field's options.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "A name",
|
||||
"description": "A description",
|
||||
"required": true,
|
||||
"param1": "One\nTwo\nThree"
|
||||
}
|
||||
}}
|
||||
|
||||
<fieldset>
|
||||
{{> mod_data/fields/basicfields }}
|
||||
{{> mod_data/fields/requiredfield }}
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3 col-form-label d-flex pb-0 pr-md-0">
|
||||
<label for="param1">{{#str}}fieldoptions, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<textarea class="optionstextarea form-control" name="param1" id="param1" cols="80" rows="10">{{param1}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
|
@ -1,14 +0,0 @@
|
|||
<table width="100%" cellpadding="5">
|
||||
<tr>
|
||||
<td class="c0"><label for="name"><?php echo get_string('fieldname', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fieldname" type="text" name="name" id="name" value="<?php p($this->field->name); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description);?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="required"><?php echo get_string('requiredfield', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="requiredfield" type="checkbox" name="required" id="required" <?php p($this->field->required?"checked=\"checked\"":""); ?>/></td>
|
||||
</tr>
|
||||
</table>
|
44
mod/data/field/number/templates/number.mustache
Normal file
44
mod/data/field/number/templates/number.mustache
Normal file
|
@ -0,0 +1,44 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template datafield_number/number
|
||||
|
||||
The purpose of this template is to enable the user to define a number field.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* name string The field's name.
|
||||
* description string The field's description.
|
||||
* required bool The field's requiredness.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "A name",
|
||||
"description": "A description",
|
||||
"required": true
|
||||
}
|
||||
}}
|
||||
|
||||
<fieldset>
|
||||
{{> mod_data/fields/basicfields }}
|
||||
{{> mod_data/fields/requiredfield }}
|
||||
</fieldset>
|
|
@ -451,4 +451,23 @@ class data_field_picture extends data_field_base {
|
|||
}
|
||||
return $configs;
|
||||
}
|
||||
|
||||
public function get_field_params(): array {
|
||||
global $DB, $CFG;
|
||||
|
||||
$data = parent::get_field_params();
|
||||
|
||||
$course = $DB->get_record('course', ['id' => $this->data->course]);
|
||||
$filesizes = get_max_upload_sizes($CFG->maxbytes, $course->maxbytes, 0, $this->field->param3);
|
||||
|
||||
foreach ($filesizes as $value => $name) {
|
||||
if (!((isset($this->field->param3) && $value == $this->field->param3))) {
|
||||
$data['options'][] = ['name' => $name, 'value' => $value, 'selected' => 0];
|
||||
} else {
|
||||
$data['options'][] = ['name' => $name, 'value' => $value, 'selected' => 1];
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
<table width="100%" cellpadding="5">
|
||||
<tr>
|
||||
<td class="c0"><label for="name">
|
||||
<?php echo get_string('fieldname', 'data');?></label></td>
|
||||
<td class="c1"><input class="fieldname" type="text" name="name" id="name" value="<?php p($this->field->name); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="description">
|
||||
<?php echo get_string('fielddescription', 'data');?></label></td>
|
||||
<td class="c1">
|
||||
<input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description);?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="required"><?php echo get_string('requiredfield', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="requiredfield" type="checkbox" name="required" id="required" <?php p($this->field->required?"checked=\"checked\"":""); ?>/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="param1">
|
||||
<?php echo get_string('fieldwidthsingleview', 'data');?></label></td>
|
||||
<td class="c1">
|
||||
<input class="picturefieldsize" type="number" name="param1" id="param1" value="<?php if (!empty($this->field->param1)) p($this->field->param1); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="param2">
|
||||
<?php echo get_string('fieldheightsingleview', 'data');?></label></td>
|
||||
<td class="c1">
|
||||
<input class="picturefieldsize" type="number" name="param2" id="param2" value="<?php if (!empty($this->field->param2)) p($this->field->param2); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="param4">
|
||||
<?php echo get_string('fieldwidthlistview', 'data');?></label></td>
|
||||
<td class="c1"><input class="picturefieldsize" type="number" name="param4" id="param4" value="<?php if (!empty($this->field->param4)) p($this->field->param4); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="param5">
|
||||
<?php echo get_string('fieldheightlistview', 'data');?></label></td>
|
||||
<td class="c1">
|
||||
<input class="picturefieldsize" type="number" name="param5" id="param5" value="<?php if (!empty($this->field->param5)) p($this->field->param5); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="param3">
|
||||
<?php echo get_string('maxsize', 'data'); ?></label></td>
|
||||
<td class="c1">
|
||||
<?php
|
||||
$course = $DB->get_record('course', array('id'=>$this->data->course));
|
||||
$choices = get_max_upload_sizes($CFG->maxbytes, $course->maxbytes, 0, $this->field->param3);
|
||||
echo html_writer::select($choices, 'param3', $this->field->param3, false, array('id'=>'param3'));
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
97
mod/data/field/picture/templates/picture.mustache
Normal file
97
mod/data/field/picture/templates/picture.mustache
Normal file
|
@ -0,0 +1,97 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template datafield_picture/picture
|
||||
|
||||
The purpose of this template is to enable the user to define a picture field.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* name string The field's name.
|
||||
* description string The field's description.
|
||||
* required bool The field's requiredness.
|
||||
* param1 int The fields width in single view value.
|
||||
* param2 int The fields height in single view value.
|
||||
* param3 int The file's maximum size.
|
||||
* param4 int The fields width in list view value.
|
||||
* param5 int The fields height in list view value.
|
||||
* filesizes array The field's file sizes.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "A name",
|
||||
"description": "A description",
|
||||
"required": true,
|
||||
"param1": 100,
|
||||
"param2": 200,
|
||||
"param3": 67108864,
|
||||
"param4": 300,
|
||||
"param5": 400,
|
||||
"options": [ { "name": "Site upload limit (64MB)", "value": "0", "selected": true },
|
||||
{ "name": "64MB", "value": "67108864", "selected": false } ]
|
||||
}
|
||||
}}
|
||||
|
||||
<fieldset>
|
||||
{{> mod_data/fields/basicfields }}
|
||||
{{> mod_data/fields/requiredfield }}
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3">
|
||||
<label for="param1">{{#str}}fieldwidthsingleview, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<input class="picturefieldsize form-control" type="text" name="param1" id="param1" value="{{param1}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3"><label for="param2">{{#str}}fieldheightsingleview, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<input class="picturefieldsize form-control" type="text" name="param2" id="param2" value="{{param2}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3"><label for="param4">{{#str}}fieldwidthlistview, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<input class="picturefieldsize form-control" type="text" name="param4" id="param4" value="{{param4}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3"><label for="param5">{{#str}}fieldheightlistview, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<input class="picturefieldsize form-control" type="text" name="param5" id="param5" value="{{param5}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3"><label for="param3" class="mb-0">
|
||||
{{#str}}maxsize, data{{/str}}</label></div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<select id="param3" class="select custom-select form-control" name="param3">
|
||||
{{#options}}
|
||||
<option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
|
||||
{{/options}}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
|
@ -1,18 +0,0 @@
|
|||
<table width="100%" cellpadding="5">
|
||||
<tr>
|
||||
<td class="c0"><label for="name"><?php echo get_string('fieldname', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fieldname" type="text" name="name" id="name" value="<?php p($this->field->name); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="required"><?php echo get_string('requiredfield', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="requiredfield" type="checkbox" name="required" id="required" <?php p($this->field->required?"checked=\"checked\"":""); ?>/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0" valign="top"><label for="param1"><?php echo get_string('fieldoptions', 'data'); ?></label></td>
|
||||
<td class="c1"><textarea class="optionstextarea" name="param1" id="param1" cols="80" rows="10"><?php if($this->field->param1) {p($this->field->param1);} ?></textarea></td>
|
||||
</tr>
|
||||
</table>
|
54
mod/data/field/radiobutton/templates/radiobutton.mustache
Normal file
54
mod/data/field/radiobutton/templates/radiobutton.mustache
Normal file
|
@ -0,0 +1,54 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template datafield_radiobutton/radiobutton
|
||||
|
||||
The purpose of this template is to enable the user to define a radiobutton field.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* name string The field's name.
|
||||
* description string The field's description.
|
||||
* required bool The field's requiredness.
|
||||
* param1 string The field's options.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "A name",
|
||||
"description": "A description",
|
||||
"required": true,
|
||||
"param1": "One\nTwo\nThree"
|
||||
}
|
||||
}}
|
||||
|
||||
<fieldset>
|
||||
{{> mod_data/fields/basicfields }}
|
||||
{{> mod_data/fields/requiredfield }}
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3 col-form-label d-flex pb-0 pr-md-0">
|
||||
<label for="param1">{{#str}}fieldoptions, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<textarea class="optionstextarea form-control" name="param1" id="param1" cols="80" rows="10">{{param1}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
|
@ -1,14 +0,0 @@
|
|||
<table width="100%" cellpadding="5">
|
||||
<tr>
|
||||
<td class="c0"><label for="name"><?php echo get_string('fieldname', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fieldname" type="text" name="name" id="name" value="<?php p($this->field->name); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="required"><?php echo get_string('requiredfield', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="requiredfield" type="checkbox" name="required" id="required" <?php p($this->field->required?"checked=\"checked\"":""); ?>/></td>
|
||||
</tr>
|
||||
</table>
|
46
mod/data/field/text/templates/text.mustache
Normal file
46
mod/data/field/text/templates/text.mustache
Normal file
|
@ -0,0 +1,46 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template datafield_text/text
|
||||
|
||||
The purpose of this template is to enable the user to define a text field.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* name string The field's name.
|
||||
* description string The field's description.
|
||||
* required bool The field's requiredness.
|
||||
* param1 string The field's auto link value.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "A name",
|
||||
"description": "A description",
|
||||
"required": true,
|
||||
"param1": 1
|
||||
}
|
||||
}}
|
||||
|
||||
<fieldset>
|
||||
{{> mod_data/fields/basicfields }}
|
||||
{{> mod_data/fields/requiredfield }}
|
||||
</fieldset>
|
|
@ -1,54 +0,0 @@
|
|||
<table width="100%" cellpadding="5">
|
||||
<tr>
|
||||
<td class="c0"><label for="name"><?php echo get_string('fieldname', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fieldname" type="text" name="name" id="name" value="<?php p($this->field->name); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
|
||||
<td class="c1">
|
||||
<input class="fielddescription" type="text" name="description" id="description"
|
||||
value="<?php p($this->field->description); ?>" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="required"><?php echo get_string('requiredfield', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="requiredfield" type="checkbox" name="required" id="required" <?php p($this->field->required?"checked=\"checked\"":""); ?>/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="param2">
|
||||
<?php echo get_string('fieldwidth', 'data'); ?></label></td>
|
||||
<td class="c1">
|
||||
<input class="textareafieldsize" type="text" name="param2" id="param2" value=
|
||||
<?php
|
||||
if (empty($this->field->param2)) {
|
||||
echo('"60"');
|
||||
} else {
|
||||
echo '"'.s($this->field->param2).'"';
|
||||
}
|
||||
?> /> <?php echo get_string('columns', 'data'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="param3">
|
||||
<?php echo get_string('fieldheight', 'data'); ?></label></td>
|
||||
<td class="c1">
|
||||
<input class="textareafieldsize" type="text" name="param3" id="param3" value=
|
||||
<?php
|
||||
if (empty($this->field->param3)) {
|
||||
echo('"35"');
|
||||
} else {
|
||||
echo '"'.s($this->field->param3).'"';
|
||||
}
|
||||
?> /> <?php echo get_string('rows', 'data'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="param5"><?php echo get_string('maxbytes', 'datafield_textarea'); ?></label></td>
|
||||
<td class="c1">
|
||||
<input class="c1" type="text" name="param5" id="param5"
|
||||
value="<?php if (isset($this->field->param5)) { p($this->field->param5); } else { echo '0'; } ?>" />
|
||||
<?php echo get_string('maxbytes_desc', 'datafield_textarea'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name="param4" id="param4" value="<?php echo FORMAT_HTML; ?>" />
|
75
mod/data/field/textarea/templates/textarea.mustache
Normal file
75
mod/data/field/textarea/templates/textarea.mustache
Normal file
|
@ -0,0 +1,75 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template datafield_textarea/textarea
|
||||
|
||||
The purpose of this template is to enable the user to define a textarea field.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* name string The field's name.
|
||||
* description string The field's description.
|
||||
* required bool The field's requiredness.
|
||||
* param2 int The field's width in columns.
|
||||
* param3 int The field's height in rows.
|
||||
* param5 int The field's attached files maxsize.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "A name",
|
||||
"description": "A description",
|
||||
"required": true,
|
||||
"param2": 60,
|
||||
"param3": 35,
|
||||
"param5": 4096
|
||||
}
|
||||
}}
|
||||
|
||||
<fieldset>
|
||||
{{> mod_data/fields/basicfields }}
|
||||
{{> mod_data/fields/requiredfield }}
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3">
|
||||
<label for="param2">{{#str}}fieldwidth, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<input class="textareafieldsize form-control mr-1" type="text" name="param2" id="param2" value="{{#param2}}{{param2}}{{/param2}}{{^param2}}60{{/param2}}">
|
||||
{{#str}}columns, data{{/str}}</div>
|
||||
</div>
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3">
|
||||
<label for="param3">{{#str}}fieldheight, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<input class="textareafieldsize form-control mr-1" type="text" name="param3" id="param3" value="{{#param3}}{{param3}}{{/param3}}{{^param3}}35{{/param3}}">
|
||||
{{#str}}rows, data{{/str}}</div>
|
||||
</div>
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3">
|
||||
<label for="param5">{{#str}}maxbytes, datafield_textarea{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<input class="c1 form-control mr-1" type="text" name="param5" id="param5" value="{{#param5}}{{param5}}{{/param5}}{{^param5}}0{{/param5}}">
|
||||
{{#str}}maxbytes_desc, datafield_textarea{{/str}}</div>
|
||||
</div>
|
||||
<input type="hidden" name="param4" id="param4" value="1"/>
|
||||
</fieldset>
|
|
@ -1,26 +0,0 @@
|
|||
<table width="100%" cellpadding="5">
|
||||
<tr>
|
||||
<td class="c0"><label for="name"><?php echo get_string('fieldname', 'data'); ?></label></td>
|
||||
<td class="c1"> <input class="fieldname" type="text" name="name" id="name" value="<?php p($this->field->name); ?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description);?>" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="param1"><?php echo get_string('autolinkurl', 'data') ?></label></td>
|
||||
<td class="c1"><input type="checkbox" name="param1" id="param1" <?php if($this->field->param1) {echo 'checked="checked"';} ?> value="1" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="required"><?php echo get_string('requiredfield', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="requiredfield" type="checkbox" name="required" id="required" <?php p($this->field->required?"checked=\"checked\"":""); ?>/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="param3"><?php echo get_string('openlinkinnewwindow', 'datafield_url') ?></label></td>
|
||||
<td class="c1"><input type="checkbox" name="param3" id="param3" <?php if($this->field->param3) {echo 'checked="checked"';} ?> value="1" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c0"><label for="forcelinkname"><?php echo get_string('forcelinkname', 'data'); ?></label></td>
|
||||
<td class="c1"><input class="forcelinkname" type="text" name="param2" id="forcelinkname" value="<?php p($this->field->param2);?>" /></td>
|
||||
</tr>
|
||||
</table>
|
76
mod/data/field/url/templates/url.mustache
Normal file
76
mod/data/field/url/templates/url.mustache
Normal file
|
@ -0,0 +1,76 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template datafield_url/url
|
||||
|
||||
The purpose of this template is to enable the user to define a URL field.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* name string The field's name.
|
||||
* description string The field's description.
|
||||
* required bool The field's requiredness.
|
||||
* param1 string The field's auto link value.
|
||||
* param3 string The field's open link in new window value.
|
||||
* param2 string The field's forced link name.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "A name",
|
||||
"description": "A description",
|
||||
"required": true,
|
||||
"param1": 1,
|
||||
"param3": 1,
|
||||
"param2": "Link"
|
||||
}
|
||||
}}
|
||||
|
||||
<fieldset>
|
||||
{{> mod_data/fields/basicfields }}
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3 d-flex pb-0 pr-md-0">
|
||||
<label for="required" class="mb-0">{{#str}}autolinkurl, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<input class="requiredfield form-check-input" type="checkbox" name="param1" id="param1" {{#param1}}
|
||||
checked="checked" {{/param1}}>
|
||||
</div>
|
||||
</div>
|
||||
{{> mod_data/fields/requiredfield }}
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3 d-flex pb-0 pr-md-0">
|
||||
<label for="param3">{{#str}}openlinkinnewwindow, datafield_url{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<input class="requiredfield form-check-input" type="checkbox" name="param3" id="param3" {{#param3}}
|
||||
checked="checked" {{/param3}}>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3 col-form-label">
|
||||
<label for="forcelinkname">{{#str}}forcelinkname, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<input class="forcelinkname form-control" type="text" name="param2" id="forcelinkname" value="{{param2}}">
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
|
@ -428,11 +428,26 @@ class data_field_base { // Base class for Database Field Types (see field/*/
|
|||
|
||||
echo $OUTPUT->heading($this->name(), 3);
|
||||
|
||||
$filepath = $CFG->dirroot.'/mod/data/field/'.$this->type.'/mod.html';
|
||||
$filepath = $CFG->dirroot . '/mod/data/field/' . $this->type . '/mod.html';
|
||||
$templatename = 'datafield_' . $this->type . '/' . $this->type;
|
||||
|
||||
if (!file_exists($filepath)) {
|
||||
throw new \moodle_exception(get_string('missingfieldtype', 'data', (object)['name' => $this->field->name]));
|
||||
try {
|
||||
$templatefilepath = \core\output\mustache_template_finder::get_template_filepath($templatename);
|
||||
$templatefileexists = true;
|
||||
} catch (moodle_exception $e) {
|
||||
if (!file_exists($filepath)) {
|
||||
// Neither file exists.
|
||||
throw new \moodle_exception(get_string('missingfieldtype', 'data', (object)['name' => $this->field->name]));
|
||||
}
|
||||
$templatefileexists = false;
|
||||
}
|
||||
|
||||
if ($templatefileexists) {
|
||||
// Give out templated Bootstrap formatted form fields.
|
||||
$data = $this->get_field_params();
|
||||
echo $OUTPUT->render_from_template($templatename, $data);
|
||||
} else {
|
||||
// Fall back to display mod.html for backward compatibility.
|
||||
require_once($filepath);
|
||||
}
|
||||
|
||||
|
@ -742,6 +757,37 @@ class data_field_base { // Base class for Database Field Types (see field/*/
|
|||
}
|
||||
return $configs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to let field define their parameters.
|
||||
*
|
||||
* This method that should be overridden by the datafield plugins
|
||||
* when they need to define their data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_field_params(): array {
|
||||
// Name and description of the field.
|
||||
$data = [
|
||||
'name' => $this->field->name,
|
||||
'description' => $this->field->description,
|
||||
];
|
||||
|
||||
// Whether the field is required.
|
||||
if (isset($this->field->required)) {
|
||||
$data['required'] = $this->field->required;
|
||||
}
|
||||
|
||||
// Add all the field parameters.
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
if (isset($this->field->{"param$i"})) {
|
||||
$data["param$i"] = $this->field->{"param$i"};
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
54
mod/data/templates/fields/basicfields.mustache
Normal file
54
mod/data/templates/fields/basicfields.mustache
Normal file
|
@ -0,0 +1,54 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template mod_data/fields/basicfields
|
||||
|
||||
The purpose of this template is to enable the user to define the two values which every field has.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* name string The field's name.
|
||||
* description string The field's description.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"name": "A name",
|
||||
"description": "A description"
|
||||
}
|
||||
}}
|
||||
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3 col-form-label d-flex pb-0 pr-md-0">
|
||||
<label for="name" class="mb-0">{{#str}}fieldname, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<input class="fieldname form-control" type="text" name="name" id="name" value="{{name}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3 col-form-label d-flex pb-0 pr-md-0">
|
||||
<label for="description" class="mb-0">{{#str}}fielddescription, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<input class="fielddescription form-control" type="text" name="description" id="description" value="{{description}}">
|
||||
</div>
|
||||
</div>
|
45
mod/data/templates/fields/requiredfield.mustache
Normal file
45
mod/data/templates/fields/requiredfield.mustache
Normal file
|
@ -0,0 +1,45 @@
|
|||
{{!
|
||||
This file is part of Moodle - http://moodle.org/
|
||||
|
||||
Moodle is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Moodle is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template mod_data/fields/requiredfield
|
||||
|
||||
The purpose of this template is to enable the user to define the 'required' field.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* none
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"required": false
|
||||
}
|
||||
}}
|
||||
|
||||
<div class="form-group row fitem">
|
||||
<div class="col-md-3 d-flex pb-0 pr-md-0">
|
||||
<label for="required" class="mb-0">{{#str}}requiredfield, data{{/str}}</label>
|
||||
</div>
|
||||
<div class="col-md-9 form-inline align-items-start felement">
|
||||
<input class="requiredfield form-check-input" type="checkbox" name="required" id="required" {{#required}}
|
||||
checked="checked" {{/required}}>
|
||||
</div>
|
||||
</div>
|
|
@ -5,8 +5,10 @@ information provided here is intended especially for developers.
|
|||
* The following behat steps are now deprecated. Use data generators instead:
|
||||
- I add a ":fieldtype" field to ":activityname" database and I fill the form with:
|
||||
- I add an entry to ":activityname" database with:
|
||||
* Use of mustache templates for rendering add/modify fields forms. Elimination of all mod/data/field/*/mod.html files.
|
||||
* A function get_field_params() in data_field_base can be extended by datafield plugins to get their parameters.
|
||||
|
||||
== 4.3 ==
|
||||
=== 4.3 ===
|
||||
* Function data_export_xls() has been deprecated and moved to deprecatedlib, because xls support has already been dropped.
|
||||
* Functions data_export_csv(), data_export_ods() and data_get_exportdata() have been deprecated due to a bigger
|
||||
refactoring of the way data is being exported. This is now being done by new exporter classes
|
||||
|
@ -26,7 +28,7 @@ information provided here is intended especially for developers.
|
|||
field type will have to implement the method import_file_value() doing the actual import of the file being passed.
|
||||
* The field types file and picture now are able to import the file/picture.
|
||||
|
||||
== 4.2 ==
|
||||
=== 4.2 ===
|
||||
* The field base class now has a method validate(). Overwrite it in the field type to provide validation of field type's
|
||||
parameters in the field add/modify form.
|
||||
* New tags are added to the current mod_data\templates class: ##otherfields##, [[FIELD#name]],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue