Skip to content

Conversation

@jawad-khan
Copy link
Member

@jawad-khan jawad-khan commented Jul 22, 2024

Description

Enable courseware access api for all types of course(expired, closed, not started yet etc)

Useful information to include:

  • This will effect all mobile app users.

Supporting information

Jira Ticket: https://2u-internal.atlassian.net/browse/LEARNER-10121

Sample response data that this api should return

{
  "id": "course-v1:IB12T21",
  "course_updates": {course-updates-url},
  "course_handouts":{{course-handouts-url}},
  "discussion_url": {discussion-url},
  "course_access_details": {
    "has_unmet_prerequisites": false,
    "is_too_early": false,
    "is_staff": true,
    "audit_access_expires": null,
    "courseware_access": {
      "has_access": true,
      "error_code": null,
      "developer_message": null,
      "user_message": null,
      "additional_context_user_message": null,
      "user_fragment": null
    }
  },
  "certificate": {
    
  },
  "enrollment_details": {
    "mode": "",
    "is_active": false
  },
  "course_info_overview": {
      "name": "Introduction to Data Science",
  "number": "Abc",
  "org": "IBM",
  "start": "2021-07-01T16:00:00Z",
  "start_display": "July 1, 2021",
  "start_type": "timestamp",
  "end": "2023-10-16T16:00:00Z",
  "is_self_paced": true,
  "media": {
    "image": {
      "raw": "/asset-v1+_image.png",
      "small": "/asset-v1.jpg",
      "large": "/a.jpg"
    }
  },
  "course_sharing_utm_parameters": {
    "facebook": "utm_medium=social&utm_campaign=social-sharing-db&utm_source=facebook",
    "twitter": "utm_medium=social&utm_campaign=social-sharing-db&utm_source=twitter"
  },
  "course_about": {course-about-url},
  "course_modes": [
    {
      "slug": "audit",
      "sku": "5479",
      "android_sku": null,
      "ios_sku": null,
      "min_price": 0
    }
  ]
  }
}

Testing instructions

Call api /api/mobile/{api_version}/course_info/{course_id}/enrollment_details
and compare data with expected data given above.

Deadline

"ASAP".

@jawad-khan jawad-khan force-pushed the jawad/LEARNER-10121 branch from af6cf8c to 02416f8 Compare July 23, 2024 14:19

@patch('lms.djangoapps.mobile_api.course_info.utils.certificate_downloadable_status')
def test_course_not_started(self, mock_certificate_downloadable_status):
""" Test course data whic is not started yet """
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, typo: "Test course data which has not started yet"


@patch('lms.djangoapps.mobile_api.course_info.utils.certificate_downloadable_status')
def test_course_closed(self, mock_certificate_downloadable_status):
""" Test course data whic is not started yet """
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Is this bad copy-paste? Should the description for this test be different than the above unit test?


@patch('lms.djangoapps.mobile_api.course_info.utils.certificate_downloadable_status')
def test_invalid_course_id(self, mock_certificate_downloadable_status):
""" Test course data whic is not started yet """
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Bad copy-paste again for test description.


response = self.client.get(path=url)
assert response.status_code == 400
assert response.data['error']
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Should we validate the contents of the error message are what we expect?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we're missing one more unit test, for the case where the course_id is missing from the request, to cover lines 431-432 in ../course_info/views.py

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried to build this url but because of re pattern we will get page not found. Therefore I have removed that check from view.

Copy link
Contributor

@justinhynes justinhynes left a comment

Choose a reason for hiding this comment

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

I think we're missing one unit test for the new functionality, please see my comment in test_course_info_views.py.

@jawad-khan jawad-khan force-pushed the jawad/LEARNER-10121 branch from 02416f8 to 73ef648 Compare July 23, 2024 19:57
@jawad-khan
Copy link
Member Author

I think we're missing one unit test for the new functionality, please see my comment in test_course_info_views.py.

After this change that new case isn't required anymore.

Copy link
Contributor

@justinhynes justinhynes left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comments!

@jawad-khan jawad-khan merged commit b77b90a into master Jul 23, 2024
@jawad-khan jawad-khan deleted the jawad/LEARNER-10121 branch July 23, 2024 20:40
@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.

mudassir-hafeez pushed a commit to mudassir-hafeez/edx-platform that referenced this pull request Jul 24, 2024
openedx#35155)

* fix: Enable courseware access api for all types of course(expired, closed etc)
mudassir-hafeez pushed a commit to mudassir-hafeez/edx-platform that referenced this pull request Jul 24, 2024
openedx#35155)

* fix: Enable courseware access api for all types of course(expired, closed etc)
mudassir-hafeez pushed a commit to mudassir-hafeez/edx-platform that referenced this pull request Jul 24, 2024
openedx#35155)

* fix: Enable courseware access api for all types of course(expired, closed etc)
mudassir-hafeez pushed a commit to mudassir-hafeez/edx-platform that referenced this pull request Jul 24, 2024
openedx#35155)

* fix: Enable courseware access api for all types of course(expired, closed etc)
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.

4 participants