-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Implementation of metadata endpoint for sequence modules #22707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
de06c31 to
b397c0a
Compare
| self._update_position(context, len(display_items)) | ||
|
|
||
| if self._required_prereq(): | ||
| if self.runtime.user_is_staff: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The student_view_data method is called during the collect phase of the StudentViewTransformer. Because that phase happens right at the time of Studio publish, there is no student state available for it to bind to at the time, and we can't make any operations that rely on reading anything user-specific. You can put this identical functionality in a new method though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out, this method isn't needed. I was hoping to include the sequence metadata in the block API response, which would require implementing student_view_data, but since we're going to make a separate request for the sequence (to xmodule_handler/metadata), this one can be removed.
a576743 to
78a520e
Compare
abutterworth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
We also need |
…e new courseware micro-frontend.
78a520e to
507b85e
Compare
I added it in. I was concerned that the sequence nav would break in studio, but it didn't. Hurray! |
ormsbee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor thing and a question.
| 'complete': complete | ||
| }) | ||
| elif dispatch == 'metadata': | ||
| if self.category != 'sequential': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the idea is prevent subclasses of SequenceModule (like the root course descriptor) from answering here, please make an explicit check against the class–it's not common, but we do accept a couple aliases for sequential in the OLX. Also, please add a comment explaining why you're doing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ormsbee That was the intention, because the endpoint will fail if requested from the course descriptor. How about, instead of checking for classes, we just let that behavior be undefined? It wouldn't return meaningful metadata for the course, anyway.
| if item.location.block_type == 'vertical': | ||
| if completion_service: | ||
| iteminfo['complete'] = completion_service.vertical_is_complete(item) | ||
| if is_user_authenticated: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we no longer have a check for render_items here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I introduced the render_items conditional when adding the sequence module UI navigation to Studio. In that case, there's no need for completion and bookmark checks, so I hid them behind the conditional. Now we need the completion info for the Unit, regardless of whether it's rendered.
e68237f to
20235bc
Compare
|
Your PR has finished running tests. There were no failures. |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR may have caused e2e tests to fail on Stage. If you're a member of the edX org, please visit #e2e-troubleshooting on Slack to help diagnose the cause of these failures. Otherwise, it is the reviewer's responsibility. E2E tests have failed. https://gocd.tools.edx.org/go/tab/pipeline/history/STAGE_edxapp_M-D |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR may have caused e2e tests to fail on Stage. If you're a member of the edX org, please visit #e2e-troubleshooting on Slack to help diagnose the cause of these failures. Otherwise, it is the reviewer's responsibility. E2E tests have failed. https://gocd.tools.edx.org/go/tab/pipeline/history/STAGE_edxapp_M-D |
|
EdX Release Notice: This PR has been deployed to the production environment. |
This exposes sequence module metadata via the xmodule view handler facility.
Access it by making a GET request to
/courses/{course_id}/xblock/{usage_key}/handler/xmodule_handler/metadataFor instance, on devstack:
http://localhost:18000/courses/course-v1:edX+DemoX+Demo_Course/xblock/block-v1:edX+DemoX+Demo_Course+type@sequential+block@basic_questions/handler/xmodule_handler/metadata
Which will return something like this:
{ "item_id": "block-v1:edX+DemoX+Demo_Course+type@sequential+block@basic_questions", "ajax_url": "/courses/course-v1:edX+DemoX+Demo_Course/xblock/block-v1:edX+DemoX+Demo_Course+type@sequential+block@basic_questions/handler/xmodule_handler", "banner_text": null, "tag": "sequential", "gated_content": { "gated_section_name": "Homework - Question Styles", "prereq_url": null, "prereq_section_name": null, "gated": false }, "position": 1, "items": [ { "href": "", "content": "", "id": "block-v1:edX+DemoX+Demo_Course+type@vertical+block@2152d4a4aadc4cb0af5256394a3d1fc7", "graded": true, "path": "Example Week 1: Getting Started > Homework - Question Styles > Pointing on a Picture", "bookmarked": false, "page_title": "Pointing on a Picture", "type": "problem" }, { "href": "", "content": "", "id": "block-v1:edX+DemoX+Demo_Course+type@vertical+block@47dbd5f836544e61877a483c0b75606c", "graded": true, "path": "Example Week 1: Getting Started > Homework - Question Styles > Drag and Drop", "bookmarked": false, "page_title": "Drag and Drop", "type": "problem" }, { "href": "", "content": "", "id": "block-v1:edX+DemoX+Demo_Course+type@vertical+block@54bb9b142c6c4c22afc62bcb628f0e68", "graded": true, "path": "Example Week 1: Getting Started > Homework - Question Styles > Multiple Choice Questions", "bookmarked": false, "page_title": "Multiple Choice Questions", "type": "problem" }, { "href": "", "content": "", "id": "block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_0c92347a5c00", "graded": true, "path": "Example Week 1: Getting Started > Homework - Question Styles > Mathematical Expressions", "bookmarked": false, "page_title": "Mathematical Expressions", "type": "problem" }, { "href": "", "content": "", "id": "block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_1fef54c2b23b", "graded": true, "path": "Example Week 1: Getting Started > Homework - Question Styles > Chemical Equations", "bookmarked": false, "page_title": "Chemical Equations", "type": "problem" }, { "href": "", "content": "", "id": "block-v1:edX+DemoX+Demo_Course+type@vertical+block@2889db1677a549abb15eb4d886f95d1c", "graded": true, "path": "Example Week 1: Getting Started > Homework - Question Styles > Numerical Input", "bookmarked": false, "page_title": "Numerical Input", "type": "problem" }, { "href": "", "content": "", "id": "block-v1:edX+DemoX+Demo_Course+type@vertical+block@e8a5cc2aed424838853defab7be45e42", "graded": true, "path": "Example Week 1: Getting Started > Homework - Question Styles > Text input", "bookmarked": false, "page_title": "Text input", "type": "problem" } ], "element_id": "basic_questions", "exclude_units": true, "save_position": true, "prev_url": null, "show_completion": true, "next_url": null }