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

Validation for section with participant type #44271

Merged
merged 8 commits into from
Jan 26, 2022

Conversation

dmcavoy
Copy link
Contributor

@dmcavoy dmcavoy commented Jan 7, 2022

Adds a bunch of validation and conditions on the new participant_type field for sections:

  • Make sure users can only join sections where the user meets the participant_type

Screen Shot 2022-01-24 at 9 56 11 PM

  • Make sure users can only transfer to sections where the user meets the participant_type

Screen Shot 2022-01-24 at 9 58 59 PM

  • Make sure sections with participant_type other than student can only use email logins
  • Make sure participant_type of a section can not be changed once set

Links

Eng Plan
Product Spec

Testing story

  • I checked and there are currently no sections assigned to scripts on production where the script has a participant audience other than student
  • Added a bunch of new unit tests
  • Manual testing you can see in pictures above

@dmcavoy dmcavoy requested a review from a team as a code owner January 8, 2022 02:36
@dmcavoy dmcavoy requested a review from a team January 25, 2022 16:27
@davidsbailey davidsbailey removed the request for review from a team January 25, 2022 18:13
@davidsbailey
Copy link
Member

my top-level feedback is that the UI error messages sound a bit too technical to be understood by the user. Are these strings coming from the spec? if not, can we get some input from Tess? Of course, making better error messages could mean more work (e.g. to differentiate between "this course is only available for teachers" vs "students")

Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

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

LGTM

if you can't get PM input on the error messages right now that seems ok, those can always be improved later.

if participant_type_changed? && persisted?
errors.add(:participant_type, "can not be update once set.")
end
end
Copy link
Member

Choose a reason for hiding this comment

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

nice validations 👍

elsif participant_type == SharedCourseConstants::PARTICIPANT_AUDIENCE.teacher
return user.teacher?
elsif participant_type == SharedCourseConstants::PARTICIPANT_AUDIENCE.student
return true #if participant_type is student let anyone join
Copy link
Member

Choose a reason for hiding this comment

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

This comment looks off because it is saying what the code is doing (pretty clear in this case) instead of why it is doing it. It seems like the point of this comment is to remind people that you do not actually have to exactly match the participant type in order to be eligible, is that correct? if so, I would suggest removing this comment and augmenting the method-level comment to say something like: "participant does not have to exactly match the participant type to join the section, for example facilitators can join any section and anyone can join a student section."

https://blog.codinghorror.com/code-tells-you-how-comments-tell-you-why/

@dmcavoy
Copy link
Contributor Author

dmcavoy commented Jan 26, 2022

I'm going to merge this now. I have asked for Tess input on the error strings but since nobody can set a section to a participant type other than student right now nobody should see them yet.

@dmcavoy dmcavoy merged commit 860a932 into staging Jan 26, 2022
@dmcavoy dmcavoy deleted the section-with-participant-type branch January 26, 2022 19:06
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.

None yet

2 participants