MDL-79863 qtype_ordering: qtype_ordering fix issue in Moodle 3.4 in which sorted order is not returned to server for processing

This commit is contained in:
Gordon Bateson 2017-11-22 08:39:12 +09:00 committed by Mathew May
parent 3256b3acc1
commit 63eb9ac186
2 changed files with 14 additions and 6 deletions

View File

@ -100,15 +100,23 @@ class qtype_ordering_renderer extends qtype_with_combined_feedback_renderer {
$script .= " containment: '#$ablockid',\n";
$script .= " opacity: 0.6,\n";
$script .= " update: function(event, ui) {\n";
$script .= " var ItemsOrder = $(this).sortable('toArray').toString();\n";
$script .= " $('#$responseid').attr('value', ItemsOrder);\n";
$script .= " if (typeof($(this).sortable)=='function') {\n";
$script .= " var ItemsOrder = $(this).sortable('toArray');\n";
$script .= " } else {\n";
$script .= " // fix for Moodle 3.4, in which 'sortable' method disappears !!\n";
$script .= " var ItemsOrder = [];\n";
$script .= " $(this).children('li.sortableitem').each(function(){\n";
$script .= " ItemsOrder.push($(this).prop('id'));\n";
$script .= " });\n";
$script .= " }\n";
$script .= " $('#$responseid').val(ItemsOrder.toString());\n";
$script .= " }\n";
$script .= " });\n";
$script .= " $('#$sortableid').disableSelection();\n";
$script .= " });\n";
$script .= " $(document).ready(function() {\n";
$script .= " var ItemsOrder = $('#$sortableid').sortable('toArray').toString();\n";
$script .= " $('#$responseid').attr('value', ItemsOrder);\n";
$script .= " var ItemsOrder = $('#$sortableid').sortable('toArray');\n";
$script .= " $('#$responseid').val(ItemsOrder).toString();\n";
$script .= " });\n";
$script .= "}\n";
$script .= "//]]>\n";

View File

@ -29,5 +29,5 @@ $plugin->cron = 0;
$plugin->component = 'qtype_ordering';
$plugin->maturity = MATURITY_STABLE;
$plugin->requires = 2010112400; // Moodle 2.0
$plugin->version = 2017080164;
$plugin->release = '2017-08-01 (64)';
$plugin->version = 2017112265;
$plugin->release = '2017-11-22 (65)';