Skip to content

Commit

Permalink
Fix: Correctly setting child visited state for Flipcard items (ADAPT-…
Browse files Browse the repository at this point in the history
…12310) (#76)
  • Loading branch information
cahirodoherty-learningpool authored Jul 16, 2024
1 parent aafd18a commit 8974d61
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions js/FlipcardModel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ItemsComponentModel from 'core/js/models/itemsComponentModel';
import logging from 'core/js/logging';

export default class FlipcardModel extends ItemsComponentModel {

Expand All @@ -9,8 +10,13 @@ export default class FlipcardModel extends ItemsComponentModel {

// This function will set the visited status for particular flipcard item.
setVisited(index) {
const item = this.get('_items')[index];
item._isVisited = true;
const child = this.getChildren()?.models?.[index] || null;
if (!child) {
logging.warn(`Flipcard item not found for index '${index}'`);
return;
}

child.set('_isVisited', true);
this.checkCompletionStatus();
}
}

0 comments on commit 8974d61

Please sign in to comment.