Feature: Improve teacher feedback for fetch failures and empty classrooms

Đang mở
#606 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@NewtonLC đang làm issue này rồi.

Từ ngày 22/6/2026.

  • #607 của @NewtonLC — đã đóng, không merge

Đánh giá

Issue này chưa được đánh giá.

Mô tả

Description

PR #603 fixed a crash that occurred when the student data server was offline. The fix returns [] on any fetch failure, which prevents the crash — but leaves the teacher with a blank dashboard and no explanation. This issue tracks two follow-on UX improvements that build on that fix.


Problem 1 — The teacher can't tell if the fetch failed

fetchStudentData() currently returns [] for three distinct situations:

Case Cause Relevant long-term?
Missing env var MOCK_USER_DATA_URL not set No — dev/config only
Bad HTTP response Server returned 4xx/5xx Yes
Network error Server unreachable Yes

The calling code in pages/dashboard/[id].js receives [] in all cases and passes it straight to DashTabs as data. There's no way to distinguish a failed fetch from an empty class.

Proposed fix:

Return a structured result from fetchStudentData() instead of a bare array:

// Success
return { error: null, data: await response.json() };

// Runtime failures (surface to teacher)
return { error: 'FETCH_FAILED', status: response.status, data: null };
return { error: 'NETWORK_ERROR', data: null };

// Config issue (dev only — keep silent, log only)
console.warn('MOCK_USER_DATA_URL is not defined.');
return { error: 'MISSING_URL', data: null };

[id].js would pass the error code as a prop. For runtime failures, the dashboard UI would render an error message: "We couldn't load your students. Please try refreshing, or contact support at [email protected] if the problem persists." The MISSING_URL case should remain a silent console log, as it's dev-facing.


Problem 2 — Empty classrooms show nothing

When a class has no students yet, DashTabs renders a blank page:

Image

Proposed fix:

In getServerSideProps in [id].js, include fccUserIds in the classroom query. If it's empty, the dashboard should not render an empty table. Instead, it should:

  • Tell the teacher there are no students in the class yet
  • Display the classroom's join link with a copy button
  • Instruct the teacher to share the link with their students

Files likely affected

  • util/student/fetchStudentData.js
  • pages/dashboard/[id].js
  • The component(s) rendered by DashTabs that display student data
  • prisma query in pages/dashboard/[id].js (add fccUserIds to the select)
Ngôn ngữ chính
TypeScript
Star
156
Fork
141
Merge trung bình
15 giờ 56 phút
Pull request đã merge (30 ngày)
55

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của freeCodeCamp/classroom

Tất cả issue của freeCodeCamp/classroom

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.