Skip to content

Commit

Permalink
#41 Fix hinting for matching component and remove legacy code
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-steele committed Jan 24, 2020
1 parent c0e88d6 commit d7e6909
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 44 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "git",
"url": "git://github.com/cgkineo/adapt-devtools"
},
"version": "3.0.0",
"version": "3.0.1",
"framework": ">=5",
"homepage": "https://github.com/cgkineo/adapt-devtools",
"issues": "https://github.com/cgkineo/adapt-devtools/issues/",
Expand Down
35 changes: 3 additions & 32 deletions js/auto-answer.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,48 +147,19 @@ define(function(require) {
});
},

// --------------------------------------------------
// --------------------------------------------------
// NEEDS UPDATING?
// --------------------------------------------------
// --------------------------------------------------
answerMatching:function(view) {
_.each(view.model.get('_items'), function(item, itemIndex) {
var $select = view.$('select').eq(itemIndex);
var $options = $select.find('option');
var noCorrectOptions = _.where(item._options, {'_isCorrect':true}).length == 0;

if (noCorrectOptions) {
if (view.dropdowns) {
if (!view.dropdowns[itemIndex].getFirstSelectedItem()) {
var i = _.random(item._options.length - 1);
view.selectValue(itemIndex, i);
}
}
else if ($select.prop('selectedIndex') <= 0) {
if (!view.dropdowns[itemIndex].getFirstSelectedItem()) {
var i = _.random(item._options.length - 1);
var option = item._options[i];
if (view.model.setOptionSelected) {
$select.val(option.text);
$select.trigger('change');
view.model.setOptionSelected(itemIndex, i, true);
} else {
$options.eq(i+1).prop('selected', true);
}
view.selectValue(itemIndex, i);
}
} else {
_.each(item._options, function(option, optionIndex) {
if (option._isCorrect) {
if (view.selectValue) {
view.selectValue(itemIndex, option._index);
}
else if (view.model.setOptionSelected) {
$select.val(option.text);
$select.trigger('change');
view.model.setOptionSelected(itemIndex, optionIndex, true);
} else {
$options.eq(optionIndex+1).prop('selected', true);
}
view.selectValue(itemIndex, option._index);
}
});
}
Expand Down
15 changes: 4 additions & 11 deletions js/hinting.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,14 @@ define(function(require) {
}
},

// --------------------------------------------------
// --------------------------------------------------
// NEEDS UPDATING?
// --------------------------------------------------
// --------------------------------------------------
setMatchingHinting:function($el, model, hintingEnabled) {
if (hintingEnabled) {
_.each(model.get('_items'), function(item, itemIndex) {
var $select = $el.find('select').eq(itemIndex);
var $options = $select.find('option');
var $item = $el.find('.item').eq(itemIndex);
var $options = $item.find('.js-dropdown-list-item');
_.each(item._options, function(option, optionIndex) {
/*if (Modernizr.touch) {*/
if (option._isCorrect) $options.eq(optionIndex+1).append('<span class="hint"> (correct)</span>');
if (option._isCorrect) $options.eq(optionIndex+1).find('.js-dropdown-list-item-inner').append('<span class="hint"> (correct)</span>');
/*}
else {
$options.eq(optionIndex+1).addClass(option._isCorrect ? 'hintCorrect' : 'hintIncorrect');
Expand All @@ -83,12 +78,10 @@ define(function(require) {
}
else {
/*if (Modernizr.touch) */
$el.find('option .hint').remove();
$el.find('.js-dropdown-list-item-inner .hint').remove();
/*else $el.find('option').removeClass('hintCorrect hintIncorrect');*/
}
},
// --------------------------------------------------
// --------------------------------------------------

setSliderHinting:function($el, model, hintingEnabled) {
if (hintingEnabled) {
Expand Down

0 comments on commit d7e6909

Please sign in to comment.