Skip to content

Commit

Permalink
Fixup codechecker and jshint issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Mar 14, 2013
1 parent 9708d9e commit d1722ae
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 48 deletions.
31 changes: 15 additions & 16 deletions backup/moodle2/backup_qtype_ddwtos_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,55 +15,54 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* @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_ddwtos
* @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 ddwtos questions
* Provides the information to backup ddwtos 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_ddwtos_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() {

// Define the virtual plugin element with the condition to fulfill
// Define the virtual plugin element with the condition to fulfill.
$plugin = $this->get_plugin_element(null, '../../qtype', 'ddwtos');

// Create one standard named plugin element (the visible container)
// Create one standard named plugin element (the visible container).
$pluginwrapper = new backup_nested_element($this->get_recommended_name());

// connect the visible container ASAP
// Connect the visible container ASAP.
$plugin->add_child($pluginwrapper);

// This qtype uses standard question_answers, add them here
// to the tree before any other information that will use them
// to the tree before any other information that will use them.
$this->add_question_question_answers($pluginwrapper);

// Now create the qtype own structures
// Now create the qtype own structures.
$ddwtos = new backup_nested_element('ddwtos', array('id'), array(
'shuffleanswers', 'correctfeedback', 'correctfeedbackformat',
'partiallycorrectfeedback', 'partiallycorrectfeedbackformat',
'incorrectfeedback', 'incorrectfeedbackformat', 'shownumcorrect'));

// Now the own qtype tree
// Now the own qtype tree.
$pluginwrapper->add_child($ddwtos);

// set source to populate the data
// Set source to populate the data.
$ddwtos->set_source_table('question_ddwtos', array('questionid' => backup::VAR_PARENTID));

// don't need to annotate ids nor files
// Don't need to annotate ids nor files.

return $plugin;
}
Expand Down
37 changes: 18 additions & 19 deletions backup/moodle2/restore_qtype_ddwtos_plugin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* @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_ddwtos
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/


Expand All @@ -27,58 +26,58 @@

/**
* restore plugin class that provides the necessary information
* needed to restore one ddwtos qtype plugin
* needed to restore one ddwtos 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_ddwtos_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();

// This qtype uses question_answers, add them
// This qtype uses question_answers, add them.
$this->add_question_question_answers($paths);

// Add own qtype stuff
// Add own qtype stuff.
$elename = 'ddwtos';
$elepath = $this->get_pathfor('/ddwtos'); // we used get_recommended_name() so this works
$elepath = $this->get_pathfor('/ddwtos'); // We used get_recommended_name() so this works.
$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/ddwtos element
* Process the qtype/ddwtos element.
*/
public function process_ddwtos($data) {
global $DB;

$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 question_ddwtos too
// If the question has been created by restore, we need to create its question_ddwtos too.
if ($questioncreated) {
// Adjust some columns
// Adjust some columns.
$data->questionid = $newquestionid;
// Insert record
// Insert record.
$newitemid = $DB->insert_record('question_ddwtos', $data);
// Create mapping (needed for decoding links)
// Create mapping (needed for decoding links).
$this->set_mapping('question_ddwtos', $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() {

Expand Down
2 changes: 1 addition & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected function embedded_element(question_attempt $qa, $place,
protected function drag_boxes($qa, $group, $choices, question_display_options $options) {
$boxes = '';
foreach ($choices as $key => $choice) {
//Bug 8632 - long text entry causes bug in drag and drop field in IE
// Bug 8632: long text entry causes bug in drag and drop field in IE.
$content = str_replace('-', '&#x2011;', $choice->text);
$content = str_replace(' ', '&#160;', $content);

Expand Down
22 changes: 10 additions & 12 deletions yui/dd/dd.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
var DDWTOSDDNAME = 'ddwtos_dd';
var DDWTOS_DD = function() {
DDWTOS_DD.superclass.constructor.apply(this, arguments);
}
};
/**
* This is the class for ddwtos question rendering.
* A DDWTOS_DD class is created for each question.
*/
Y.extend(DDWTOS_DD, Y.Base, {
selectors : null,
initializer : function(params) {
initializer : function() {
this.selectors = this.css_selectors(this.get('topnode'));
this.set_padding_sizes_all();
this.clone_drag_items();
Expand All @@ -45,7 +45,7 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
* put all our selectors in the same place so we can quickly find and change them later
* if the structure of the document changes.
*/
css_selectors : function(topnode){
css_selectors : function(topnode) {
return {
top_node : function() {
return topnode;
Expand Down Expand Up @@ -92,7 +92,7 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
drops_group : function(groupno) {
return topnode+' span.drop.group'+groupno;
}
}
};
},
set_padding_sizes_all : function () {
for (var groupno = 1; groupno <= 8; groupno++) {
Expand Down Expand Up @@ -160,12 +160,12 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
var classes = node.getAttribute('class');
if (classes !== '') {
var classesarr = classes.split(' ');
for (index in classesarr) {
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]);
return +match[0];
return + match[0];
}
}
}
Expand Down Expand Up @@ -202,9 +202,7 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
}
},
make_draggable : function (drag) {
var choice = this.get_choice(drag);
var group = this.get_group(drag);
var dd = new Y.DD.Drag({
new Y.DD.Drag({
node: drag,
groups: [this.get_group(drag)],
dragMode: 'point'
Expand Down Expand Up @@ -261,13 +259,13 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
this.place_drag_in_drop(null, drop);
},
position_drag_items : function () {
Y.all(this.selectors.drags()).each(this.position_drag_item, this)
Y.all(this.selectors.drags()).each(this.position_drag_item, this);
},
position_drag_item : function (drag) {
if (!drag.hasClass('yui3-dd-dragging')) {
if (!this.placed[this.get_no(drag)]) {
var groupno = this.get_group(drag);
var choiceno = this.get_choice(drag)
var choiceno = this.get_choice(drag);
var home = Y.one(this.selectors.drag_home(groupno, choiceno));
drag.setXY(home.getXY());
drag.addClass('unplaced');
Expand Down Expand Up @@ -370,7 +368,7 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
M.qtype_ddwtos = M.qtype_ddwtos || {};
M.qtype_ddwtos.init_question = function(config) {
return new DDWTOS_DD(config);
}
};
}, '@VERSION@', {
requires:['node', 'dd', 'dd-drop', 'dd-constrain']
});

0 comments on commit d1722ae

Please sign in to comment.