Skip to content

Commit

Permalink
Merge remote-tracking branch 'obojobo-document-engine/master'
Browse files Browse the repository at this point in the history
Pulls in updats for fix-calc-highest-attempt-and-highest-assessment-score
from doc-engine v 1.0.3
  • Loading branch information
iturgeon committed Sep 30, 2018
2 parents 6938803 + 7bc42ec commit 59c53a2
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,93 @@ describe('AssessmentStore', () => {
expect(AssessmentStore.getState().assessments.assessmentId.currentResponses).toEqual(['q1'])
})
})

test('updateAttempts sets highestAttemptScoreAttempts and highestAssessmentScoreAttempts correctly', () => {
AssessmentStore.updateAttempts([
{
assessmentId: 'assessmentId',
attempts: [
{
attemptId: 'attempt-1',
attemptScore: 0,
assessmentScore: null,
state: {
questions: []
}
},
{
attemptID: 'attempt-2',
attemptScore: 50,
assessmentScore: 25,
state: {
questions: []
}
},
{
attemptId: 'attempt-3',
attemptScore: 100,
assessmentScore: 50,
state: {
questions: []
}
},
{
attemptId: 'attempt-4',
attemptScore: 100,
assessmentScore: null,
state: {
questions: []
}
},
{
attemptId: 'attempt-5',
attemptScore: null,
assessmentScore: 50,
state: {
questions: []
}
}
]
}
])

let state = AssessmentStore.getState()
let assessState = state.assessments.assessmentId
expect(assessState.highestAttemptScoreAttempts).toEqual([
{
attemptId: 'attempt-3',
attemptScore: 100,
assessmentScore: 50,
state: {
questions: []
}
},
{
attemptId: 'attempt-4',
attemptScore: 100,
assessmentScore: null,
state: {
questions: []
}
}
])
expect(assessState.highestAssessmentScoreAttempts).toEqual([
{
attemptId: 'attempt-3',
attemptScore: 100,
assessmentScore: 50,
state: {
questions: []
}
},
{
attemptId: 'attempt-5',
attemptScore: null,
assessmentScore: 50,
state: {
questions: []
}
}
])
})
})
4 changes: 2 additions & 2 deletions packages/obojobo-document-engine/build/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18944,8 +18944,8 @@ var AssessmentStore = function (_Store) {
}

assessments[assessId].lti = assessmentItem.ltiState;
assessments[assessId].highestAttemptScoreAttempts = _assessmentUtil2.default.findHighestAttempts(attempts, 'assessmentScore');
assessments[assessId].highestAssessmentScoreAttempts = _assessmentUtil2.default.findHighestAttempts(attempts, 'attemptScore');
assessments[assessId].highestAttemptScoreAttempts = _assessmentUtil2.default.findHighestAttempts(attempts, 'attemptScore');
assessments[assessId].highestAssessmentScoreAttempts = _assessmentUtil2.default.findHighestAttempts(attempts, 'assessmentScore');

attempts.forEach(function (attempt) {
assessment = assessments[attempt.assessmentId];
Expand Down
2 changes: 1 addition & 1 deletion packages/obojobo-document-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obojobo-document-engine",
"version": "1.0.2",
"version": "1.0.3",
"description": "",
"engines": {
"yarn": "^1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ class AssessmentStore extends Store {
assessments[assessId].lti = assessmentItem.ltiState
assessments[assessId].highestAttemptScoreAttempts = AssessmentUtil.findHighestAttempts(
attempts,
'assessmentScore'
'attemptScore'
)
assessments[assessId].highestAssessmentScoreAttempts = AssessmentUtil.findHighestAttempts(
attempts,
'attemptScore'
'assessmentScore'
)

attempts.forEach(attempt => {
Expand Down

0 comments on commit 59c53a2

Please sign in to comment.