Skip to content

Conversation

@davestgermain
Copy link
Contributor

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/metadata

For 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
}

@davestgermain davestgermain requested a review from a team January 3, 2020 20:12
self._update_position(context, len(display_items))

if self._required_prereq():
if self.runtime.user_is_staff:
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@davestgermain davestgermain force-pushed the dcs/sequence-api branch 2 times, most recently from a576743 to 78a520e Compare January 8, 2020 13:53
@davestgermain davestgermain changed the title WIP Rough implementation of metadata endpoint for sequence modules Implementation of metadata endpoint for sequence modules Jan 8, 2020
Copy link
Contributor

@abutterworth abutterworth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@abutterworth
Copy link
Contributor

We also need complete for each item in the sequence. https://github.com/edx/edx-platform/blob/78a520ebbfe8ccd7f5ee9ff4e3979084ce1f7104/common/lib/xmodule/xmodule/seq_module.py#L554 Could this be added easily?

@davestgermain
Copy link
Contributor Author

We also need complete for each item in the sequence.

I added it in. I was concerned that the sequence nav would break in studio, but it didn't. Hurray!

Copy link
Contributor

@ormsbee ormsbee left a 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':
Copy link
Contributor

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.

Copy link
Contributor Author

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:
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@edx-status-bot
Copy link

Your PR has finished running tests. There were no failures.

@davestgermain davestgermain merged commit cfd1e2a into master Jan 15, 2020
@davestgermain davestgermain deleted the dcs/sequence-api branch January 15, 2020 15:33
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

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-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

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-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants