Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 40 additions & 8 deletions src/pages/StudentsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type { EventData } from 'react-joyride';
import { DragDropContext, Droppable, Draggable, type DropResult } from '@hello-pangea/dnd';
import { getStudentsTourSteps } from '../data/TutorialSteps';
import Topbar from '../components/Layout/Topbar';
import { useAssessment, useAuthoring, useClasses, useGrading, useSettings, useStudents } from '../context/AppContext';
import { useStoreActions, useStoreSelector } from '../context/useStore';
import { useDbStatus } from '../hooks/useDbStatus';
import { useToast } from '../hooks/useToast';
import Papa from 'papaparse';
Expand Down Expand Up @@ -277,13 +277,45 @@ const derivedByStudentCache = new Map<string, { key: StudentDerivedKey; value: S
export default function StudentsPage() {
const { t, i18n } = useTranslation();
const navigate = useNavigate();
const { students, addStudent, updateStudent, deleteStudent, setStudentPassword } = useStudents();
const { classes, addClass, updateClass, deleteClass, mergeClasses } = useClasses();
const { studentRubrics } = useGrading();

const { rubrics, gradeScales } = useAuthoring();
const { selfAssessments, analysisResults, tests, studentTests } = useAssessment();
const { settings, updateSettings } = useSettings();
const {
students: allStudents,
classes,
studentRubrics: allStudentRubrics,
rubrics,
gradeScales,
selfAssessments,
analysisResults,
tests,
studentTests,
settings,
} = useStoreSelector((s) => ({
students: s.students,
classes: s.classes,
studentRubrics: s.studentRubrics,
rubrics: s.rubrics,
gradeScales: s.gradeScales,
selfAssessments: s.selfAssessments,
analysisResults: s.analysisResults,
tests: s.tests,
studentTests: s.studentTests,
settings: s.settings,
}));
// The roster domain hooks filtered soft-deleted rows; keep that behavior here.
// (DELETE_STUDENT soft-deletes via archivedAt — without this filter the student
// row would remain visible after deletion.)
const students = useMemo(() => allStudents.filter((s) => !s.archivedAt), [allStudents]);
const studentRubrics = useMemo(() => allStudentRubrics.filter((sr) => !sr.deletedAt), [allStudentRubrics]);
const {
addStudent,
updateStudent,
deleteStudent,
setStudentPassword,
addClass,
updateClass,
deleteClass,
mergeClasses,
updateSettings,
} = useStoreActions();

const dbStatus = useDbStatus();
const { showToast } = useToast();
Expand Down
5 changes: 5 additions & 0 deletions src/pages/__tests__/StudentsPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ vi.mock('../../context/AppContext', () => ({
usePlatform: () => mockAppValue,
}));

vi.mock('../../context/useStore', () => ({
useStoreSelector: (selector: (state: any) => any) => selector(mockAppValue),
useStoreActions: () => mockAppValue,
}));

vi.mock('../../utils/cefrStudentAggregator', () => ({
getCefrStudentOverview: vi.fn(
() =>
Expand Down
Loading