@coorpacademy/progression-engine
Advanced tools
Comparing version 11.5.1 to 11.5.2
@@ -345,5 +345,17 @@ import _getOr from "lodash/fp/getOr"; | ||
const pendingSlides = !_state ? [] : _state.pendingSlides; | ||
const pendingSlide = getNextPendingSlide(state.nextContent.ref, pendingSlides, state.pendingSlides); // all other questions have been already right answered, so we close the progression | ||
const pendingSlide = getNextPendingSlide(state.nextContent.ref, pendingSlides, state.pendingSlides); // all other questions have been already right answered BUT you fail the last question | ||
if (!pendingSlide && !isCorrect) { | ||
return { | ||
nextContent: { | ||
type: 'slide', | ||
ref: state.nextContent.ref | ||
}, | ||
instructions: null, | ||
isCorrect | ||
}; | ||
} | ||
if (!pendingSlide) { | ||
// all other questions have been already right answered, so we close the progression | ||
return null; | ||
@@ -350,0 +362,0 @@ } // or there are wrong question that should be reviewed again |
@@ -329,2 +329,76 @@ import _concat from "lodash/fp/concat"; | ||
}); | ||
test('computeNextStepForReview --> should return the same slide if you fail the last question', t => { | ||
const state = Object.freeze({ | ||
livesDisabled: true, | ||
isCorrect: true, | ||
slides: ['1.A1.1', '1.A1.2', '1.A1.3', '1.A1.4'], | ||
lives: 0, | ||
step: { | ||
current: 5 | ||
}, | ||
stars: 32, | ||
requestedClues: [], | ||
viewedResources: [], | ||
remainingLifeRequests: 0, | ||
hasViewedAResourceAtThisStep: false, | ||
content: { | ||
ref: '1.A1.4', | ||
type: 'slide' | ||
}, | ||
nextContent: { | ||
ref: '1.A1.5', | ||
type: 'slide' | ||
}, | ||
allAnswers: [{ | ||
slideRef: '1.A1.1', | ||
isCorrect: true, | ||
answer: ['d'] | ||
}, { | ||
slideRef: '1.A1.2', | ||
isCorrect: true, | ||
answer: ['d'] | ||
}, { | ||
slideRef: '1.A1.3', | ||
isCorrect: true, | ||
answer: ['d'] | ||
}, { | ||
slideRef: '1.A1.4', | ||
isCorrect: true, | ||
answer: ['d'] | ||
}], | ||
pendingSlides: [], | ||
variables: {} | ||
}); | ||
const _config = getConfig({ | ||
ref: 'review', | ||
version: '1' | ||
}); | ||
const _availableContent = [{ | ||
ref: 'skill_ref', | ||
slides: [], | ||
rules: null | ||
}]; | ||
const result = computeNextStepForReview(_config, state, _availableContent, { | ||
type: 'answer', | ||
payload: { | ||
answer: ['answer'], | ||
content: { | ||
ref: '1.A1.5', | ||
type: 'slide' | ||
}, | ||
godMode: false, | ||
isCorrect: false | ||
} | ||
}); | ||
t.deepEqual(result, { | ||
nextContent: { | ||
type: 'slide', | ||
ref: '1.A1.5' | ||
}, | ||
instructions: null, | ||
isCorrect: false | ||
}); | ||
}); | ||
test('computeNextStepForReview --> should avoid to return the already answered slide if there are lag on review lambda and available content are not updated', t => { | ||
@@ -331,0 +405,0 @@ const state = Object.freeze({ |
@@ -371,5 +371,17 @@ "use strict"; | ||
const pendingSlides = !_state ? [] : _state.pendingSlides; | ||
const pendingSlide = getNextPendingSlide(state.nextContent.ref, pendingSlides, state.pendingSlides); // all other questions have been already right answered, so we close the progression | ||
const pendingSlide = getNextPendingSlide(state.nextContent.ref, pendingSlides, state.pendingSlides); // all other questions have been already right answered BUT you fail the last question | ||
if (!pendingSlide && !isCorrect) { | ||
return { | ||
nextContent: { | ||
type: 'slide', | ||
ref: state.nextContent.ref | ||
}, | ||
instructions: null, | ||
isCorrect | ||
}; | ||
} | ||
if (!pendingSlide) { | ||
// all other questions have been already right answered, so we close the progression | ||
return null; | ||
@@ -376,0 +388,0 @@ } // or there are wrong question that should be reviewed again |
@@ -340,2 +340,76 @@ "use strict"; | ||
}); | ||
(0, _ava.default)('computeNextStepForReview --> should return the same slide if you fail the last question', t => { | ||
const state = Object.freeze({ | ||
livesDisabled: true, | ||
isCorrect: true, | ||
slides: ['1.A1.1', '1.A1.2', '1.A1.3', '1.A1.4'], | ||
lives: 0, | ||
step: { | ||
current: 5 | ||
}, | ||
stars: 32, | ||
requestedClues: [], | ||
viewedResources: [], | ||
remainingLifeRequests: 0, | ||
hasViewedAResourceAtThisStep: false, | ||
content: { | ||
ref: '1.A1.4', | ||
type: 'slide' | ||
}, | ||
nextContent: { | ||
ref: '1.A1.5', | ||
type: 'slide' | ||
}, | ||
allAnswers: [{ | ||
slideRef: '1.A1.1', | ||
isCorrect: true, | ||
answer: ['d'] | ||
}, { | ||
slideRef: '1.A1.2', | ||
isCorrect: true, | ||
answer: ['d'] | ||
}, { | ||
slideRef: '1.A1.3', | ||
isCorrect: true, | ||
answer: ['d'] | ||
}, { | ||
slideRef: '1.A1.4', | ||
isCorrect: true, | ||
answer: ['d'] | ||
}], | ||
pendingSlides: [], | ||
variables: {} | ||
}); | ||
const _config = (0, _config2.getConfig)({ | ||
ref: 'review', | ||
version: '1' | ||
}); | ||
const _availableContent = [{ | ||
ref: 'skill_ref', | ||
slides: [], | ||
rules: null | ||
}]; | ||
const result = (0, _computeNextStep.computeNextStepForReview)(_config, state, _availableContent, { | ||
type: 'answer', | ||
payload: { | ||
answer: ['answer'], | ||
content: { | ||
ref: '1.A1.5', | ||
type: 'slide' | ||
}, | ||
godMode: false, | ||
isCorrect: false | ||
} | ||
}); | ||
t.deepEqual(result, { | ||
nextContent: { | ||
type: 'slide', | ||
ref: '1.A1.5' | ||
}, | ||
instructions: null, | ||
isCorrect: false | ||
}); | ||
}); | ||
(0, _ava.default)('computeNextStepForReview --> should avoid to return the already answered slide if there are lag on review lambda and available content are not updated', t => { | ||
@@ -342,0 +416,0 @@ const state = Object.freeze({ |
{ | ||
"name": "@coorpacademy/progression-engine", | ||
"version": "11.5.1", | ||
"version": "11.5.2", | ||
"description": "", | ||
@@ -65,3 +65,3 @@ "main": "lib/index.js", | ||
"author": "CoorpAcademy", | ||
"gitHead": "b19a45149c174adceace9ac95e31bcfa6d5f66eb" | ||
"gitHead": "33b0221c4d08271046b8ef30112582719d1038ee" | ||
} |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1717543
16265