Skip to content

Commit

Permalink
Merge branch 'TEAMMATES:master' into Instructor_extending_table_sort_…
Browse files Browse the repository at this point in the history
…by_team_issue
  • Loading branch information
suneelval authored Jul 8, 2024
2 parents 0fbb9cc + 836f637 commit feebdd3
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/main/java/teammates/logic/api/EmailGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ private EmailWrapper generateFeedbackSessionEmailBaseForNotifiedInstructors(
"${feedbackSessionName}", SanitizationHelper.sanitizeForHtml(session.getFeedbackSessionName()),
"${deadline}", SanitizationHelper.sanitizeForHtml(
TimeHelper.formatInstant(endTime, session.getTimeZone(), DATETIME_DISPLAY_FORMAT)),
"${instructorPreamble}", fillUpInstructorPreamble(course),
"${instructorPreamble}", fillUpInstructorPreamble(course, session),
"${sessionInstructions}", session.getInstructionsString(),
"${submitUrl}", "{in the actual email sent to the students, this will be the unique link}",
"${reportUrl}", "{in the actual email sent to the students, this will be the unique link}",
Expand Down Expand Up @@ -1020,10 +1020,14 @@ private String fillUpInstructorRejoinAfterGoogleIdResetFragment(InstructorAttrib
"${supportEmail}", Config.SUPPORT_EMAIL);
}

private String fillUpInstructorPreamble(CourseAttributes course) {
private String fillUpInstructorPreamble(CourseAttributes course, FeedbackSessionAttributes session) {
var recoveryUrl = Config.getFrontEndAppUrl(Const.WebPageURIs.SESSIONS_LINK_RECOVERY_PAGE).toAbsoluteString();
return Templates.populateTemplate(EmailTemplates.FRAGMENT_INSTRUCTOR_COPY_PREAMBLE,
"${courseId}", SanitizationHelper.sanitizeForHtml(course.getId()),
"${courseName}", SanitizationHelper.sanitizeForHtml(course.getName()));
"${courseName}", SanitizationHelper.sanitizeForHtml(course.getName()),
"${feedbackSessionName}",
SanitizationHelper.sanitizeForHtml(session.getFeedbackSessionName()),
"${sessionsRecoveryLink}", recoveryUrl);
}

/**
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/teammates/sqllogic/api/SqlEmailGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ private EmailWrapper generateFeedbackSessionEmailBaseForNotifiedInstructors(
"${feedbackSessionName}", SanitizationHelper.sanitizeForHtml(session.getName()),
"${deadline}", SanitizationHelper.sanitizeForHtml(
TimeHelper.formatInstant(endTime, session.getCourse().getTimeZone(), DATETIME_DISPLAY_FORMAT)),
"${instructorPreamble}", fillUpInstructorPreamble(course),
"${instructorPreamble}", fillUpInstructorPreamble(course, session),
"${sessionInstructions}", session.getInstructionsString(),
"${submitUrl}", "{in the actual email sent to the students, this will be the unique link}",
"${reportUrl}", "{in the actual email sent to the students, this will be the unique link}",
Expand Down Expand Up @@ -1098,10 +1098,14 @@ private String fillUpInstructorRejoinAfterGoogleIdResetFragment(Instructor instr
"${supportEmail}", Config.SUPPORT_EMAIL);
}

private String fillUpInstructorPreamble(Course course) {
private String fillUpInstructorPreamble(Course course, FeedbackSession session) {
var recoveryUrl = Config.getFrontEndAppUrl(Const.WebPageURIs.SESSIONS_LINK_RECOVERY_PAGE).toAbsoluteString();

return Templates.populateTemplate(EmailTemplates.FRAGMENT_INSTRUCTOR_COPY_PREAMBLE,
"${courseId}", SanitizationHelper.sanitizeForHtml(course.getId()),
"${courseName}", SanitizationHelper.sanitizeForHtml(course.getName()));
"${courseName}", SanitizationHelper.sanitizeForHtml(course.getName()),
"${feedbackSessionName}", SanitizationHelper.sanitizeForHtml(session.getName()),
"${sessionsRecoveryLink}", recoveryUrl);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<p>
Kindly note that this email simply serves as a preview of how the email will appear to the
students, and the link is not the actual link that the students will receive.
As such, please <b style="color: red;">do not forward</b> this email to students.
We recommend that you make the following announcement (edit content as you see fit) using an alternative means (e.g., your course announcements) to alert students:
<hr>
The TEAMMATES session ${feedbackSessionName} in course [${courseId}] ${courseName} is now open.
If you did not receive the unique access link via email, and you can't find it in your spam box either, go to <a href=${sessionsRecoveryLink}>this link</a> to recover the access link.
<hr>
The email below has been sent to students of course: [${courseId}] ${courseName}.
<br><br>
=== Email message as seen by the students ===
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<p>Hello Instructor1 Course1,</p>

<p>
Kindly note that this email simply serves as a preview of how the email will appear to the
students, and the link is not the actual link that the students will receive.
As such, please <b style="color: red;">do not forward</b> this email to students.
We recommend that you make the following announcement (edit content as you see fit) using an alternative means (e.g., your course announcements) to alert students:
<hr>
The TEAMMATES session First feedback session in course [idOfTypicalCourse1] Typical Course 1 with 2 Evals is now open.
If you did not receive the unique access link via email, and you can't find it in your spam box either, go to <a href=${app.url}/web/front/help/session-links-recovery>this link</a> to recover the access link.
<hr>
The email below has been sent to students of course: [idOfTypicalCourse1] Typical Course 1 with 2 Evals.
<br><br>
=== Email message as seen by the students ===
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<p>Hello Instructor&lt;script&gt; alert(&#39;hi!&#39;); &lt;&#x2f;script&gt;,</p>

<p>
Kindly note that this email simply serves as a preview of how the email will appear to the
students, and the link is not the actual link that the students will receive.
As such, please <b style="color: red;">do not forward</b> this email to students.
We recommend that you make the following announcement (edit content as you see fit) using an alternative means (e.g., your course announcements) to alert students:
<hr>
The TEAMMATES session Normal feedback session name in course [idOfTestingSanitizationCourse] Testing&lt;script&gt; alert(&#39;hi!&#39;); &lt;&#x2f;script&gt; is now open.
If you did not receive the unique access link via email, and you can't find it in your spam box either, go to <a href=${app.url}/web/front/help/session-links-recovery>this link</a> to recover the access link.
<hr>
The email below has been sent to students of course: [idOfTestingSanitizationCourse] Testing&lt;script&gt; alert(&#39;hi!&#39;); &lt;&#x2f;script&gt;.
<br><br>
=== Email message as seen by the students ===
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<p>Hello Instructor1 Course1,</p>

<p>
Kindly note that this email simply serves as a preview of how the email will appear to the
students, and the link is not the actual link that the students will receive.
As such, please <b style="color: red;">do not forward</b> this email to students.
We recommend that you make the following announcement (edit content as you see fit) using an alternative means (e.g., your course announcements) to alert students:
<hr>
The TEAMMATES session First feedback session in course [idOfTypicalCourse1] Typical Course 1 with 2 Evals is now open.
If you did not receive the unique access link via email, and you can't find it in your spam box either, go to <a href=${app.url}/web/front/help/session-links-recovery>this link</a> to recover the access link.
<hr>
The email below has been sent to students of course: [idOfTypicalCourse1] Typical Course 1 with 2 Evals.
<br><br>
=== Email message as seen by the students ===
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<p>Hello Instructor&lt;script&gt; alert(&#39;hi!&#39;); &lt;&#x2f;script&gt;,</p>

<p>
Kindly note that this email simply serves as a preview of how the email will appear to the
students, and the link is not the actual link that the students will receive.
As such, please <b style="color: red;">do not forward</b> this email to students.
We recommend that you make the following announcement (edit content as you see fit) using an alternative means (e.g., your course announcements) to alert students:
<hr>
The TEAMMATES session Normal feedback session name in course [idOfTestingSanitizationCourse] Testing&lt;script&gt; alert(&#39;hi!&#39;); &lt;&#x2f;script&gt; is now open.
If you did not receive the unique access link via email, and you can't find it in your spam box either, go to <a href=${app.url}/web/front/help/session-links-recovery>this link</a> to recover the access link.
<hr>
The email below has been sent to students of course: [idOfTestingSanitizationCourse] Testing&lt;script&gt; alert(&#39;hi!&#39;); &lt;&#x2f;script&gt;.
<br><br>
=== Email message as seen by the students ===
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<p>Hello Instructor1 Course1,</p>

<p>
Kindly note that this email simply serves as a preview of how the email will appear to the
students, and the link is not the actual link that the students will receive.
As such, please <b style="color: red;">do not forward</b> this email to students.
We recommend that you make the following announcement (edit content as you see fit) using an alternative means (e.g., your course announcements) to alert students:
<hr>
The TEAMMATES session First feedback session in course [idOfTypicalCourse1] Typical Course 1 with 2 Evals is now open.
If you did not receive the unique access link via email, and you can't find it in your spam box either, go to <a href=${app.url}/web/front/help/session-links-recovery>this link</a> to recover the access link.
<hr>
The email below has been sent to students of course: [idOfTypicalCourse1] Typical Course 1 with 2 Evals.
<br><br>
=== Email message as seen by the students ===
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<p>Hello Instructor1 Course1,</p>

<p>
Kindly note that this email simply serves as a preview of how the email will appear to the
students, and the link is not the actual link that the students will receive.
As such, please <b style="color: red;">do not forward</b> this email to students.
We recommend that you make the following announcement (edit content as you see fit) using an alternative means (e.g., your course announcements) to alert students:
<hr>
The TEAMMATES session First feedback session in course [idOfTypicalCourse1] Typical Course 1 with 2 Evals is now open.
If you did not receive the unique access link via email, and you can't find it in your spam box either, go to <a href=${app.url}/web/front/help/session-links-recovery>this link</a> to recover the access link.
<hr>
The email below has been sent to students of course: [idOfTypicalCourse1] Typical Course 1 with 2 Evals.
<br><br>
=== Email message as seen by the students ===
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<p>Hello Instructor1 Course1,</p>

<p>
Kindly note that this email simply serves as a preview of how the email will appear to the
students, and the link is not the actual link that the students will receive.
As such, please <b style="color: red;">do not forward</b> this email to students.
We recommend that you make the following announcement (edit content as you see fit) using an alternative means (e.g., your course announcements) to alert students:
<hr>
The TEAMMATES session First feedback session in course [idOfTypicalCourse1] Typical Course 1 with 2 Evals is now open.
If you did not receive the unique access link via email, and you can't find it in your spam box either, go to <a href=${app.url}/web/front/help/session-links-recovery>this link</a> to recover the access link.
<hr>
The email below has been sent to students of course: [idOfTypicalCourse1] Typical Course 1 with 2 Evals.
<br><br>
=== Email message as seen by the students ===
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="plain-text-area" *ngIf="!questionDetails.shouldAllowRichText">
<textarea [ngModel]="responseDetails.answer" (ngModelChange)="triggerResponseDetailsChange('answer', $event)" [attr.aria-label]="getAriaLabel()" [disabled]="isDisabled"></textarea>
<textarea [ngModel]="decodedAnswer" (ngModelChange)="triggerResponseDetailsChange('answer', $event)" [attr.aria-label]="getAriaLabel()" [disabled]="isDisabled"></textarea>
</div>
<tm-rich-text-editor *ngIf="questionDetails.shouldAllowRichText" role="textbox" [attr.aria-label]="getAriaLabel()" [richText]="responseDetails.answer" (richTextChange)="triggerResponseDetailsChange('answer', $event)" [isDisabled]="isDisabled"></tm-rich-text-editor>
<div class="margin-top-7px text-secondary text-end">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';

import { FormsModule } from '@angular/forms';
import { TextQuestionEditAnswerFormComponent } from './text-question-edit-answer-form.component';
import { FeedbackQuestionType } from '../../../../types/api-request';
import { RichTextEditorModule } from '../../rich-text-editor/rich-text-editor.module';

describe('TextQuestionEditAnswerFormComponent', () => {
Expand All @@ -22,10 +23,33 @@ describe('TextQuestionEditAnswerFormComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(TextQuestionEditAnswerFormComponent);
component = fixture.componentInstance;
component.questionDetails = {
shouldAllowRichText: false,
questionType: FeedbackQuestionType.TEXT,
questionText: 'Sample question',
recommendedLength: 50,
};
component.responseDetails = { answer: '', questionType: FeedbackQuestionType.TEXT };
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});

it('should decode HTML entities for @ sign in plain-text mode', () => {
component.questionDetails.shouldAllowRichText = false;
component.responseDetails.answer = 'Test &#64; symbol';
fixture.detectChanges();

expect(component.decodedAnswer).toBe('Test @ symbol');
});

it('should decode HTML entities for apostrophe in plain-text mode', () => {
component.questionDetails.shouldAllowRichText = false;
component.responseDetails.answer = 'It&#39;s a test';
fixture.detectChanges();

expect(component.decodedAnswer).toBe("It's a test");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ export class TextQuestionEditAnswerFormComponent
super(DEFAULT_TEXT_QUESTION_DETAILS(), DEFAULT_TEXT_RESPONSE_DETAILS());
}

decodeHtml(html: string): string {
const txt = document.createElement('textarea');
txt.innerHTML = html;
return txt.value;
}

get wordCount(): number {
return this.responseDetails.answer.split(/\s/g)
.filter((item: string) => item.match(/\w/)).length;
Expand All @@ -41,4 +47,8 @@ export class TextQuestionEditAnswerFormComponent

return this.wordCount > lowerLimit && this.wordCount < upperLimit;
}

get decodedAnswer(): string {
return this.decodeHtml(this.responseDetails.answer);
}
}

0 comments on commit feebdd3

Please sign in to comment.