Skip to content

Commit

Permalink
Merge pull request #370 from correctexam/367-send-email-to-only-one-s…
Browse files Browse the repository at this point in the history
…tudent

allow send email to only one student close #367
  • Loading branch information
barais authored Oct 12, 2023
2 parents e41d706 + 706b9ec commit 3503863
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/main/webapp/app/config/font-awesome-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
faImage,
faRotateRight,
faTrash,
faEnvelope,

// jhipster-needle-add-icon-import
} from '@fortawesome/free-solid-svg-icons';
Expand Down Expand Up @@ -104,6 +105,7 @@ export const fontAwesomeIcons = [
faImage,
faRotateRight,
faTrash,
faEnvelope,

// jhipster-needle-add-icon-import
];
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ export class ExportanonymoupdfComponent implements OnInit {
this.examId = params.get('examid')!;
if (params.get('sheetuid') !== null) {
this.sheetuid = params.get('sheetuid')!;
this.exportPdfService.generatePdf(this.examId, this.messageService, true, this.sheetuid).then(() => (this.blocked = false));
this.exportPdfService
.generatePdf(this.examId, this.messageService, true, false, this.sheetuid)
.then(() => (this.blocked = false));
} else {
this.exportPdfService.generatePdf(this.examId, this.messageService, true).then(() => (this.blocked = false));
this.exportPdfService.generatePdf(this.examId, this.messageService, true, false).then(() => (this.blocked = false));
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ExportPdfService {
examId = '';
scan!: IScan;
scale = 2;
sheetuid: string | undefined;
upload = true;
nbrPageInTemplate = 0;
nbrPageInExam = 0;
examExport: ExportPDFDto | undefined;
Expand All @@ -65,13 +65,19 @@ export class ExportPdfService {
private db: CacheServiceImpl,
) {}

async generatePdf(examId: string, messageService: MessageService, anonymous: boolean, sheetuuid?: string): Promise<boolean> {
async generatePdf(
examId: string,
messageService: MessageService,
anonymous: boolean,
upload: boolean,
sheetuuid?: string,
): Promise<boolean> {
this.messageService = messageService;
this.anonymous = anonymous;
this.examId = examId;
this.upload = true;
let uri = 'api/exportpdf/' + this.examId;
if (sheetuuid !== undefined) {
this.sheetuid = sheetuuid;
uri = 'api/exportpdf4sheet/' + this.examId + '/' + sheetuuid;
}

Expand Down Expand Up @@ -287,7 +293,7 @@ export class ExportPdfService {
}
this.canvass.delete(page)!;
}
if (!this.sheetuid) {
if (this.upload) {
const blob = new Blob([pdf.output('blob')], { type: 'application/pdf' });
await this.cacheUploadService.uploadStudentPdf(blob, +this.examId, this.translateService, this.messageService, sheet.name! + '.pdf', {
setMessage(v: string): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h4 jhiTranslate="scanexam.confirmemail">Confirmation envoi mail</h4>
<label jhiTranslate="scanexam.envoipdf">Envoi de la copie en pdf:</label>
<p-checkbox [binary]="true" [(ngModel)]="mailpdf" [style]="{ width: '100%' }" />
</div>
<div class="col-12">
<div *ngIf="!currentStudentMail" class="col-12">
<label jhiTranslate="scanexam.envoiabi">Envoi du mail aux absents:</label>
<p-checkbox [binary]="true" [(ngModel)]="mailabi" [style]="{ width: '100%' }" />
</div>
Expand Down Expand Up @@ -133,6 +133,7 @@ <h2 id="jhi-course-heading" data-cy="CourseCreateUpdateHeading" jhiTranslate="sc
<th jhiTranslate="scanexam.lienprof">LIEN PROF</th>
<th jhiTranslate="scanexam.lieneleve">LIEN</th>
<th jhiTranslate="scanexam.lienelevepdf">LIEN</th>
<th jhiTranslate="scanexam.envoimailpersonal">Envoi Mail</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-student>
Expand All @@ -155,6 +156,20 @@ <h2 id="jhi-course-heading" data-cy="CourseCreateUpdateHeading" jhiTranslate="sc
<a target="_blank" href="{{ 'exportpdf/' + examid! + '/' + student.uuid }}" jhiTranslate="scanexam.pdf">pdf</a>
</td>
<td *ngIf="student.abi">ABI</td>
<td *ngIf="!student.abi">
<button
type="submit"
id="save-entity"
data-cy="entityCreateSaveButton"
class="p-button p-button-primary mr-5"
[pTooltip]="'scanexam.sendirectemail' | translate"
[tooltipPosition]="'left'"
(click)="showEmailSt(student)"
>
<fa-icon icon="envelope"></fa-icon>
</button>
</td>
<td *ngIf="student.abi"></td>
</tr>
</ng-template>
</p-table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ResultatStudentcourseComponent implements OnInit {
mailSubject = '';
mailBody = '';
mailabiBody = '';

currentStudentMail: any;
mailabi = false;
mailpdf = false;
exam: IExam | undefined;
Expand Down Expand Up @@ -80,6 +80,12 @@ export class ResultatStudentcourseComponent implements OnInit {
}

showEmailStudent(): void {
this.currentStudentMail = undefined;
this.showEmail = true;
}

showEmailSt(st: any): void {
this.currentStudentMail = st;
this.showEmail = true;
}

Expand All @@ -90,16 +96,18 @@ export class ResultatStudentcourseComponent implements OnInit {
mailabi: this.mailabi,
mailpdf: this.mailpdf,
bodyabi: this.mailabiBody,
sheetuuid: this.currentStudentMail?.uuid,
};
this.blocked = true;
let res = true;
if (this.mailpdf) {
res = await this.exportPdfService.generatePdf(this.examid!, this.messageService, false);
res = await this.exportPdfService.generatePdf(this.examid!, this.messageService, false, true, this.currentStudentMail?.uuid);
}
try {
if (res) {
await firstValueFrom(this.http.post(this.applicationConfigService.getEndpointFor('api/sendResult/' + this.examid), mail));
this.showEmail = false;
this.currentStudentMail = undefined;
this.translate.get('scanexam.mailsent').subscribe(data => {
this.blocked = false;
this.messageService.add({
Expand All @@ -110,6 +118,8 @@ export class ResultatStudentcourseComponent implements OnInit {
});
} else {
this.showEmail = false;
this.currentStudentMail = undefined;

this.translate.get('scanexam.mailnotsent').subscribe(data => {
this.blocked = false;
this.messageService.add({
Expand All @@ -121,7 +131,7 @@ export class ResultatStudentcourseComponent implements OnInit {
}
} catch (e: any) {
this.showEmail = false;

this.currentStudentMail = undefined;
this.translate.get('scanexam.mailnotsent').subscribe(data => {
this.blocked = false;
this.messageService.add({
Expand Down
4 changes: 3 additions & 1 deletion src/main/webapp/i18n/en/scanexammodule.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@
"cleancachesessiondone": "The browser's cache has been cleared, you can try to reconnect.",
"libelle": "Question label",
"libelletooltip": "This allows you to give a label to a question (if required)",
"gotolistquestion": "Go back to question list"
"gotolistquestion": "Go back to question list",
"sendirectemail": "Send an email with the results for this student",
"envoimailpersonal": "Send email"
}
}
4 changes: 3 additions & 1 deletion src/main/webapp/i18n/fr/scanexammodule.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@
"cleancachesessiondone": "Le nettoyage du cache est effectuée, vous pouvez essayer de vous reconnecter",
"libelle": "Intitulé de la question",
"libelletooltip": "Cela permet de mettre un intitulé pour une question",
"gotolistquestion": "Retourner à la liste des questions (résumé de l'état de la correction)"
"gotolistquestion": "Retourner à la liste des questions (résumé de l'état de la correction)",
"sendirectemail": "Envoi d'un email avec les résultats pour cet étudiant",
"envoimailpersonal": "Envoi Email"
}
}

0 comments on commit 3503863

Please sign in to comment.