* @return array
*/
public function buttons() {
- $save = html_writer::empty_tag('input', array(
+ global $OUTPUT;
+
+ $save = $OUTPUT->render_from_template('gradereport_singleview/button', [
'type' => 'submit',
'value' => get_string('save', 'gradereport_singleview'),
- ));
+ ]);
return array($save);
}
* @return string HTML
*/
public function html() {
- $insertvalue = get_string('bulkinsertvalue', 'gradereport_singleview');
- $insertappliesto = get_string('bulkappliesto', 'gradereport_singleview');
+ global $OUTPUT;
- $insertoptions = array(
- 'all' => get_string('all_grades', 'gradereport_singleview'),
- 'blanks' => get_string('blanks', 'gradereport_singleview')
- );
-
- $selectlabel = html_writer::label(
- $insertappliesto,
- 'menu' . $this->selectname
- );
- $select = html_writer::select(
- $insertoptions,
- $this->selectname,
- 'blanks',
- false,
- array(
- 'id' => 'menu' . $this->selectname
- )
- );
-
- $textlabel = html_writer::label(
- $insertvalue,
- $this->insertname
- );
$text = new text_attribute($this->insertname, "0", 'bulk');
-
- $inner = implode(' ', array(
- $selectlabel,
- $select,
- $textlabel,
- $text->html()
- ));
-
- $fieldset = html_writer::tag(
- 'fieldset',
- html_writer::tag(
- 'legend',
- get_string('bulklegend', 'gradereport_singleview'),
- array(
- 'class' => 'accesshide'
- )
- ) .
- $inner
- );
-
- $apply = html_writer::checkbox(
- $this->applyname,
- 1,
- false,
- get_string('bulkperform', 'gradereport_singleview')
- );
- $applydiv = html_writer::div($apply, 'enable');
-
- return $applydiv . $fieldset;
+ $context = (object) [
+ 'label' => get_string('bulklegend', 'gradereport_singleview'),
+ 'applylabel' => get_string('bulkperform', 'gradereport_singleview'),
+ 'applyname' => $this->applyname,
+ 'menuname' => $this->selectname,
+ 'menulabel' => get_string('bulkappliesto', 'gradereport_singleview'),
+ 'menuoptions' => [
+ ['value' => 'all', 'name' => get_string('all_grades', 'gradereport_singleview')],
+ ['value' => 'blanks', 'name' => get_string('blanks', 'gradereport_singleview'), 'selected' => true],
+ ],
+ 'valuename' => $this->insertname,
+ 'valuelabel' => get_string('bulkinsertvalue', 'gradereport_singleview'),
+ 'valuefield' => $text->html()
+ ];
+
+ return $OUTPUT->render_from_template('gradereport_singleview/bulk_insert', $context);
}
/**
* @return string
*/
public function html() {
- $old = array(
- 'type' => 'hidden',
- 'name' => 'old' . $this->name,
- 'value' => $this->selected
- );
-
- $attributes = array('tabindex' => '1');
+ global $OUTPUT;
- if (!empty($this->isdisabled)) {
- $attributes['disabled'] = 'DISABLED';
- }
+ $options = $this->options;
+ $selected = $this->selected;
- $select = html_writer::select(
- $this->options, $this->name, $this->selected, false, $attributes
+ $context = array(
+ 'name' => $this->name,
+ 'value' => $this->selected,
+ 'tabindex' => 1,
+ 'disabled' => !empty($this->isdisabled),
+ 'options' => array_map(function($option) use ($options, $selected) {
+ return [
+ 'name' => $options[$option],
+ 'value' => $option,
+ 'selected' => $selected == $option
+ ];
+ }, array_keys($options))
);
- return ($select . html_writer::empty_tag('input', $old));
+ return $OUTPUT->render_from_template('gradereport_singleview/dropdown_attribute', $context);
}
}
* @return string The HTML.
*/
public function html() {
- $attributes = array(
- 'type' => 'text',
+ global $OUTPUT;
+
+ $context = (object) [
+ 'id' => $this->name,
'name' => $this->name,
'value' => $this->value,
- 'id' => $this->name
- );
-
- if ($this->isdisabled) {
- $attributes['disabled'] = 'DISABLED';
- }
-
- $hidden = array(
- 'type' => 'hidden',
- 'name' => 'old' . $this->name,
- 'value' => $this->value
- );
+ 'disabled' => $this->isdisabled,
+ ];
- $label = '';
+ $context->label = '';
if (preg_match("/^feedback/", $this->name)) {
- $labeltitle = get_string('feedbackfor', 'gradereport_singleview', $this->label);
- $attributes['tabindex'] = '2';
- $label = html_writer::tag('label', $labeltitle, array('for' => $this->name, 'class' => 'accesshide'));
+ $context->label = get_string('feedbackfor', 'gradereport_singleview', $this->label);
+ $context->tabindex = '2';
} else if (preg_match("/^finalgrade/", $this->name)) {
- $labeltitle = get_string('gradefor', 'gradereport_singleview', $this->label);
- $attributes['tabindex'] = '1';
- $label = html_writer::tag('label', $labeltitle, array('for' => $this->name, 'class' => 'accesshide'));
+ $context->label = get_string('gradefor', 'gradereport_singleview', $this->label);
+ $context->tabindex = '1';
}
- return (
- $label .
- html_writer::empty_tag('input', $attributes) .
- html_writer::empty_tag('input', $hidden)
- );
+ return $OUTPUT->render_from_template('gradereport_singleview/text_attribute', $context);
}
}
--- /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/>.
+}}
+{{!
+ Bulk insert attribute.
+}}
+<div class="enable">
+ <input type="checkbox" name="{{applyname}}" value="1" id="{{applyname}}">
+ <label for="{{applyname}}">{{applylabel}}</label>
+</div>
+<fieldset>
+ <legend class="accesshide">{{label}}</legend>
+ <label for="{{menuname}}">{{menulabel}}</label>
+ <select name="{{menuname}}" id="{{menuname}}">
+ {{#menuoptions}}
+ <option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
+ {{/menuoptions}}
+ </select>
+ <label for="{{valuename}}">{{valuelabel}}</label>
+ {{{valuefield}}}
+</fieldset>
--- /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/>.
+}}
+{{!
+ Button.
+}}
+<input type="{{type}}" value={{#quote}}{{value}}{{/quote}}>
--- /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/>.
+}}
+{{!
+ Dropdown attribute.
+}}
+<select id="{{name}}" name="{{name}}" tabindex="1" {{#disabled}}disabled{{/disabled}}>
+ {{#options}}
+ <option value="{{value}}" {{#selected}}selected{{/selected}}>{{name}}</option>
+ {{/options}}
+</select>
+<input type="hidden" name="old{{name}}" value="{{value}}">
--- /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/>.
+}}
+{{!
+ Text attribute.
+}}
+<label for="{{name}}" class="accesshide">{{label}}</label>
+<input id="{{name}}" name="{{name}}" type="text" value="{{value}}" {{#tabindex}}tabindex="{{.}}"{{/tabindex}} {{#disabled}}disabled{{/disabled}}>
+<input type="hidden" name="old{{name}}" value="{{value}}">