diff --git a/question/type/ddimageortext/edit_ddimageortext_form.php b/question/type/ddimageortext/edit_ddimageortext_form.php index 2a524080d58..01f229a1207 100644 --- a/question/type/ddimageortext/edit_ddimageortext_form.php +++ b/question/type/ddimageortext/edit_ddimageortext_form.php @@ -298,7 +298,8 @@ class qtype_ddimageortext_edit_form extends question_edit_form { $PAGE->requires->yui_module('moodle-qtype_ddimageortext-form', 'M.qtype_ddimageortext.init_form', array($params)); - $PAGE->requires->css('/lib/yui/3.4.0/build/cssfonts/fonts-context-min.css'); + $PAGE->requires->css('/lib/yui/3.4.0/build/cssfonts-context/fonts-context-min.css'); + $PAGE->requires->css('/lib/yui/3.4.0/build/cssreset-context/cssreset-context-min.css'); return $question; } diff --git a/question/type/ddimageortext/renderer.php b/question/type/ddimageortext/renderer.php index ea27e8c1edc..08752a1a5db 100755 --- a/question/type/ddimageortext/renderer.php +++ b/question/type/ddimageortext/renderer.php @@ -38,7 +38,9 @@ require_once($CFG->dirroot . '/question/type/gapselect/rendererbase.php'); class qtype_ddimageortext_renderer extends qtype_with_combined_feedback_renderer { public function head_code(question_attempt $qa) { - $this->page->requires->css('/lib/yui/3.4.0/build/csscssfonts/fonts-context-min.css'); + $this->page->requires->css('/lib/yui/3.4.0/build/cssfonts-context/fonts-context-min.css'); + $this->page->requires->css( + '/lib/yui/3.4.0/build/cssreset-context/cssreset-context-min.css'); return parent::head_code($qa); } public function clear_wrong(question_attempt $qa) { diff --git a/question/type/ddimageortext/yui/dd/dd.js b/question/type/ddimageortext/yui/dd/dd.js index 78bc5969c31..2365e970e28 100644 --- a/question/type/ddimageortext/yui/dd/dd.js +++ b/question/type/ddimageortext/yui/dd/dd.js @@ -92,7 +92,8 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { var oldhome = this.drag_item_home(dragitemno); var classes = 'draghome dragitemhomes'+dragitemno+' group'+group; var imghtml = ''+alt+''; - var divhtml = '
'+alt+'
'; + var divhtml = '
'+alt+'
'; if (oldhome === null) { if (url) { dragitemsarea.append(imghtml); @@ -211,8 +212,8 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { } }, convert_to_window_xy : function (bgimgxy) { - return [+bgimgxy[0] + this.doc.bg_img().getX(), - +bgimgxy[1] + this.doc.bg_img().getY()]; + return [+bgimgxy[0] + this.doc.bg_img().getX() + 1, + +bgimgxy[1] + this.doc.bg_img().getY() + 1]; } }, { NAME : DDIMAGEORTEXTDDNAME, diff --git a/question/type/ddimageortext/yui/form/form.js b/question/type/ddimageortext/yui/form/form.js index 5983b45018e..e49ebeaac25 100644 --- a/question/type/ddimageortext/yui/form/form.js +++ b/question/type/ddimageortext/yui/form/form.js @@ -151,6 +151,11 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { Y.all('fieldset#dropzoneheader input').on('blur', function (e){ var name = e.target.getAttribute('name'); var draginstanceno = this.form.from_name_with_index(name).indexes[0]; + var fromform = [this.form.get_form_value('drops', [draginstanceno, 'xleft']), + this.form.get_form_value('drops', [draginstanceno, 'ytop'])]; + var constrainedxy = this.constrain_xy(draginstanceno, fromform); + this.form.set_form_value('drops', [draginstanceno, 'xleft'], constrainedxy[0]); + this.form.set_form_value('drops', [draginstanceno, 'ytop'], constrainedxy[1]); }, this); //change in selected item @@ -177,10 +182,10 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { this.draw_dd_area(); }, this); Y.all('fieldset#draggableitemheader_'+i+' input[type="text"]') - .on('blur', function (e){ - this.doc.drag_items().remove(true); + .on('blur', function (e, draginstanceno){ + this.doc.drag_item(draginstanceno).remove(true); this.draw_dd_area(); - }, this); + }, this, i); //change to infinite checkbox Y.all('fieldset#draggableitemheader_'+i+' input[type="checkbox"]') .on('change', this.set_options_for_drag_item_selectors, this); @@ -223,8 +228,7 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { var dragitemno = drag.getData('dragitemno'); drag.setXY(this.doc.drag_item_home(dragitemno).getXY()); } else { - var constrainedxy = this.constrain_xy(draginstanceno, fromform); - drag.setXY(this.convert_to_window_xy(constrainedxy)); + drag.setXY(this.convert_to_window_xy(fromform)); } } },