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

fix: pollAttempt call on download page #113

Merged
merged 3 commits into from
Aug 7, 2023

Conversation

Zacharis278
Copy link
Contributor

MST-1951

pair PR with edx/frontend-app-exams-dashboard#11

The network call made by the download interstitial is a bit of a special snowflake it bypasses the thunk and calls the api directly. Added support to the existing 'poll' function to support requesting a specific exam by sequence id in this case.

@codecov
Copy link

codecov bot commented Aug 4, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.06% ⚠️

Comparison is base (f6228ed) 93.84% compared to head (9645672) 93.78%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #113      +/-   ##
==========================================
- Coverage   93.84%   93.78%   -0.06%     
==========================================
  Files          71       71              
  Lines        1023     1030       +7     
  Branches      280      281       +1     
==========================================
+ Hits          960      966       +6     
- Misses         58       59       +1     
  Partials        5        5              
Files Changed Coverage Δ
src/data/api.js 98.00% <100.00%> (-2.00%) ⬇️
...ons/proctored_exam/download-instructions/index.jsx 84.44% <100.00%> (ø)

... and 1 file with indirect coverage changes

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

@Zacharis278 Zacharis278 force-pushed the zhancock/latest-attempt-fix branch 3 times, most recently from 1ab724f to 2815b5c Compare August 4, 2023 19:51
const activeAttemptUrl = new URL(`${getConfig().EXAMS_BASE_URL}/api/v1/exams/attempt/latest`);
const activeAttemptResponse = await getAuthenticatedHttpClient().get(activeAttemptUrl.href);
return activeAttemptResponse.data;
}

async function fetchLatestExamAttempt(sequenceId) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

basically the same thing as the above function. I broke this out to make reading the behavior a bit easier

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be worth adding a comment noting this so that people don't confused by these functions having similar functionality later on?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea 👍

@@ -50,7 +50,7 @@ const DownloadSoftwareProctoredExamInstructions = ({ intl, skipProctoredExam })
? `${getConfig().EXAMS_BASE_URL}/lti/start_proctoring/${attemptId}` : downloadUrl;

const handleDownloadClick = () => {
pollExamAttempt(`${pollUrl}?sourceid=instructions`)
pollExamAttempt(pollUrl, sequenceId)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

sourceid=instructions doesn't do anything. Was just copied behavior from the old frontend.

Copy link
Contributor

@ilee2u ilee2u left a comment

Choose a reason for hiding this comment

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

Just a couple of small things, otherwise LGTM

src/data/api.js Outdated

// Update dictionaries returned by edx-exams to have correct status key for legacy compatibility
if (data.attempt_status) {
data.status = data.attempt_status;
delete data.attempt_status;
}
} else {
logError('pollExamAttempt called but no pollUrl is set');
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this error msg could be improved by describing that we intended to call the legacy system specifically (which from what I can tell is what requires the pollUrl value), not just this API function.

const activeAttemptUrl = new URL(`${getConfig().EXAMS_BASE_URL}/api/v1/exams/attempt/latest`);
const activeAttemptResponse = await getAuthenticatedHttpClient().get(activeAttemptUrl.href);
return activeAttemptResponse.data;
}

async function fetchLatestExamAttempt(sequenceId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be worth adding a comment noting this so that people don't confused by these functions having similar functionality later on?

@Zacharis278 Zacharis278 force-pushed the zhancock/latest-attempt-fix branch 2 times, most recently from af1abf7 to e3f3221 Compare August 7, 2023 17:36
@Zacharis278 Zacharis278 merged commit 8b0f15c into main Aug 7, 2023
6 checks passed
@Zacharis278 Zacharis278 deleted the zhancock/latest-attempt-fix branch August 7, 2023 19:19
@github-actions
Copy link

github-actions bot commented Aug 7, 2023

🎉 This PR is included in version 2.20.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

pedromartello pushed a commit to hammerlabs-net/frontend-lib-special-exams that referenced this pull request Aug 31, 2023
* fix: pollAttempt call on download page

* feat: review cleanup

* fix: string format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants