Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes strange rubric rendering with set passing score #1866

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITHOUT_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITH_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_LESS_THAN_100,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_NO_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_MODS_REWARDED,
TYPE_PASSFAIL_FAILED_GIVEN_ATTEMPT_SCORE,
Expand Down Expand Up @@ -69,7 +70,6 @@ describe('getDisplayType', () => {
//
// Attempt type where score < 100 and mods rewarded
//

expect(tc('attempt', p, '100', 0, 1)).toEqual(ERROR_UNKNOWN_DISPLAY_TYPE)
expect(tc('attempt', f, '100', 0, 1)).toEqual(ERROR_UNKNOWN_DISPLAY_TYPE)
expect(tc('attempt', u, '100', 0, 1)).toEqual(ERROR_UNKNOWN_DISPLAY_TYPE)
Expand Down Expand Up @@ -131,6 +131,9 @@ describe('getDisplayType', () => {
)
expect(tc('pass-fail', f, '100', 1, 0)).toEqual(TYPE_PASSFAIL_FAILED_GIVEN_SCORE)
expect(tc('pass-fail', u, '100', 1, 0)).toEqual(TYPE_PASSFAIL_UNABLE_TO_PASS_GIVEN_SCORE)
expect(tc('pass-fail', p, '90', 1, 0)).toEqual(
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100
)
expect(tc('pass-fail', p, attScore, 1, 0)).toEqual(
TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITHOUT_MODS_REWARDED
)
Expand All @@ -150,7 +153,6 @@ describe('getDisplayType', () => {
//
// Pass/Fail type where score < 100 and mods rewarded
//

expect(tc('pass-fail', p, '100', 0, 1)).toEqual(
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_LESS_THAN_100
)
Expand All @@ -174,8 +176,12 @@ describe('getDisplayType', () => {
expect(tc('pass-fail', p, '100', 1, 1)).toEqual(
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_MODS_REWARDED
)
expect(tc('pass-fail', p, '90', 1, 1)).toEqual(
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100
)
expect(tc('pass-fail', f, '100', 1, 1)).toEqual(ERROR_UNKNOWN_DISPLAY_TYPE)
expect(tc('pass-fail', u, '100', 1, 1)).toEqual(ERROR_UNKNOWN_DISPLAY_TYPE)

expect(tc('pass-fail', p, attScore, 1, 1)).toEqual(
TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITH_MODS_REWARDED
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITHOUT_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITH_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_LESS_THAN_100,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_NO_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_MODS_REWARDED,
TYPE_PASSFAIL_FAILED_GIVEN_ATTEMPT_SCORE,
Expand Down Expand Up @@ -395,6 +396,164 @@ describe('getTextItems', () => {
])
})

test('TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100 (Without mods)', () => {
getDisplayType.mockReturnValueOnce(
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100
)
expect(
getTextItems(
{
isAssessScoreOver100: true,
mods: [],
statusResult: 90
},
displayValues
)
).toEqual([
{
type: 'value',
text: 'Attempt Score (Passed)',
value: 'AttemptScore'
},
{
type: 'divider'
},
{
type: 'value',
text: 'Score adjusted for passing',
value: '90'
},
{
type: 'divider'
},
{
type: 'total',
text: 'Total Score (Max 100%)',
value: 'AssessmentScore'
}
])

getDisplayType.mockReturnValueOnce(
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100
)
expect(
getTextItems(
{
isAssessScoreOver100: false,
mods: [],
statusResult: 90
},
displayValues
)
).toEqual([
{
type: 'value',
text: 'Attempt Score (Passed)',
value: 'AttemptScore'
},
{
type: 'divider'
},
{
type: 'value',
text: 'Score adjusted for passing',
value: '90'
},
{
type: 'divider'
},
{
type: 'total',
text: 'Total Score',
value: 'AssessmentScore'
}
])
})

test('TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100 (With mods)', () => {
getDisplayType.mockReturnValueOnce(
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100
)
expect(
getTextItems(
{
isAssessScoreOver100: true,
mods,
statusResult: 90
},
displayValues
)
).toEqual([
{
type: 'value',
text: 'Attempt Score (Passed)',
value: 'AttemptScore'
},
{
type: 'divider'
},
{
type: 'value',
text: 'Score adjusted for passing',
value: '90'
},
{
type: 'extra-credit',
text: 'Passed on first attempt',
value: '5'
},
{
type: 'divider'
},
{
type: 'total',
text: 'Total Score (Max 100%)',
value: 'AssessmentScore'
}
])

getDisplayType.mockReturnValueOnce(
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100
)
expect(
getTextItems(
{
isAssessScoreOver100: false,
mods,
statusResult: 90
},
displayValues
)
).toEqual([
{
type: 'value',
text: 'Attempt Score (Passed)',
value: 'AttemptScore'
},
{
type: 'divider'
},
{
type: 'value',
text: 'Score adjusted for passing',
value: '90'
},
{
type: 'extra-credit',
text: 'Passed on first attempt',
value: '5'
},
{
type: 'divider'
},
{
type: 'total',
text: 'Total Score',
value: 'AssessmentScore'
}
])
})

test('TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_NO_MODS_REWARDED', () => {
getDisplayType.mockReturnValueOnce(
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_NO_MODS_REWARDED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITH_MODS_REWARDED =
'passfail-passed-given-attempt-score-with-mods-rewarded'
const TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_LESS_THAN_100 =
'passfail-passed-given-score-and-attempt-score-less-than-100'
const TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100 =
'passfail-passed-given-score-and-attempt-score-is-100-and-result-is-less-than-100'
const TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_NO_MODS_REWARDED =
'passfail-passed-given-score-and-attempt-score-is-100-and-no-mods-rewarded'
const TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_MODS_REWARDED =
Expand All @@ -25,6 +27,7 @@ export {
TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITHOUT_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITH_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_LESS_THAN_100,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_NO_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_MODS_REWARDED,
TYPE_PASSFAIL_FAILED_GIVEN_ATTEMPT_SCORE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITHOUT_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITH_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_LESS_THAN_100,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_NO_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_MODS_REWARDED,
TYPE_PASSFAIL_FAILED_GIVEN_ATTEMPT_SCORE,
Expand All @@ -22,6 +23,7 @@ const getDisplayType = ({ rubricType, mods, status, statusResult, isAttemptScore
const isAttemptRubric = rubricType === 'attempt'
const isPassFailRubric = rubricType === 'pass-fail'
const isRewardedMods = mods.length > 0
const isResult100 = parseFloat(statusResult) === 100
const isResultNumeric = Number.isFinite(parseFloat(statusResult))
const isResultNoScore = statusResult === 'no-score'
const isResultAttemptScore = statusResult === '$attempt_score'
Expand All @@ -42,6 +44,9 @@ const getDisplayType = ({ rubricType, mods, status, statusResult, isAttemptScore
if (isPassFailRubric && passed && isResultNumeric && !isAttemptScore100) {
return TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_LESS_THAN_100
}
if (isPassFailRubric && passed & isResultNumeric && isAttemptScore100 && !isResult100) {
return TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100
}
if (isPassFailRubric && passed && isResultNumeric && isAttemptScore100 && !isRewardedMods) {
return TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_NO_MODS_REWARDED
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITHOUT_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITH_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_LESS_THAN_100,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_NO_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_MODS_REWARDED,
TYPE_PASSFAIL_FAILED_GIVEN_ATTEMPT_SCORE,
Expand Down Expand Up @@ -67,6 +68,7 @@ const getTextItems = (
})
break

case TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100:
case TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_LESS_THAN_100:
items.push(
{
Expand Down