Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix-stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
nygrenh committed Oct 6, 2023
2 parents d5d9a11 + 7fa2e12 commit 05c2a6f
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ const MultipleChoiceEditor: React.FC<MultipleChoiceEditorProps> = ({ quizItemId
value: "points-off-unselected-options",
label: t("multiple-choice-grading-points-off-unselected-options"),
},
{
value: "some-correct-none-incorrect",
label: t("multiple-choice-grading-some-correct-none-incorrect"),
},
]

const { selected, updateState } =
Expand Down Expand Up @@ -348,6 +352,11 @@ const MultipleChoiceEditor: React.FC<MultipleChoiceEditorProps> = ({ quizItemId
// eslint-disable-next-line i18next/no-literal-string
"points-off-unselected-options"
break
case "some-correct-none-incorrect":
draft.multipleChoiceMultipleOptionsGradingPolicy =
// eslint-disable-next-line i18next/no-literal-string
"some-correct-none-incorrect"
break
}
})
}}
Expand Down Expand Up @@ -375,6 +384,9 @@ const MultipleChoiceEditor: React.FC<MultipleChoiceEditorProps> = ({ quizItemId
{selected.multipleChoiceMultipleOptionsGradingPolicy ==
"points-off-unselected-options" &&
t("multiple-choice-grading-points-off-unselected-options-description")}
{selected.multipleChoiceMultipleOptionsGradingPolicy ==
"some-correct-none-incorrect" &&
t("multiple-choice-grading-some-correct-none-incorrect-description")}
</span>
<OptionTitle> {t("feedback-message")} </OptionTitle>
<ParsedTextField
Expand Down
4 changes: 4 additions & 0 deletions services/quizzes/src/grading/assessment/multiple-choice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ const getMultipleChoicePointsByGradingPolicy = (
countOfCorrectAnswers * 2 - totalCorrectAnswers - countOfIncorrectAnswers,
)
break
case "some-correct-none-incorrect":
totalScore =
countOfCorrectAnswers !== 0 && countOfIncorrectAnswers == 0 ? totalCorrectAnswers : 0
break
default:
totalScore =
countOfCorrectAnswers == totalCorrectAnswers && countOfIncorrectAnswers == 0
Expand Down
40 changes: 40 additions & 0 deletions services/quizzes/tests/api/grade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,44 @@ describe('grade', () => {
expect(gradingResult.score_given).toBe(0.25)
})

//Some correct, none incorrect
it('returns full points for all correct answers in multiple-choice-options', async () => {
const data = generateMultipleChoiceRequest(3, 3, ['option-1', 'option-2', 'option-3'], "some-correct-none-incorrect")
const response = await client.post('/api/grade').send(data)
const result = JSON.parse(response.text)
expect(isExerciseTaskGradingResult(result))

const gradingResult: ExerciseTaskGradingResult = result as ExerciseTaskGradingResult
expect(gradingResult.score_given).toBe(1)
})

it('returns full points for some correct answers in multiple-choice-options', async () => {
const data = generateMultipleChoiceRequest(6, 6, ['option-1', 'option-2', 'option-3'], "some-correct-none-incorrect")
const response = await client.post('/api/grade').send(data)
const result = JSON.parse(response.text)
expect(isExerciseTaskGradingResult(result))

const gradingResult: ExerciseTaskGradingResult = result as ExerciseTaskGradingResult
expect(gradingResult.score_given).toBe(1)
})

it('returns zero points if correct answer and wrong answer is selected in multiple-choice-options', async () => {
const data = generateMultipleChoiceRequest(6, 3, ['option-1', 'option-6'], "some-correct-none-incorrect")
const response = await client.post('/api/grade').send(data)
const result = JSON.parse(response.text)
expect(isExerciseTaskGradingResult(result))

const gradingResult: ExerciseTaskGradingResult = result as ExerciseTaskGradingResult
expect(gradingResult.score_given).toBe(0)
})

it('returns zero points for wrong answer in multiple-choice-options', async () => {
const data = generateMultipleChoiceRequest(6, 3, ['option-6'], "some-correct-none-incorrect")
const response = await client.post('/api/grade').send(data)
const result = JSON.parse(response.text)
expect(isExerciseTaskGradingResult(result))

const gradingResult: ExerciseTaskGradingResult = result as ExerciseTaskGradingResult
expect(gradingResult.score_given).toBe(0)
})
})
1 change: 1 addition & 0 deletions services/quizzes/types/oldQuizTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export type oldMultipleChoiceMultipleOptionsGradingPolicy =
| "default"
| "points-off-incorrect-options"
| "points-off-unselected-options"
| "some-correct-none-incorrect"
/** @deprecated */
export interface QuizItem {
shuffleOptions: boolean
Expand Down
1 change: 1 addition & 0 deletions services/quizzes/types/quizTypes/modelSolutionSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type multipleChoiceMultipleOptionsGradingPolicy =
| "default"
| "points-off-incorrect-options"
| "points-off-unselected-options"
| "some-correct-none-incorrect"

export type ModelSolutionQuizItem =
| ModelSolutionQuizItemMultiplechoice
Expand Down
1 change: 1 addition & 0 deletions services/quizzes/types/quizTypes/privateSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type multipleChoiceMultipleOptionsGradingPolicy =
| "default"
| "points-off-incorrect-options"
| "points-off-unselected-options"
| "some-correct-none-incorrect"

export type PrivateSpecQuizItem =
| PrivateSpecQuizItemMultiplechoice
Expand Down
2 changes: 2 additions & 0 deletions shared-module/src/locales/en/quizzes.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
"multiple-choice-grading-points-off-incorrect-options-description": "Wrong options will reduce the points",
"multiple-choice-grading-points-off-unselected-options": "Reduce points from incorrect and unselected options",
"multiple-choice-grading-points-off-unselected-options-description": "Wrong options and unselected correct options will reduce the points",
"multiple-choice-grading-some-correct-none-incorrect": "Some correct, none incorrect",
"multiple-choice-grading-some-correct-none-incorrect-description": "Give full points if some of the correct options were chosen and none of the incorrect ones were selected",
"multiple-choice-header": "Multiple choice:",
"not-answered": "Not answered",
"number-of-tries-allowed": "Number of tries allowed",
Expand Down
2 changes: 2 additions & 0 deletions shared-module/src/locales/fi/quizzes.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
"multiple-choice-grading-points-off-incorrect-options-description": "Vääristä valinnoista vähennetään piste",
"multiple-choice-grading-points-off-unselected-options": "Pisteiden vähennys vääristä- ja oikeista valitsemattomista valinnoista",
"multiple-choice-grading-points-off-unselected-options-description": "Vääristä ja jätetyistä oikeista valinnoista vähennetään piste",
"multiple-choice-grading-some-correct-none-incorrect": "Osa oikein, ei yhtään väärin",
"multiple-choice-grading-some-correct-none-incorrect-description": "Täydet pisteet jos osa tai kaikki valinnoista on oikein ja yhtään väärää ei ole valittu",
"multiple-choice-header": "Monivalinnat:",
"not-answered": "Ei vastattu",
"number-of-tries-allowed": "Sallittujen yritysten määrä",
Expand Down

0 comments on commit 05c2a6f

Please sign in to comment.