@coorpacademy/progression-engine
Advanced tools
Comparing version 5.3.3 to 5.3.4-alpha.480555b7
@@ -0,6 +1,33 @@ | ||
import map from 'lodash/fp/map'; | ||
import pipe from 'lodash/fp/pipe'; | ||
import some from 'lodash/fp/some'; | ||
import sortBy from 'lodash/fp/sortBy'; | ||
import isEqual from 'lodash/fp/isEqual'; | ||
import identity from 'lodash/fp/identity'; | ||
import toLower from 'lodash/fp/toLower'; | ||
import './types'; | ||
// eslint-disable-next-line lodash-fp/prefer-constant | ||
export default function checkAnswer() { | ||
return true; | ||
var sort = sortBy(identity); | ||
var normalize = function normalize(orderMatters, answer) { | ||
return pipe(map(toLower), orderMatters ? identity : sort)(answer); | ||
}; | ||
function checkAnswerForQCM(orderMatters, allowedAnswers, givenAnswer) { | ||
var sortedGivenAnswer = normalize(orderMatters, givenAnswer); | ||
return some(function (allowedAnswer) { | ||
return isEqual(normalize(orderMatters, allowedAnswer), sortedGivenAnswer); | ||
}, allowedAnswers); | ||
} | ||
export default function checkAnswer(options, question, givenAnswer) { | ||
var allowedAnswers = question.content.answers; | ||
switch (question.type) { | ||
case 'qcm': | ||
return checkAnswerForQCM(false, allowedAnswers, givenAnswer); | ||
case 'qcmDrag': | ||
return checkAnswerForQCM(true, allowedAnswers, givenAnswer); | ||
default: | ||
return true; | ||
} | ||
} | ||
//# sourceMappingURL=check-answer.js.map |
import computeNextStep from './compute-next-step'; | ||
import checkAnswer from './check-answer'; | ||
import updateProgression from './update-progression'; | ||
import updateState from './update-state'; | ||
export { computeNextStep, checkAnswer, updateProgression }; | ||
export { computeNextStep, checkAnswer, updateState }; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,6 +6,57 @@ exports.__esModule = true; | ||
// eslint-disable-next-line lodash-fp/prefer-constant | ||
function checkAnswer() { | ||
return true; | ||
var _map = require('lodash/fp/map'); | ||
var _map2 = _interopRequireDefault(_map); | ||
var _pipe = require('lodash/fp/pipe'); | ||
var _pipe2 = _interopRequireDefault(_pipe); | ||
var _some = require('lodash/fp/some'); | ||
var _some2 = _interopRequireDefault(_some); | ||
var _sortBy = require('lodash/fp/sortBy'); | ||
var _sortBy2 = _interopRequireDefault(_sortBy); | ||
var _isEqual = require('lodash/fp/isEqual'); | ||
var _isEqual2 = _interopRequireDefault(_isEqual); | ||
var _identity = require('lodash/fp/identity'); | ||
var _identity2 = _interopRequireDefault(_identity); | ||
var _toLower = require('lodash/fp/toLower'); | ||
var _toLower2 = _interopRequireDefault(_toLower); | ||
require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var sort = (0, _sortBy2.default)(_identity2.default); | ||
var normalize = function normalize(orderMatters, answer) { | ||
return (0, _pipe2.default)((0, _map2.default)(_toLower2.default), orderMatters ? _identity2.default : sort)(answer); | ||
}; | ||
function checkAnswerForQCM(orderMatters, allowedAnswers, givenAnswer) { | ||
var sortedGivenAnswer = normalize(orderMatters, givenAnswer); | ||
return (0, _some2.default)(function (allowedAnswer) { | ||
return (0, _isEqual2.default)(normalize(orderMatters, allowedAnswer), sortedGivenAnswer); | ||
}, allowedAnswers); | ||
} | ||
function checkAnswer(options, question, givenAnswer) { | ||
var allowedAnswers = question.content.answers; | ||
switch (question.type) { | ||
case 'qcm': | ||
return checkAnswerForQCM(false, allowedAnswers, givenAnswer); | ||
case 'qcmDrag': | ||
return checkAnswerForQCM(true, allowedAnswers, givenAnswer); | ||
default: | ||
return true; | ||
} | ||
} | ||
//# sourceMappingURL=check-answer.js.map |
'use strict'; | ||
exports.__esModule = true; | ||
exports.updateProgression = exports.checkAnswer = exports.computeNextStep = undefined; | ||
exports.updateState = exports.checkAnswer = exports.computeNextStep = undefined; | ||
@@ -14,5 +14,5 @@ var _computeNextStep = require('./compute-next-step'); | ||
var _updateProgression = require('./update-progression'); | ||
var _updateState = require('./update-state'); | ||
var _updateProgression2 = _interopRequireDefault(_updateProgression); | ||
var _updateState2 = _interopRequireDefault(_updateState); | ||
@@ -23,3 +23,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.checkAnswer = _checkAnswer2.default; | ||
exports.updateProgression = _updateProgression2.default; | ||
exports.updateState = _updateState2.default; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@coorpacademy/progression-engine", | ||
"version": "5.3.3", | ||
"version": "5.3.4-alpha.480555b7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
16201
132
0
2