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

Validating A levels when publishing for teacher degree apprenticeship courses #4339

Merged

Conversation

tomas-stefano
Copy link
Contributor

Context

We need to add a validation for the A levels when publishing a course.

Trello card & Lucid board

https://trello.com/c/BzbwKssS/1895-a-level-validation-when-publishing-a-course
https://lucid.app/lucidspark/ba759696-865b-46b4-ab23-9d3af92d79fb/edit?view_items=ohfKW2nmrz23&invitationId=inv_fa1f4bfe-7a1f-49d1-ae9c-1e46971e8f85

Changes proposed in this pull request

Please see trello card AND the lucid board for more details.

Guidance to review

I added the option render_errors: with default being true to avoid breaking existing code but passing false to A levels Because:

  • The A levels are a multi step form and I need to inject the error on the row in any way is described in the card
  • The row has the wizard step name attached to the link so different from the way GCSEs or degrees or others are doing when publishing
  1. Is it working all the validations?
  2. Is it working all the content?
  3. Is it working all the error links?
  4. When you click the link does it show the error validation in the page?

We need to add a validation for the A levels when publishing a course.

I added the option render_errors: with default being true to avoid
breaking existing code but passing false to A levels Because:

* The A levels are a multi step form and I need to inject the error
on the row in any way is described in the card
* The row has the wizard step name attached to the link so different
from the way GCSEs or degrees or others are doing when publishing
@tomas-stefano tomas-stefano requested a review from a team July 3, 2024 14:34
@tomas-stefano tomas-stefano changed the title Validating A levels when the course is teacher degree apprenticeship Validating A levels when publishing for teacher degree apprenticeship courses Jul 3, 2024
if fields.any? { |field| @errors&.key? field.to_sym }
errors = fields.map do |field|
@errors[field.to_sym]&.map { |error| enrichment_error_link(model, field, error) }
end.flatten

value = raw(*errors)
value = raw(*errors) if render_errors.present?
Copy link
Contributor Author

@tomas-stefano tomas-stefano Jul 3, 2024

Choose a reason for hiding this comment

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

Avoiding the automatic behaviour because on the row, the error message is slightly different on A level since the A levels is the only multi step form in the course description tab. Unfortunately I have to do this to follow the same pattern but avoiding undesirable results.


return record.errors.add(:accept_pending_a_level, :blank) if record.accept_pending_a_level.nil?

record.errors.add(:accept_a_level_equivalency, :blank) if record.accept_a_level_equivalency.nil?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The validations are sequential (meaning one at a time), so I opt-in to add a custom validator.

@tomas-stefano
Copy link
Contributor Author

If you click on the error and goes to the wizard the back links are like if you're navigating within the wizard. I will leave as it is and wait for tomorrow bug party and I will talk with the designer about it.

Copy link
Contributor

@elceebee elceebee left a comment

Choose a reason for hiding this comment

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

Tested locally and everything works as expected. nice work!

@tomas-stefano
Copy link
Contributor Author

thank you @elceebee , I appreciate 🙏

@tomas-stefano tomas-stefano merged commit 11a39a7 into main Jul 3, 2024
19 checks passed
@tomas-stefano tomas-stefano deleted the 1895-a-level-validation-when-publishing-a-course branch July 3, 2024 16:16
@tomas-stefano
Copy link
Contributor Author

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.

3 participants