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

Add co-teacher input field #54392

Merged
merged 51 commits into from
Oct 24, 2023
Merged

Add co-teacher input field #54392

merged 51 commits into from
Oct 24, 2023

Conversation

lfryemason
Copy link
Contributor

@lfryemason lfryemason commented Oct 20, 2023

Adds an input field to add a coteacher to a section for edit and create new section.
image (3)
image (2)
image (1)

Note: does not currently hook up to the validation endpoint. That will be a FLUP PR.

Links

Testing story

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@lfryemason lfryemason changed the title Add coteacher input field [WIP] Add coteacher input field Oct 20, 2023
@lfryemason lfryemason changed the title [WIP] Add coteacher input field Add co-teacher input field Oct 20, 2023
@lfryemason lfryemason marked this pull request as ready for review October 23, 2023 18:31
@lfryemason lfryemason requested a review from a team as a code owner October 23, 2023 18:31
const handleAddEmail = e => {
e.preventDefault();
const newEmail = inputValue;
console.log(sectionInstructors);
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this console.log snuck in the final PR :)

@@ -484,6 +484,13 @@
"coteacherAdd": "Add Co-Teachers",
"coteacherAddTooltip": "Co-teachers have the same access as you in managing this section and viewing student work. Co-teachers will see the invitation on their teacher dashboard.",
"coteacherAddInfo": "Add co-teachers by entering the email address associated with their Code.org account in the field below. Each section can have up to five co-teachers.",
"coteacherAddNoEmail": "Please enter an email address.",
"coteacherAddInvalidEmail": "{email} is not a valid email address.",
"coteacherAddAlreadyExists": "{email} is already a co-teacher for this section.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking, I know this is more of a design question, but if I were a teacher who got this error, my next question question would be "now what?" - do we have a tool tip or something that directs a teacher to do something if they get this error? Something like "The co-teacher with this email address has already been notified and can find their invitations at X"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Below the input there will be a table including the names/emails and statuses of all the coteacher invitations. So the teacher would be able to look down at the table and see whether that teacher has already accepted, has declined or needs to accept.

Copy link
Contributor

@etaderhold etaderhold left a comment

Choose a reason for hiding this comment

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

Nice start!

apps/src/templates/sectionsRefresh/CoteacherSettings.jsx Outdated Show resolved Hide resolved

// coteacher count is teachers to add + the existing teachers - the primary teacher.
const numCoteachers = useMemo(
() => sectionInstructors.length + coteachersToAdd.length - 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Is there any case where either sectionInstructors or coteachersToAdd might be null or otherwise not-arrays, making this calculation problematic?
  2. Will this be off by 1 when creating a new section and there isn't a sectionInstructors entry for the main instructor yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. coteachersToAdd will never be null, but I did need to add some checking for sectionInstructors
  2. fixed

() => <div>{i18n.coteacherAddInfo()}</div>,
() => (
<CoteacherSettings
sectionInstructors={sections[0].sectionInstructors}
Copy link
Contributor

Choose a reason for hiding this comment

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

At first glance this looks suspiciously like it might fail when editing something other than one's first section, but then I see this pattern repeated elsewhere in this file. Is sections always a one-element array? If so, any reason we couldn't get rid of the array and switch all the sections[0] references to simply section?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is because we eventually want to allow multiple sections to be created on the same form. Let's keep this around

};

// coteacher count is teachers to add + the existing teachers - the primary teacher.
const numCoteachers = useMemo(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to use useMemo here? It seems like this is getting passed down directly from the props. I should mention I have never used useMemo before so I am just applying it for the first time in this review. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. I thought it was useful for every time you are making a computation that doesn't need to change every render, but it seems like it also isn't necessary for short and small computations. If you are interested, I thought this blog post was an interesting read

Copy link
Contributor

@kobryan0619 kobryan0619 left a comment

Choose a reason for hiding this comment

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

I left a few notes - I am brand new to useMemo so I might recommend having someone with more knowledge of it take a look. So exciting to get this feature out there to folks!

lfryemason and others added 2 commits October 24, 2023 12:39
Co-authored-by: Eric Aderhold <eric.aderhold@code.org>
@lfryemason lfryemason merged commit 2dfdecb into staging Oct 24, 2023
2 checks passed
@lfryemason lfryemason deleted the lfm/co-input-1 branch October 24, 2023 22:56
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