Skip to content

[Feature:InstructorUI] Toggle date format#12844

Merged
bmcutler merged 33 commits into
Submitty:mainfrom
AtCloudDiwash:feature/11751-user-date-format-preference
Jun 8, 2026
Merged

[Feature:InstructorUI] Toggle date format#12844
bmcutler merged 33 commits into
Submitty:mainfrom
AtCloudDiwash:feature/11751-user-date-format-preference

Conversation

@AtCloudDiwash

@AtCloudDiwash AtCloudDiwash commented May 7, 2026

Copy link
Copy Markdown
Contributor

Why is this Change Important & Necessary?

Closes #11751

Despite having multiple date/time formats (MDY, DMY, YMD) defined in the codebase, the site was hardcoded at models/Config.php to use YMD format.

What is the New Behavior?

Users can now select their preferred date/time format from their profile settings page. The selected format is saved to the database and applied across the entire site. Except the notification banner (which I think is due to hardcoded date format)
Screenshot 2026-05-07 at 12 59 24 AM

Before: All dates displayed in YMD format.
After: Users can choose MDY, DMY, or YMD from their profile.

What steps should a reviewer take to reproduce or test the bug or new feature?

Note: Make sure your host files are synced with the vagrant VM before running these steps.

Database Migration:

  1. vagrant ssh
  2. cd /usr/local/submitty/GIT_CHECKOUT/Submitty/migration
  3. python3 run_migrator.py -c /usr/local/submitty/config -e master migrate

UI Changes:
3. cd /usr/local/submitty/GIT_CHECKOUT/Submitty/site
4. submitty_install_site

Alternatively, run submitty_install to apply all migrations and changes at once

What steps should a reviewer take to reproduce or test the bug or new feature?

  1. Log in as any user
  2. Navigate to profile page
  3. Find the "Date/Time Format" dropdown
  4. Select a different format
  5. Navigate to any gradeable page and verify dates display in the selected format

Steps for migration?

  1. SSH into vagrant
  2. Run the master database migration:

Automated Testing & Documentation

No automated tests added. A new GitHub issue should be created to add Cypress tests for this feature.

Other information

  • This PR includes a master database migration to add date_format column to the users table
  • Existing users will default to YMD (ISO 8601 standard) matching current behavior
  • Not a breaking change

@jndlansh jndlansh left a comment

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.

I think the changes do work as described.
Only the date format at Notification panel is the same, you have mentioned that. I am not sure if the maintainers want to leave it that way. We can address that too, if required.

Also, add the DB migration step in the PR description.

@github-project-automation github-project-automation Bot moved this from Seeking Reviewer to Work in Progress in Submitty Development May 7, 2026
@AtCloudDiwash

Copy link
Copy Markdown
Contributor Author

Thank you @jndlansh for feedback. I will add migration steps and try to resolve the notification panel date issue. Seems like it’s a python script from sbin folder.

@AtCloudDiwash

Copy link
Copy Markdown
Contributor Author

Hey @jndlansh, I checked the notification system, and it looks like the notification content is constructed as one full text string, like
Submissions Open: <title> | Due .

The full string is then saved in the notifications table under column content. I have included a screenshot for reference.
Screenshot 2026-05-07 at 2 34 54 PM

A possible quick fix would be to make a database call to get the user’s preferred date format before running the format_timestamp() function in sbin/send_notification.py( currently hardcodes the format as "%Y-%m-%d @ %I:%M %p")
Screenshot 2026-05-07 at 2 43 19 PM

However, this approach is still challenging because if the user changes their preferred date format later, existing notifications will remain in the old format. The change would only apply to notifications created after the preference update.

Could you and the other mentors provide some guidance on the preferred approach here. So that I can take this forward.

@codecov

codecov Bot commented May 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 32.43243% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 21.62%. Comparing base (cc61478) to head (a35f48a).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##               main   #12844   +/-   ##
=========================================
  Coverage     21.62%   21.62%           
- Complexity     9824     9839   +15     
=========================================
  Files           268      268           
  Lines         36816    36848   +32     
  Branches        490      490           
=========================================
+ Hits           7960     7967    +7     
- Misses        28370    28395   +25     
  Partials        486      486           
Flag Coverage Δ
autograder 21.32% <ø> (ø)
js 2.02% <ø> (ø)
migrator 100.00% <ø> (ø)
php 20.67% <32.43%> (+<0.01%) ⬆️
python_submitty_utils 80.08% <ø> (ø)
submitty_daemon_jobs 91.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AtCloudDiwash AtCloudDiwash changed the title [Feature:InstructorUI] Allow user to toggle between date/time formats [Feature:InstructorUI] Toggle date format May 8, 2026
@GarvitKhandelwal31

Copy link
Copy Markdown
Contributor

Tag me anytime you want to run them again after making changes.

@AtCloudDiwash

Copy link
Copy Markdown
Contributor Author

Tag me anytime you want to run them again after making changes.

Thank you @GarvitKhandelwal31. Will keep in mind next. I’ll start working on fixes. If you have any tips on fixing unit tests. Do share.

@GarvitKhandelwal31

Copy link
Copy Markdown
Contributor

Tag me anytime you want to run them again after making changes.

Thank you @GarvitKhandelwal31. Will keep in mind next. I’ll start working on fixes. If you have any tips on fixing unit tests. Do share.

I will check the failing results tomorrow.

@AtCloudDiwash
AtCloudDiwash force-pushed the feature/11751-user-date-format-preference branch from 5302afa to f8d7028 Compare May 8, 2026 19:13
@AtCloudDiwash

Copy link
Copy Markdown
Contributor Author

I checked the CI failures for PHP lint and unit tests. From what I understand, the existing test setup may not cover the feature I added yet. Could someone please help me confirm whether I need to update/add tests for this feature, or suggest the right direction to fix the failures?

@AtCloudDiwash

AtCloudDiwash commented May 9, 2026

Copy link
Copy Markdown
Contributor Author

I removed few lines from phpstan-baseline.neon because the test were old according to the changes made in the DateTimeFormat.php under site/app/models directory, which resolves the php lint failures. However, php unit CI still fails along with other cypress tests.

@AtCloudDiwash

Copy link
Copy Markdown
Contributor Author

@GarvitKhandelwal31 Could you run the tests again? There is still a unit test failing, and I’d appreciate it if you could take a look when you get a chance.

@AtCloudDiwash

AtCloudDiwash commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

@dagemcn @IDzyre , please review my recent commits. I'll modify the overlapping changes in the PR #12846 too.

@AtCloudDiwash
AtCloudDiwash requested review from IDzyre and dagemcn June 4, 2026 20:35
@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to In Review in Submitty Development Jun 4, 2026

@dagemcn dagemcn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Functionality remains the same and changes look good! Good work here.

Comment thread site/tests/app/models/UserTester.php Outdated
Comment on lines +165 to +166
'preferred_given_name' => "",
'preferred_family_name' => "",
'preferred_given_name' => null,
'preferred_family_name' => null,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this change required for "date format toggle" PR?

@IDzyre

IDzyre commented Jun 5, 2026

Copy link
Copy Markdown
Member

Question, is there a reason to not support date and time format? I think the wording of the UI is a little misleading if we don't support both. I think "Change date/time format" should be just "Change date format" and not display " @ 10:30 am" or " @ 10:30 "

@AtCloudDiwash

AtCloudDiwash commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

Question, is there a reason to not support date and time format? I think the wording of the UI is a little misleading if we don't support both. I think "Change date/time format" should be just "Change date format" and not display " @ 10:30 am" or " @ 10:30 "

@IDzyre , I agree with you on the wording. I should change the UI text to just date format instead of date/time. However, there is one issue. The variables names used in the code can be misleading too. Should I address the variable naming in a seperate issue ?

@AtCloudDiwash
AtCloudDiwash requested a review from IDzyre June 6, 2026 02:48

@dagemcn dagemcn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comments related, also please address IDzyre's comment.

Comment thread site/app/templates/UserProfile.twig Outdated
@github-project-automation github-project-automation Bot moved this from In Review to Work in Progress in Submitty Development Jun 8, 2026
@AtCloudDiwash

Copy link
Copy Markdown
Contributor Author

@IDzyre @dagemcn . Please review the recent commit that addresses confused UI wording.

@AtCloudDiwash
AtCloudDiwash requested a review from dagemcn June 8, 2026 14:38
@automateprojectmangement automateprojectmangement Bot moved this from Work in Progress to In Review in Submitty Development Jun 8, 2026

@dagemcn dagemcn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please address IDzyre's other comment on line 165/166 of UserTester.php

@AtCloudDiwash

Copy link
Copy Markdown
Contributor Author

removed the unnecessary changes in UserTester.php. Kindly review.

@bmcutler
bmcutler merged commit 23d522b into Submitty:main Jun 8, 2026
45 of 50 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in Submitty Development Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Allow user to toggle between date/time formats

6 participants