* @copyright 2017 David Monllao
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-define(['jquery', 'core/str', 'core/log', 'core/notification', 'core/modal_factory', 'core/modal_events'],
- function($, Str, log, Notification, ModalFactory, ModalEvents) {
+define(['jquery', 'core/str', 'core/log', 'core/notification', 'core/modal_factory', 'core/modal_events', 'core/templates'],
+ function($, Str, log, Notification, ModalFactory, ModalEvents, Templates) {
/**
* List of actions that require confirmation and confirmation message.
}
};
- /**
- * Template to display the evaluation mode choices.
- */
- var evaluationRadioHTML = '<div class="box mb-4">{{evaluationmodeinfo}}</div>' +
- '<div class="form-check">' +
- '<input class="form-check-input" type="radio" name="evaluationmode" id="id-mode-trainedmodel" value="trainedmodel" ' +
- 'checked>' +
- '<label class="form-check-label" for="id-mode-trainedmodel">{{trainedmodellabel}}</label>' +
- '</div>' +
- '<div class="form-check">' +
- '<input class="form-check-input" type="radio" name="evaluationmode" id="id-mode-configuration" value="configuration">' +
- '<label class="form-check-label" for="id-mode-configuration">{{configurationlabel}}</label>' +
- '</div>';
-
/**
* Returns the model name.
*
}, {
key: 'evaluationmode',
component: 'tool_analytics'
- }, {
- key: 'evaluationmodeinfo',
- component: 'tool_analytics'
- }, {
- key: 'evaluationmodetrainedmodel',
- component: 'tool_analytics'
- }, {
- key: 'evaluationmodeconfiguration',
- component: 'tool_analytics'
}
]);
var modalPromise = ModalFactory.create({type: ModalFactory.types.SAVE_CANCEL});
+ var bodyPromise = Templates.render('tool_analytics/evaluation_mode_selection', {});
$.when(stringsPromise, modalPromise).then(function(strings, modal) {
modal.setTitle(strings[1]);
modal.setSaveButtonText(strings[0]);
-
- var body = evaluationRadioHTML.replace(/{{evaluationmodeinfo}}/, strings[2])
- .replace(/{{trainedmodellabel}}/, strings[3])
- .replace(/{{configurationlabel}}/, strings[4]);
- modal.setBody(body);
+ modal.setBody(bodyPromise);
modal.getRoot().on(ModalEvents.save, function() {
var evaluationMode = $("input[name='evaluationmode']:checked").val();
--- /dev/null
+{{!
+ 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 tool_analytics/evaluation_mode_selector
+
+ Evaluation mode selector.
+
+ The purpose of this template is to render the evaluation mode radio button.
+
+ Classes required for JS:
+ * none
+
+ Data attributes required for JS:
+ * none
+
+ Example context (json):
+ {
+ }
+}}
+<div class="box mb-4">{{#str}} evaluationmodeinfo, tool_analytics {{/str}}</div>
+<div class="form-check">
+ <input class="form-check-input" type="radio" name="evaluationmode" id="id-mode-trainedmodel" value="trainedmodel" checked>
+ <label class="form-check-label" for="id-mode-trainedmodel">{{#str}} evaluationmodetrainedmodel, tool_analytics {{/str}}</label>
+</div>
+<div class="form-check">
+ <input class="form-check-input" type="radio" name="evaluationmode" id="id-mode-configuration" value="configuration">
+ <label class="form-check-label" for="id-mode-configuration">{{#str}} evaluationmodeconfiguration, tool_analytics {{/str}}</label>
+</div>
\ No newline at end of file