From 8edf95a2bcbb55c10eb995dcef46f499aabc9d41 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 12 Oct 2011 17:46:18 +0100 Subject: [PATCH] MDL-47494 ddwtos: Some minor coding style clean-up. --- question/type/ddwtos/lang/en/qtype_ddwtos.php | 6 +-- question/type/ddwtos/pix/icon.gif | Bin 13308 -> 0 bytes question/type/ddwtos/pix/icon.png | Bin 0 -> 224 bytes question/type/ddwtos/renderer.php | 27 ++++++++----- question/type/ddwtos/yui/dd/dd.js | 36 +++++++++++++++--- 5 files changed, 51 insertions(+), 18 deletions(-) delete mode 100755 question/type/ddwtos/pix/icon.gif create mode 100644 question/type/ddwtos/pix/icon.png diff --git a/question/type/ddwtos/lang/en/qtype_ddwtos.php b/question/type/ddwtos/lang/en/qtype_ddwtos.php index a4077f9b028..2aa55b2e056 100755 --- a/question/type/ddwtos/lang/en/qtype_ddwtos.php +++ b/question/type/ddwtos/lang/en/qtype_ddwtos.php @@ -22,13 +22,13 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['addingddwtos'] = 'Adding drag and drop into text'; -$string['addmorechoiceblanks'] = 'Blanks for {no} More Choices'; +$string['addingddwtos'] = 'Adding a drag and drop into text'; +$string['addmorechoiceblanks'] = 'Blanks for {no} more choices'; $string['answer'] = 'Answer'; $string['correctansweris'] = 'The correct answer is: {$a}'; $string['ddwtos'] = 'Drag and drop into text'; $string['ddwtos_help'] = 'Type in some question text like "The [[1]] jumped over the [[2]]", then enter the possible words to go in gaps 1 and 2 underneath.'; $string['ddwtossummary'] = 'Missing words in some text are filled in using drag-and-drop.'; -$string['editingddwtos'] = 'Editing drag and drop into text'; +$string['editingddwtos'] = 'Editing a drag and drop into text'; $string['infinite'] = 'Infinite'; $string['pleaseputananswerineachbox'] = 'Please put an answer in each box.'; diff --git a/question/type/ddwtos/pix/icon.gif b/question/type/ddwtos/pix/icon.gif deleted file mode 100755 index 707af1c96548620393c0def73f9b2b3d55d290db..0000000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~k0cU&(m5okR2a4&FqE zG7I}d3y*A_9$hg1d!$EENlBLocPfYL+qWWuI|}9~KfM)D*rR>WC*tYjuj1;4_H2pY TYx+L}tzqzV^>bP0l+XkKfYed% literal 0 HcmV?d00001 diff --git a/question/type/ddwtos/renderer.php b/question/type/ddwtos/renderer.php index 5d0443bce25..e381aa5048c 100755 --- a/question/type/ddwtos/renderer.php +++ b/question/type/ddwtos/renderer.php @@ -44,19 +44,24 @@ class qtype_ddwtos_renderer extends qtype_elements_embedded_in_question_text_ren public function formulation_and_controls(question_attempt $qa, question_display_options $options) { global $PAGE; + $result = parent::formulation_and_controls($qa, $options); - $topnode = 'div.que.ddwtos#q'.$qa->get_slot(); + $inputids = array(); $question = $qa->get_question(); foreach ($question->places as $placeno => $place) { $inputids[$placeno] = $this->box_id($qa, $question->field($placeno)); } - $params = array('inputids' => $inputids, - 'topnode' => $topnode, - 'readonly' => $options->readonly); - $PAGE->requires->yui_module('moodle-qtype_ddwtos-dd', 'M.qtype_ddwtos.init_question', - array($params)); + $params = array( + 'inputids' => $inputids, + 'topnode' => 'div.que.ddwtos#q' . $qa->get_slot(), + 'readonly' => $options->readonly + ); + + $PAGE->requires->yui_module('moodle-qtype_ddwtos-dd', + 'M.qtype_ddwtos.init_question', array($params)); + return $result; } @@ -64,11 +69,13 @@ class qtype_ddwtos_renderer extends qtype_elements_embedded_in_question_text_ren question_display_options $options) { $result = ''; $question = $qa->get_question(); + $dragboxs = ''; foreach ($question->choices as $group => $choices) { $dragboxs .= $this->drag_boxes($qa, $group, $question->get_ordered_choices($group), $options); } + $classes = array('answercontainer'); if (!$options->readonly) { $classes[] = 'notreadonly'; @@ -84,6 +91,7 @@ class qtype_ddwtos_renderer extends qtype_elements_embedded_in_question_text_ren $classes[] = 'readonly'; } $result .= html_writer::tag('div', '', array('class' => implode(' ', $classes))); + // We abuse the clear_wrong method to output the hidden form fields we // want irrespective of whether we are actually clearing the wrong // bits of the response. @@ -102,7 +110,7 @@ class qtype_ddwtos_renderer extends qtype_elements_embedded_in_question_text_ren $value = $qa->get_last_qt_var($question->field($place)); $attributes = array( - 'class' => 'place'.$place.' drop group' . $group + 'class' => 'place' . $place . ' drop group' . $group ); if ($options->readonly) { @@ -138,11 +146,12 @@ class qtype_ddwtos_renderer extends qtype_elements_embedded_in_question_text_ren } $boxes .= html_writer::tag('span', $content, array( - 'class' => 'draghome choice'.$key.' group' . $choice->draggroup . $infinite)) . ' '; + 'class' => 'draghome choice' . $key . ' group' . + $choice->draggroup . $infinite)) . ' '; } return html_writer::nonempty_tag('div', $boxes, - array('class' => 'draggrouphomes'. $choice->draggroup)); + array('class' => 'draggrouphomes' . $choice->draggroup)); } /** diff --git a/question/type/ddwtos/yui/dd/dd.js b/question/type/ddwtos/yui/dd/dd.js index 2b0a0d143d0..aed7326cba5 100644 --- a/question/type/ddwtos/yui/dd/dd.js +++ b/question/type/ddwtos/yui/dd/dd.js @@ -1,3 +1,27 @@ +// 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 . + +/** + * JavaScript code for the ddwtos question type. + * + * @package qtype + * @subpackage ddwtos + * @copyright 2011 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + YUI.add('moodle-qtype_ddwtos-dd', function(Y) { var DDWTOSDDNAME = 'ddwtos_dd'; var DDWTOS_DD = function() { @@ -326,12 +350,12 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) { _event: (Y.UA.webkit || Y.UA.ie) ? 'keydown' : 'keypress', _keys: { - '32': 'next', - '37': 'previous', - '38': 'previous', - '39': 'next', - '40': 'next', - '27': 'remove' + '32': 'next', // Space + '37': 'previous', // Left arrow + '38': 'previous', // Up arrow + '39': 'next', // Right arrow + '40': 'next', // Down arrow + '27': 'remove' // Escape }, _keyHandler: function (e, notifier) {