-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix: validation and error display for due date extensions in the API #36187
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, @efortish! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Hello @mariajgrimaldi , could you help me with the review of this PR? I will also refine the issue with some things I found. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @efortish! Thanks for your contribution. I was testing the changes and everything works fine! I only have a few minor comments.
- Remove the trailing spaces in the function. I recommend using trailing spaces extension in VSCode.
- Remove the double line break in the function.
As a suggestion, It's possible to add a margin in the error message?
12e5359
to
c9141f6
Compare
try: | ||
due_date = parse_datetime(due_datetime) | ||
except DashboardError: | ||
return JsonResponse({'error': 'The extension due date and time format is incorrect'}, status=400) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same suggestion here. Also, some error responses are marked for translation: https://github.com/openedx/edx-platform/blob/c9141f6f8e30c1ffcfce61c2fff1e0f19e491779/lms/djangoapps/instructor/views/api.py#L1356C40-L1356C87. Should we do that here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I will apply the same here.
About the translations I don't know if we must, I also reviewed other classes and not every single one has the mark for translation, in my opinion we should, but I would like to know your POV first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I also think we should :)
@efortish: thank you for addressing all my comments! Can you please review the failing checks? Thank you! |
85dd9d9
to
6cdb8af
Compare
@mariajgrimaldi Hello !, It was about 2 commit with the wrong structure. Fixed |
Fix validation and error display for due date extensions in the API
Description
This PR addresses the issue where the API did not correctly handle and display error cases where the due_datetime field was empty or incorrectly formatted; also, the API did not correctly handle the student/email field when it does not exist. Additionally, this PR ensures that the error messages returned by the API are clear and relevant to the actual validation error encountered.
This is the fix for this issue
Changes Made
Consistent Error Handling:
Detailed Error Message:
Objective
The objective of these changes was to improve the user experience by providing clear and accurate error messages when validation fails. This helps users understand what went wrong and how to correct their input.
Achievements
Improved User Feedback: Users now receive specific error messages for each validation issue, making it easier to correct their input.
Consistent Error Handling: All validation errors are handled consistently, making the API more robust and predictable.
Better Code Organization: The validation checks are now logically ordered, improving the readability and maintainability of the code.
Testing
Tested with various inputs to ensure that the correct error messages are returned for each validation failure.
Verified that the frontend correctly displays the error messages returned by the API.
How to test
In the lms, go to the Extensions section in the instructor dashboard and try different inputs, you can:
Note: Please keep in mind that the input "reason" is not required in the serializer, therefore it doesnt matter whether it is filled out or not
Screencast.from.2025-01-28.11-49-33.webm
Related Issues
PR #35392: https://github.com/openedx/edx-platform/pull/35392/files#diff-2e708ec7862cbe8e9fe138f4cde50b224d98e95f958dfc645b5ab76075035d8dR2994-R3008