Commit c545556
Remap Unit extra_fields.options node IDs when copying via copy_node (#5860)
* Remap Unit extra_fields.options node IDs when copying via copy_node
When a Unit topic (UNIT modality) is cloned, lesson node IDs and
pre/post test node IDs in extra_fields.options are rewritten to the
IDs of their copies. Entries whose source nodes were not part of the
copy operation (e.g. excluded via excluded_descendants) are dropped.
Adds _remap_unit_options() static helper on CustomContentNodeTreeManager,
calls it in _recurse_to_create_tree() for the deep-copy path and in
_copy() for the shallow-copy path. _deep_copy() and _copy() now return
(nodes, source_copy_id_map) so the map is available to callers;
copy_node() unwraps the tuple and returns only the node list.
* Test Unit extra_fields.options remapping across copy paths
Adds UnitCopyExtraFieldsTestCase covering:
- lesson_objectives keys remapped to cloned lesson PKs (deep and shallow)
- pre_test/post_test values remapped to cloned node PKs (deep and shallow)
- excluded lesson entry dropped from cloned Unit's lesson_objectives
- excluded Unit: copy succeeds with no remap error (deep and shallow)
- resource excluded inside lesson: lesson entry preserved (deep and shallow)
- assessment_objectives, learning_objectives, completion_criteria unchanged
- standalone Unit copy remaps its lesson children correctly
- extra_fields on Course and Lesson topics is copied verbatim
* Remove pre/post test remapping — Unit options contain no such node-ID keys
The pre_test/post_test entries in a Unit's options are assessment items
on the Unit node itself, not separate ContentNode IDs. Remove the
dead code in _remap_unit_options() and the fantasy test coverage that
accompanied it.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
* test: drop test_standalone_unit_copy_remaps_lesson_children
Reviewer noted this test is redundant — the same behaviour is already
exercised by the deep/shallow copy integration tests for Unit nodes.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
---------
Co-authored-by: Claude Sonnet 4.6 <[email protected]>1 parent d87d43f commit c545556
2 files changed
Lines changed: 427 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
359 | 360 | | |
360 | 361 | | |
361 | 362 | | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
362 | 372 | | |
363 | 373 | | |
364 | 374 | | |
| |||
394 | 404 | | |
395 | 405 | | |
396 | 406 | | |
397 | | - | |
| 407 | + | |
398 | 408 | | |
399 | 409 | | |
400 | 410 | | |
| |||
406 | 416 | | |
407 | 417 | | |
408 | 418 | | |
| 419 | + | |
409 | 420 | | |
410 | 421 | | |
411 | 422 | | |
| |||
424 | 435 | | |
425 | 436 | | |
426 | 437 | | |
427 | | - | |
| 438 | + | |
428 | 439 | | |
429 | 440 | | |
430 | 441 | | |
| |||
436 | 447 | | |
437 | 448 | | |
438 | 449 | | |
439 | | - | |
| 450 | + | |
440 | 451 | | |
441 | 452 | | |
442 | 453 | | |
| |||
451 | 462 | | |
452 | 463 | | |
453 | 464 | | |
| 465 | + | |
454 | 466 | | |
455 | | - | |
| 467 | + | |
456 | 468 | | |
457 | 469 | | |
458 | 470 | | |
| |||
464 | 476 | | |
465 | 477 | | |
466 | 478 | | |
467 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
468 | 492 | | |
469 | 493 | | |
470 | 494 | | |
| |||
582 | 606 | | |
583 | 607 | | |
584 | 608 | | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
585 | 630 | | |
586 | 631 | | |
587 | 632 | | |
| |||
665 | 710 | | |
666 | 711 | | |
667 | 712 | | |
668 | | - | |
| 713 | + | |
0 commit comments