;
}
export interface StudentStore {
diff --git a/test/run-tests.ts b/test/run-tests.ts
index abc2993..fb6e1df 100644
--- a/test/run-tests.ts
+++ b/test/run-tests.ts
@@ -694,7 +694,70 @@ async function runAllTests() {
assert(pwaContent.includes('btnSync'), 'pwa.js must manage sync buttons in offline mode');
});
- // 6. Optional Live Portal Test (via environment variables only)
+ // 6. Security & Hardening Tests
+ await test('LocalDatabase: saveCredentials encrypts with AES-256-GCM and getRememberedCredentials decrypts', () => {
+ const fs = require('fs');
+ const path = require('path');
+ const db = LocalDatabase.getInstance();
+ const dbFile = path.resolve(process.cwd(), 'data', 'db.json');
+ const testId = 'audit_security_student';
+ const rawPass = 'SuperSecret123!';
+
+ db.saveCredentials(testId, rawPass);
+
+ // Verify stored format on disk is encrypted
+ const onDiskRaw = JSON.parse(fs.readFileSync(dbFile, 'utf-8'));
+ const storedCred = onDiskRaw.students[testId]?.rememberedCredentials;
+ assert(storedCred, 'Credentials must be saved');
+ assert(storedCred.password.startsWith('enc:'), 'Stored password must be encrypted with enc: prefix');
+ assert(!storedCred.password.includes(rawPass), 'Raw password must not be present in database file');
+
+ // Verify retrieval returns decrypted password
+ const retrieved = db.getRememberedCredentials(testId);
+ assert(retrieved !== null, 'Retrieved credentials must not be null');
+ assert.strictEqual(retrieved.password, rawPass, 'Decrypted password must match original raw password');
+
+ // Clean up
+ db.clearCredentials(testId);
+ });
+
+ await test('LocalDatabase: saveExamQuestions and getExamQuestions persists question review cache', () => {
+ const db = LocalDatabase.getInstance();
+ const testId = 'audit_exam_student';
+ const examKey = '3366_Y';
+ const sampleQuestions = [
+ {
+ questionNumber: 1,
+ correctAnswer: 'A',
+ studentAnswer: 'C',
+ imageUrl: 'https://panel.example.com/soru/1.png',
+ status: 'wrong' as const,
+ subjectId: '10',
+ subjectName: 'Türkçe'
+ }
+ ];
+
+ db.saveExamQuestions(testId, examKey, sampleQuestions);
+ const cached = db.getExamQuestions(testId, examKey);
+ assert(cached !== null, 'Cached questions should exist');
+ assert.strictEqual(cached.length, 1);
+ assert.strictEqual(cached[0].questionNumber, 1);
+ assert.strictEqual(cached[0].correctAnswer, 'A');
+ });
+
+ await test('PWA: sw.js contains route-specific offline fallbacks and ignoreSearch', () => {
+ const fs = require('fs');
+ const path = require('path');
+ const swPath = path.resolve(__dirname, '../public/sw.js');
+ const swContent = fs.readFileSync(swPath, 'utf-8');
+
+ assert(swContent.includes('ignoreSearch: true'), 'sw.js must match cache ignoring query strings');
+ assert(swContent.includes("url.pathname.startsWith('/exams')"), 'sw.js must have route fallback for exams');
+ assert(swContent.includes("url.pathname.startsWith('/syllabus')"), 'sw.js must have route fallback for syllabus');
+ assert(swContent.includes("url.pathname.startsWith('/private-lessons')"), 'sw.js must have route fallback for private lessons');
+ });
+
+ // 7. Optional Live Portal Test (via environment variables only)
const testStudentId = process.env.TEST_STUDENT_ID;
const testPassword = process.env.TEST_PASSWORD;
diff --git a/views/exams.ejs b/views/exams.ejs
index da8c4e2..a29b58c 100644
--- a/views/exams.ejs
+++ b/views/exams.ejs
@@ -140,7 +140,7 @@
<%= selectedExam.summary.name %>
<% if (selectedExam.hasAnswerKey && selectedExam.answerKeyUrl) { %>
-
+
Cevap Anahtarı
<% } %>
diff --git a/views/syllabus.ejs b/views/syllabus.ejs
index 201a557..342fb58 100644
--- a/views/syllabus.ejs
+++ b/views/syllabus.ejs
@@ -174,14 +174,18 @@
<% [1, 2, 3, 4, 5].forEach(function(d) { %>
- <% const lesson = (filteredSchedule[d] || []).find(l => l.periodNumber === p); %>
-
- <% if (lesson) { %>
- <%= lesson.subject %>
- <%= lesson.teacher %>
- <% if (lesson.station) { %>
- <%= lesson.station %>
- <% } %>
+ <% const dayLessons = (filteredSchedule[d] || []).filter(l => l.periodNumber === p); %>
+ |
+ <% if (dayLessons.length > 0) { %>
+ <% dayLessons.forEach(function(lesson) { %>
+
+ <%= lesson.subject %>
+ <%= lesson.teacher %>
+ <% if (lesson.station) { %>
+ <%= lesson.station %>
+ <% } %>
+
+ <% }); %>
<% } else { %>
—
<% } %>
|