Skip to content
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

refactor: handle relative proctoring link #974

Conversation

navinkarkera
Copy link
Contributor

Description

If proctoring link is not an absolute url, update it to use studio as base url.

Supporting information

Private-ref: BB-8832

@navinkarkera navinkarkera requested a review from a team as a code owner May 2, 2024 14:32
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label May 2, 2024
@openedx-webhooks
Copy link

Thanks for the pull request, @navinkarkera! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

1 similar comment
@openedx-webhooks
Copy link

Thanks for the pull request, @navinkarkera! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

if (proctoringExamConfigurationLink && !(
proctoringExamConfigurationLink.indexOf('http://') === 0 || proctoringExamConfigurationLink.indexOf('https://') === 0
)) {
fullProctoringExamConfigurationLink = new URL(proctoringExamConfigurationLink, getConfig().STUDIO_BASE_URL).href;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
fullProctoringExamConfigurationLink = new URL(proctoringExamConfigurationLink, getConfig().STUDIO_BASE_URL).href;
fullProctoringExamConfigurationLink = () => new URL(proctoringExamConfigurationLink, getConfig().STUDIO_BASE_URL).href;

Copy link
Member

Choose a reason for hiding this comment

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

There are known issues with Tutor where the variable will not generate the link unless new URL is called as the return of a function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KristinAoki Thanks! updated.

Copy link

codecov bot commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.20%. Comparing base (65f45f7) to head (3e74e63).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #974   +/-   ##
=======================================
  Coverage   92.20%   92.20%           
=======================================
  Files         703      703           
  Lines       12334    12336    +2     
  Branches     2671     2665    -6     
=======================================
+ Hits        11372    11374    +2     
  Misses        926      926           
  Partials       36       36           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@navinkarkera navinkarkera force-pushed the navin/course-outline/proctoring-link-fix branch from 03f362a to c0368d2 Compare May 2, 2024 14:49
Comment on lines 64 to 75
let fullProctoringExamConfigurationLink = () => proctoringExamConfigurationLink;

// check if proctoringExamConfigurationLink is a relative link
if (proctoringExamConfigurationLink && !(
proctoringExamConfigurationLink.indexOf('http://') === 0 || proctoringExamConfigurationLink.indexOf('https://') === 0
)) {
// new URL needs to called inside a function for tutor
fullProctoringExamConfigurationLink = () => new URL(
proctoringExamConfigurationLink,
getConfig().STUDIO_BASE_URL,
).href;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I this this code is more complex than it needs to be.

Suggested change
let fullProctoringExamConfigurationLink = () => proctoringExamConfigurationLink;
// check if proctoringExamConfigurationLink is a relative link
if (proctoringExamConfigurationLink && !(
proctoringExamConfigurationLink.indexOf('http://') === 0 || proctoringExamConfigurationLink.indexOf('https://') === 0
)) {
// new URL needs to called inside a function for tutor
fullProctoringExamConfigurationLink = () => new URL(
proctoringExamConfigurationLink,
getConfig().STUDIO_BASE_URL,
).href;
}
const fullProctoringExamConfigurationLink = () => (
proctoringExamConfigurationLink && new URL(proctoringExamConfigurationLink, getConfig().STUDIO_BASE_URL.href;
);

If the link is defined, and is relative then this will make the url relative to the studio base. If it's not a relative url it will override the base url.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also not sure why this needs to be a function, nothing that runs in it should change between the component being mounted and the function being called.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xitij2000 Thanks! updated.

I'm also not sure why this needs to be a function, nothing that runs in it should change between the component being mounted and the function being called.

Same here. @KristinAoki Do we have a link or a PR which explains this tutor related bug?

Copy link
Member

Choose a reason for hiding this comment

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

@navinkarkera navinkarkera force-pushed the navin/course-outline/proctoring-link-fix branch from c0368d2 to 3e74e63 Compare May 3, 2024 09:20
Copy link
Contributor

@xitij2000 xitij2000 left a comment

Choose a reason for hiding this comment

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

👍

  • I tested this: tested on tutor devstack
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

@xitij2000 xitij2000 merged commit 087c82c into openedx:master May 7, 2024
6 checks passed
@openedx-webhooks
Copy link

@navinkarkera 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@xitij2000 xitij2000 deleted the navin/course-outline/proctoring-link-fix branch May 7, 2024 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

4 participants