feat: implement modern Sınav Rapor dashboard with dual-metric delta tracking and inline mistake review
This commit is contained in:
parent
455baa6aa4
commit
f138403918
10 changed files with 2838 additions and 3 deletions
|
|
@ -1447,3 +1447,710 @@ code {
|
|||
color: var(--text-muted);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
/* ==================================================== */
|
||||
/* Exam Reports (Sınav Rapor) Styling */
|
||||
/* ==================================================== */
|
||||
|
||||
.exam-filter-row {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.filter-pills {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.filter-pill {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text-muted);
|
||||
padding: 5px 12px;
|
||||
border-radius: var(--radius);
|
||||
font-size: 0.825rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
.filter-pill:hover {
|
||||
background: #f8fafc;
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.filter-pill.active {
|
||||
background: var(--primary);
|
||||
border-color: var(--primary);
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Exam Cards Strip */
|
||||
.exam-cards-strip {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
|
||||
gap: 12px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.exam-pill-card {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 12px 14px;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s ease;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.exam-pill-card:hover {
|
||||
border-color: #cbd5e1;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
|
||||
}
|
||||
|
||||
.exam-pill-card.active {
|
||||
border-color: var(--primary);
|
||||
box-shadow: 0 0 0 1.5px var(--primary);
|
||||
background: #fdfdfe;
|
||||
}
|
||||
|
||||
.exam-pill-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.exam-type-badge {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 700;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.exam-type-tyt {
|
||||
background: #e0f2fe;
|
||||
color: #0369a1;
|
||||
}
|
||||
|
||||
.exam-type-ayt {
|
||||
background: #ede9fe;
|
||||
color: #6d28d9;
|
||||
}
|
||||
|
||||
.exam-type-other {
|
||||
background: #f1f5f9;
|
||||
color: #475569;
|
||||
}
|
||||
|
||||
.exam-pill-name {
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-main);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
flex: 1;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.exam-pill-metrics {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.exam-pill-net {
|
||||
font-size: 1.05rem;
|
||||
color: var(--text-main);
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.net-unit {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.exam-pill-rank {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.rank-badge {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.delta-badge {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 700;
|
||||
padding: 1px 5px;
|
||||
border-radius: 4px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.delta-up {
|
||||
background: #ecfdf5;
|
||||
color: #047857;
|
||||
}
|
||||
|
||||
.delta-down {
|
||||
background: #fef2f2;
|
||||
color: #b91c1c;
|
||||
}
|
||||
|
||||
.delta-rank-badge {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 700;
|
||||
padding: 1px 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.rank-up {
|
||||
background: #eff6ff;
|
||||
color: #1d4ed8;
|
||||
}
|
||||
|
||||
.rank-down {
|
||||
background: #fff1f2;
|
||||
color: #be123c;
|
||||
}
|
||||
|
||||
.exam-pill-rating {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
/* Exam Detail Card */
|
||||
.exam-detail-card {
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 20px 24px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.exam-detail-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
margin-bottom: 20px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.detail-title-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.exam-title-text {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.exam-type-tag {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.detail-badge-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.detail-action-group {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* Exam Sub-Tabs */
|
||||
.exam-subtabs {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.subtab-btn {
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
color: var(--text-muted);
|
||||
padding: 8px 14px;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s ease;
|
||||
margin-bottom: -1px;
|
||||
}
|
||||
|
||||
.subtab-btn:hover {
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.subtab-btn.active {
|
||||
color: var(--primary);
|
||||
border-bottom-color: var(--primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* Exam Score Table */
|
||||
.exam-score-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.exam-score-table th,
|
||||
.exam-score-table td {
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.exam-score-table th {
|
||||
background: #f8fafc;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
.exam-score-table tbody tr:hover {
|
||||
background: #fcfdfe;
|
||||
}
|
||||
|
||||
.table-total-row {
|
||||
background: #f8fafc;
|
||||
border-top: 2px solid var(--border);
|
||||
border-bottom: 2px solid var(--border);
|
||||
}
|
||||
|
||||
.total-net-text {
|
||||
font-size: 1rem;
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
.badge-btn {
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
font-weight: 600;
|
||||
padding: 2px 8px;
|
||||
font-size: 0.8rem;
|
||||
cursor: pointer;
|
||||
transition: transform 0.1s ease, filter 0.1s ease;
|
||||
}
|
||||
|
||||
.badge-btn:hover {
|
||||
transform: scale(1.08);
|
||||
filter: brightness(0.95);
|
||||
}
|
||||
|
||||
.score-progress-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.score-progress-bar {
|
||||
width: 75px;
|
||||
height: 6px;
|
||||
background: #e2e8f0;
|
||||
border-radius: 9999px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.score-progress-fill {
|
||||
height: 100%;
|
||||
border-radius: 9999px;
|
||||
}
|
||||
|
||||
.fill-high {
|
||||
background: #10b981;
|
||||
}
|
||||
|
||||
.fill-mid {
|
||||
background: #f59e0b;
|
||||
}
|
||||
|
||||
.fill-low {
|
||||
background: #ef4444;
|
||||
}
|
||||
|
||||
.score-progress-pct {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
min-width: 32px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* Topic Weakness View */
|
||||
.weakness-loading-state,
|
||||
.modal-loading-state {
|
||||
padding: 30px;
|
||||
text-align: center;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.weakness-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: 12px;
|
||||
padding-top: 6px;
|
||||
}
|
||||
|
||||
.weakness-card {
|
||||
background: white;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 12px 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.weakness-card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.weakness-subject {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
color: var(--primary);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.weakness-topic {
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.weakness-stats {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* ==================================================== */
|
||||
/* Mistake Review Modal */
|
||||
/* ==================================================== */
|
||||
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(15, 23, 42, 0.55);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1050;
|
||||
padding: 16px;
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
.modal-dialog.modal-xl {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
width: 100%;
|
||||
max-width: 980px;
|
||||
max-height: 90vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 14px 20px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: white;
|
||||
}
|
||||
|
||||
.modal-title-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: 1.15rem;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.modal-subtitle {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.modal-close-btn {
|
||||
background: transparent;
|
||||
border: none;
|
||||
font-size: 1.5rem;
|
||||
line-height: 1;
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.modal-close-btn:hover {
|
||||
color: var(--text-main);
|
||||
background: #f1f5f9;
|
||||
}
|
||||
|
||||
.modal-filter-bar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px 20px;
|
||||
background: #f8fafc;
|
||||
border-bottom: 1px solid var(--border);
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.modal-lesson-pills {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
overflow-x: auto;
|
||||
max-width: 65%;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.modal-lesson-btn {
|
||||
background: white;
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text-muted);
|
||||
padding: 4px 10px;
|
||||
border-radius: var(--radius);
|
||||
font-size: 0.775rem;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
.modal-lesson-btn:hover {
|
||||
background: #f1f5f9;
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.modal-lesson-btn.active {
|
||||
background: var(--primary);
|
||||
border-color: var(--primary);
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.modal-type-toggles {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.modal-type-btn {
|
||||
background: white;
|
||||
border: 1px solid var(--border);
|
||||
color: var(--text-muted);
|
||||
padding: 4px 8px;
|
||||
border-radius: var(--radius);
|
||||
font-size: 0.75rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-type-btn.active {
|
||||
background: #0f172a;
|
||||
color: white;
|
||||
border-color: #0f172a;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
flex: 1;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.questions-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.question-card {
|
||||
background: white;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
padding: 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.question-card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.question-no-badge {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 700;
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
.question-subject-badge {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.question-card-answers {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.answer-pill {
|
||||
padding: 2px 8px;
|
||||
border-radius: 4px;
|
||||
font-weight: 600;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.answer-correct {
|
||||
background: #ecfdf5;
|
||||
color: #047857;
|
||||
border: 1px solid #a7f3d0;
|
||||
}
|
||||
|
||||
.answer-student-wrong {
|
||||
background: #fef2f2;
|
||||
color: #b91c1c;
|
||||
border: 1px solid #fecaca;
|
||||
}
|
||||
|
||||
.answer-student-empty {
|
||||
background: #f1f5f9;
|
||||
color: #475569;
|
||||
border: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.question-img-wrapper {
|
||||
background: #fafafa;
|
||||
border: 1px solid #f1f5f9;
|
||||
border-radius: 6px;
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
cursor: zoom-in;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.question-img {
|
||||
max-width: 100%;
|
||||
max-height: 480px;
|
||||
height: auto;
|
||||
object-fit: contain;
|
||||
transition: transform 0.15s ease;
|
||||
}
|
||||
|
||||
.question-img-wrapper:hover .question-img {
|
||||
transform: scale(1.015);
|
||||
}
|
||||
|
||||
/* Lightbox Overlay */
|
||||
.lightbox-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(0, 0, 0, 0.85);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1100;
|
||||
padding: 20px;
|
||||
cursor: zoom-out;
|
||||
}
|
||||
|
||||
.lightbox-content {
|
||||
position: relative;
|
||||
max-width: 95vw;
|
||||
max-height: 95vh;
|
||||
}
|
||||
|
||||
.lightbox-content img {
|
||||
max-width: 95vw;
|
||||
max-height: 90vh;
|
||||
object-fit: contain;
|
||||
border-radius: 6px;
|
||||
background: white;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.lightbox-close-btn {
|
||||
position: absolute;
|
||||
top: -40px;
|
||||
right: 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: white;
|
||||
font-size: 2rem;
|
||||
cursor: pointer;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.exam-cards-strip {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.questions-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.modal-filter-bar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
.modal-lesson-pills {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
500
public/js/exams.js
Normal file
500
public/js/exams.js
Normal file
|
|
@ -0,0 +1,500 @@
|
|||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// ----------------------------------------------------
|
||||
// Elements
|
||||
// ----------------------------------------------------
|
||||
const categoryFilterPills = document.getElementById('categoryFilterPills');
|
||||
const examCardsStrip = document.getElementById('examCardsStrip');
|
||||
const btnSyncExams = document.getElementById('btnSyncExams');
|
||||
const btnEmptySync = document.getElementById('btnEmptySync');
|
||||
const examsAlert = document.getElementById('examsAlert');
|
||||
|
||||
// Subtabs
|
||||
const subtabBreakdown = document.getElementById('subtabBreakdown');
|
||||
const subtabWeakness = document.getElementById('subtabWeakness');
|
||||
const breakdownView = document.getElementById('breakdownView');
|
||||
const weaknessView = document.getElementById('weaknessView');
|
||||
const weaknessContainer = document.getElementById('weaknessContainer');
|
||||
const weaknessLoading = document.getElementById('weaknessLoading');
|
||||
|
||||
// Mistake Review Modal
|
||||
const btnReviewMistakes = document.getElementById('btnReviewMistakes');
|
||||
const mistakeModal = document.getElementById('mistakeModal');
|
||||
const btnMistakeModalClose = document.getElementById('btnMistakeModalClose');
|
||||
const modalLessonPills = document.getElementById('modalLessonPills');
|
||||
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');
|
||||
const lightboxImg = document.getElementById('lightboxImg');
|
||||
const btnLightboxClose = document.getElementById('btnLightboxClose');
|
||||
|
||||
// State
|
||||
let currentExamId = btnReviewMistakes ? btnReviewMistakes.getAttribute('data-exam-id') : null;
|
||||
let cachedQuestions = null; // raw fetched questions by subject
|
||||
let activeLessonFilter = 'ALL';
|
||||
let activeTypeFilter = 'all'; // 'all' | 'wrong' | 'empty'
|
||||
let cachedWeaknesses = null;
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Helper: Show Alert
|
||||
// ----------------------------------------------------
|
||||
function showAlert(msg, type = 'info') {
|
||||
if (!examsAlert) return;
|
||||
examsAlert.className = `alert alert-${type}`;
|
||||
examsAlert.textContent = msg;
|
||||
examsAlert.classList.remove('hidden');
|
||||
setTimeout(() => {
|
||||
examsAlert.classList.add('hidden');
|
||||
}, 4000);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Category Filter (All / TYT / AYT)
|
||||
// ----------------------------------------------------
|
||||
if (categoryFilterPills && examCardsStrip) {
|
||||
categoryFilterPills.addEventListener('click', (e) => {
|
||||
const btn = e.target.closest('.filter-pill');
|
||||
if (!btn) return;
|
||||
|
||||
categoryFilterPills.querySelectorAll('.filter-pill').forEach(b => b.classList.remove('active'));
|
||||
btn.classList.add('active');
|
||||
|
||||
const category = btn.getAttribute('data-category');
|
||||
const cards = examCardsStrip.querySelectorAll('.exam-pill-card');
|
||||
|
||||
cards.forEach(card => {
|
||||
const cardCat = card.getAttribute('data-category');
|
||||
if (category === 'ALL' || cardCat === category) {
|
||||
card.style.display = '';
|
||||
} else {
|
||||
card.style.display = 'none';
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Exam Card Switching
|
||||
// ----------------------------------------------------
|
||||
if (examCardsStrip) {
|
||||
examCardsStrip.addEventListener('click', (e) => {
|
||||
const card = e.target.closest('.exam-pill-card');
|
||||
if (!card) return;
|
||||
|
||||
const examId = card.getAttribute('data-id');
|
||||
if (examId && examId !== currentExamId) {
|
||||
window.location.href = `/exams?id=${encodeURIComponent(examId)}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Sync Exams Action
|
||||
// ----------------------------------------------------
|
||||
async function handleSync() {
|
||||
const triggerBtn = btnSyncExams || btnEmptySync;
|
||||
if (triggerBtn) {
|
||||
triggerBtn.disabled = true;
|
||||
triggerBtn.textContent = 'Syncing...';
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/exams/sync', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
const data = await res.json();
|
||||
|
||||
if (data.success) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
showAlert(data.error || 'Failed to sync exams', 'danger');
|
||||
if (triggerBtn) {
|
||||
triggerBtn.disabled = false;
|
||||
triggerBtn.textContent = 'Sync Exams';
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
showAlert('Connection error while syncing exams.', 'danger');
|
||||
if (triggerBtn) {
|
||||
triggerBtn.disabled = false;
|
||||
triggerBtn.textContent = 'Sync Exams';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (btnSyncExams) btnSyncExams.addEventListener('click', handleSync);
|
||||
if (btnEmptySync) btnEmptySync.addEventListener('click', handleSync);
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Subtabs Toggle (Breakdown vs Weaknesses)
|
||||
// ----------------------------------------------------
|
||||
if (subtabBreakdown && subtabWeakness) {
|
||||
subtabBreakdown.addEventListener('click', () => {
|
||||
subtabBreakdown.classList.add('active');
|
||||
subtabWeakness.classList.remove('active');
|
||||
breakdownView.classList.remove('hidden');
|
||||
weaknessView.classList.add('hidden');
|
||||
});
|
||||
|
||||
subtabWeakness.addEventListener('click', async () => {
|
||||
subtabWeakness.classList.add('active');
|
||||
subtabBreakdown.classList.remove('active');
|
||||
weaknessView.classList.remove('hidden');
|
||||
breakdownView.classList.add('hidden');
|
||||
|
||||
if (!cachedWeaknesses && currentExamId) {
|
||||
await loadTopicWeaknesses(currentExamId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function loadTopicWeaknesses(examId) {
|
||||
weaknessLoading.classList.remove('hidden');
|
||||
weaknessContainer.innerHTML = '';
|
||||
|
||||
try {
|
||||
const res = await fetch(`/api/exams/${encodeURIComponent(examId)}/weaknesses`);
|
||||
const data = await res.json();
|
||||
weaknessLoading.classList.add('hidden');
|
||||
|
||||
if (data.success && data.weaknesses && data.weaknesses.length > 0) {
|
||||
cachedWeaknesses = data.weaknesses;
|
||||
renderTopicWeaknesses(data.weaknesses);
|
||||
} 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>
|
||||
</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>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
function renderTopicWeaknesses(weaknesses) {
|
||||
// Sort weaknesses by most wrong answers, then lowest success rate
|
||||
const sorted = [...weaknesses].sort((a, b) => {
|
||||
if (b.wrongCount !== a.wrongCount) return b.wrongCount - a.wrongCount;
|
||||
return a.successRate - b.successRate;
|
||||
});
|
||||
|
||||
let html = '<div class="weakness-grid">';
|
||||
sorted.forEach(item => {
|
||||
const fillClass = item.successRate >= 70 ? 'fill-high' : item.successRate >= 40 ? 'fill-mid' : 'fill-low';
|
||||
html += `
|
||||
<div class="weakness-card">
|
||||
<div class="weakness-card-header">
|
||||
<span class="weakness-subject">${escapeHtml(item.subjectName)}</span>
|
||||
<span class="score-progress-pct font-bold">${item.successRate}%</span>
|
||||
</div>
|
||||
<div class="weakness-topic">${escapeHtml(item.topicName)}</div>
|
||||
<div class="score-progress-bar" style="width: 100%;">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
html += '</div>';
|
||||
weaknessContainer.innerHTML = html;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Inline Mistake Review Modal
|
||||
// ----------------------------------------------------
|
||||
function openReviewModal(targetSubjectName = null) {
|
||||
if (!mistakeModal || !currentExamId) return;
|
||||
mistakeModal.classList.remove('hidden');
|
||||
document.body.style.overflow = 'hidden';
|
||||
|
||||
if (!cachedQuestions) {
|
||||
loadExamQuestions(targetSubjectName);
|
||||
} else {
|
||||
if (targetSubjectName) {
|
||||
activeLessonFilter = targetSubjectName;
|
||||
}
|
||||
updateModalLessonPills();
|
||||
renderQuestions();
|
||||
}
|
||||
}
|
||||
|
||||
function closeReviewModal() {
|
||||
if (!mistakeModal) return;
|
||||
mistakeModal.classList.add('hidden');
|
||||
document.body.style.overflow = '';
|
||||
}
|
||||
|
||||
if (btnReviewMistakes) {
|
||||
btnReviewMistakes.addEventListener('click', () => openReviewModal());
|
||||
}
|
||||
|
||||
if (btnMistakeModalClose) {
|
||||
btnMistakeModalClose.addEventListener('click', closeReviewModal);
|
||||
}
|
||||
|
||||
// Clicking clickable mistake badge in table
|
||||
document.querySelectorAll('.clickable-mistake-btn').forEach(btn => {
|
||||
btn.addEventListener('click', (e) => {
|
||||
e.stopPropagation();
|
||||
const subjectName = btn.getAttribute('data-subject-name');
|
||||
openReviewModal(subjectName);
|
||||
});
|
||||
});
|
||||
|
||||
// Close modal when clicking outside dialog
|
||||
if (mistakeModal) {
|
||||
mistakeModal.addEventListener('click', (e) => {
|
||||
if (e.target === mistakeModal) {
|
||||
closeReviewModal();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Escape key closes modal & lightbox
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
if (imageLightbox && !imageLightbox.classList.contains('hidden')) {
|
||||
closeLightbox();
|
||||
} else if (mistakeModal && !mistakeModal.classList.contains('hidden')) {
|
||||
closeReviewModal();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async function loadExamQuestions(initialSubjectFilter = null) {
|
||||
mistakeLoading.classList.remove('hidden');
|
||||
questionsGrid.innerHTML = '';
|
||||
modalLessonPills.innerHTML = '';
|
||||
|
||||
try {
|
||||
// Fetch both Wrong (Y) and Empty (B) questions
|
||||
const [wrongRes, emptyRes] = await Promise.all([
|
||||
fetch(`/api/exams/${encodeURIComponent(currentExamId)}/questions?tip=Y`).then(r => r.json()),
|
||||
fetch(`/api/exams/${encodeURIComponent(currentExamId)}/questions?tip=B`).then(r => r.json())
|
||||
]);
|
||||
|
||||
mistakeLoading.classList.add('hidden');
|
||||
|
||||
const subjectsMap = {};
|
||||
|
||||
if (wrongRes.success && wrongRes.subjects) {
|
||||
wrongRes.subjects.forEach(s => {
|
||||
if (!subjectsMap[s.subjectName]) {
|
||||
subjectsMap[s.subjectName] = { subjectName: s.subjectName, subjectId: s.subjectId, questions: [] };
|
||||
}
|
||||
s.questions.forEach(q => {
|
||||
q.subjectName = s.subjectName;
|
||||
subjectsMap[s.subjectName].questions.push(q);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (emptyRes.success && emptyRes.subjects) {
|
||||
emptyRes.subjects.forEach(s => {
|
||||
if (!subjectsMap[s.subjectName]) {
|
||||
subjectsMap[s.subjectName] = { subjectName: s.subjectName, subjectId: s.subjectId, questions: [] };
|
||||
}
|
||||
s.questions.forEach(q => {
|
||||
q.subjectName = s.subjectName;
|
||||
subjectsMap[s.subjectName].questions.push(q);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
cachedQuestions = Object.values(subjectsMap);
|
||||
|
||||
if (initialSubjectFilter && subjectsMap[initialSubjectFilter]) {
|
||||
activeLessonFilter = initialSubjectFilter;
|
||||
} else {
|
||||
activeLessonFilter = 'ALL';
|
||||
}
|
||||
|
||||
updateModalLessonPills();
|
||||
renderQuestions();
|
||||
} catch (err) {
|
||||
mistakeLoading.classList.add('hidden');
|
||||
questionsGrid.innerHTML = `
|
||||
<div class="alert alert-danger">Sorular yüklenirken bir hata oluştu.</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
function updateModalLessonPills() {
|
||||
if (!modalLessonPills || !cachedQuestions) return;
|
||||
|
||||
let totalAll = 0;
|
||||
cachedQuestions.forEach(s => {
|
||||
totalAll += s.questions.length;
|
||||
});
|
||||
|
||||
let html = `
|
||||
<button type="button" class="modal-lesson-btn ${activeLessonFilter === 'ALL' ? 'active' : ''}" data-lesson="ALL">
|
||||
Tüm Yanlışlar (${totalAll})
|
||||
</button>
|
||||
`;
|
||||
|
||||
cachedQuestions.forEach(s => {
|
||||
const count = s.questions.length;
|
||||
html += `
|
||||
<button type="button" class="modal-lesson-btn ${activeLessonFilter === s.subjectName ? 'active' : ''}" data-lesson="${escapeHtml(s.subjectName)}">
|
||||
${escapeHtml(s.subjectName)} (${count})
|
||||
</button>
|
||||
`;
|
||||
});
|
||||
|
||||
modalLessonPills.innerHTML = html;
|
||||
}
|
||||
|
||||
if (modalLessonPills) {
|
||||
modalLessonPills.addEventListener('click', (e) => {
|
||||
const btn = e.target.closest('.modal-lesson-btn');
|
||||
if (!btn) return;
|
||||
|
||||
modalLessonPills.querySelectorAll('.modal-lesson-btn').forEach(b => b.classList.remove('active'));
|
||||
btn.classList.add('active');
|
||||
|
||||
activeLessonFilter = btn.getAttribute('data-lesson');
|
||||
renderQuestions();
|
||||
});
|
||||
}
|
||||
|
||||
// Type filter inside modal (all / wrong / empty)
|
||||
modalTypeBtns.forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
modalTypeBtns.forEach(b => b.classList.remove('active'));
|
||||
btn.classList.add('active');
|
||||
activeTypeFilter = btn.getAttribute('data-type');
|
||||
renderQuestions();
|
||||
});
|
||||
});
|
||||
|
||||
function renderQuestions() {
|
||||
if (!questionsGrid || !cachedQuestions) return;
|
||||
|
||||
let filteredList = [];
|
||||
|
||||
cachedQuestions.forEach(s => {
|
||||
if (activeLessonFilter === 'ALL' || activeLessonFilter === s.subjectName) {
|
||||
s.questions.forEach(q => {
|
||||
if (activeTypeFilter === 'all') {
|
||||
filteredList.push(q);
|
||||
} else if (activeTypeFilter === 'wrong' && q.status === 'wrong') {
|
||||
filteredList.push(q);
|
||||
} else if (activeTypeFilter === 'empty' && q.status === 'empty') {
|
||||
filteredList.push(q);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Sort by question number ascending
|
||||
filteredList.sort((a, b) => a.questionNumber - b.questionNumber);
|
||||
|
||||
if (filteredList.length === 0) {
|
||||
questionsGrid.innerHTML = `
|
||||
<div class="empty-lessons-card" style="grid-column: 1 / -1;">
|
||||
<p>Seçili filtrelere uygun soru bulunamadı.</p>
|
||||
</div>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
let html = '';
|
||||
filteredList.forEach(q => {
|
||||
const isWrong = q.status === 'wrong';
|
||||
const studentClass = isWrong ? 'answer-student-wrong' : 'answer-student-empty';
|
||||
const studentText = isWrong ? q.studentAnswer : 'Boş';
|
||||
|
||||
html += `
|
||||
<div class="question-card">
|
||||
<div class="question-card-header">
|
||||
<span class="question-no-badge">Soru #${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>
|
||||
</span>
|
||||
<span class="answer-pill ${studentClass}">
|
||||
Öğrenci: <strong>${escapeHtml(studentText)}</strong>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
${
|
||||
q.imageUrl
|
||||
? `
|
||||
<div class="question-img-wrapper" title="Büyütmek için tıklayınız">
|
||||
<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>
|
||||
`;
|
||||
});
|
||||
|
||||
questionsGrid.innerHTML = html;
|
||||
|
||||
// Attach click-to-zoom on images
|
||||
questionsGrid.querySelectorAll('.question-img').forEach(img => {
|
||||
img.addEventListener('click', () => {
|
||||
openLightbox(img.src);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Lightbox Zoom
|
||||
// ----------------------------------------------------
|
||||
function openLightbox(src) {
|
||||
if (!imageLightbox || !lightboxImg) return;
|
||||
lightboxImg.src = src;
|
||||
imageLightbox.classList.remove('hidden');
|
||||
}
|
||||
|
||||
function closeLightbox() {
|
||||
if (!imageLightbox) return;
|
||||
imageLightbox.classList.add('hidden');
|
||||
if (lightboxImg) lightboxImg.src = '';
|
||||
}
|
||||
|
||||
if (btnLightboxClose) {
|
||||
btnLightboxClose.addEventListener('click', closeLightbox);
|
||||
}
|
||||
|
||||
if (imageLightbox) {
|
||||
imageLightbox.addEventListener('click', (e) => {
|
||||
if (e.target === imageLightbox || e.target === btnLightboxClose) {
|
||||
closeLightbox();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ----------------------------------------------------
|
||||
// Utility: Escape HTML
|
||||
// ----------------------------------------------------
|
||||
function escapeHtml(str) {
|
||||
if (!str) return '';
|
||||
return str
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue