Skip to content

Commit

Permalink
Fix for #38
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-steele committed Oct 23, 2019
1 parent a3f4756 commit 04d6c1c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url": "git://github.com/cgkineo/adapt-devtools"
},
"framework": ">=2.2.0",
"version": "2.1.24",
"version": "2.1.25",
"homepage": "https://github.com/cgkineo/adapt-devtools",
"issues": "https://github.com/cgkineo/adapt-devtools/issues/",
"displayName": "Developer tools",
Expand Down
22 changes: 19 additions & 3 deletions js/auto-answer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define(function(require) {

var Adapt = require('coreJS/adapt');
var ItemsQuestionModel = require('core/js/models/itemsQuestionModel');
var ItemsQuestionModel = undefined;
var Hinting = require('./hinting');
var isQuestionSupported = require('./is-question-supported');

Expand Down Expand Up @@ -34,6 +34,22 @@ define(function(require) {
}
},

isItemsQuestionModel:function(model) {
if (ItemsQuestionModel) {
return model instanceof ItemsQuestionModel;
} else if (ItemsQuestionModel === null) {
return false;
}

if (require.defined('core/js/models/'+'itemsQuestionModel')) {

This comment has been minimized.

Copy link
@oliverfoster

oliverfoster Oct 23, 2019

Member

nice

This comment has been minimized.

Copy link
@chris-steele

chris-steele Oct 24, 2019

Author Contributor

I chuckled writing this

ItemsQuestionModel = require('core/js/models/'+'itemsQuestionModel');
return model instanceof ItemsQuestionModel;
} else {
ItemsQuestionModel = null;
return false;
}
},

answer:function(view, incorrectly) {
if (view.model.get('_isSubmitted')) return;

Expand Down Expand Up @@ -68,7 +84,7 @@ define(function(require) {
},

answerMultipleChoice:function(view, isGraphical) {
var items = view.model instanceof ItemsQuestionModel ? view.model.getChildren().toJSON() : view.model.get('_items');
var items = this.isItemsQuestionModel(view.model) ? view.model.getChildren().toJSON() : view.model.get('_items');
var noCorrectOptions = _.where(items, {'_shouldBeSelected':true}).length == 0;

if (noCorrectOptions) {
Expand All @@ -86,7 +102,7 @@ define(function(require) {

answerMultipleChoiceIncorrectly:function(view, isGraphical) {
var model = view.model;
var items = model instanceof ItemsQuestionModel ? model.getChildren().toJSON() : model.get('_items');
var items = this.isItemsQuestionModel(model) ? model.getChildren().toJSON() : model.get('_items');
var itemCount = items.length;
var selectionStates = _.times(itemCount, function() {return false;});
// number of items that should be selected
Expand Down

0 comments on commit 04d6c1c

Please sign in to comment.