Summary
When inside a Problem Builder (or other StudioContainerWithNestedXBlocksMixin) container block, the "Add Component" buttons for pb-message variants (Message complete / incomplete / Max attempts) all create the same default block, ignoring the selected boilerplate template.
For detail look at this comment: #3058 (comment)
Root Cause
Two bugs in src/course-unit/add-component/AddComponent.tsx:
- Rendering — the
default case button click handler called handleCreateNewXBlock(type) without forwarding firstTemplate?.boilerplateName.
- Handler — the
default branch of handleCreateNewXBlock called handleCreateNewCourseXBlock(...) without boilerplate: moduleName, so the backend always used the default template.
Fix
- Pass
firstTemplate?.boilerplateName from the button onClick to handleCreateNewXBlock.
- Forward it as
boilerplate in the handleCreateNewCourseXBlock call inside the default handler branch.
Related
Summary
When inside a Problem Builder (or other
StudioContainerWithNestedXBlocksMixin) container block, the "Add Component" buttons for pb-message variants (Message complete / incomplete / Max attempts) all create the same default block, ignoring the selected boilerplate template.For detail look at this comment: #3058 (comment)
Root Cause
Two bugs in
src/course-unit/add-component/AddComponent.tsx:defaultcase button click handler calledhandleCreateNewXBlock(type)without forwardingfirstTemplate?.boilerplateName.defaultbranch ofhandleCreateNewXBlockcalledhandleCreateNewCourseXBlock(...)withoutboilerplate: moduleName, so the backend always used the default template.Fix
firstTemplate?.boilerplateNamefrom the buttononClicktohandleCreateNewXBlock.boilerplatein thehandleCreateNewCourseXBlockcall inside thedefaulthandler branch.Related