From 81c87fa76dcfc7fbde0db1773f2d43d4d10b9b5f Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Thu, 14 Mar 2013 14:22:59 +0000 Subject: [PATCH] MDL-47494 ddimageortext: Fix codechecker and jshint issues. --- ...ackup_qtype_ddimageortext_plugin.class.php | 15 +++--- ...store_qtype_ddimageortext_plugin.class.php | 49 +++++++++--------- .../ddimageortext/edit_ddimageortext_form.php | 30 +++++------ .../edit_ddtoimage_form_base.php | 2 +- question/type/ddimageortext/questiontype.php | 4 +- question/type/ddimageortext/yui/dd/dd.js | 51 +++++++++---------- question/type/ddimageortext/yui/form/form.js | 46 ++++++++--------- 7 files changed, 95 insertions(+), 102 deletions(-) diff --git a/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimageortext_plugin.class.php b/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimageortext_plugin.class.php index 929a2269aa9..e328408352a 100644 --- a/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimageortext_plugin.class.php +++ b/question/type/ddimageortext/backup/moodle2/backup_qtype_ddimageortext_plugin.class.php @@ -15,19 +15,18 @@ // along with Moodle. If not, see . /** - * @package moodlecore - * @subpackage backup-moodle2 - * @copyright 2011 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package qtype_ddimageortext + * @copyright 2011 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** - * Provides the information to backup ddimageortext questions + * Provides the information to backup ddimageortext questions. * - * @copyright 2011 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @copyright 2011 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class backup_qtype_ddimageortext_plugin extends backup_qtype_plugin { @@ -36,7 +35,7 @@ class backup_qtype_ddimageortext_plugin extends backup_qtype_plugin { } /** - * Returns the qtype information to attach to question element + * Returns the qtype information to attach to question element. */ protected function define_question_plugin_structure() { $qtype = self::qtype_name(); diff --git a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimageortext_plugin.class.php b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimageortext_plugin.class.php index f6ea4fdbf7d..b4e8d8943cf 100644 --- a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimageortext_plugin.class.php +++ b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddimageortext_plugin.class.php @@ -15,20 +15,19 @@ // along with Moodle. If not, see . /** - * @package moodlecore - * @subpackage backup-moodle2 - * @copyright 2011 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package qtype_ddimageortext + * @copyright 2011 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * restore plugin class that provides the necessary information - * needed to restore one ddimageortext qtype plugin + * needed to restore one ddimageortext qtype plugin. * - * @copyright 2011 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @copyright 2011 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class restore_qtype_ddimageortext_plugin extends restore_qtype_plugin { @@ -37,13 +36,13 @@ class restore_qtype_ddimageortext_plugin extends restore_qtype_plugin { } /** - * Returns the paths to be handled by the plugin at question level + * Returns the paths to be handled by the plugin at question level. */ protected function define_question_plugin_structure() { $paths = array(); - // Add own qtype stuff + // Add own qtype stuff. $elename = 'dds'; $elepath = $this->get_pathfor('/'.self::qtype_name()); $paths[] = new restore_path_element($elename, $elepath); @@ -56,11 +55,11 @@ class restore_qtype_ddimageortext_plugin extends restore_qtype_plugin { $elepath = $this->get_pathfor('/drops/drop'); $paths[] = new restore_path_element($elename, $elepath); - return $paths; // And we return the interesting paths + return $paths; // And we return the interesting paths. } /** - * Process the qtype/{qtypename} element + * Process the qtype/{qtypename} element. */ public function process_dds($data) { global $DB; @@ -70,25 +69,25 @@ class restore_qtype_ddimageortext_plugin extends restore_qtype_plugin { $data = (object)$data; $oldid = $data->id; - // Detect if the question is created or mapped + // Detect if the question is created or mapped. $oldquestionid = $this->get_old_parentid('question'); $newquestionid = $this->get_new_parentid('question'); $questioncreated = $this->get_mappingid('question_created', $oldquestionid) ? true : false; // If the question has been created by restore, - // we need to create its qtype_ddimageortext too + // we need to create its qtype_ddimageortext too. if ($questioncreated) { - // Adjust some columns + // Adjust some columns. $data->questionid = $newquestionid; - // Insert record + // Insert record. $newitemid = $DB->insert_record($prefix, $data); - // Create mapping (needed for decoding links) + // Create mapping (needed for decoding links). $this->set_mapping($prefix, $oldid, $newitemid); } } /** - * Process the qtype/drags/drag element + * Process the qtype/drags/drag element. */ public function process_drag($data) { global $DB; @@ -98,23 +97,23 @@ class restore_qtype_ddimageortext_plugin extends restore_qtype_plugin { $data = (object)$data; $oldid = $data->id; - // Detect if the question is created or mapped + // Detect if the question is created or mapped. $oldquestionid = $this->get_old_parentid('question'); $newquestionid = $this->get_new_parentid('question'); $questioncreated = $this->get_mappingid('question_created', $oldquestionid) ? true : false; if ($questioncreated) { $data->questionid = $newquestionid; - // Insert record + // Insert record. $newitemid = $DB->insert_record("{$prefix}_drags", $data); - // Create mapping (there are files and states based on this) + // Create mapping (there are files and states based on this). $this->set_mapping("{$prefix}_drags", $oldid, $newitemid); } } /** - * Process the qtype/drags/drag element + * Process the qtype/drags/drag element. */ public function process_drop($data) { global $DB; @@ -124,21 +123,21 @@ class restore_qtype_ddimageortext_plugin extends restore_qtype_plugin { $data = (object)$data; $oldid = $data->id; - // Detect if the question is created or mapped + // Detect if the question is created or mapped. $oldquestionid = $this->get_old_parentid('question'); $newquestionid = $this->get_new_parentid('question'); $questioncreated = $this->get_mappingid('question_created', $oldquestionid) ? true : false; if ($questioncreated) { $data->questionid = $newquestionid; - // Insert record + // Insert record. $newitemid = $DB->insert_record("{$prefix}_drops", $data); - // Create mapping (there are files and states based on this) + // Create mapping (there are files and states based on this). $this->set_mapping("{$prefix}_drops", $oldid, $newitemid); } } /** - * Return the contents of this qtype to be processed by the links decoder + * Return the contents of this qtype to be processed by the links decoder. */ public static function define_decode_contents() { diff --git a/question/type/ddimageortext/edit_ddimageortext_form.php b/question/type/ddimageortext/edit_ddimageortext_form.php index 1e868fee2f0..1f82049ad26 100644 --- a/question/type/ddimageortext/edit_ddimageortext_form.php +++ b/question/type/ddimageortext/edit_ddimageortext_form.php @@ -14,24 +14,25 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -require_once($CFG->dirroot.'/question/type/ddimageortext/edit_ddtoimage_form_base.php'); /** * Defines the editing form for the drag-and-drop images onto images question type. * - * @package qtype - * @subpackage ddimageortext - * @copyright 2009 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package qtype_ddimageortext + * @copyright 2009 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); +require_once($CFG->dirroot . '/question/type/ddimageortext/edit_ddtoimage_form_base.php'); + + /** * Drag-and-drop images onto images editing form definition. * - * @copyright 2009 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @copyright 2009 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qtype_ddimageortext_edit_form extends qtype_ddtoimage_edit_form_base { @@ -44,7 +45,7 @@ class qtype_ddimageortext_edit_form extends qtype_ddtoimage_edit_form_base { $question = $this->data_preprocessing_combined_feedback($question, true); $question = $this->data_preprocessing_hints($question, true, true); - $dragids = array(); // drag no -> dragid + $dragids = array(); // Drag no -> dragid. if (!empty($question->options)) { $question->shuffleanswers = $question->options->shuffleanswers; $question->drags = array(); @@ -65,7 +66,7 @@ class qtype_ddimageortext_edit_form extends qtype_ddtoimage_edit_form_base { $question->drops[$drop->no -1]['ytop'] = $drop->ytop; } } - //initialise file picker for bgimage + // Initialise file picker for bgimage. $draftitemid = file_get_submitted_draft_itemid('bgimage'); file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_ddimageortext', @@ -73,12 +74,12 @@ class qtype_ddimageortext_edit_form extends qtype_ddtoimage_edit_form_base { self::file_picker_options()); $question->bgimage = $draftitemid; - //initialise file picker for dragimages + // Initialise file picker for dragimages. list(, $imagerepeats) = $this->get_drag_item_repeats(); $draftitemids = optional_param_array('dragitem', array(), PARAM_INT); for ($imageindex = 0; $imageindex < $imagerepeats; $imageindex++) { $draftitemid = isset($draftitemids[$imageindex]) ? $draftitemids[$imageindex] :0; - //numbers not allowed in filearea name + // Numbers not allowed in filearea name. $itemid = isset($dragids[$imageindex]) ? $dragids[$imageindex] : null; file_prepare_draft_area($draftitemid, $this->context->id, 'qtype_ddimageortext', 'dragimage', $itemid, self::file_picker_options()); @@ -124,7 +125,7 @@ class qtype_ddimageortext_edit_form extends qtype_ddtoimage_edit_form_base { array($params)); } - //drag items + // Drag items. protected function definition_draggable_items($mform, $itemrepeatsatstart) { @@ -176,7 +177,7 @@ class qtype_ddimageortext_edit_form extends qtype_ddtoimage_edit_form_base { return $repeatedoptions; } - //drop zones + // Drop zones. protected function drop_zone($mform, $imagerepeats) { $dropzoneitem = array(); @@ -223,7 +224,7 @@ class qtype_ddimageortext_edit_form extends qtype_ddtoimage_edit_form_base { return $repeatedoptions; } - public function validation($data, $files) { + public function validation($data, $files) { $errors = parent::validation($data, $files); if (!self::file_uploaded($data['bgimage'])) { $errors["bgimage"] = get_string('formerror_nobgimage', 'qtype_'.$this->qtype()); @@ -289,5 +290,4 @@ class qtype_ddimageortext_edit_form extends qtype_ddtoimage_edit_form_base { } return $errors; } - } diff --git a/question/type/ddimageortext/edit_ddtoimage_form_base.php b/question/type/ddimageortext/edit_ddtoimage_form_base.php index 335840fe5ee..d834aa9ea36 100644 --- a/question/type/ddimageortext/edit_ddtoimage_form_base.php +++ b/question/type/ddimageortext/edit_ddtoimage_form_base.php @@ -71,7 +71,7 @@ abstract class qtype_ddtoimage_edit_form_base extends question_edit_form { get_string('shuffleimages', 'qtype_'.$this->qtype())); $mform->setDefault('shuffleanswers', 0); $mform->closeHeaderBefore('shuffleanswers'); - //add the draggable image fields to the form + // Add the draggable image fields to the form. $this->definition_draggable_items($mform, $itemrepeatsatstart); $this->add_combined_feedback_fields(true); diff --git a/question/type/ddimageortext/questiontype.php b/question/type/ddimageortext/questiontype.php index 787530fa3f0..e848a9547b6 100644 --- a/question/type/ddimageortext/questiontype.php +++ b/question/type/ddimageortext/questiontype.php @@ -89,7 +89,7 @@ class qtype_ddimageortext extends qtype_ddtoimage_base { $DB->insert_record('qtype_ddimageortext_drops', $drop); } - //an array of drag no -> drag id + // An array of drag no -> drag id. $olddragids = $DB->get_records_menu('qtype_ddimageortext_drags', array('questionid' => $formdata->id), '', 'no, id'); @@ -121,7 +121,7 @@ class qtype_ddimageortext extends qtype_ddtoimage_base { 'qtype_ddimageortext', 'dragimage', $drag->id, array('subdirs' => 0, 'maxbytes' => 0, 'maxfiles' => 1)); } else { - //delete any existing files for draggable text item type + // Delete any existing files for draggable text item type. $fs = get_file_storage(); $fs->delete_area_files($formdata->context->id, 'qtype_ddimageortext', 'dragimage', $drag->id); diff --git a/question/type/ddimageortext/yui/dd/dd.js b/question/type/ddimageortext/yui/dd/dd.js index e8fe20c907e..0d5177809b2 100644 --- a/question/type/ddimageortext/yui/dd/dd.js +++ b/question/type/ddimageortext/yui/dd/dd.js @@ -2,7 +2,7 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { var DDIMAGEORTEXTDDNAME = 'ddimageortext_dd'; var DDIMAGEORTEXT_DD = function() { DDIMAGEORTEXT_DD.superclass.constructor.apply(this, arguments); - } + }; /** * This is the base class for the question rendering and question editing form code. */ @@ -120,8 +120,8 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { var classes = node.getAttribute('class'); if (classes !== '') { var classesarr = classes.split(' '); - for (index in classesarr) { - var patt1 = new RegExp('^'+prefix+'([0-9])+$'); + for (var index = 0; index < classesarr.length; index++) { + var patt1 = new RegExp('^' + prefix + '([0-9])+$'); if (patt1.test(classesarr[index])) { var patt2 = new RegExp('([0-9])+$'); var match = patt2.exec(classesarr[index]); @@ -149,7 +149,7 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { return drag; }, draggable_for_question : function (drag, group, choice) { - var dd = new Y.DD.Drag({ + new Y.DD.Drag({ node: drag, dragMode: 'point', groups: [group] @@ -168,7 +168,6 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { var dragnode = e.target.get('node'); var draginstanceno = dragnode.getData('draginstanceno'); var gooddrop = dragnode.getData('gooddrop'); - var endxy; if (!gooddrop) { mainobj.reset_drag_xy(draginstanceno); @@ -183,7 +182,7 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { } - } + }; }, update_padding_sizes_all : function () { @@ -233,7 +232,7 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { * This is the code for question rendering. */ Y.extend(DDIMAGEORTEXT_QUESTION, M.qtype_ddimageortext.dd_base_class, { - initializer : function(params) { + initializer : function() { this.doc = this.doc_structure(this); this.poll_for_image_load(null, false, 0, this.create_all_drag_and_drops); this.doc.bg_img().after('load', this.poll_for_image_load, this, @@ -250,7 +249,7 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { var dragitemno = +this.doc.get_classname_numeric_suffix(dragitemhome, 'dragitemhomes'); var choice = +this.doc.get_classname_numeric_suffix(dragitemhome, 'choice'); - var group = +this.doc.get_classname_numeric_suffix(dragitemhome, 'group') + var group = +this.doc.get_classname_numeric_suffix(dragitemhome, 'group'); var groupsize = this.doc.drop_zone_group(group).size(); var dragnode = this.doc.clone_new_drag_item(i, dragitemno); i++; @@ -275,8 +274,7 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { this.doc.drop_zones().each( function(v){ v.on('dragchange', this.drop_zone_key_press, this); - } - , this); + }, this); } }, drop_zone_key_press : function (e) { @@ -304,7 +302,7 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { var next; var current = this.current_drag_in_drop(drop); if ('' === current) { - if (direction == 1) { + if (direction === 1) { next = 1; } else { next = 1; @@ -381,22 +379,20 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { }, get_choices_for_drop : function(choice, drop) { var group = drop.getData('group'); - var dragitem = null; - var dragitems = this.doc.top_node() - .all('div.dragitemgroup'+group+' .choice'+choice+'.drag'); - return dragitems; + return this.doc.top_node().all( + 'div.dragitemgroup' + group + ' .choice' + choice + '.drag'); }, get_unplaced_choice_for_drop : function(choice, drop) { var dragitems = this.get_choices_for_drop(choice, drop); var dragitem = null; - if (dragitems.some(function (d) { + dragitems.some(function (d) { if (!d.hasClass('placed') && !d.hasClass('yui3-dd-dragging')) { dragitem = d; return true; } else { return false; } - })); + }); return dragitem; }, init_drops : function () { @@ -407,7 +403,14 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { dropareas.append(groupnode); groupnodes[groupno] = groupnode; } - for (var dropno in this.get('drops')){ + var drop_hit_handler = function(e) { + var drag = e.drag.get('node'); + var drop = e.drop.get('node'); + if (+drop.getData('group') === drag.getData('group')){ + this.place_drag_in_drop(drag, drop); + } + }; + for (var dropno in this.get('drops')) { var drop = this.get('drops')[dropno]; var nodeclass = 'dropzone group'+drop.group+' place'+dropno; var title = drop.text.replace('"', '\"'); @@ -421,14 +424,8 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { dropnode.setData('group', drop.group); var dropdd = new Y.DD.Drop({ node: dropnode, groups : [drop.group]}); - dropdd.on('drop:hit', function(e) { - var drag = e.drag.get('node'); - var drop = e.drop.get('node'); - if (+drop.getData('group') === drag.getData('group')){ - this.place_drag_in_drop(drag, drop); - } - }, this); - }; + dropdd.on('drop:hit', drop_hit_handler, this); + } } }, {NAME : DDIMAGEORTEXTQUESTIONNAME, ATTRS : {}}); @@ -462,7 +459,7 @@ YUI.add('moodle-qtype_ddimageortext-dd', function(Y) { }); M.qtype_ddimageortext.init_question = function(config) { return new DDIMAGEORTEXT_QUESTION(config); - } + }; }, '@VERSION@', { requires:['node', 'dd', 'dd-drop', 'dd-constrain'] }); diff --git a/question/type/ddimageortext/yui/form/form.js b/question/type/ddimageortext/yui/form/form.js index 05ba3ef07b3..46808cba954 100644 --- a/question/type/ddimageortext/yui/form/form.js +++ b/question/type/ddimageortext/yui/form/form.js @@ -9,7 +9,7 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { Y.extend(DDIMAGEORTEXT_FORM, M.qtype_ddimageortext.dd_base_class, { fp : null, - initializer : function(params) { + initializer : function() { this.fp = this.file_pickers(); Y.one(this.get('topnode')).append('
'+ '
'+ @@ -76,11 +76,9 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { }, load_drag_home : function (dragitemno) { + var url = null; if ('image' === this.form.get_form_value('dragitemtype', [dragitemno])) { - var url = - this.fp.file(this.form.to_name_with_index('dragitem', [dragitemno])).href; - } else { - var url = null; + url = this.fp.file(this.form.to_name_with_index('dragitem', [dragitemno])).href; } this.doc.add_or_update_drag_item_home(dragitemno, url, this.form.get_form_value('drags', [dragitemno, 'draglabel']), @@ -106,12 +104,12 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { var file = this.fp.file(this.form.to_name_with_index('dragitem', [i])); if ('image' === this.form.get_form_value('dragitemtype', [i]) && file.name !== null) { - dragitemsoptions[i+1] = (i+1)+'. '+label+' ('+file.name+')'; - } else if (label != '') { - dragitemsoptions[i+1] = (i+1)+'. '+label; + dragitemsoptions[i + 1] = (i + 1) + '. ' + label + ' (' + file.name + ')'; + } else if (label !== '') { + dragitemsoptions[i + 1] = (i + 1) + '. ' + label; } } - for (var i=0; i < this.form.get_form_value('nodropzone', []); i++) { + for (i = 0; i < this.form.get_form_value('nodropzone', []); i++) { var selector = Y.one('#id_drops_'+i+'_choice'); var selectedvalue = selector.get('value'); selector.all('option').remove(true); @@ -121,7 +119,7 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { + dragitemsoptions[value] + ''; selector.append(option); - var optionnode = selector.one('option[value="' + value + '"]') + var optionnode = selector.one('option[value="' + value + '"]'); if (value === +selectedvalue) { optionnode.set('selected', true); } else { @@ -132,7 +130,7 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { var infinite = cbel.get('checked'); if (!infinite) { Y.all('fieldset#dropzoneheader select').some(function (selector) { - if (+selector.get('value') == value){ + if (+selector.get('value') === value) { optionnode.set('disabled', true); return true; // stop looping } @@ -153,7 +151,7 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { //events triggered by changes to form data //x and y coordinates - Y.all('fieldset#dropzoneheader input').on('blur', function (e){ + 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']), @@ -164,7 +162,7 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { }, this); //change in selected item - Y.all('fieldset#dropzoneheader select').on('change', function (e){ + Y.all('fieldset#dropzoneheader select').on('change', function (e) { var name = e.target.getAttribute('name'); var draginstanceno = this.form.from_name_with_index(name).indexes[0]; var old = this.doc.drag_item(draginstanceno); @@ -176,13 +174,13 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { for (var i=0; i < this.form.get_form_value('noitems', []); i++) { //change to group selector - Y.all('fieldset#draggableitemheader_'+i+' select.draggroup') - .on('change', function (e){ + Y.all('fieldset#draggableitemheader_'+i+' select.draggroup').on( + 'change', function () { this.doc.drag_items().remove(true); this.draw_dd_area(); }, this); - Y.all('fieldset#draggableitemheader_'+i+' select.dragitemtype') - .on('change', function (e){ + Y.all('fieldset#draggableitemheader_' + i + ' select.dragitemtype').on( + 'change', function () { this.doc.drag_items().remove(true); this.draw_dd_area(); }, this); @@ -193,7 +191,7 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { .on('change', this.set_options_for_drag_item_selectors, this); } //event on file picker new file selection - Y.after(function (e){ + Y.after(function (e) { var name = this.fp.name(e.id); if (name !== 'bgimage') { this.doc.drag_items().remove(true); @@ -226,7 +224,7 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { if (null !== drag && !drag.hasClass('yui3-dd-dragging')) { var fromform = [this.form.get_form_value('drops', [draginstanceno, 'xleft']), this.form.get_form_value('drops', [draginstanceno, 'ytop'])]; - if (fromform[0] == '' && fromform[1] == '') { + if (fromform[0] === '' && fromform[1] === '') { var dragitemno = drag.getData('dragitemno'); drag.setXY(this.doc.drag_item_home(dragitemno).getXY()); } else { @@ -273,7 +271,7 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { }, get_el : function (name, indexes) { var form = document.getElementById('mform1'); - return form.elements[this.to_name_with_index(name, indexes)] + return form.elements[this.to_name_with_index(name, indexes)]; }, get_form_value : function(name, indexes) { var el = this.get_el(name, indexes); @@ -312,7 +310,7 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { draftitemidstoname = {}; nametoparentnode = {}; var filepickers = Y.all('form.mform input.filepickerhidden'); - filepickers.each(function(filepicker, k, items) { + filepickers.each(function(filepicker) { draftitemidstoname[filepicker.get('value')] = filepicker.get('name'); nametoparentnode[filepicker.get('name')] = filepicker.get('parentNode'); }, this); @@ -330,14 +328,14 @@ YUI.add('moodle-qtype_ddimageortext-form', function(Y) { name : function (draftitemid) { return draftitemidstoname[draftitemid]; } - } + }; return toreturn; } }, {NAME : DDIMAGEORTEXTFORMNAME, ATTRS : {maxsizes:{value:null}}}); M.qtype_ddimageortext = M.qtype_ddimageortext || {}; M.qtype_ddimageortext.init_form = function(config) { return new DDIMAGEORTEXT_FORM(config); - } + }; }, '@VERSION@', { requires:['moodle-qtype_ddimageortext-dd', 'form_filepicker'] -}); \ No newline at end of file +});