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

[#4552] Increase course ID, course name, and session name max length #11277

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ac77768
Increase session name max length to 64
samuelfangjw Jul 13, 2021
2d61450
Increase course name and id max length
samuelfangjw Jul 15, 2021
cb52896
Update test snapshots
samuelfangjw Jul 16, 2021
d5dce35
Update component tests
samuelfangjw Jul 16, 2021
821bdf9
Fix buttons on student home page overflowing
samuelfangjw Jul 16, 2021
475da60
Fix text overflow issues
samuelfangjw Jul 16, 2021
ddc87c5
Fix text overflow issues
samuelfangjw Jul 16, 2021
112c7e4
Merge branch 'master' into 4552-course-name-id-max-length
samuelfangjw Jul 16, 2021
b1a0a09
Merge branch 'master' into 4552-course-name-id-max-length
samuelfangjw Jul 21, 2021
91edcf3
Move text-break class to global css file
samuelfangjw Jul 21, 2021
6362918
Remove unused css properties
samuelfangjw Jul 21, 2021
de1836a
Revert accidental changes to styles.scss
samuelfangjw Jul 21, 2021
12e51fc
Update failing snapshots
samuelfangjw Jul 21, 2021
d4501ff
Merge branch 'master' into 4552-course-name-id-max-length
samuelfangjw Jul 23, 2021
85a3ea6
Rename text-break-class to text-break
samuelfangjw Jul 23, 2021
c3ab563
Update text-break style
samuelfangjw Jul 23, 2021
b0f96c3
Merge branch 'upstream-master' into 4552-course-name-id-max-length
samuelfangjw Jul 28, 2021
71c1044
Update comment for text-break class
samuelfangjw Jul 28, 2021
4041ba5
Fix more text-overflow issues
samuelfangjw Jul 28, 2021
70e5e40
Merge branch 'master' into 4552-course-name-id-max-length
rrtheonlyone Aug 1, 2021
b8fe695
Merge branch 'master' into 4552-course-name-id-max-length
ccyccyccy Aug 6, 2021
0deff35
Merge branch 'master' into 4552-course-name-id-max-length
samuelfangjw Aug 7, 2021
468d9de
Update test snapshots
samuelfangjw Aug 7, 2021
3cd83b2
Merge branch 'master' into 4552-course-name-id-max-length
samuelfangjw Aug 7, 2021
51fc3a7
Merge branch 'master' into 4552-course-name-id-max-length
wkurniawan07 Aug 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/teammates/common/util/FieldValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public final class FieldValidator {
public static final String NATIONALITY_FIELD_NAME = "nationality";

public static final String COURSE_NAME_FIELD_NAME = "course name";
public static final int COURSE_NAME_MAX_LENGTH = 64;
public static final int COURSE_NAME_MAX_LENGTH = 80;

public static final String FEEDBACK_SESSION_NAME_FIELD_NAME = "feedback session name";
public static final int FEEDBACK_SESSION_NAME_MAX_LENGTH = 38;
public static final int FEEDBACK_SESSION_NAME_MAX_LENGTH = 64;

public static final String TEAM_NAME_FIELD_NAME = "team name";
public static final int TEAM_NAME_MAX_LENGTH = 60;
Expand Down Expand Up @@ -71,7 +71,7 @@ public final class FieldValidator {
* TODO: make case insensitive
*/
public static final String COURSE_ID_FIELD_NAME = "course ID";
public static final int COURSE_ID_MAX_LENGTH = 40;
public static final int COURSE_ID_MAX_LENGTH = 64;

public static final String SESSION_START_TIME_FIELD_NAME = "start time";
public static final String SESSION_END_TIME_FIELD_NAME = "end time";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,9 @@ public void testValidate() {
.build();

String feedbackSessionNameError = "The field 'feedback session name' should not be empty. The value of 'feedback "
+ "session name' field should be no longer than 38 characters.";
+ "session name' field should be no longer than 64 characters.";
String courseIdError = "The field 'course ID' is empty. A course ID can contain letters, numbers, fullstops, "
+ "hyphens, underscores, and dollar signs. It cannot be longer than 40 characters, cannot be empty and "
+ "hyphens, underscores, and dollar signs. It cannot be longer than 64 characters, cannot be empty and "
+ "cannot contain spaces.";
String creatorEmailError = "The field 'email' is empty. An email address contains some text followed "
+ "by one '@' sign followed by some more text, and should end with a top level domain address like .com. "
Expand Down
22 changes: 12 additions & 10 deletions src/test/java/teammates/common/util/FieldValidatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,10 @@ public void testGetInvalidityInfoForFeedbackSessionName_invalid_returnSpecificEr
String actual = FieldValidator.getInvalidityInfoForFeedbackSessionName(invalidSessionName);
assertEquals("Invalid feedback session name (too long) should return error message specific to feedback "
+ "session name",
"\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" is not acceptable to TEAMMATES as a/an "
+ "feedback session name because it is too long. The value of a/an feedback session "
+ "name should be no longer than 38 characters. It should not be empty.",
"\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" "
+ "is not acceptable to TEAMMATES as a/an feedback session name because it is too long. "
+ "The value of a/an feedback session name should be no longer than 64 characters. "
+ "It should not be empty.",
actual);
}

Expand Down Expand Up @@ -493,7 +494,7 @@ public void testGetInvalidityInfoForCourseId_invalid_returnErrorString() {
assertEquals("Invalid Course ID (empty) should return appropriate error string",
"The field 'course ID' is empty. A course ID can contain letters, numbers, "
+ "fullstops, hyphens, underscores, and dollar signs. It cannot be "
+ "longer than 40 characters, cannot be empty and cannot contain spaces.",
+ "longer than 64 characters, cannot be empty and cannot contain spaces.",
FieldValidator.getInvalidityInfoForCourseId(emptyCourseId));

String untrimmedCourseId = " $cs1101-sem1.2_ ";
Expand All @@ -511,25 +512,26 @@ public void testGetInvalidityInfoForCourseId_invalid_returnErrorString() {
String tooLongCourseId = StringHelperExtension.generateStringOfLength(
FieldValidator.COURSE_ID_MAX_LENGTH + 1);
assertEquals("Invalid Course ID (too long) should return appropriate error string",
"\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" is not acceptable to TEAMMATES as a/an "
+ "course ID because it is too long. A course ID can contain letters, numbers, "
+ "fullstops, hyphens, underscores, and dollar signs. It cannot be longer than 40 "
+ "characters, cannot be empty and cannot contain spaces.",
"\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" "
+ "is not acceptable to TEAMMATES as a/an course ID because it is too long. "
+ "A course ID can contain letters, numbers, fullstops, hyphens, underscores, "
+ "and dollar signs. It cannot be longer than 64 characters, "
+ "cannot be empty and cannot contain spaces.",
FieldValidator.getInvalidityInfoForCourseId(tooLongCourseId));

String courseIdWithSpaces = "my course id with spaces";
assertEquals("Invalid Course ID (contains spaces) should return appropriate error string",
"\"my course id with spaces\" is not acceptable to TEAMMATES as a/an course ID because "
+ "it is not in the correct format. A course ID can contain letters, numbers, "
+ "fullstops, hyphens, underscores, and dollar signs. It cannot be longer than 40 "
+ "fullstops, hyphens, underscores, and dollar signs. It cannot be longer than 64 "
+ "characters, cannot be empty and cannot contain spaces.",
FieldValidator.getInvalidityInfoForCourseId(courseIdWithSpaces));

String courseIdWithInvalidChar = "cour@s*hy#";
assertEquals("Invalid Course ID (invalid char) should return appropriate error string",
"\"cour@s*hy#\" is not acceptable to TEAMMATES as a/an course ID because it is not in "
+ "the correct format. A course ID can contain letters, numbers, fullstops, "
+ "hyphens, underscores, and dollar signs. It cannot be longer than 40 characters, "
+ "hyphens, underscores, and dollar signs. It cannot be longer than 64 characters, "
+ "cannot be empty and cannot contain spaces.",
FieldValidator.getInvalidityInfoForCourseId(courseIdWithInvalidChar));
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/teammates/logic/core/CoursesLogicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ private void testCreateCourseAndInstructor() throws Exception {
"\"" + invalidCourse.getId() + "\" is not acceptable to TEAMMATES as a/an course ID because"
+ " it is not in the correct format. "
+ "A course ID can contain letters, numbers, fullstops, hyphens, underscores, and dollar signs. "
+ "It cannot be longer than 40 characters, cannot be empty and cannot contain spaces.";
+ "It cannot be longer than 64 characters, cannot be empty and cannot contain spaces.";

InvalidParametersException ipe = assertThrows(InvalidParametersException.class,
() -> coursesLogic.createCourseAndInstructor(i.googleId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ protected void testExecute() throws Exception {
getJsonResult(getAction(getTypicalCreateRequest(), params));
});

______TS("Error: Invalid parameters (invalid session name > 38 characters)");
______TS("Error: Invalid parameters (invalid session name > 64 characters)");

assertThrows(InvalidHttpRequestBodyException.class, () -> {
FeedbackSessionCreateRequest request = getTypicalCreateRequest();
request.setFeedbackSessionName(StringHelperExtension.generateStringOfLength(39));
request.setFeedbackSessionName(StringHelperExtension.generateStringOfLength(65));
getJsonResult(getAction(request, params));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ exports[`CopySessionModalComponent should snap with default fields 1`] = `
<input
class="form-control ng-untouched ng-pristine ng-valid"
id="copy-session-name"
maxlength="38"
maxlength="64"
type="text"
/>
<span>
38 characters left
64 characters left
</span>
</div>

Expand Down Expand Up @@ -137,11 +137,11 @@ exports[`CopySessionModalComponent should snap with some session and courses can
<input
class="form-control ng-untouched ng-pristine ng-valid"
id="copy-session-name"
maxlength="38"
maxlength="64"
type="text"
/>
<span>
26 characters left
52 characters left
</span>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h5 class="text-md-right">Or: </h5>
<div class="col-md-2 text-md-right font-bold" [ngClass]="{'col-form-label': formMode === SessionEditFormMode.ADD}">
<span class="ngb-tooltip-class" ngbTooltip="Course for which the feedback session is for.">Course ID</span>
</div>
<div class="col-md-4 text-md-left">
<div class="col-md-auto text-md-left">
<div *ngIf="formMode === SessionEditFormMode.ADD">
<select id="add-course-id" class="form-control" [ngClass]="{'is-invalid': courseCandidates.length === 0}" [ngModel]="model.courseId" (ngModelChange)="courseIdChangeHandler($event)" [disabled]="courseCandidates.length === 0">
<option *ngFor="let course of courseCandidates" [ngValue]="course.courseId">{{ course.courseId }}</option>
Expand All @@ -59,10 +59,13 @@ <h5 class="text-md-right">Or: </h5>
</div>
<div id="edit-course-id" *ngIf="formMode === SessionEditFormMode.EDIT"> {{ model.courseId }} </div>
</div>
<div class="col-md-2 text-md-right font-bold mt-3 mt-md-0" [ngClass]="{'col-form-label': formMode === SessionEditFormMode.ADD}">
</div>
<br/>
<div class="row text-center">
<div class="col-md-2 text-md-right font-bold" [ngClass]="{'col-form-label': formMode === SessionEditFormMode.ADD}">
Time Zone
</div>
<div id="time-zone" class="col-md-4 text-md-left" [ngClass]="{'col-form-label': formMode === SessionEditFormMode.ADD}">
<div id="time-zone" class="col-md-2 text-md-left" [ngClass]="{'col-form-label': formMode === SessionEditFormMode.ADD}">
<span class="ngb-tooltip-class" ngbTooltip="To change this, edit the course settings. TEAMMATES automatically adjusts to match the current time offset in your area, including clock changes due to daylight saving time.">{{ model.timeZone }}</span>
</div>
</div>
Expand All @@ -71,7 +74,7 @@ <h5 class="text-md-right">Or: </h5>
<div class="col-md-2 text-md-right font-bold">
Course Name
</div>
<div id="course-name" class="col-md-4 text-md-left">
<div id="course-name" class="col-md-10 text-md-left">
{{ model.courseName }}
</div>
</div>
Expand All @@ -81,9 +84,9 @@ <h5 class="text-md-right">Or: </h5>
<span *ngIf="formMode === SessionEditFormMode.ADD" class="ngb-tooltip-class" ngbTooltip="Enter the name of the feedback session e.g. Feedback Session 1.">Session Name</span>
<span *ngIf="formMode !== SessionEditFormMode.ADD">Session Name</span>
</div>
<div class="col-md-4 text-md-left">
<div class="col-md-10 text-md-left">
<div *ngIf="formMode === SessionEditFormMode.ADD">
<input id="add-session-name" type="text" class="form-control" [ngModel]="model.feedbackSessionName" (ngModelChange)="triggerModelChange('feedbackSessionName', $event)" placeholder="e.g. Feedback for Project Presentation 1" maxlength="38" />
<input id="add-session-name" type="text" class="form-control" [ngModel]="model.feedbackSessionName" (ngModelChange)="triggerModelChange('feedbackSessionName', $event)" placeholder="e.g. Feedback for Project Presentation 1" maxlength="64" />
<div>
{{FEEDBACK_SESSION_NAME_MAX_LENGTH - model.feedbackSessionName.length}} characters left
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ <h2 class="text-muted">
</thead>
<tbody>
<tr *ngFor="let recycleBinFeedbackSessionRowModel of recycleBinFeedbackSessionRowModels; let i = index">
<td>{{ recycleBinFeedbackSessionRowModel.feedbackSession.courseId }}</td>
<td>{{ recycleBinFeedbackSessionRowModel.feedbackSession.feedbackSessionName }}</td>
<td class="td-text-break">{{ recycleBinFeedbackSessionRowModel.feedbackSession.courseId }}</td>
<td class="td-text-break">{{ recycleBinFeedbackSessionRowModel.feedbackSession.feedbackSessionName }}</td>
<td>
<span class="ngb-tooltip-class" [ngbTooltip]="recycleBinFeedbackSessionRowModel.feedbackSession.createdAtTimestamp | formatDateDetail:recycleBinFeedbackSessionRowModel.feedbackSession.timeZone" container="body">
{{ recycleBinFeedbackSessionRowModel.feedbackSession.createdAtTimestamp | recycleBinTableFormatDate:recycleBinFeedbackSessionRowModel.feedbackSession.timeZone }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@
.actions-cell button {
margin-right: var(--btn-margin);
}

.td-text-break {
word-break: break-word;
overflow-wrap: break-word;
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ exports[`SessionsTableComponent should snap like in home page with 2 sessions so

<tr>

<td>
<td
class="td-text-break"
>
Season 8 Review
</td>

Expand Down Expand Up @@ -270,7 +272,9 @@ exports[`SessionsTableComponent should snap like in home page with 2 sessions so
</tr>
<tr>

<td>
<td
class="td-text-break"
>
Season 7 Review
</td>

Expand Down Expand Up @@ -537,10 +541,14 @@ exports[`SessionsTableComponent should snap like in sessions page with 2 session

<tr>

<td>
<td
class="td-text-break"
>
GOT
</td>
<td>
<td
class="td-text-break"
>
Season 8 Review
</td>

Expand Down Expand Up @@ -679,10 +687,14 @@ exports[`SessionsTableComponent should snap like in sessions page with 2 session
</tr>
<tr>

<td>
<td
class="td-text-break"
>
GOT
</td>
<td>
<td
class="td-text-break"
>
Season 7 Review
</td>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
</thead>
<tbody>
<tr *ngFor="let sessionsTableRowModel of sessionsTableRowModels; let idx = index">
<td *ngIf="columnsToShow.includes(SessionsTableColumn.COURSE_ID)">{{ sessionsTableRowModel.feedbackSession.courseId }}</td>
<td>{{ sessionsTableRowModel.feedbackSession.feedbackSessionName }}</td>
<td class="td-text-break" *ngIf="columnsToShow.includes(SessionsTableColumn.COURSE_ID)">{{ sessionsTableRowModel.feedbackSession.courseId }}</td>
<td class="td-text-break">{{ sessionsTableRowModel.feedbackSession.feedbackSessionName }}</td>
<td *ngIf="columnsToShow.includes(SessionsTableColumn.START_DATE)">
<span class="ngb-tooltip-class" [ngbTooltip]="sessionsTableRowModel.feedbackSession.submissionStartTimestamp | formatDateDetail: sessionsTableRowModel.feedbackSession.timeZone" >{{ sessionsTableRowModel.feedbackSession.submissionStartTimestamp | formatDateBrief: sessionsTableRowModel.feedbackSession.timeZone }}</span></td>
<td *ngIf="columnsToShow.includes(SessionsTableColumn.END_DATE)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
cursor: pointer;
}

.td-text-break {
word-break: break-word;
overflow-wrap: break-word;
}

.margin-bottom-0 {
margin-bottom: 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h3 style="margin-top: 20px; margin-bottom: 30px;">
</thead>
<tbody>
<tr *ngFor="let course of instructorCourses">
<td>[{{ course.courseId }}] {{ course.courseName }}</td>
<td class="td-text-break">[{{ course.courseId }}] {{ course.courseName }}</td>
<td>
<button class="btn btn-sm btn-danger" (click)="removeInstructorFromCourse(course.courseId)">
<i class="fas fa-trash-alt"></i> Remove From Course
Expand Down Expand Up @@ -75,7 +75,7 @@ <h3 style="margin-top: 20px; margin-bottom: 30px;">
</thead>
<tbody>
<tr *ngFor="let course of studentCourses">
<td>[{{ course.courseId }}] {{ course.courseName }}</td>
<td class="td-text-break">[{{ course.courseId }}] {{ course.courseName }}</td>
<td>
<button class="btn btn-sm btn-danger" (click)="removeStudentFromCourse(course.courseId)">
<i class="fas fa-trash-alt"></i> Remove From Course
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.control-label {
font-weight: 600;
}

.td-text-break {
word-break: break-word;
overflow-wrap: break-word;
}
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,9 @@ exports[`AdminSearchPageComponent should snap with an expanded student table 1`]

<tr>
<td>
<span>
<span
class="text-break"
>
test-exa.demo [section] (team)
</span>
<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<ng-container *ngFor="let student of students; let i = index">
<tr (click)="student.showLinks = !student.showLinks">
<td>
<span [ngbTooltip]="student.courseName">
<span class="text-break" [ngbTooltip]="student.courseName">
{{ student.courseId }} [{{ student.section }}] ({{ student.team }})
</span>
<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ <h4>
<tbody>
<tr *ngFor="let session of mapping.value">
<td>{{ session.ongoingSession.sessionStatus }}</td>
<td><strong>[{{ session.ongoingSession.courseId }}]</strong> {{ session.ongoingSession.feedbackSessionName }}</td>
<td class="td-text-break">
<strong>[{{ session.ongoingSession.courseId }}]</strong>
{{ session.ongoingSession.feedbackSessionName }}
</td>
<td>
<span *ngIf="session.responseRate">{{ session.responseRate }}</span>
<span *ngIf="!session.responseRate"><a href="javascript:;" (click)="getResponseRate(mapping.key, session.ongoingSession.courseId, session.ongoingSession.feedbackSessionName, $event)">Show</a></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@
.session-table {
margin-bottom: 0;
}

.td-text-break {
word-break: break-word;
overflow-wrap: break-word;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ exports[`InstructorAuditLogsPageComponent should snap with results of a search 1
>
<div
class="card-header alert-success cursor-pointer"
id="feedback-session-details"
>
Feedback session 1
<div
Expand Down Expand Up @@ -1279,6 +1280,7 @@ exports[`InstructorAuditLogsPageComponent should snap with results of a search 1
>
<div
class="card-header alert-success cursor-pointer"
id="feedback-session-details"
>
Feedback session 2
<div
Expand Down