Save user state for Blockstore XBlocks in CSM, clean up CSM a bit (#21630)
This commit introduces the changes needed for XBlocks in Blockstore to save their user state into CSM. Before this commit, all student state for Blockstore blocks was ephemeral (in-process dict store). Notes: * The main risk factor of this PR is that it adds non-course keys to the course_id field in CSM. If any code (like analytics?) reads course keys directly out of CSM and doesn't have graceful handling for key types it doesn't recognize, it could cause an issue. With the included changes to opaque-keys, calling CourseKey.from_string(...) on these values will raise InvalidKeyError since they're not CourseKeys. (But calling LearningContextKey.from_string(...) will work for both course and library keys.) * This commit introduces a slight regression for the Studio view of XBlocks in Blockstore content libraries: their state is now lost from request to request. I have a follow up PR to give them a proper studio-appropriate state store, but I want to review it separately so it doesn't hold up this PR and we can test this PR on its own.
Showing
- common/lib/xmodule/xmodule/video_module/video_module.py 1 addition, 2 deletionscommon/lib/xmodule/xmodule/video_module/video_module.py
- lms/djangoapps/courseware/migrations/0012_adjust_fields.py 32 additions, 0 deletionslms/djangoapps/courseware/migrations/0012_adjust_fields.py
- lms/djangoapps/courseware/model_data.py 5 additions, 4 deletionslms/djangoapps/courseware/model_data.py
- lms/djangoapps/courseware/models.py 8 additions, 16 deletionslms/djangoapps/courseware/models.py
- lms/envs/common.py 7 additions, 0 deletionslms/envs/common.py
- lms/envs/test.py 7 additions, 0 deletionslms/envs/test.py
- openedx/core/djangoapps/content_libraries/api.py 5 additions, 2 deletionsopenedx/core/djangoapps/content_libraries/api.py
- openedx/core/djangoapps/content_libraries/library_context.py 6 additions, 2 deletionsopenedx/core/djangoapps/content_libraries/library_context.py
- openedx/core/djangoapps/content_libraries/tests/test_content_libraries.py 1 addition, 0 deletions...ngoapps/content_libraries/tests/test_content_libraries.py
- openedx/core/djangoapps/content_libraries/tests/test_student_state.py 162 additions, 0 deletions.../djangoapps/content_libraries/tests/test_student_state.py
- openedx/core/djangoapps/xblock/api.py 1 addition, 1 deletionopenedx/core/djangoapps/xblock/api.py
- openedx/core/djangoapps/xblock/apps.py 2 additions, 4 deletionsopenedx/core/djangoapps/xblock/apps.py
- openedx/core/djangoapps/xblock/learning_context/learning_context.py 3 additions, 1 deletion...re/djangoapps/xblock/learning_context/learning_context.py
- openedx/core/djangoapps/xblock/runtime/blockstore_field_data.py 25 additions, 17 deletions...x/core/djangoapps/xblock/runtime/blockstore_field_data.py
- openedx/core/djangoapps/xblock/runtime/runtime.py 86 additions, 31 deletionsopenedx/core/djangoapps/xblock/runtime/runtime.py
Please register or sign in to comment