Skip to content
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
12 changes: 6 additions & 6 deletions js/textInputModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,8 @@ class TextInputModel extends QuestionModel {
}

isCorrect() {
if (this.get('_answers')) {
this.markGenericAnswers();
} else {
this.markSpecificAnswers();
}
this.markGenericAnswers();
this.markSpecificAnswers();
return this.get('_items').every(({ _isCorrect }) => _isCorrect);
}

Expand All @@ -109,6 +106,8 @@ class TextInputModel extends QuestionModel {
const usedAnswerIndexes = [];

this.get('_items').forEach(item => {
const hasItemAnswers = Boolean(item._answers?.length);
if (hasItemAnswers) return;
correctAnswers.forEach((answerGroup, answerIndex) => {
if (usedAnswerIndexes.includes(answerIndex)) return;

Expand All @@ -133,8 +132,9 @@ class TextInputModel extends QuestionModel {
markSpecificAnswers() {
let numberOfCorrectAnswers = 0;
this.get('_items').forEach(item => {
const hasItemAnswers = Boolean(item._answers?.length);
if (!hasItemAnswers) return;
const answers = item._answers;
if (!answers) return;
const userAnswer = item.userAnswer || '';
const isCorrect = this.checkAnswerIsCorrect(answers, userAnswer);
item._isCorrect = isCorrect;
Expand Down
2 changes: 1 addition & 1 deletion templates/textinput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function TextInput (props) {
role='group'
>

{props._items.map(({ prefix, _index, input, placeholder, userAnswer, suffix }, index) =>
{props._items.map(({ prefix, _index, input, placeholder, userAnswer, suffix, _isCorrect }, index) =>

<div
className={classes([
Expand Down