Skip to content

Commit 950e9b2

Browse files
fix: not rendering classroom students
1 parent 933d217 commit 950e9b2

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/main/resources/static/dashboard.html

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,9 @@ <h4><i class="bi bi-people"></i> My Classrooms and Students</h4>
691691

692692
for (let i = 0; i < classrooms.length; i++) {
693693
const classroom = classrooms[i];
694-
const users = classroom.usersInClassroom || [];
695-
const students = users.filter(u => u.id !== userId && u.stats !== undefined);
694+
const users = classroom.users || []; // ← changed from usersInClassroom to users
695+
const students = users.filter(u => u.isProfessor === false); // ← filter by isProfessor flag
696+
696697
const collapseId = `collapse-${classroom.id}`;
697698
const headingId = `heading-${classroom.id}`;
698699

@@ -719,13 +720,8 @@ <h5 class="mb-0">📖 ${escapeHtml(classroom.name)}</h5>
719720
studentsRow.html('<div class="col-12 text-muted">No students enrolled in this classroom.</div>');
720721
} else {
721722
for (const student of students) {
722-
let currentBook = 'Not reading';
723-
if (student.stats && student.stats.currentBook && student.stats.currentBook.book) {
724-
currentBook = student.stats.currentBook.book.title;
725-
} else if (student.stats && student.stats.currentBook && student.stats.currentBook.title) {
726-
currentBook = student.stats.currentBook.title;
727-
}
728723
const lastLogin = student.lastLogin || 'Never';
724+
const currentBook = (student.currentBook && student.currentBook.title) ? student.currentBook.title : 'Not reading';
729725
const studentCard = $(`
730726
<div class="col-md-6 col-lg-4 mb-3">
731727
<div class="card h-100">
@@ -750,6 +746,7 @@ <h5 class="card-title">${escapeHtml(student.name || student.username)}</h5>
750746
container.append(classroomCard);
751747
}
752748

749+
// Attach summary button handlers after all cards are built
753750
$('.view-summary-btn').off('click').on('click', async function() {
754751
const studentId = $(this).data('student-id');
755752
const studentName = $(this).data('student-name');

0 commit comments

Comments
 (0)