-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Instructor: home page: fix sort by date #7919 #8677
Conversation
Adding date stamp has made student home page an unpredictable html resulting in build failure. I will try solving it using #8332 (comment). |
Ready for review. |
@joanneong Ready for review. |
@nidhi98gupta Can you do an interactive rebase onto |
Oh nevermind, there are no merge conflicts so the changes in the merge conflict is not reflected in the PR. |
@darrenwee This is ready for review. Build is failing due to Bad Gateway error. I haven't added any new commits since last build success. Please review. |
Hi @nidhi98gupta! The build failed because the dependency repository went down. I've triggered a rebuild and I'll review within the next few days! You do not have to keep updating the branch to keep up with master! |
Can you perform the following git commands to clean up the branch history? I'm puzzled by the build failure because it doesn't seem like there's anything that changed between the first failing build and the last passing build, and I don't get the same failures locally. git remote add upstream https://github.com/TEAMMATES/teammates.git # if you already have this, you can skip this step
git fetch upstream
git checkout 7919-sort-by-date
git rebase upstream/master
git push -f |
fe32fa9
to
64a3a0f
Compare
@darrenwee I rebased the changes and build has passed! Kindly review. :) |
👍👍 This would really help #8640 too (no need for time zone detection anymore if we know the exact instant each time stamp is referring to)! |
Sorry, I did not see the year field 😅 I'll test it a bit more. |
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.
Looks pretty good! I have requested some naming changes for better documentation, but everything looks pretty solid.
There are two more places that you can add the sort by date functionality into.
- the student's home page (at
/page/studentHomePage
) - theDeadline
column doesn't have any sorting functionality. - the admin's sessions page (at
/admin/adminSessionsPage
) - the sort here doesn't work correctly. You'll need to inject the time stamp and add the extractor to the header cell.
Once you have done that, remember to rebase onto upstream/master
and ping me again 😃
@@ -610,6 +610,10 @@ public String getEndTimeInIso8601Format() { | |||
return TimeHelper.formatInstantToIso8601Utc(endTime); | |||
} | |||
|
|||
public String getStartTimeInIso8601Format() { |
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.
Rename this method to getStartTimeInIso8601UtcFormat
and do the same for the EndTime
equivalent. This is because ISO 8601 timestamps can have a UTC-offset, so it's best to disambiguate in the getter's name.
@@ -3,19 +3,24 @@ | |||
public class InstructorHomeFeedbackSessionRow extends HomeFeedbackSessionRow { | |||
private String startTime; | |||
private String startTimeToolTip; | |||
private String startTimeDateStamp; |
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.
Rename this field to something more self-explanatory, like startTimeIso8601Utc
. Since the type is of String
and not Instant
, it cannot be inferred right away that the time stamp here is on the universal timeline.
private String endTime; | ||
private String endTimeToolTip; | ||
private String endTimeDateStamp; |
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 as above.
private String href; | ||
private InstructorFeedbackSessionActions actions; | ||
|
||
public InstructorHomeFeedbackSessionRow(String name, String submissionsTooltip, String publishedTooltip, | ||
String submissionStatus, String publishedStatus, String startTime, String startTimeToolTip, | ||
String endTime, String endTimeToolTip, String href, InstructorFeedbackSessionActions actions) { | ||
String submissionStatus, String publishedStatus, String startTime, String startTimeDateStamp, |
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 as above.
@@ -2,14 +2,16 @@ | |||
|
|||
public class StudentHomeFeedbackSessionRow extends HomeFeedbackSessionRow { | |||
private String endTime; | |||
private String endTimeDateStamp; |
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.
Rename this field to something more self-explanatory, like endTimeIso8601Utc
. Since the type is of String and not Instant, it cannot be inferred right away that the time stamp here is on the universal timeline.
private StudentFeedbackSessionActions actions; | ||
private int index; | ||
|
||
public StudentHomeFeedbackSessionRow(String name, String submissionsTooltip, String publishedTooltip, | ||
String submissionStatus, String publishedStatus, String endTime, StudentFeedbackSessionActions actions, | ||
int index) { | ||
String submissionStatus, String publishedStatus, String endTime, String endTimeDateStamp, |
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 as above.
@@ -44,10 +44,10 @@ | |||
<td> | |||
${sessionRow.name} | |||
</td> | |||
<td class="text-nowrap"> | |||
<td class="text-nowrap" data-date-stamp="${sessionRow.startTimeDateStamp}"> |
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.
All the templates need to be updated to reflect the change in variable names from above.
@@ -27,7 +27,7 @@ | |||
<div class="form-group"> | |||
<label class="col-sm-2 control-label">Opening time:</label> | |||
<div class="col-sm-10"> | |||
<p class="form-control-static">${feedbackSession.startTimeString}</p> | |||
<p class="form-control-static" data-start-time="${feedbackSession.startTimeInIso8601Format}">${feedbackSession.startTimeString}</p> |
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.
Can we standardise the name of the data attribute? It should be the same here as in all the other files.
On that topic of |
@@ -71,6 +71,7 @@ private void setCourseTables(List<CourseDetailsBundle> courses, | |||
getStudentSubmissionStatusForSession(feedbackSession, hasSubmitted), | |||
getStudentPublishedStatusForSession(feedbackSession), | |||
TimeHelper.formatTime12H(feedbackSession.getEndTimeLocal()), |
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.
This isn't directly related, but since you are improving the student home page by adding the sort by deadline, could you take this chance to also show the time zone info in the deadline display? Simply change formatTime12H
here to formatDateTimeForSessions
and run godmode. Forgot to do this in #8687 😅
What are our options? I think we started using |
Actually once #8640 is properly fixed through the use of data attributes everywhere, display would be pretty much independent of sorting/testing etc. I can only think of three workarounds that exist in the code to support this feature: teammates/src/main/java/teammates/common/util/TimeHelper.java Lines 282 to 292 in dc85dd0
teammates/src/main/java/teammates/common/util/TimeHelper.java Lines 345 to 356 in dc85dd0
Furthermore, the last one will be removed once #8640 is properly fixed. As such, I find the current workarounds acceptable. This issue only arose because display of dates was tied to logic, and we have been moving away from such coupling with the use of data attributes. |
Maybe to get rid of the workarounds in |
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.
LGTM 👍 (Once the two test cases are updated to fix the build)
@@ -131,7 +131,8 @@ private void testFeedbackSession(int index, HomeFeedbackSessionRow row, Feedback | |||
String expectedPublishedStatus) { | |||
StudentHomeFeedbackSessionRow studentRow = (StudentHomeFeedbackSessionRow) row; | |||
assertEquals(session.getFeedbackSessionName(), studentRow.getName()); | |||
assertEquals(TimeHelper.formatTime12H(session.getEndTimeLocal()), studentRow.getEndTime()); | |||
assertEquals(TimeHelper.formatDateTimeForSessions(session.getEndTime(), session.getTimeZone()), | |||
studentRow.getEndTime()); |
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.
8-space indentation. You may need to change your IDE settings?
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.
IntelliJ indented it in 8 spaces, but then I looked at other assertEquals statements in the codebase just to be sure, it was indented like this only.
Nevermind I'll change it.
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.
👍 The codebase is still in transition towards 8-space indentation; it hasn't been applied everywhere yet.
Fixes #7919
Continuing the work done by @HirdayGupta according to the #7966 (comment).
Outline of Solution:
This PR will add ISO8601 date stamps to all the date elements of TEAMMATES. (Hopefully I have covered all)
I have added the data-date-stamp to the tables on the instructorHomePage and changed the extractor to dateStampExtractor from tooltipExtractor, which fixes the Sort By Date bug.
Also added the end-time date-stamp to the studentHomePage and ISO8601 datestamp to the start-time in feedbackSessionDetailsPanel tag.