Subject of the issue
The v4.1.0 > v4.2.0 migration throws a TypeError when a course contains an mcq component without an _items array. The mutate steps access MCQ._items.forEach(...) directly with no guard, so an itemless mcq crashes the whole migration (and any authoring-tool import that runs it). The bug is present on master (7.7.2).
Your environment
- Framework 5.56.2, adapt-contrib-mcq 7.7.2 (also present on
master)
- N/A (build-time migration, not browser)
Steps to reproduce
- Take a course with an mcq component that has no
_items property.
- Run the mcq migrations against it, e.g.
grunt migration:test --file=adapt-contrib-mcq, or import the course into the authoring tool. (The migration's own testSuccessWhere already includes an itemless mcq: { _id: 'c-100', _component: 'mcq' }.)
Expected behaviour
An mcq with no _items should be handled gracefully (nothing to update) and the migration should pass.
Actual behaviour
The migration throws:
mutateContent -- MCQ - add item _isPartlyCorrect attribute TypeError: Cannot read properties of undefined (reading 'forEach')
In migrations/v4.js, the v4.1.0 > v4.2.0 block does MCQ._items.forEach(...) in the "add item _isPartlyCorrect" and "add item _score" mutates, and MCQ._items.every(...) in the matching checks, with no protection for a missing _items. (Other components such as accordion/hotgraphic use _items?.forEach(...).)
Suggested Fix (if known)
Guard _items in that block, e.g. MCQ._items?.forEach(...) in the mutates and (MCQ._items ?? []).every(...) in the checks.
Posted via collaboration with Claude Code
Subject of the issue
The
v4.1.0 > v4.2.0migration throws aTypeErrorwhen a course contains an mcq component without an_itemsarray. The mutate steps accessMCQ._items.forEach(...)directly with no guard, so an itemless mcq crashes the whole migration (and any authoring-tool import that runs it). The bug is present onmaster(7.7.2).Your environment
master)Steps to reproduce
_itemsproperty.grunt migration:test --file=adapt-contrib-mcq, or import the course into the authoring tool. (The migration's owntestSuccessWherealready includes an itemless mcq:{ _id: 'c-100', _component: 'mcq' }.)Expected behaviour
An mcq with no
_itemsshould be handled gracefully (nothing to update) and the migration should pass.Actual behaviour
The migration throws:
In
migrations/v4.js, thev4.1.0 > v4.2.0block doesMCQ._items.forEach(...)in the "add item_isPartlyCorrect" and "add item_score" mutates, andMCQ._items.every(...)in the matching checks, with no protection for a missing_items. (Other components such as accordion/hotgraphic use_items?.forEach(...).)Suggested Fix (if known)
Guard
_itemsin that block, e.g.MCQ._items?.forEach(...)in the mutates and(MCQ._items ?? []).every(...)in the checks.Posted via collaboration with Claude Code