feat: upgrade to SQLite session & data store with zero-data-loss migration, dark theme, and Turkish i18n
This commit is contained in:
parent
1af973d001
commit
56274f479b
27 changed files with 4222 additions and 1360 deletions
|
|
@ -24,8 +24,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
const modalTypeBtns = document.querySelectorAll('.modal-type-btn');
|
||||
const questionsGrid = document.getElementById('questionsGrid');
|
||||
const mistakeLoading = document.getElementById('mistakeLoading');
|
||||
const mistakeModalTitle = document.getElementById('mistakeModalTitle');
|
||||
const mistakeModalSubtitle = document.getElementById('mistakeModalSubtitle');
|
||||
|
||||
// Lightbox
|
||||
const imageLightbox = document.getElementById('imageLightbox');
|
||||
|
|
@ -39,6 +37,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
let activeTypeFilter = 'all'; // 'all' | 'wrong' | 'empty'
|
||||
let cachedWeaknesses = null;
|
||||
|
||||
function t(key, params) {
|
||||
if (typeof window.BeKulturT === 'function') {
|
||||
return window.BeKulturT(key, params);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Helper: Show Alert
|
||||
// ----------------------------------------------------
|
||||
|
|
@ -97,14 +102,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
// ----------------------------------------------------
|
||||
async function handleSync() {
|
||||
if (window.BeKulturPWA && window.BeKulturPWA.isOffline()) {
|
||||
showAlert('Çevrimdışı moddasınız. Sınav senkronizasyonu için internet bağlantısı gereklidir.', 'danger');
|
||||
showAlert(t('dashboard.offlineSyncAlert'), 'danger');
|
||||
return;
|
||||
}
|
||||
|
||||
const triggerBtn = btnSyncExams || btnEmptySync;
|
||||
if (triggerBtn) {
|
||||
triggerBtn.disabled = true;
|
||||
triggerBtn.textContent = 'Syncing...';
|
||||
triggerBtn.textContent = t('exams.syncing');
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -117,17 +122,17 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if (data.success) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
showAlert(data.error || 'Failed to sync exams', 'danger');
|
||||
showAlert(data.error || t('dashboard.syncFailed'), 'danger');
|
||||
if (triggerBtn) {
|
||||
triggerBtn.disabled = false;
|
||||
triggerBtn.textContent = 'Sync Exams';
|
||||
triggerBtn.textContent = t('exams.syncBtn');
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
showAlert('Connection error while syncing exams.', 'danger');
|
||||
showAlert(t('dashboard.networkError'), 'danger');
|
||||
if (triggerBtn) {
|
||||
triggerBtn.disabled = false;
|
||||
triggerBtn.textContent = 'Sync Exams';
|
||||
triggerBtn.textContent = t('exams.syncBtn');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -173,14 +178,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
} else {
|
||||
weaknessContainer.innerHTML = `
|
||||
<div class="empty-lessons-card">
|
||||
<p>Bu sınav için henüz zayıf konu kaydı bulunamadı veya tüm konularda tam başarı sağlandı.</p>
|
||||
<p>${escapeHtml(t('exams.weaknessEmpty'))}</p>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
} catch (err) {
|
||||
weaknessLoading.classList.add('hidden');
|
||||
weaknessContainer.innerHTML = `
|
||||
<div class="alert alert-danger">Zayıf konu raporu yüklenirken bir hata oluştu.</div>
|
||||
<div class="alert alert-danger">${escapeHtml(t('exams.weaknessError'))}</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
|
@ -206,10 +211,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
<div class="score-progress-fill ${fillClass}" style="width: ${item.successRate}%;"></div>
|
||||
</div>
|
||||
<div class="weakness-stats">
|
||||
<span>Toplam: <strong>${item.totalCount}</strong></span>
|
||||
<span class="text-success">Doğru: <strong>${item.correctCount}</strong></span>
|
||||
<span class="text-danger">Yanlış: <strong>${item.wrongCount}</strong></span>
|
||||
<span class="text-muted">Boş: <strong>${item.emptyCount}</strong></span>
|
||||
<span>${escapeHtml(t('exams.weaknessTotal'))} <strong>${item.totalCount}</strong></span>
|
||||
<span class="text-success">${escapeHtml(t('exams.weaknessCorrect'))} <strong>${item.correctCount}</strong></span>
|
||||
<span class="text-danger">${escapeHtml(t('exams.weaknessWrong'))} <strong>${item.wrongCount}</strong></span>
|
||||
<span class="text-muted">${escapeHtml(t('exams.weaknessEmptyCount'))} <strong>${item.emptyCount}</strong></span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
|
@ -340,7 +345,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
} catch (err) {
|
||||
mistakeLoading.classList.add('hidden');
|
||||
questionsGrid.innerHTML = `
|
||||
<div class="alert alert-danger">Sorular yüklenirken bir hata oluştu.</div>
|
||||
<div class="alert alert-danger">${escapeHtml(t('exams.modalError'))}</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
|
@ -355,7 +360,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
|
||||
let html = `
|
||||
<button type="button" class="modal-lesson-btn ${activeLessonFilter === 'ALL' ? 'active' : ''}" data-lesson="ALL">
|
||||
Tüm Yanlışlar (${totalAll})
|
||||
${escapeHtml(t('exams.modalAllMistakes'))} (${totalAll})
|
||||
</button>
|
||||
`;
|
||||
|
||||
|
|
@ -419,7 +424,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if (filteredList.length === 0) {
|
||||
questionsGrid.innerHTML = `
|
||||
<div class="empty-lessons-card" style="grid-column: 1 / -1;">
|
||||
<p>Seçili filtrelere uygun soru bulunamadı.</p>
|
||||
<p>${escapeHtml(t('exams.modalNoMatch'))}</p>
|
||||
</div>
|
||||
`;
|
||||
return;
|
||||
|
|
@ -429,32 +434,32 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
filteredList.forEach(q => {
|
||||
const isWrong = q.status === 'wrong';
|
||||
const studentClass = isWrong ? 'answer-student-wrong' : 'answer-student-empty';
|
||||
const studentText = isWrong ? q.studentAnswer : 'Boş';
|
||||
const studentText = isWrong ? q.studentAnswer : t('exams.emptyAnswerText');
|
||||
|
||||
html += `
|
||||
<div class="question-card">
|
||||
<div class="question-card-header">
|
||||
<span class="question-no-badge">Soru #${q.questionNumber}</span>
|
||||
<span class="question-no-badge">${escapeHtml(t('exams.questionNo', { num: q.questionNumber }))}</span>
|
||||
<span class="question-subject-badge">${escapeHtml(q.subjectName || '')}</span>
|
||||
</div>
|
||||
|
||||
<div class="question-card-answers">
|
||||
<span class="answer-pill answer-correct">
|
||||
Doğru: <strong>${escapeHtml(q.correctAnswer)}</strong>
|
||||
${escapeHtml(t('exams.correctAnswer'))} <strong>${escapeHtml(q.correctAnswer)}</strong>
|
||||
</span>
|
||||
<span class="answer-pill ${studentClass}">
|
||||
Öğrenci: <strong>${escapeHtml(studentText)}</strong>
|
||||
${escapeHtml(t('exams.studentAnswer'))} <strong>${escapeHtml(studentText)}</strong>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
${
|
||||
q.imageUrl
|
||||
? `
|
||||
<div class="question-img-wrapper" title="Büyütmek için tıklayınız">
|
||||
<div class="question-img-wrapper" title="${escapeHtml(t('exams.zoomHint'))}">
|
||||
<img src="${escapeHtml(q.imageUrl)}" alt="Soru ${q.questionNumber}" class="question-img" loading="lazy" />
|
||||
</div>
|
||||
`
|
||||
: `<div class="text-muted small">Soru görseli bulunamadı.</div>`
|
||||
: `<div class="text-muted small">${escapeHtml(t('exams.noImage'))}</div>`
|
||||
}
|
||||
</div>
|
||||
`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue