Commit cd0e2e89 authored by Dan Poltawski's avatar Dan Poltawski
Browse files

Merge branch 'MDL-57368-master-2' of https://github.com/snake/moodle

parents afcb0800 195f646d
......@@ -120,8 +120,9 @@ class feedback_item_captcha extends feedback_item_base {
$inputname = $item->typ . '_' . $item->id;
if ($form->get_mode() != mod_feedback_complete_form::MODE_COMPLETE) {
// Span to hold the element id. The id is used for drag and drop reordering.
$form->add_form_element($item,
['static', $inputname, $name],
['static', $inputname, $name, html_writer::span('', '', ['id' => 'feedback_item_' . $item->id])],
false,
false);
} else {
......
......@@ -294,7 +294,11 @@ class feedback_item_pagebreak extends feedback_item_base {
*/
public function complete_form_element($item, $form) {
$form->add_form_element($item,
['static', $item->typ.'_'.$item->id, '', '<hr class="feedback_pagebreak">']);
['static',
$item->typ.'_'.$item->id,
'',
html_writer::empty_tag('hr', ['class' => 'feedback_pagebreak', 'id' => 'feedback_item_' . $item->id])
]);
}
/**
......
......@@ -194,6 +194,7 @@ class feedback_item_label extends feedback_item_base {
$context->id, 'mod_feedback', $filearea, $item->id);
$formatoptions = array('overflowdiv' => true, 'noclean' => true);
$output = format_text($output, FORMAT_HTML, $formatoptions);
$output = html_writer::div($output, '', ['id' => 'feedback_item_' . $item->id]);
$inputname = $item->typ . '_' . $item->id;
......
......@@ -342,6 +342,8 @@ class feedback_item_multichoice extends feedback_item_base {
$objs[] = ['advcheckbox', $inputname.'['.$idx.']', '', $label, null, array(0, $idx)];
$form->set_element_type($inputname.'['.$idx.']', PARAM_INT);
}
// Span to hold the element id. The id is used for drag and drop reordering.
$objs[] = ['static', '', '', html_writer::span('', '', ['id' => 'feedback_item_' . $item->id])];
$element = $form->add_form_group_element($item, 'group_'.$inputname, $name, $objs, $separator, $class);
if ($tmpvalue) {
foreach (explode(FEEDBACK_MULTICHOICE_LINE_SEP, $tmpvalue) as $v) {
......@@ -357,6 +359,8 @@ class feedback_item_multichoice extends feedback_item_base {
foreach ($options as $idx => $label) {
$objs[] = ['radio', $inputname.'[0]', '', $label, $idx];
}
// Span to hold the element id. The id is used for drag and drop reordering.
$objs[] = ['static', '', '', html_writer::span('', '', ['id' => 'feedback_item_' . $item->id])];
$element = $form->add_form_group_element($item, 'group_'.$inputname, $name, $objs, $separator, $class);
$form->set_element_default($inputname.'[0]', $tmpvalue);
$form->set_element_type($inputname.'[0]', PARAM_INT);
......
......@@ -312,6 +312,8 @@ class feedback_item_multichoicerated extends feedback_item_base {
foreach ($options as $idx => $label) {
$objs[] = ['radio', $inputname, '', $label, $idx];
}
// Span to hold the element id. The id is used for drag and drop reordering.
$objs[] = ['static', '', '', html_writer::span('', '', ['id' => 'feedback_item_' . $item->id])];
$separator = $info->horizontal ? ' ' : '<br>';
$class .= ' multichoicerated-' . ($info->horizontal ? 'horizontal' : 'vertical');
$el = $form->add_form_group_element($item, 'group_'.$inputname, $name, $objs, $separator, $class);
......
......@@ -167,12 +167,20 @@ YUI.add('moodle-mod_feedback-dragdrop', function(Y) {
if (!drop.contains(drag)) {
drop.appendChild(drag);
}
myElements = '';
var childElement;
var elementId;
var elements = [];
drop.all(CSS.DRAGITEM).each(function(v) {
myElements = myElements + ',' + this.get_node_id(v.get('id'));
childElement = v.one('.felement').one('[id^="feedback_item_"]');
if (childElement) {
elementId = this.get_node_id(childElement.get('id'));
if (elements.indexOf(elementId) == -1) {
elements.push(elementId);
}
}
}, this);
var spinner = M.util.add_spinner(Y, dragnode);
this.save_item_order(this.cmid, myElements, spinner);
this.save_item_order(this.cmid, elements.toString(), spinner);
}
},
......
{{!
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 core_form/element-template
Template for the form element wrapper template.
Context variables required for this template:
* label
* required
* advanced
* helpbutton
* error
* element
* id
* name
Example context (json):
{
"label": "Course full name",
"required": true,
"advanced": false,
"error": null,
"element": {
"id": "id_fullname",
"name": "fullname"
}
}
}}
<div class="form-group row {{#error}}has-danger{{/error}} fitem {{#advanced}}advanced{{/advanced}} {{{element.extraclasses}}}">
<div class="col-md-3">
<span class="pull-xs-right text-nowrap">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment