Commit a9c32a6f authored by Tim Hunt's avatar Tim Hunt
Browse files

MDL-47494 ddwtos: Fix lots of coding style issues.

parent 8ba17a58
......@@ -35,7 +35,6 @@ require_once($CFG->dirroot . '/question/type/ddwtos/tests/helper.php');
*
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @group qtype_ddwtos
*/
class qtype_ddwtos_question_test extends basic_testcase {
......@@ -213,7 +212,7 @@ class qtype_ddwtos_question_test extends basic_testcase {
$this->assertEquals(array(1, question_state::$gradedright),
$dd->grade_response(array('p1' => '1', 'p2' => '1', 'p3' => '1')));
$this->assertEquals(array(1/3, question_state::$gradedpartial),
$this->assertEquals(array(1 / 3, question_state::$gradedpartial),
$dd->grade_response(array('p1' => '1')));
$this->assertEquals(array(0, question_state::$gradedwrong),
$dd->grade_response(array('p1' => '2', 'p2' => '2', 'p3' => '2')));
......@@ -238,13 +237,13 @@ class qtype_ddwtos_question_test extends basic_testcase {
$dd->start_attempt(new question_attempt_step(), 1);
$this->assertEquals(array(
1 => new question_classified_response(1, 'quick', 1/3),
1 => new question_classified_response(1, 'quick', 1 / 3),
2 => new question_classified_response(2, 'dog', 0),
3 => new question_classified_response(1, 'lazy', 1/3),
3 => new question_classified_response(1, 'lazy', 1 / 3),
), $dd->classify_response(array('p1' => '1', 'p2' => '2', 'p3' => '1')));
$this->assertEquals(array(
1 => question_classified_response::no_response(),
2 => new question_classified_response(1, 'fox', 1/3),
2 => new question_classified_response(1, 'fox', 1 / 3),
3 => new question_classified_response(2, 'assiduous', 0),
), $dd->classify_response(array('p1' => '0', 'p2' => '1', 'p3' => '2')));
}
......
......@@ -35,7 +35,6 @@ require_once($CFG->dirroot . '/question/type/ddwtos/tests/helper.php');
*
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @group qtype_ddwtos
*/
class qtype_ddwtos_test extends question_testcase {
/** @var qtype_ddwtos instance of the question type class to test. */
......@@ -137,15 +136,15 @@ class qtype_ddwtos_test extends question_testcase {
$this->assertEquals(array(
1 => array(
1 => new question_possible_response('quick', 1/3),
1 => new question_possible_response('quick', 1 / 3),
2 => new question_possible_response('slow', 0),
null => question_possible_response::no_response()),
2 => array(
1 => new question_possible_response('fox', 1/3),
1 => new question_possible_response('fox', 1 / 3),
2 => new question_possible_response('dog', 0),
null => question_possible_response::no_response()),
3 => array(
1 => new question_possible_response('lazy', 1/3),
1 => new question_possible_response('lazy', 1 / 3),
2 => new question_possible_response('assiduous', 0),
null => question_possible_response::no_response()),
), $this->qtype->get_possible_responses($q));
......
......@@ -35,7 +35,6 @@ require_once($CFG->dirroot . '/question/type/ddwtos/tests/helper.php');
*
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @group qtype_ddwtos
*/
class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base {
......
......@@ -51,46 +51,46 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
return topnode;
},
drag_container : function() {
return topnode+' div.drags';
return topnode + ' div.drags';
},
drags : function() {
return this.drag_container()+' span.drag';
return this.drag_container() + ' span.drag';
},
drag : function(no) {
return this.drags()+'.no'+no;
return this.drags() + '.no' + no;
},
drags_in_group : function(groupno) {
return this.drags()+'.group'+groupno;
return this.drags() + '.group' + groupno;
},
unplaced_drags_in_group : function(groupno) {
return this.drags_in_group(groupno)+'.unplaced';
return this.drags_in_group(groupno) + '.unplaced';
},
drags_for_choice_in_group : function(choiceno, groupno) {
return this.drags_in_group(groupno)+'.choice'+choiceno;
return this.drags_in_group(groupno) + '.choice' + choiceno;
},
unplaced_drags_for_choice_in_group : function(choiceno, groupno) {
return this.unplaced_drags_in_group(groupno)+'.choice'+choiceno;
return this.unplaced_drags_in_group(groupno) + '.choice' + choiceno;
},
drops : function() {
return topnode+' span.drop';
return topnode + ' span.drop';
},
drop_for_place : function(placeno) {
return this.drops()+'.place'+placeno;
return this.drops() + '.place' + placeno;
},
drops_in_group : function(groupno) {
return this.drops()+'.group'+groupno;
return this.drops() + '.group' + groupno;
},
drag_homes : function() {
return topnode+' span.draghome';
return topnode + ' span.draghome';
},
drag_homes_group : function(groupno) {
return topnode+' .draggrouphomes'+groupno+' span.draghome';
return topnode + ' .draggrouphomes' + groupno + ' span.draghome';
},
drag_home : function(groupno, choiceno) {
return topnode+' .draggrouphomes'+groupno+' span.draghome.choice'+choiceno;
return topnode + ' .draggrouphomes' + groupno + ' span.draghome.choice' + choiceno;
},
drops_group : function(groupno) {
return topnode+' span.drop.group'+groupno;
return topnode + ' span.drop.group' + groupno;
}
};
},
......@@ -120,8 +120,8 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
}
},
pad_to_width_height : function (node, width, height) {
node.setStyle('width', width+'px').setStyle('height', height+'px')
.setStyle('lineHeight', height+'px');
node.setStyle('width', width + 'px').setStyle('height', height + 'px')
.setStyle('lineHeight', height + 'px');
},
/**
......@@ -136,7 +136,7 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
if (draghome.hasClass('infinite')) {
var groupno = this.get_group(draghome);
var noofdrags = Y.all(this.selectors.drops_in_group(groupno)).size();
for (var i=0; i < noofdrags; i++) {
for (var i = 0; i < noofdrags; i++) {
this.clone_drag_item(draghome);
}
} else {
......@@ -148,7 +148,7 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
var drag = draghome.cloneNode(true);
drag.removeClass('draghome');
drag.addClass('drag');
drag.addClass('no'+this.nextdragitemno);
drag.addClass('no' + this.nextdragitemno);
this.nextdragitemno++;
drag.setStyles({'visibility': 'visible', 'position' : 'absolute'});
Y.one(this.selectors.drag_container()).appendChild(drag);
......@@ -161,15 +161,15 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
if (classes !== '') {
var classesarr = classes.split(' ');
for (var index = 0; index < classesarr.length; index++) {
var patt1 = new RegExp('^'+prefix+'([0-9])+$');
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 Number(match[0]);
}
}
}
throw 'Prefix "'+prefix+'" not found in class names.';
throw 'Prefix "' + prefix + '" not found in class names.';
},
get_choice : function(node) {
return this.get_classname_numeric_suffix(node, 'choice');
......@@ -189,8 +189,8 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
this.placed = [];
for (var placeno in this.get('inputids')) {
var inputid = this.get('inputids')[placeno];
var inputnode = Y.one('input#'+inputid);
var choiceno = +inputnode.get('value');
var inputnode = Y.one('input#' + inputid);
var choiceno = Number(inputnode.get('value'));
if (choiceno !== 0) {
var drop = Y.one(this.selectors.drop_for_place(placeno));
var groupno = this.get_group(drop);
......@@ -229,7 +229,7 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
place_drag_in_drop : function (drag, drop) {
var placeno = this.get_place(drop);
var inputid = this.get('inputids')[placeno];
var inputnode = Y.one('input#'+inputid);
var inputnode = Y.one('input#' + inputid);
if (drag !== null) {
inputnode.set('value', this.get_choice(drag));
} else {
......@@ -272,7 +272,7 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
} else {
var placeno = this.placed[this.get_no(drag)];
var drop = Y.one(this.selectors.drop_for_place(placeno));
drag.setXY([drop.getX()+2, drop.getY()+2]);
drag.setXY([drop.getX() + 2, drop.getY() + 2]);
drag.removeClass('unplaced');
}
}
......@@ -326,8 +326,8 @@ YUI.add('moodle-qtype_ddwtos-dd', function(Y) {
},
current_choice_in_drop : function(drop) {
var inputid = this.get('inputids')[this.get_place(drop)];
var inputnode = Y.one('input#'+inputid);
return +inputnode.get('value');
var inputnode = Y.one('input#' + inputid);
return Number(inputnode.get('value'));
}
}, {
NAME : DDWTOSDDNAME,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment