Skip to content

Conversation

@andrii-hantkovskyi
Copy link
Contributor

@andrii-hantkovskyi andrii-hantkovskyi commented Jun 3, 2025

Extend Courseware API with New Fields

This PR extends the Courseware API with several new fields to enhance the course metadata provided to API consumers.
The changes include updates to the serializer, model properties, and comprehensive tests to ensure the correct behavior of each new field.

Key changes:

  • Adds the following fields to the CourseInfoSerializer:
    • show_courseware_link
    • is_course_full
    • can_enroll
    • invitation_only
    • is_shib_course
    • allow_anonymous
    • ecommerce_checkout
    • single_paid_mode
    • ecommerce_checkout_link
    • course_image_urls
    • start_date_is_still_default
    • advertised_start
    • course_price
    • pre_requisite_courses
    • sidebar_html_enabled
    • course_about_section_html
  • Implements corresponding properties on the CoursewareMeta class to provide these fields' values.
  • Adds and updates unit tests to verify that each new field is correctly returned by the API.

These changes provide richer and more detailed course metadata to frontend clients, supporting improved user experiences and new UI features.

Unit and integration tests cover all new fields and confirm correct values based on various course and user scenarios.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jun 3, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented Jun 3, 2025

Thanks for the pull request, @andrii-hantkovskyi!

This repository is currently maintained by @openedx/wg-maintenance-edx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@andrii-hantkovskyi andrii-hantkovskyi force-pushed the rg/axm-course-catalog-extend-courseware-api branch from f389467 to c43e1be Compare June 3, 2025 15:17
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Jun 3, 2025
@andrii-hantkovskyi andrii-hantkovskyi self-assigned this Jun 11, 2025
@andrii-hantkovskyi andrii-hantkovskyi marked this pull request as ready for review June 11, 2025 17:24
@andrii-hantkovskyi
Copy link
Contributor Author

andrii-hantkovskyi commented Jun 11, 2025

Hi @diana-villalvazo-wgu, would you have a chance to review this PR when you have a moment?

@andrii-hantkovskyi andrii-hantkovskyi requested review from diana-villalvazo-wgu and removed request for kdmccormick June 11, 2025 17:40
@kdmccormick
Copy link
Member

Hi @andrii-hantkovskyi , why are you tagging me for review on all of these PRs?

By the way, thank you for making detailed pull request descriptions--they are very helpful--but you should not call them "ADRs". An ADR is separate piece of documentation which you'd write if you were making some decisions that you wanted to record more formally than a PR descrption. ADR info.

@andrii-hantkovskyi
Copy link
Contributor Author

@kdmccormick, sorry for tagging, I thought you were a reviewer for this project as well, have already changed, so sorry

Thank you for the clarification about ADR

@kdmccormick
Copy link
Member

No problem @andrii-hantkovskyi . Glad to see these pages getting converted, best of luck.

advertised_start = serializers.CharField()
course_price = serializers.CharField()
pre_requisite_courses = serializers.ListField(
child=serializers.CharField(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a PrerequisiteCourseSerializer that will return serialized data instead of a string with a tuple?

class PrerequisiteCourseSerializer(serializers.Serializer):
    """
    Serializer for prerequisite course data with key and display name.
    """
    key = serializers.CharField()
    display = serializers.CharField()
Suggested change
child=serializers.CharField(),
child=PrerequisiteCourseSerializer(),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Copy link
Contributor

Choose a reason for hiding this comment

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

Resolved

allow_blank=True,
allow_null=True,
default=None,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a new field display_number_with_default

display_number_with_default = serializers.CharField()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Copy link
Contributor

Choose a reason for hiding this comment

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

Resolved

allow_blank=True,
allow_null=True,
default=None,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add display_org_with_default

org = serializers.CharField(source='display_org_with_default')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Copy link
Contributor

Choose a reason for hiding this comment

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

Resolved



@method_decorator(transaction.non_atomic_requests, name='dispatch')
class CoursewareInformation(RetrieveAPIView):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the docstring and check if all API fields are actually in it

I found the following fields for which the op is missing:

        * content_type_gating_enabled: Whether the content type gating is enabled for the course
        * show_calculator: Whether the calculator should be shown in the course details page
        * can_access_proctored_exams: Whether the user is eligible to access proctored exams
        * notes: An object containing note settings for the course
            * enabled: Boolean indicating whether edxnotes feature is enabled for the course
            * visible: Boolean indicating whether notes are visible in the course
        * marketing_url: The marketing URL for the course

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remember to update this docstring after the final version of the API content is approved

@andrii-hantkovskyi andrii-hantkovskyi changed the title feat: extend courseware api with new fields feat: [FC-86] extend courseware api with new fields Jun 18, 2025
@andrii-hantkovskyi andrii-hantkovskyi force-pushed the rg/axm-course-catalog-extend-courseware-api branch from cbc169b to ca43788 Compare June 19, 2025 14:55
Comment on lines 662 to 663
* ocw_links: A list of OpenCourseWare links for the course
* prerequisites: A list of prerequisite courses for the course
Copy link
Contributor

@PKulkoRaccoonGang PKulkoRaccoonGang Jun 24, 2025

Choose a reason for hiding this comment

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

I managed to get data for the prerequisites field through the settings on the Schedule & Details, but on the legacy page nothing is displayed in the sidebar. This may indicate that the API is returning data in an incorrect format. Could you check this?

Template

    "prerequisites": [
        "course-v1:openedx2+123+2024"
    ]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

* studio_url: The URL to the course in Studio, if the user is staff
* is_cosmetic_price_enabled: Boolean indicating whether the cosmetic price feature is enabled
* overview: The overview HTML content for the course
* ocw_links: A list of OpenCourseWare links for the course
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add some test instructions or an explanation of how to get the data for ocw_links? I'm not entirely sure where the data for ocw_links comes from.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ocw_links is a part of the course about section, but as far as I see, it's not configurable right now

@andrii-hantkovskyi andrii-hantkovskyi force-pushed the rg/axm-course-catalog-extend-courseware-api branch from 0e1aa04 to 3c47f1c Compare June 24, 2025 12:07
Copy link
Contributor

@PKulkoRaccoonGang PKulkoRaccoonGang left a comment

Choose a reason for hiding this comment

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

I reviewed this PR and left some comments. Some fields in this API need additional validation (as per Brian's question in [DEPR]: Deprecation of Prerequisites and OCW Links sections) and Catalog About Page API Design.

allow_blank=True,
allow_null=True,
default=None,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Resolved

advertised_start = serializers.CharField()
course_price = serializers.CharField()
pre_requisite_courses = serializers.ListField(
child=serializers.CharField(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Resolved

start_date_is_still_default = serializers.BooleanField()
advertised_start = serializers.CharField()
course_price = serializers.CharField()
pre_requisite_courses = serializers.ListField(
Copy link
Contributor

Choose a reason for hiding this comment

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

We have DEPR for fields prerequisites and ocw_links, we need to:

  1. ensure that these fields really do not have corresponding BE logic
  2. reply to the comment left in this DEPR
  3. remove unnecessary fields from this serializer

Copy link
Contributor

Choose a reason for hiding this comment

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

After some investigation, I can confirm that there is no BE logic that would populate these two fields. I left a reply in the DEPR and updated this PR accordingly.

allow_blank=True,
allow_null=True,
default=None,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Resolved

return get_course_about_section(self.request, self.course, "overview")

@property
def ocw_links(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding the prerequisites and ocw_links fields, we will need to decide whether we leave them in this view after discussions in this DEPR

Copy link
Contributor

Choose a reason for hiding this comment

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

I left a reply in the DEPR concerning theses two fields - it looks like we can remove them. I updated the PR accordingly.

return get_prerequisite_courses_display(self.course)

@property
def about_sidebar_html(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the discussions in Catalog About Page API Design, it was decided to change sidebar_html_enabled (WaffleSwitch "course_experience.enable_about_sidebar_html) sidebar content via frontend plugin slots. It seems that we don't need this field in the serializer anymore.



@method_decorator(transaction.non_atomic_requests, name='dispatch')
class CoursewareInformation(RetrieveAPIView):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remember to update this docstring after the final version of the API content is approved

@feanil
Copy link
Contributor

feanil commented Sep 2, 2025

Once the DEPR related work is done, do you need me to merge this or does someone on your team have merge rights?

@Serj-N Serj-N force-pushed the rg/axm-course-catalog-extend-courseware-api branch from 447f071 to 84f0690 Compare September 3, 2025 10:05
@sarina
Copy link
Contributor

sarina commented Sep 3, 2025

@feanil looks like it would be great if you could provide the merge when this is ready
image

@sarina
Copy link
Contributor

sarina commented Sep 3, 2025

@Serj-N looks like the tests weren't updated after the last two commits, could you address?

@Serj-N Serj-N force-pushed the rg/axm-course-catalog-extend-courseware-api branch 2 times, most recently from c98fd28 to a41dcb7 Compare September 4, 2025 08:58
@Serj-N
Copy link
Contributor

Serj-N commented Sep 4, 2025

@Serj-N looks like the tests weren't updated after the last two commits, could you address?

@sarina Sure thing, the tests have been fixed now.

@Serj-N Serj-N force-pushed the rg/axm-course-catalog-extend-courseware-api branch from a41dcb7 to ed69cb5 Compare September 4, 2025 11:09
@sarina
Copy link
Contributor

sarina commented Sep 4, 2025

@PKulkoRaccoonGang @NiedielnitsevIvan are your concerns addressed?

@feanil feanil dismissed stale reviews from NiedielnitsevIvan and PKulkoRaccoonGang September 4, 2025 13:45

The comments from the review have been resolved.

@feanil feanil merged commit 06b54e7 into openedx:master Sep 4, 2025
89 of 97 checks passed
@github-project-automation github-project-automation bot moved this from Waiting on Author to Done in Contributions Sep 4, 2025
@edx-pipeline-bot
Copy link
Contributor

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

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

@nsprenkle
Copy link
Contributor

nsprenkle commented Sep 9, 2025

Hey 👋 just writing to say that I've identified a bug with this PR.

I have a resolution here #37338 that I'm rushing out since it is currently causing production outages for us but I'd like to ask your help updating the test suites to cover those cases that weren't caught in unit testing

@andrii-hantkovskyi / @PKulkoRaccoonGang

@cmltaWt0
Copy link
Contributor

cmltaWt0 commented Sep 9, 2025

Hey 👋 just writing to say that I've identified a bug with this PR.

I have a resolution here #37338 that I'm rushing out since it is currently causing production outages for us but I'd like to ask your help updating the test suites to cover those cases that weren't caught in unit testing

@andrii-hantkovskyi / @PKulkoRaccoonGang

Hey @nsprenkle.
Sad to hear that. Is adding additional tests blocks the fix PR to be merged?
We will definitely help to add new tests, just asking about timing.

@sarina
Copy link
Contributor

sarina commented Sep 9, 2025

@nsprenkle am I correct that what broke was the ecommerce service that is deprecated on the Open edX side? If so I'm not entirely sure how we would even go about testing this.

@feanil
Copy link
Contributor

feanil commented Sep 12, 2025

@cmltaWt0 I think we can add the tests after the fact for possible null values for that field. Especially since it's from a deprecated system, that makes sense that it could be null sometimes. The bug fix has already merged so I think we just need to get the tests landed.

It looks like the bug is in this test. We should split this into to tests and explicitly make sure we allow null values like the upstream objects could produce.

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

Labels

FC Relates to an Axim Funded Contribution project open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.