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

feat: Enable copying of publicly shared question code (if allowed by instructor) #9800

Merged
merged 12 commits into from
May 30, 2024

Conversation

SethPoulsen
Copy link
Collaborator

implements parts of #9397

Copy link
Contributor

github-actions bot commented May 1, 2024

All images

Image Platform Old Size New Size Change
prairielearn/executor:43299d226721738ce837a1bb76ce964770acd2f4 null 1189.94 MB 1189.94 MB 0.00%
prairielearn/prairielearn:43299d226721738ce837a1bb76ce964770acd2f4 linux/amd64 1189.94 MB 1189.94 MB -0.00%

@SethPoulsen SethPoulsen marked this pull request as ready for review May 28, 2024 00:58
@SethPoulsen
Copy link
Collaborator Author

I am aware that this doesn't actually make a way to mark the publicly_shared_source column as true in the database.

Doing that is going to be a bunch of UI design/mess on the question settings page, I thought it would be nice to do that in a separate PR from this.

Copy link

codecov bot commented May 28, 2024

Codecov Report

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

Project coverage is 67.40%. Comparing base (7d1feb5) to head (43299d2).

Files Patch % Lines
...CopyPublicQuestion/instructorCopyPublicQuestion.ts 0.00% 2 Missing ⚠️
apps/prairielearn/src/server.js 75.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9800      +/-   ##
==========================================
- Coverage   67.40%   67.40%   -0.01%     
==========================================
  Files         458      458              
  Lines       71712    71715       +3     
  Branches     5786     5782       -4     
==========================================
+ Hits        48336    48338       +2     
- Misses      22939    22940       +1     
  Partials      437      437              

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

Comment on lines 1879 to 1914
'/pl/course/:course_id(\\d+)/copy_template_course_question',
(
await import(
'./pages/instructorCopyTemplateCourseQuestion/instructorCopyTemplateCourseQuestion.js'
)
).default,
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing a route like this is generally not safe; what happens when someone tries to copy a question during a deploy? I agree that we want to rename this route, but we should do it with roughly the same strategy we'd use for any database columns:

  • Add the new route; deploy
  • Update anything referencing the old route to instead point to the new route; deploy
  • Remove the old route

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good. I'll put the new route (and leave the old route) in this PR, and make follow-up PRs to do the other things.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done here:

#9918
#9919

@SethPoulsen
Copy link
Collaborator Author

I created the following two PRs to complete deprecating the old copy endpoint:

#9918
#9919

@@ -19,7 +19,7 @@ const sql = sqldb.loadSqlEquiv(import.meta.url);
export async function setQuestionCopyTargets(res: Response) {
// Avoid querying for editable courses if we won't be able to copy this
// question anyways.
if (!res.locals.course.template_course) {
if (!(res.locals.course.template_course || res.locals.question.shared_publicly_with_source)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Total nit: IMO the version of this where ! is distributed is easier to parse, what do you think?

Suggested change
if (!(res.locals.course.template_course || res.locals.question.shared_publicly_with_source)) {
if (!res.locals.course.template_course && !res.locals.question.shared_publicly_with_source) {

Ditto for the similar conditional on the instructorCopyPublicQuestion page. Feel free to ignore if you disagree.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It doesn't really matter to me either way, I'm happy to change it though.

@SethPoulsen SethPoulsen added this pull request to the merge queue May 30, 2024
Merged via the queue into master with commit 8adc651 May 30, 2024
9 checks passed
@SethPoulsen SethPoulsen deleted the public-sharing-copy branch May 30, 2024 22:25
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

3 participants