Update app.js
Browse files
app.js
CHANGED
|
@@ -344,14 +344,14 @@ function generatePDFReport() {
|
|
| 344 |
const contentWidth = pageWidth - 2 * margin;
|
| 345 |
let yPosition = 30;
|
| 346 |
|
| 347 |
-
// Couleurs IFS
|
| 348 |
const ifsBlue = [0, 102, 204];
|
| 349 |
const ifsGray = [108, 117, 125];
|
| 350 |
const successGreen = [40, 167, 69];
|
| 351 |
const dangerRed = [220, 53, 69];
|
| 352 |
|
| 353 |
// === EN-TÊTE ===
|
| 354 |
-
doc.setFillColor
|
| 355 |
doc.rect(0, 0, pageWidth, 25, 'F');
|
| 356 |
|
| 357 |
doc.setTextColor(255, 255, 255);
|
|
@@ -404,7 +404,7 @@ function generatePDFReport() {
|
|
| 404 |
const pass = (points / total) >= STATE.passThreshold;
|
| 405 |
|
| 406 |
// Boîte de résultat
|
| 407 |
-
doc.setFillColor(pass ?
|
| 408 |
doc.rect(margin, yPosition, contentWidth, 30, 'F');
|
| 409 |
|
| 410 |
doc.setTextColor(255, 255, 255);
|
|
@@ -513,7 +513,7 @@ function generatePDFReport() {
|
|
| 513 |
|
| 514 |
doc.setFontSize(9);
|
| 515 |
doc.setFont(undefined, 'normal');
|
| 516 |
-
doc.setTextColor
|
| 517 |
doc.text(`[${q.category || 'Sans catégorie'}]`, margin + 50, yPosition);
|
| 518 |
|
| 519 |
// Indicateur de résultat
|
|
@@ -523,10 +523,10 @@ function generatePDFReport() {
|
|
| 523 |
doc.setTextColor(128, 128, 128);
|
| 524 |
doc.text('NON REPONDU', pageWidth - margin - 30, yPosition);
|
| 525 |
} else if (isCorrect) {
|
| 526 |
-
doc.setTextColor
|
| 527 |
doc.text('CORRECT', pageWidth - margin - 30, yPosition);
|
| 528 |
} else {
|
| 529 |
-
doc.setTextColor
|
| 530 |
doc.text('INCORRECT', pageWidth - margin - 30, yPosition);
|
| 531 |
}
|
| 532 |
|
|
@@ -549,11 +549,11 @@ function generatePDFReport() {
|
|
| 549 |
let prefix = `${String.fromCharCode(65 + optIndex)}. `;
|
| 550 |
|
| 551 |
if (optIndex === q.correctAnswer) {
|
| 552 |
-
doc.setTextColor
|
| 553 |
doc.setFont(undefined, 'bold');
|
| 554 |
prefix = `[CORRECT] ${prefix}`;
|
| 555 |
} else if (optIndex === userAnswer && optIndex !== q.correctAnswer) {
|
| 556 |
-
doc.setTextColor
|
| 557 |
doc.setFont(undefined, 'normal');
|
| 558 |
prefix = `[VOTRE CHOIX] ${prefix}`;
|
| 559 |
} else {
|
|
@@ -571,7 +571,7 @@ function generatePDFReport() {
|
|
| 571 |
// Explication si disponible
|
| 572 |
if (q.explanation || q.regulation) {
|
| 573 |
yPosition += 3;
|
| 574 |
-
doc.setTextColor
|
| 575 |
doc.setFontSize(8);
|
| 576 |
doc.setFont(undefined, 'italic');
|
| 577 |
|
|
@@ -597,7 +597,7 @@ function generatePDFReport() {
|
|
| 597 |
for (let i = 1; i <= pageCount; i++) {
|
| 598 |
doc.setPage(i);
|
| 599 |
doc.setFontSize(8);
|
| 600 |
-
doc.setTextColor
|
| 601 |
doc.text(`Page ${i}/${pageCount}`, pageWidth - margin, doc.internal.pageSize.getHeight() - 10);
|
| 602 |
doc.text('Généré par IFS Quiz App', margin, doc.internal.pageSize.getHeight() - 10);
|
| 603 |
}
|
|
|
|
| 344 |
const contentWidth = pageWidth - 2 * margin;
|
| 345 |
let yPosition = 30;
|
| 346 |
|
| 347 |
+
// Couleurs IFS - utilisation de apply() au lieu du spread operator
|
| 348 |
const ifsBlue = [0, 102, 204];
|
| 349 |
const ifsGray = [108, 117, 125];
|
| 350 |
const successGreen = [40, 167, 69];
|
| 351 |
const dangerRed = [220, 53, 69];
|
| 352 |
|
| 353 |
// === EN-TÊTE ===
|
| 354 |
+
doc.setFillColor.apply(doc, ifsBlue);
|
| 355 |
doc.rect(0, 0, pageWidth, 25, 'F');
|
| 356 |
|
| 357 |
doc.setTextColor(255, 255, 255);
|
|
|
|
| 404 |
const pass = (points / total) >= STATE.passThreshold;
|
| 405 |
|
| 406 |
// Boîte de résultat
|
| 407 |
+
doc.setFillColor.apply(doc, pass ? successGreen : dangerRed);
|
| 408 |
doc.rect(margin, yPosition, contentWidth, 30, 'F');
|
| 409 |
|
| 410 |
doc.setTextColor(255, 255, 255);
|
|
|
|
| 513 |
|
| 514 |
doc.setFontSize(9);
|
| 515 |
doc.setFont(undefined, 'normal');
|
| 516 |
+
doc.setTextColor.apply(doc, ifsGray);
|
| 517 |
doc.text(`[${q.category || 'Sans catégorie'}]`, margin + 50, yPosition);
|
| 518 |
|
| 519 |
// Indicateur de résultat
|
|
|
|
| 523 |
doc.setTextColor(128, 128, 128);
|
| 524 |
doc.text('NON REPONDU', pageWidth - margin - 30, yPosition);
|
| 525 |
} else if (isCorrect) {
|
| 526 |
+
doc.setTextColor.apply(doc, successGreen);
|
| 527 |
doc.text('CORRECT', pageWidth - margin - 30, yPosition);
|
| 528 |
} else {
|
| 529 |
+
doc.setTextColor.apply(doc, dangerRed);
|
| 530 |
doc.text('INCORRECT', pageWidth - margin - 30, yPosition);
|
| 531 |
}
|
| 532 |
|
|
|
|
| 549 |
let prefix = `${String.fromCharCode(65 + optIndex)}. `;
|
| 550 |
|
| 551 |
if (optIndex === q.correctAnswer) {
|
| 552 |
+
doc.setTextColor.apply(doc, successGreen);
|
| 553 |
doc.setFont(undefined, 'bold');
|
| 554 |
prefix = `[CORRECT] ${prefix}`;
|
| 555 |
} else if (optIndex === userAnswer && optIndex !== q.correctAnswer) {
|
| 556 |
+
doc.setTextColor.apply(doc, dangerRed);
|
| 557 |
doc.setFont(undefined, 'normal');
|
| 558 |
prefix = `[VOTRE CHOIX] ${prefix}`;
|
| 559 |
} else {
|
|
|
|
| 571 |
// Explication si disponible
|
| 572 |
if (q.explanation || q.regulation) {
|
| 573 |
yPosition += 3;
|
| 574 |
+
doc.setTextColor.apply(doc, ifsGray);
|
| 575 |
doc.setFontSize(8);
|
| 576 |
doc.setFont(undefined, 'italic');
|
| 577 |
|
|
|
|
| 597 |
for (let i = 1; i <= pageCount; i++) {
|
| 598 |
doc.setPage(i);
|
| 599 |
doc.setFontSize(8);
|
| 600 |
+
doc.setTextColor.apply(doc, ifsGray);
|
| 601 |
doc.text(`Page ${i}/${pageCount}`, pageWidth - margin, doc.internal.pageSize.getHeight() - 10);
|
| 602 |
doc.text('Généré par IFS Quiz App', margin, doc.internal.pageSize.getHeight() - 10);
|
| 603 |
}
|