MDL-47494 ddimageortext: NOBUG fixing code that constrains xy coords to within the background image.
And also fixed links to css to standardize character metrics.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+4
-3
@@ -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 = '<img class="'+classes+'" src="'+url+'" alt="'+alt+'" />';
|
||||
var divhtml = '<div class="yui3-cssfonts '+classes+'">'+alt+'</div>';
|
||||
var divhtml = '<div class="yui3-cssfonts yui3-cssreset '
|
||||
+classes+'">'+alt+'</div>';
|
||||
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,
|
||||
|
||||
+9
-5
@@ -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));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user