Skip to content

Commit

Permalink
[#4552] Increase course ID, course name, and session name max length (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelfangjw committed Aug 7, 2021
1 parent bed3a5b commit eb550ce
Show file tree
Hide file tree
Showing 51 changed files with 382 additions and 285 deletions.
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.getGoogleId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,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 @@ -65,12 +65,12 @@ exports[`CopyCourseModalComponent should snap when copying from other sessions 1
<input
class="form-control ng-untouched ng-pristine ng-valid"
id="copy-course-id"
maxlength="40"
maxlength="64"
placeholder="e.g. CS3215-2013Semester1"
type="text"
/>
<span>
40 characters left
64 characters left
</span>
</div>
<div
Expand All @@ -82,12 +82,12 @@ exports[`CopyCourseModalComponent should snap when copying from other sessions 1
<input
class="form-control ng-untouched ng-pristine ng-valid"
id="copy-course-name"
maxlength="64"
maxlength="80"
placeholder="e.g. Software Engineering"
type="text"
/>
<span>
64 characters left
80 characters left
</span>
</div>
<div
Expand Down Expand Up @@ -3170,12 +3170,12 @@ exports[`CopyCourseModalComponent should snap with default fields 1`] = `
<input
class="form-control ng-untouched ng-pristine ng-valid"
id="copy-course-id"
maxlength="40"
maxlength="64"
placeholder="e.g. CS3215-2013Semester1"
type="text"
/>
<span>
40 characters left
64 characters left
</span>
</div>
<div
Expand All @@ -3187,12 +3187,12 @@ exports[`CopyCourseModalComponent should snap with default fields 1`] = `
<input
class="form-control ng-untouched ng-pristine ng-valid"
id="copy-course-name"
maxlength="64"
maxlength="80"
placeholder="e.g. Software Engineering"
type="text"
/>
<span>
64 characters left
80 characters left
</span>
</div>
<div
Expand Down Expand Up @@ -6258,12 +6258,12 @@ exports[`CopyCourseModalComponent should snap with some course id 1`] = `
<input
class="form-control ng-untouched ng-pristine ng-valid"
id="copy-course-id"
maxlength="40"
maxlength="64"
placeholder="e.g. CS3215-2013Semester1"
type="text"
/>
<span>
34 characters left
58 characters left
</span>
</div>
<div
Expand All @@ -6275,12 +6275,12 @@ exports[`CopyCourseModalComponent should snap with some course id 1`] = `
<input
class="form-control ng-untouched ng-pristine ng-valid"
id="copy-course-name"
maxlength="64"
maxlength="80"
placeholder="e.g. Software Engineering"
type="text"
/>
<span>
64 characters left
80 characters left
</span>
</div>
<div
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,19 +137,19 @@ 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>
<div
class="form-check"
>
<label
class="form-check-label"
class="form-check-label text-break"
>
<input
class="form-check-input"
Expand All @@ -175,7 +175,7 @@ exports[`CopySessionModalComponent should snap with some session and courses can
class="form-check"
>
<label
class="form-check-label"
class="form-check-label text-break"
>
<input
class="form-check-input"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h5 class="modal-title">
<span>{{ FEEDBACK_SESSION_NAME_MAX_LENGTH - newFeedbackSessionName.length }} characters left</span>
</div>
<div class="form-check" *ngFor="let course of courseCandidates">
<label class="form-check-label">
<label class="form-check-label text-break">
<input type="checkbox" name="copySessionChooseCourse" class="form-check-input"
[checked]="copyToCourseSet.has(course.courseId)" (click)="select(course.courseId)">
[<span [ngClass]="{ 'text-danger': sessionToCopyCourseId === course.courseId }">{{ course.courseId }}</span>]
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-3 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="text-break">{{ recycleBinFeedbackSessionRowModel.feedbackSession.courseId }}</td>
<td class="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 @@ -117,7 +117,9 @@ exports[`SessionsTableComponent should snap like in home page with 2 sessions so
<tr>
<td>
<td
class="text-break"
>
Season 8 Review
</td>
Expand Down Expand Up @@ -271,7 +273,9 @@ exports[`SessionsTableComponent should snap like in home page with 2 sessions so
</tr>
<tr>
<td>
<td
class="text-break"
>
Season 7 Review
</td>
Expand Down Expand Up @@ -539,10 +543,14 @@ exports[`SessionsTableComponent should snap like in sessions page with 2 session
<tr>
<td>
<td
class="text-break"
>
GOT
</td>
<td>
<td
class="text-break"
>
Season 8 Review
</td>
Expand Down Expand Up @@ -682,10 +690,14 @@ exports[`SessionsTableComponent should snap like in sessions page with 2 session
</tr>
<tr>
<td>
<td
class="text-break"
>
GOT
</td>
<td>
<td
class="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="text-break" *ngIf="columnsToShow.includes(SessionsTableColumn.COURSE_ID)">{{ sessionsTableRowModel.feedbackSession.courseId }}</td>
<td class="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

0 comments on commit eb550ce

Please sign in to comment.