@01-edu/shared 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/attrs-defs.js +19 -3
  2. package/package.json +1 -1
package/attrs-defs.js CHANGED
@@ -3016,7 +3016,6 @@ const sharedScopeExtraDuration = Literal(0, {
3016
3016
  relationAttrs.scopeExtraDuration = {
3017
3017
  piscine: {
3018
3018
  quest: sharedScopeExtraDuration,
3019
- project: sharedScopeExtraDuration,
3020
3019
  },
3021
3020
  }
3022
3021
 
@@ -3248,6 +3247,12 @@ const isPathStatusSucceeded = (path, object) => {
3248
3247
  }
3249
3248
  }
3250
3249
 
3250
+ const addVersionChain = (object, path) => {
3251
+ const objReq = object.parent.children[path.slice('../'.length)]
3252
+ const versions = objReq?.versions?.map(({ key }) => `../${key}`)
3253
+ return versions?.length ? [path, ...versions] : [path]
3254
+ }
3255
+
3251
3256
  /**
3252
3257
  * @throws This function throws an error if any of the required objects is invalid
3253
3258
  * @returns {bool} true if all the required objects are succeeded, false otherwise
@@ -3258,11 +3263,22 @@ const hasSucceededRequiredObjects = (requirements, object) => {
3258
3263
  const { objects } = requirements
3259
3264
  if (!objects || !objects.length) return true
3260
3265
 
3266
+ // include the old versions
3267
+ const processedObjects = objects.map(p =>
3268
+ Array.isArray(p)
3269
+ ? p.flatMap(path => addVersionChain(object, path))
3270
+ : addVersionChain(object, p),
3271
+ )
3272
+
3261
3273
  // required objects are the ones that need to be done to unblock the current object
3262
- const requiredObjects = objects.filter(p => !Array.isArray(p) && Boolean(p))
3274
+ const requiredObjects = processedObjects.filter(
3275
+ p => !Array.isArray(p) && Boolean(p),
3276
+ )
3263
3277
  // pathway objects represent the choices a student can take to unblock the current object
3264
3278
  // note: at least one object from each pathway must be successfully completed
3265
- const pathWayObjects = objects?.filter(p => Array.isArray(p) && Boolean(p))
3279
+ const pathWayObjects = processedObjects?.filter(
3280
+ p => Array.isArray(p) && Boolean(p),
3281
+ )
3266
3282
 
3267
3283
  const hasSeccededRequiredObjects = requiredObjects.every(path =>
3268
3284
  isPathStatusSucceeded(path, object),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@01-edu/shared",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "scripts": {