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

Fix: Remove isOptional checks preventing optional questions from treated as always being correct (Fixes #54) #55

Merged
merged 2 commits into from
May 14, 2024
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
6 changes: 3 additions & 3 deletions js/BranchingSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default class BranchingSet {
}

const lastChildModel = branchedModels[branchedModels.length - 1];
const isLastIncomplete = !lastChildModel.get('_isComplete') && !lastChildModel.get('_isOptional');
const isLastIncomplete = !lastChildModel.get('_isComplete');
if (isLastIncomplete && !isTheoretical) {
return false;
}
Expand Down Expand Up @@ -224,7 +224,7 @@ export default class BranchingSet {
if (isAnyPartRestored) {
// Make sure to explicitly set the block to complete if complete
// This helps trickle setup locking correctly
const areAllDescendantsComplete = cloned.getAllDescendantModels(true).every(model => model.get('_isComplete') || model.get('_isOptional'));
const areAllDescendantsComplete = cloned.getAllDescendantModels(true).every(model => model.get('_isComplete'));
if (areAllDescendantsComplete) {
cloned.setCompletionStatus();
}
Expand Down Expand Up @@ -282,7 +282,7 @@ export default class BranchingSet {
// Excludes non-trackable extension components, like trickle buttons
const areAllAvailableTrackableChildrenComplete = childModel.getChildren()
.filter(model => model.get('_isAvailable') && model.get('_isTrackable') !== false)
.every(model => model.get('_isComplete') || model.get('_isOptional'));
.every(model => model.get('_isComplete'));
return areAllAvailableTrackableChildrenComplete;
});
return isEffectivelyComplete && this.isAtEnd;
Expand Down
6 changes: 3 additions & 3 deletions js/branchingAlgorithm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import data from 'core/js/data';

export function getCorrectness(model) {
const questionModels = model.getAllDescendantModels().concat([model]).filter(model => model instanceof QuestionModel);
const numberOfCorrect = (questionModels.filter(child => (child.isCorrect()) && !child.get('_isOptional'))).length;
const numberOfPartlyCorrect = (questionModels.filter(child => (child.isPartlyCorrect()) && !child.get('_isOptional'))).length;
const isCorrect = questionModels.every(child => child.isCorrect() || child.get('_isOptional'));
const numberOfCorrect = (questionModels.filter(child => (child.isCorrect()))).length;
const numberOfPartlyCorrect = (questionModels.filter(child => (child.isPartlyCorrect()))).length;
const isCorrect = questionModels.every(child => child.isCorrect());
const isPartlyCorrect = (numberOfCorrect > 0) || (numberOfPartlyCorrect > 0);
const correctnessState = isCorrect ?
'correct' :
Expand Down
Loading