Skip to content

add page to dashboard for batch printing of certificates - #48000

Merged
davidsbailey merged 27 commits into
stagingfrom
certificates-batch
Sep 13, 2022
Merged

add page to dashboard for batch printing of certificates#48000
davidsbailey merged 27 commits into
stagingfrom
certificates-batch

Conversation

@davidsbailey

@davidsbailey davidsbailey commented Sep 8, 2022

Copy link
Copy Markdown
Member

Starts PLAT-1533. Sets up the new batch certificate pages on dashboard. The next PR will make existing pages on pegasus redirect here and will make teacher dashboard link here. See requirement #5 and background image 4 in the spec. This implements the highlighted part of the diagram seen in the work plan:
Screen Shot 2022-09-13 at 10 21 00 AM

screenshots

new behavior

basic functionality (saucelabs video):

print-certificates-uitest.mp4

instructions are hidden when printing:

Screen Shot 2022-09-12 at 7 42 45 PM

when a student tries to access studio.code.org/certificates/batch:

Screen Shot 2022-09-12 at 6 31 49 PM

before & after

configure certificates

Screen Shot 2022-09-12 at 7 35 52 PM

print certificates

Screen Shot 2022-09-12 at 8 18 44 PM

Testing story

new unit tests, ui tests and eyes tests, plus existing test coverage.

the one thing that doesn't have a good unit test is the CertificateBatch react component. This is difficult to test because the implementation uses a form post rather than an ajax request, and form posts cannot be stubbed out with sinon. however the component is very simple and its behavior is well covered by the UI test, so it doesn't quite seem worth upgrading to an ajax-based approach until/unless we plan to do a lot more here to upgrade the component.

Deployment strategy

Safe to deploy this PR without experiment flag since no traffic is pointing to it yet. the next PR will only link/redirect to this page conditionally, based on the experiment flag.

Follow-up work

note that the new page prints "hourofcode" (the script name) instead of "Hour of Code" (the script display name). This is covered by https://codedotorg.atlassian.net/browse/PLAT-1888 and will be fixed before the experiment is launched.

@davidsbailey
davidsbailey force-pushed the certificates-batch branch 2 times, most recently from 7d19ce6 to e27155e Compare September 9, 2022 19:09
@davidsbailey davidsbailey changed the title Certificates batch add page for batch printing of certificates to dashboard Sep 13, 2022
@davidsbailey davidsbailey changed the title add page for batch printing of certificates to dashboard add page to dashboard for batch printing of certificates Sep 13, 2022
@davidsbailey
davidsbailey marked this pull request as ready for review September 13, 2022 06:15
@davidsbailey
davidsbailey requested a review from a team as a code owner September 13, 2022 06:15
@davidsbailey
davidsbailey requested review from tess323 and removed request for a team September 13, 2022 06:15
#certificate-batch {
p {
font-size: inherit;
line-height: inherit;

@davidsbailey davidsbailey Sep 13, 2022

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is to override these styles:

p, ol, ul, td {
font-size: 13px;
line-height: 18px;

without this, SafeMarkdown renders p elements whose font size and line height can not be overridden by the parent component.

@davidsbailey
davidsbailey requested review from a team September 13, 2022 17:16
@tess323

tess323 commented Sep 13, 2022

Copy link
Copy Markdown

LGTM thanks Dave!

Comment thread apps/Gruntfile.js
view_options(no_header: true, no_footer: true, white_background: true, full_width: true)

student_names = params[:studentNames]&.split("\n")&.map(&:strip)&.shift(30)
course_name = params[:courseName].presence || ScriptConstants::HOC_NAME

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

TIL about presence!

def batch
view_options(no_header: true, no_footer: true, white_background: true, full_width: true)

student_names = params[:studentNames]&.split("\n")&.map(&:strip)&.shift(30)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I see the instruction above that this will only print 30 names, but it looks like this will still "work" if there are more than 30 names, with no warning that some names didn't get printed. Is there a plan for a warning/error?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm also curious where this limit comes from –– teachers can easily have 120 students

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

good points. to answer questions literally:

  1. there is this "warning" ahead of time:
    Screen Shot 2022-09-13 at 12 50 49 PM

  2. there is not a plan to add a better warning here. the specced behavior is just to match parity with the existing pages.

I'm not sure where the earlier limit came from, but I think we do want some upper bound, since generating images can be expensive for our servers, and attacks are often measured by how much load you can put on a server per web request.

@tess323 do you have a thought here on whether a better warning experience is worth doing?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Got it, sounds good!

export default function CertificateBatch({courseName, imageUrl}) {
return (
<div style={styles.wrapper}>
<h1>Print a batch of certificates</h1>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be translated?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oops, yes, thanks!

@megcrenshaw megcrenshaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants