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

Implement delivering client assets for custom elements in shared questions #9786

Merged
merged 47 commits into from
May 28, 2024

Conversation

SethPoulsen
Copy link
Collaborator

@SethPoulsen SethPoulsen commented Apr 29, 2024

partial replacement for #9776

resolves part of #9397

Copy link
Contributor

github-actions bot commented Apr 29, 2024

All images

Image Platform Old Size New Size Change
prairielearn/executor:4c4ae2d8900cc97c9dd39a5d6e12b191f92f8813 null 1187.93 MB 1187.78 MB -0.01%
prairielearn/prairielearn:4c4ae2d8900cc97c9dd39a5d6e12b191f92f8813 linux/amd64 1187.92 MB 1187.78 MB -0.01%

@SethPoulsen SethPoulsen changed the title Implment delivering client assets for custom elements in shared questions Implement delivering client assets for custom elements in shared questions Apr 29, 2024
@SethPoulsen SethPoulsen marked this pull request as ready for review April 29, 2024 22:38
@SethPoulsen
Copy link
Collaborator Author

Do we have any automated tests for the elementFiles endpoint that I should be updating for this?

Copy link
Member

@jonatanschroeder jonatanschroeder left a comment

Choose a reason for hiding this comment

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

I don't think there is an easy solution to the questions I'm bringing here, we can discuss it in our meeting.

apps/prairielearn/src/question-servers/freeform.js Outdated Show resolved Hide resolved
apps/prairielearn/src/pages/elementFiles/elementFiles.js Outdated Show resolved Hide resolved
SethPoulsen and others added 2 commits May 2, 2024 11:11
Co-authored-by: Jonatan Schroeder <jonatan@yorku.ca>
@SethPoulsen
Copy link
Collaborator Author

I'm getting a circular dependency error now:

error no-circular: apps/prairielearn/src/lib/assets.ts → 
      apps/prairielearn/src/pages/elementFiles/elementFiles.js →
      apps/prairielearn/src/lib/question-variant.ts →
      apps/prairielearn/src/question-servers/index.ts →
      apps/prairielearn/src/question-servers/freeform.js →
      apps/prairielearn/src/lib/assets.ts

This was brought about by the fact that I am now using getQuestionCourse in elementFiles.js, which has to be imported from question-variant.ts.

Anyone have recommendations on fixing?

I was surprised that assets.ts is importing elementFiles.js this appears to be so that it can add or remove asset cacheing based on being in dev mode or production mode.

@jonatanschroeder
Copy link
Member

Anyone have recommendations on fixing?

What I've done in the past to fix these was to split a library in two.

I was surprised that assets.ts is importing elementFiles.js this appears to be so that it can add or remove asset cacheing based on being in dev mode or production mode.

I suggest moving the applyMiddleware function in assets.ts to a separate file, possibly in middlewares.

Copy link
Contributor

@nwalters512 nwalters512 left a comment

Choose a reason for hiding this comment

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

Make sure you reformat these files to reorder imports once you resolve the merge conflicts!

apps/prairielearn/src/server.js Outdated Show resolved Hide resolved
apps/prairielearn/src/tests/accessibility/index.test.ts Outdated Show resolved Hide resolved
apps/prairielearn/src/tests/helperQuestionPreview.ts Outdated Show resolved Hide resolved
apps/prairielearn/src/tests/helperQuestionPreview.ts Outdated Show resolved Hide resolved
apps/prairielearn/src/tests/sharedQuestionPreview.test.ts Outdated Show resolved Hide resolved
Copy link

codecov bot commented May 27, 2024

Codecov Report

Attention: Patch coverage is 89.88764% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 67.33%. Comparing base (d6382d6) to head (4c4ae2d).

Files Patch % Lines
apps/prairielearn/src/server.js 75.00% 0 Missing and 6 partials ⚠️
...rairielearn/src/pages/elementFiles/elementFiles.js 86.95% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9786   +/-   ##
=======================================
  Coverage   67.32%   67.33%           
=======================================
  Files         458      458           
  Lines       71419    71503   +84     
  Branches     5756     5770   +14     
=======================================
+ Hits        48081    48144   +63     
- Misses      22909    22921   +12     
- Partials      429      438    +9     

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

Comment on lines +109 to +124
describe('Shared Question Previews Within a Course Instance', function () {
const previewPageInfo = {
siteUrl,
baseUrl,
questionBaseUrl: baseUrl + `/course_instance/2/instructor/question`,
questionPreviewTabUrl: '/preview',
isStudentPage: false,
};

testQuestionPreviews(previewPageInfo, addNumbers, addVectors);

testFileDownloads(previewPageInfo, downloadFile, false);

testElementClientFiles(previewPageInfo, customElement);
});
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In addition to resolving all the PR comments, the latest commits also added these few lines to test question previews under course_instance urls, another thing we haven't had any tests for before now

Copy link
Contributor

@nwalters512 nwalters512 left a comment

Choose a reason for hiding this comment

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

No blockers, but a number of nits that would be nice to address.

apps/prairielearn/src/question-servers/freeform.js Outdated Show resolved Hide resolved
apps/prairielearn/src/tests/helperQuestionPreview.ts Outdated Show resolved Hide resolved
apps/prairielearn/src/tests/instructorQuestions.test.ts Outdated Show resolved Hide resolved
apps/prairielearn/src/server.js Show resolved Hide resolved
@SethPoulsen SethPoulsen added this pull request to the merge queue May 28, 2024
Merged via the queue into master with commit c15fce5 May 28, 2024
9 checks passed
@SethPoulsen SethPoulsen deleted the sharing-element-client-code branch May 28, 2024 22:57
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.

None yet

4 participants