Skip to content

Commit

Permalink
Merge branch 'master' into jsegawa-InstructorResponsesViewBase-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
domoberzin authored Jul 5, 2024
2 parents 4487b99 + f604c11 commit 1ba39b8
Show file tree
Hide file tree
Showing 20 changed files with 215 additions and 37 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
Expand Up @@ -4,6 +4,9 @@ exports[`AccountRequestTableComponent should display account requests with no re
<tm-account-request-table
accountRequests={[Function Array]}
accountService={[Function AccountService]}
isApprovingAccount={[Function Array]}
isRejectingAccount={[Function Array]}
isResettingAccount={[Function Array]}
ngbModal={[Function _NgbModal]}
searchString=""
simpleModalService={[Function SimpleModalService]}
Expand Down Expand Up @@ -267,6 +270,9 @@ exports[`AccountRequestTableComponent should display account requests with reset
<tm-account-request-table
accountRequests={[Function Array]}
accountService={[Function AccountService]}
isApprovingAccount={[Function Array]}
isRejectingAccount={[Function Array]}
isResettingAccount={[Function Array]}
ngbModal={[Function _NgbModal]}
searchString={[Function String]}
simpleModalService={[Function SimpleModalService]}
Expand Down Expand Up @@ -592,6 +598,9 @@ exports[`AccountRequestTableComponent should snap with an expanded account reque
<tm-account-request-table
accountRequests={[Function Array]}
accountService={[Function AccountService]}
isApprovingAccount={[Function Array]}
isRejectingAccount={[Function Array]}
isResettingAccount={[Function Array]}
ngbModal={[Function _NgbModal]}
searchString=""
simpleModalService={[Function SimpleModalService]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@
<i class="fa-solid fa-eye"></i>
</a>
</div>
<button id="approve-account-request-{{i}}" class="btn btn-success" [disabled]="!accountRequest.status || accountRequest.status === 'APPROVED' || accountRequest.status === 'REGISTERED'" (click)="$event.stopPropagation(); approveAccountRequest(accountRequest)">Approve</button>
<button id="approve-account-request-{{i}}" class="btn btn-success" [disabled]="!accountRequest.status || accountRequest.status === 'APPROVED' || accountRequest.status === 'REGISTERED' || isApprovingAccount[i]" (click)="$event.stopPropagation(); approveAccountRequest(accountRequest, i)"> <tm-ajax-loading *ngIf="isApprovingAccount[i]"></tm-ajax-loading>Approve</button>
<span ngbDropdown container="body">
<button id="reject-account-request-{{i}}" type="button" class="btn btn-warning" [disabled]="!accountRequest.status || accountRequest.status === 'REGISTERED' || accountRequest.status === 'APPROVED' || accountRequest.status === 'REJECTED'" ngbDropdownToggle> Reject </button>
<button id="reject-account-request-{{i}}" type="button" class="btn btn-warning" [disabled]="!accountRequest.status || accountRequest.status === 'REGISTERED' || accountRequest.status === 'APPROVED' || accountRequest.status === 'REJECTED' || isRejectingAccount[i]" ngbDropdownToggle> <tm-ajax-loading *ngIf="isRejectingAccount[i]"></tm-ajax-loading> Reject </button>
<div ngbDropdownMenu (click)="$event.stopPropagation()">
<button id="reject-request-{{i}}" class="btn btn-light btn-sm dropdown-item" (click)="$event.stopPropagation(); rejectAccountRequest(accountRequest)"> Reject </button>
<button id="reject-request-with-reason-{{i}}" class="btn btn-light btn-sm dropdown-item" (click)="$event.stopPropagation(); rejectAccountRequestWithReason(accountRequest)"> Reject With Reason </button>
<button id="reject-request-{{i}}" class="btn btn-light btn-sm dropdown-item" (click)="$event.stopPropagation(); rejectAccountRequest(accountRequest, i)"> Reject </button>
<button id="reject-request-with-reason-{{i}}" class="btn btn-light btn-sm dropdown-item" (click)="$event.stopPropagation(); rejectAccountRequestWithReason(accountRequest, i)"> Reject With Reason </button>
</div>
</span>
<div *ngIf="searchString" class="ngb-tooltip-class" [ngbTooltip]="accountRequest.registeredAtText && 'Account requests of registered instructors cannot be deleted'" placement="top">
<button id="reset-account-request-{{i}}" class="btn btn-primary" [disabled]="!accountRequest.registeredAtText" (click)="$event.stopPropagation(); resetAccountRequest(accountRequest);">Reset</button>
<button id="reset-account-request-{{i}}" class="btn btn-primary" [disabled]="!accountRequest.registeredAtText || isResettingAccount[i]" (click)="$event.stopPropagation(); resetAccountRequest(accountRequest, i);"> <tm-ajax-loading *ngIf="isResettingAccount[i]"></tm-ajax-loading>Reset</button>
</div>
</div>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,15 @@ describe('AccountRequestTableComponent', () => {
component.searchString = 'test';
fixture.detectChanges();

const modalSpy = jest.spyOn(simpleModalService, 'openConfirmationModal').mockImplementation(() => {
return createMockNgbModalRef({});
});
const mockModalRef = {
componentInstance: {},
result: Promise.resolve({}),
dismissed: {
subscribe: jest.fn(),
},
};

const modalSpy = jest.spyOn(simpleModalService, 'openConfirmationModal').mockReturnValue(mockModalRef as any);

jest.spyOn(accountService, 'resetAccountRequest').mockReturnValue(of({
joinLink: 'joinlink',
Expand Down Expand Up @@ -245,9 +251,15 @@ describe('AccountRequestTableComponent', () => {
component.searchString = 'test';
fixture.detectChanges();

const modalSpy = jest.spyOn(simpleModalService, 'openConfirmationModal').mockImplementation(() => {
return createMockNgbModalRef({});
});
const mockModalRef = {
componentInstance: {},
result: Promise.resolve({}),
dismissed: {
subscribe: jest.fn(),
},
};

const modalSpy = jest.spyOn(simpleModalService, 'openConfirmationModal').mockReturnValue(mockModalRef as any);

jest.spyOn(accountService, 'resetAccountRequest').mockReturnValue(throwError(() => ({
error: {
Expand Down Expand Up @@ -318,6 +330,9 @@ describe('AccountRequestTableComponent', () => {
const mockModalRef = {
componentInstance: {},
result: Promise.resolve({}),
dismissed: {
subscribe: jest.fn(),
},
};

const modalSpy = jest.spyOn(ngbModal, 'open').mockReturnValue(mockModalRef as any);
Expand Down
Loading

0 comments on commit 1ba39b8

Please sign in to comment.