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 all commits
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 @@ -2,14 +2,11 @@ const TYPE_ATTEMPT_WITHOUT_MODS_REWARDED = 'attempt-without-mods-rewarded'
const TYPE_ATTEMPT_WITH_MODS_REWARDED = 'attempt-with-mods-rewarded'
const TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITHOUT_MODS_REWARDED =
'passfail-passed-given-attempt-score-without-mods-rewarded'
const TYPE_PASSFAIL_PASSED_GIVEN_SCORE = 'passfail-passed-given-score'
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_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 =
'passfail-passed-given-score-and-attempt-score-is-100-and-mods-rewarded'
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_FAILED_GIVEN_ATTEMPT_SCORE = 'passfail-failed-given-attempt-score'
const TYPE_PASSFAIL_FAILED_GIVEN_NO_SCORE = 'passfail-failed-given-no-score'
const TYPE_PASSFAIL_FAILED_GIVEN_SCORE = 'passfail-failed-given-score'
Expand All @@ -24,9 +21,8 @@ export {
TYPE_ATTEMPT_WITH_MODS_REWARDED,
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_NO_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100,
TYPE_PASSFAIL_FAILED_GIVEN_ATTEMPT_SCORE,
TYPE_PASSFAIL_FAILED_GIVEN_NO_SCORE,
TYPE_PASSFAIL_FAILED_GIVEN_SCORE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import {
TYPE_ATTEMPT_WITH_MODS_REWARDED,
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_NO_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100,
TYPE_PASSFAIL_FAILED_GIVEN_ATTEMPT_SCORE,
TYPE_PASSFAIL_FAILED_GIVEN_NO_SCORE,
TYPE_PASSFAIL_FAILED_GIVEN_SCORE,
Expand All @@ -23,6 +22,7 @@ const getDisplayType = ({ rubricType, mods, status, statusResult, isAttemptScore
const isAttemptRubric = rubricType === AssessmentRubric.TYPE_ATTEMPT
const isPassFailRubric = rubricType === AssessmentRubric.TYPE_PASS_FAIL
const isRewardedMods = mods.length > 0
const isResult100 = parseFloat(statusResult) === 100
const isResultNumeric = Number.isFinite(parseFloat(statusResult))
const isResultNoScore = statusResult === AssessmentRubric.NO_SCORE
const isResultAttemptScore = statusResult === AssessmentRubric.VAR_ATTEMPT_SCORE
Expand All @@ -40,14 +40,11 @@ const getDisplayType = ({ rubricType, mods, status, statusResult, isAttemptScore
if (isPassFailRubric && passed && isResultAttemptScore && isRewardedMods) {
return TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITH_MODS_REWARDED
}
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
}
if (isPassFailRubric && passed && isResultNumeric && isAttemptScore100 && isRewardedMods) {
return TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_MODS_REWARDED
if (isPassFailRubric && passed && isResultNumeric) {
return TYPE_PASSFAIL_PASSED_GIVEN_SCORE
}
if (isPassFailRubric && failed && isResultAttemptScore && !isRewardedMods) {
return TYPE_PASSFAIL_FAILED_GIVEN_ATTEMPT_SCORE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import {
TYPE_ATTEMPT_WITH_MODS_REWARDED,
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_NO_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100,
TYPE_PASSFAIL_FAILED_GIVEN_ATTEMPT_SCORE,
TYPE_PASSFAIL_FAILED_GIVEN_NO_SCORE,
TYPE_PASSFAIL_FAILED_GIVEN_SCORE,
Expand Down Expand Up @@ -69,7 +68,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 @@ -102,9 +100,7 @@ describe('getDisplayType', () => {
//
// Pass/Fail type where score < 100 and no mods rewarded
//
expect(tc('pass-fail', p, '100', 0, 0)).toEqual(
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_LESS_THAN_100
)
expect(tc('pass-fail', p, '100', 0, 0)).toEqual(TYPE_PASSFAIL_PASSED_GIVEN_SCORE)
expect(tc('pass-fail', f, '100', 0, 0)).toEqual(TYPE_PASSFAIL_FAILED_GIVEN_SCORE)
expect(tc('pass-fail', u, '100', 0, 0)).toEqual(TYPE_PASSFAIL_UNABLE_TO_PASS_GIVEN_SCORE)
expect(tc('pass-fail', p, attScore, 0, 0)).toEqual(
Expand All @@ -126,11 +122,12 @@ describe('getDisplayType', () => {
//
// Pass/Fail type where score === 100 and no mods rewarded
//
expect(tc('pass-fail', p, '100', 1, 0)).toEqual(
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_NO_MODS_REWARDED
)
expect(tc('pass-fail', p, '100', 1, 0)).toEqual(TYPE_PASSFAIL_PASSED_GIVEN_SCORE)
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,10 +147,7 @@ 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
)
expect(tc('pass-fail', p, '100', 0, 1)).toEqual(TYPE_PASSFAIL_PASSED_GIVEN_SCORE)
expect(tc('pass-fail', f, '100', 0, 1)).toEqual(ERROR_UNKNOWN_DISPLAY_TYPE)
expect(tc('pass-fail', u, '100', 0, 1)).toEqual(ERROR_UNKNOWN_DISPLAY_TYPE)
expect(tc('pass-fail', p, attScore, 0, 1)).toEqual(
Expand All @@ -171,11 +165,13 @@ describe('getDisplayType', () => {
//
// Pass/Fail type where score === 100 and mods rewarded
//
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, '100', 1, 1)).toEqual(TYPE_PASSFAIL_PASSED_GIVEN_SCORE)
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 @@ -7,9 +7,8 @@ import {
TYPE_ATTEMPT_WITH_MODS_REWARDED,
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_NO_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_MODS_REWARDED,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE,
TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100,
TYPE_PASSFAIL_FAILED_GIVEN_ATTEMPT_SCORE,
TYPE_PASSFAIL_FAILED_GIVEN_NO_SCORE,
TYPE_PASSFAIL_FAILED_GIVEN_SCORE,
Expand Down Expand Up @@ -49,7 +48,6 @@ const getTextItems = (
) {
case TYPE_ATTEMPT_WITHOUT_MODS_REWARDED:
case TYPE_PASSFAIL_PASSED_GIVEN_ATTEMPT_SCORE_WITHOUT_MODS_REWARDED:
case TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_NO_MODS_REWARDED:
case ERROR_UNKNOWN_DISPLAY_TYPE: // Shouldn't get here but we still want to show their score
items.push({
type: 'total',
Expand All @@ -67,7 +65,8 @@ const getTextItems = (
})
break

case TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_LESS_THAN_100:
case TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_RESULT_IS_LESS_THAN_100:
case TYPE_PASSFAIL_PASSED_GIVEN_SCORE:
items.push(
{
type: 'value',
Expand All @@ -85,14 +84,6 @@ const getTextItems = (
)
break

case TYPE_PASSFAIL_PASSED_GIVEN_SCORE_AND_ATTEMPT_SCORE_IS_100_AND_MODS_REWARDED:
items.push({
type: 'value',
text: 'Attempt Score (Passed)',
value: attemptScore
})
break

case TYPE_PASSFAIL_FAILED_GIVEN_ATTEMPT_SCORE:
case TYPE_PASSFAIL_FAILED_GIVEN_NO_SCORE:
items.push(
Expand Down
Loading