Skip to content

Commit

Permalink
[5241] Cannot publish session with '#' in name
Browse files Browse the repository at this point in the history
  • Loading branch information
bamboo3250 authored and bamboo3250 committed Apr 21, 2016
2 parents 80ee013 + ab1a0c0 commit 108f149
Show file tree
Hide file tree
Showing 12 changed files with 355 additions and 357 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import teammates.common.datatransfer.FeedbackSessionAttributes;
import teammates.common.datatransfer.InstructorAttributes;
import teammates.common.util.Const;
import teammates.common.util.Sanitizer;
import teammates.ui.controller.PageData;

public class FeedbackSessionPublishButton {
Expand All @@ -22,7 +21,7 @@ public class FeedbackSessionPublishButton {
public FeedbackSessionPublishButton(PageData data, FeedbackSessionAttributes session, String returnUrl,
InstructorAttributes instructor, String buttonType) {
String courseId = session.courseId;
this.feedbackSessionName = Sanitizer.sanitizeForJs(session.feedbackSessionName);
this.feedbackSessionName = session.feedbackSessionName;
this.isSendingPublishedEmail = session.isPublishedEmailEnabled;

boolean isUnpublishing = !session.isWaitingToOpen() && session.isPublished();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import teammates.common.datatransfer.FeedbackSessionAttributes;
import teammates.common.datatransfer.InstructorAttributes;
import teammates.common.util.Const;
import teammates.common.util.Sanitizer;
import teammates.ui.controller.PageData;

public class InstructorFeedbackSessionActions {
Expand Down Expand Up @@ -37,8 +36,8 @@ public InstructorFeedbackSessionActions(PageData data, FeedbackSessionAttributes

this.privateSession = session.isPrivateSession();

this.courseId = Sanitizer.sanitizeForJs(courseId);
this.fsName = Sanitizer.sanitizeForJs(feedbackSessionName);
this.courseId = courseId;
this.fsName = feedbackSessionName;

this.resultsLink = data.getInstructorFeedbackResultsLink(courseId, feedbackSessionName);
this.editLink = data.getInstructorFeedbackEditLink(courseId, feedbackSessionName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void classSetup() throws Exception {

newSession = new FeedbackSessionAttributes();
newSession.courseId = "CFeedbackUiT.CS1101";
newSession.feedbackSessionName = "New Session";
newSession.feedbackSessionName = "New Session ##";
// start time is in future, hence the year.
newSession.startTime = TimeHelper.convertToDate("2035-04-01 11:59 PM UTC");
newSession.endTime = TimeHelper.convertToDate("2035-04-30 10:00 PM UTC");
Expand Down Expand Up @@ -157,9 +157,9 @@ public void testContent() throws Exception {
feedbackPage.verifyHtmlMainContent("/instructorFeedbackAllSessionTypes.html");

feedbackPage.sortByName().verifyTablePattern(
0, 1,"Awaiting Session{*}First Session{*}Manual Session{*}Open Session{*}Private Session");
0, 1,"Awaiting Session #{*}First Session #1{*}Manual Session #1{*}Open Session #{*}Private Session #");
feedbackPage.sortByName().verifyTablePattern(
0, 1,"Private Session{*}Open Session{*}Manual Session{*}First Session{*}Awaiting Session");
0, 1,"Private Session #{*}Open Session #{*}Manual Session #1{*}First Session #1{*}Awaiting Session #");


______TS("sort by course id");
Expand Down Expand Up @@ -246,7 +246,7 @@ public void testAddAction() throws Exception{
feedbackPage.verifyHidden(By.id("responsesVisibleFromColumn"));
feedbackPage.verifyHidden(By.id("instructionsRow"));

newSession.feedbackSessionName = "private session of characters123456789";
newSession.feedbackSessionName = "private session of characters1234567 #";
newSession.courseId = "CFeedbackUiT.CS2104";
newSession.timeZone = 5.75;
newSession.endTime = null;
Expand Down Expand Up @@ -285,7 +285,7 @@ public void testAddAction() throws Exception{
feedbackPage.clickCustomVisibleTimeButton();
feedbackPage.clickDefaultPublishTimeButton();

newSession.feedbackSessionName = "Allow Early Viewing Session";
newSession.feedbackSessionName = "Allow Early Viewing Session #";
newSession.courseId = "CFeedbackUiT.CS1101";
newSession.timeZone = -4.5;

Expand Down Expand Up @@ -323,7 +323,7 @@ public void testAddAction() throws Exception{
feedbackPage.clickDefaultVisibleTimeButton();
feedbackPage.clickNeverPublishTimeButton();

newSession.feedbackSessionName = "responses cant be seen my students 1";
newSession.feedbackSessionName = "responses cant be seen my students 1 #";
// start time in past
newSession.startTime = TimeHelper.convertToDate("2012-05-01 4:00 AM UTC");
newSession.endTime = TimeHelper.convertToDate("2017-31-12 11:59 PM UTC");
Expand Down Expand Up @@ -355,7 +355,7 @@ public void testAddAction() throws Exception{
feedbackPage.clickEditUncommonSettingsButton();
feedbackPage.clickDefaultVisibleTimeButton();
feedbackPage.clickCustomPublishTimeButton();
newSession.feedbackSessionName = "Long Instruction Test";
newSession.feedbackSessionName = "Long Instruction Test ##";
newSession.timeZone = 0;
newSession.startTime = TimeHelper.convertToDate("2012-05-01 8:00 AM UTC");
newSession.endTime = TimeHelper.convertToDate("2012-09-01 11:00 PM UTC");
Expand Down Expand Up @@ -386,7 +386,7 @@ public void testAddAction() throws Exception{
feedbackPage.clickCustomVisibleTimeButton();
feedbackPage.clickCustomPublishTimeButton();

newSession.feedbackSessionName = "invalid publish time";
newSession.feedbackSessionName = "invalid publish time #";
newSession.startTime = TimeHelper.convertToDate("2012-05-01 8:00 PM UTC");
newSession.endTime = TimeHelper.convertToDate("2012-05-01 4:00 PM UTC");

Expand Down Expand Up @@ -427,15 +427,15 @@ public void testAddAction() throws Exception{

//feedbackPage = getFeedbackPageForInstructor(idOfInstructorWithSessions);

newSession.feedbackSessionName = "bad name %%";
newSession.feedbackSessionName = "bad name %% #";
newSession.endTime = Const.TIME_REPRESENTS_LATER;
feedbackPage.addFeedbackSession(
newSession.feedbackSessionName, newSession.courseId,
newSession.startTime, newSession.endTime, null, null,
newSession.instructions, newSession.gracePeriod);
assertEquals(String.format(
FieldValidator.INVALID_NAME_ERROR_MESSAGE,
"bad name %%",
"bad name %% #",
FieldValidator.FEEDBACK_SESSION_NAME_FIELD_NAME,
FieldValidator.REASON_CONTAINS_INVALID_CHAR,
FieldValidator.FEEDBACK_SESSION_NAME_FIELD_NAME),
Expand All @@ -446,22 +446,22 @@ public void testAddAction() throws Exception{
public void testCopyFromAction() throws Exception{

______TS("Success case: copy successfully a previous session");
feedbackPage.copyFeedbackSession("New Session (Copied)", newSession.courseId);
feedbackPage.copyFeedbackSession("New Session ## (Copied)", newSession.courseId);
feedbackPage.verifyStatus(Const.StatusMessages.FEEDBACK_SESSION_COPIED);
// Check that we are redirected to the edit page.
feedbackPage.verifyHtmlMainContent("/instructorFeedbackCopySuccess.html");

______TS("Success case: copy successfully a previous session with trimmed name");
feedbackPage = getFeedbackPageForInstructor(idOfInstructorWithSessions);
feedbackPage.copyFeedbackSession(" New Session Trimmed (Copied) ", newSession.courseId);
feedbackPage.copyFeedbackSession(" New Session ## Trimmed (Copied) ", newSession.courseId);
feedbackPage.verifyStatus(Const.StatusMessages.FEEDBACK_SESSION_COPIED);
// Check that we are redirected to the edit page.
feedbackPage.verifyHtmlMainContent("/instructorFeedbackCopyTrimmedSuccess.html");

______TS("Failure case: copy fail since the feedback session name is the same with existing one");
feedbackPage = getFeedbackPageForInstructor(idOfInstructorWithSessions);

feedbackPage.copyFeedbackSession("New Session (Copied)", newSession.courseId);
feedbackPage.copyFeedbackSession("New Session ## (Copied)", newSession.courseId);
feedbackPage.verifyStatus("A feedback session by this name already exists under this course");

feedbackPage.reloadPage();
Expand All @@ -478,9 +478,9 @@ public void testCopyFromAction() throws Exception{
______TS("Failure case: copy fail since the feedback session name starts with (");
feedbackPage = getFeedbackPageForInstructor(idOfInstructorWithSessions);

feedbackPage.copyFeedbackSession("(New Session)", newSession.courseId);
feedbackPage.copyFeedbackSession("(New Session ##)", newSession.courseId);
feedbackPage.verifyStatus(
"\"(New Session)\" is not acceptable to TEAMMATES as feedback session name because "
"\"(New Session ##)\" is not acceptable to TEAMMATES as feedback session name because "
+ "it starts with a non-alphanumeric character. "
+ "All feedback session name must start with an alphanumeric character, "
+ "and cannot contain any vertical bar (|) or percent sign (%).");
Expand All @@ -489,7 +489,7 @@ public void testCopyFromAction() throws Exception{
}

public void testCopyToAction() throws Exception {
String feedbackSessionName = "Open Session";
String feedbackSessionName = "Open Session #";
String courseId = newSession.courseId;

______TS("Submit empty course list: Feedbacks Page");
Expand Down Expand Up @@ -558,7 +558,7 @@ public void testCopyToAction() throws Exception {
public void testDeleteAction() throws Exception{

String courseId = newSession.courseId;
String sessionName = "Long Instruction Test";
String sessionName = "Long Instruction Test ##";

// refresh page
feedbackPage = getFeedbackPageForInstructor(idOfInstructorWithSessions);
Expand Down Expand Up @@ -794,12 +794,12 @@ public void testDefaultTimeZone() {
public void testResponseRateLink(){
______TS("test response rate link clickable");

feedbackPage.clickViewResponseLink("CFeedbackUiT.CS2104", "Private Session");
feedbackPage.verifyResponseValue("0 / 0", "CFeedbackUiT.CS2104","Private Session");
feedbackPage.clickViewResponseLink("CFeedbackUiT.CS2104", "Private Session #");
feedbackPage.verifyResponseValue("0 / 0", "CFeedbackUiT.CS2104","Private Session #");


______TS("test response rate already displayed");
assertEquals("0 / 0", feedbackPage.getResponseValue("CFeedbackUiT.CS1101", "Open Session"));
assertEquals("0 / 0", feedbackPage.getResponseValue("CFeedbackUiT.CS1101", "Open Session #"));
}

public void testViewResultsLink() {
Expand Down
10 changes: 5 additions & 5 deletions src/test/resources/data/InstructorFeedbackPageUiTest.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@

"feedbackSessions" : {
"publishedSession": {
"feedbackSessionName" : "First Session",
"feedbackSessionName" : "First Session #1",
"courseId" : "CFeedbackUiT.CS2104",
"creatorEmail" : "teammates.test2@gmail.tmt",
"instructions": {"value" : "Instructions for first session"},
Expand All @@ -294,7 +294,7 @@
"sentPublishedEmail" : true
},
"privateSession": {
"feedbackSessionName" : "Private Session",
"feedbackSessionName" : "Private Session #",
"courseId" : "CFeedbackUiT.CS2104",
"creatorEmail" : "teammates.test1@gmail.tmt",
"instructions": {"value" : "Please please fill in the second feedback session"},
Expand All @@ -310,7 +310,7 @@
"sentPublishedEmail" : false
},
"manualSession": {
"feedbackSessionName" : "Manual Session",
"feedbackSessionName" : "Manual Session #1",
"courseId" : "CFeedbackUiT.CS1101",
"creatorEmail" : "teammates.test1@gmail.tmt",
"instructions": {"value" : "Please please fill in the third feedback session"},
Expand All @@ -326,7 +326,7 @@
"sentPublishedEmail" : false
},
"openSession": {
"feedbackSessionName" : "Open Session",
"feedbackSessionName" : "Open Session #",
"courseId" : "CFeedbackUiT.CS1101",
"creatorEmail" : "teammates.test2@gmail.tmt",
"instructions": {"value" : "Please please fill in the fourth feedback session"},
Expand All @@ -342,7 +342,7 @@
"sentPublishedEmail" : false
},
"awaitingSession": {
"feedbackSessionName" : "Awaiting Session",
"feedbackSessionName" : "Awaiting Session #",
"courseId" : "CFeedbackUiT.CS2104",
"creatorEmail" : "teammates.test2@gmail.tmt",
"instructions": {"value" : "Instructions for first session"},
Expand Down
18 changes: 9 additions & 9 deletions src/test/resources/pages/instructorFeedbackAddSuccess.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ <h1>
<button class="btn btn-primary btn-sm" disabled="" id="fsSaveLink" onclick="return checkEditFeedbackSession(this.form);" style="display:none;" type="submit">
Save Changes
</button>
<a class="btn btn-primary btn-sm" data-original-title="Delete the feedback session" data-placement="top" data-toggle="tooltip" href="/page/instructorFeedbackDelete?courseid=CFeedbackUiT.CS1101&fsname=New+Session&next=%2Fpage%2FinstructorFeedbacksPage&user=CFeedbackUiT.instructor" id="fsDeleteLink" onclick="return toggleDeleteFeedbackSessionConfirmation('CFeedbackUiT.CS1101','New Session');" title="">
<a class="btn btn-primary btn-sm" data-original-title="Delete the feedback session" data-placement="top" data-toggle="tooltip" href="/page/instructorFeedbackDelete?courseid=CFeedbackUiT.CS1101&fsname=New+Session+%23%23&next=%2Fpage%2FinstructorFeedbacksPage&user=CFeedbackUiT.instructor" id="fsDeleteLink" onclick="return toggleDeleteFeedbackSessionConfirmation('CFeedbackUiT.CS1101','New Session ##');" title="">
Delete
</a>
<span data-original-title="Copy this feedback session to other courses" data-placement="top" data-toggle="tooltip" title="">
<a class="btn btn-primary btn-sm" data-actionlink="/page/instructorFeedbackEditCopyPage?user=CFeedbackUiT.instructor" data-courseid="CFeedbackUiT.CS1101" data-fsname="New Session" data-placement="top" data-target="#fsCopyModal" data-toggle="modal" href="#" id="button_fscopy">
<a class="btn btn-primary btn-sm" data-actionlink="/page/instructorFeedbackEditCopyPage?user=CFeedbackUiT.instructor" data-courseid="CFeedbackUiT.CS1101" data-fsname="New Session ##" data-placement="top" data-target="#fsCopyModal" data-toggle="modal" href="#" id="button_fscopy">
Copy
</a>
</span>
Expand Down Expand Up @@ -187,7 +187,7 @@ <h5 class="col-sm-2">
</h5>
<div class="col-sm-10">
<h5 class="form-control-static font-weight-normal">
New Session
New Session ##
</h5>
</div>
</div>
Expand Down Expand Up @@ -732,7 +732,7 @@ <h5 class="col-xs-2" data-original-title="Select this option to use a custom tim
</div>
</div>
</div>
<input disabled="" name="fsname" type="hidden" value="New Session">
<input disabled="" name="fsname" type="hidden" value="New Session ##">
<input disabled="" name="courseid" type="hidden" value="CFeedbackUiT.CS1101">
<input disabled="" name="user" type="hidden" value="CFeedbackUiT.instructor">
</form>
Expand Down Expand Up @@ -840,7 +840,7 @@ <h4 class="modal-title">
<a class="btn btn-primary margin-bottom-7px" id="button_copy">
Copy Question
</a>
<a class="btn btn-primary margin-bottom-7px" href="/page/instructorFeedbacksPage?user=CFeedbackUiT.instructor&courseid=CFeedbackUiT.CS1101&fsname=New+Session">
<a class="btn btn-primary margin-bottom-7px" href="/page/instructorFeedbacksPage?user=CFeedbackUiT.instructor&courseid=CFeedbackUiT.CS1101&fsname=New+Session+%23%23">
Done Editing
</a>
</div>
Expand Down Expand Up @@ -1588,7 +1588,7 @@ <h4 class="modal-title">
</div>
</div>
<input name="questionnum" type="hidden" value="1">
<input name="fsname" type="hidden" value="New Session">
<input name="fsname" type="hidden" value="New Session ##">
<input name="courseid" type="hidden" value="CFeedbackUiT.CS1101">
<input name="showresponsesto" type="hidden" value="RECEIVER,INSTRUCTORS">
<input name="showgiverto" type="hidden" value="RECEIVER,INSTRUCTORS">
Expand Down Expand Up @@ -1643,7 +1643,7 @@ <h4 class="modal-title" id="copyModalTitle">
</tr>
</thead>
</table>
<input name="fsname" type="hidden" value="New Session">
<input name="fsname" type="hidden" value="New Session ##">
<input name="user" type="hidden" value="CFeedbackUiT.instructor">
<input name="courseid" type="hidden" value="CFeedbackUiT.CS1101">
</form>
Expand Down Expand Up @@ -1680,7 +1680,7 @@ <h4 class="modal-title" id="copyModalTitle">
</option>
</select>
</div>
<input name="fsname" type="hidden" value="New Session">
<input name="fsname" type="hidden" value="New Session ##">
<input name="courseid" type="hidden" value="CFeedbackUiT.CS1101">
<div class="col-sm-6">
<input class="btn btn-primary" id="button_preview_student" type="submit" value="Preview as Student">
Expand All @@ -1703,7 +1703,7 @@ <h4 class="modal-title" id="copyModalTitle">
</option>
</select>
</div>
<input name="fsname" type="hidden" value="New Session">
<input name="fsname" type="hidden" value="New Session ##">
<input name="courseid" type="hidden" value="CFeedbackUiT.CS1101">
<div class="col-sm-6">
<input class="btn btn-primary" id="button_preview_instructor" type="submit" value="Preview as Instructor">
Expand Down
Loading

0 comments on commit 108f149

Please sign in to comment.