Skip to content

Commit

Permalink
Fix: Ensure parent node of units get completed
Browse files Browse the repository at this point in the history
  • Loading branch information
legendword committed Nov 29, 2024
1 parent 63a7baa commit 95203cb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tapestry.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

add_action('plugins_loaded', function () {
global $TAPESTRY_VERSION_NUMBER;
global $TYDE_YOUTH_ROLES;
global $TYDE_DYAD_ROLES;
if (!isset($TAPESTRY_VERSION_NUMBER)) {

// Used to force-refresh assets and run updates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,21 @@ export default {
if (!this.node.completed && this.rows.every(row => row.node.completed)) {
this.$emit("complete", this.node.id)
}
// if this node is completed, check for parent node completion
// this is also just in case it hasn't done this properly before
if (this.node.completed && this.isUnitChild && !this.parentNode.completed) {
const allUnitsCompleted = this.parentNode.childOrdering.every(childId => {
const child = this.getNode(childId)
return child.completed
})
if (allUnitsCompleted) {
console.log(
"All units completed but parent node not marked as completed, marking now"
)
this.$emit("complete", this.parentNode.id)
}
}
},
methods: {
...mapMutations(["updateNode"]),
Expand Down

0 comments on commit 95203cb

Please sign in to comment.