Rename UserType -> StudentType

This commit is contained in:
C. Fuhrman 2024-09-25 13:05:36 -04:00
parent 35770dd105
commit 68d7d8c0a9
6 changed files with 28 additions and 28 deletions

View file

@ -1,4 +1,4 @@
export interface UserType { export interface StudentType {
name: string; name: string;
id: string; id: string;
} }

View file

@ -0,0 +1,15 @@
//StudentType.test.tsx
import { StudentType } from "../../Types/StudentType";
const user : StudentType = {
name: 'Student',
id: '123'
}
describe('StudentType', () => {
test('creates a student with name and id', () => {
expect(user.name).toBe('Student');
expect(user.id).toBe('123');
});
});

View file

@ -1,15 +0,0 @@
//UserTyper.test.tsx
import { UserType } from "../../Types/UserType";
const user : UserType = {
name: 'Student',
id: '123'
}
describe('UserType', () => {
test('creates a user with name and id', () => {
expect(user.name).toBe('Student');
expect(user.id).toBe('123');
});
});

View file

@ -19,7 +19,7 @@ import {
TableHead, TableHead,
TableRow TableRow
} from '@mui/material'; } from '@mui/material';
import { UserType } from '../../Types/UserType'; import { StudentType } from '../../Types/StudentType';
import { formatLatex } from '../GiftTemplate/templates/TextType'; import { formatLatex } from '../GiftTemplate/templates/TextType';
interface LiveResultsProps { interface LiveResultsProps {
@ -27,7 +27,7 @@ interface LiveResultsProps {
questions: QuestionType[]; questions: QuestionType[];
showSelectedQuestion: (index: number) => void; showSelectedQuestion: (index: number) => void;
quizMode: 'teacher' | 'student'; quizMode: 'teacher' | 'student';
students: UserType[] students: StudentType[]
} }
interface Answer { interface Answer {
@ -64,7 +64,7 @@ const LiveResults: React.FC<LiveResultsProps> = ({ socket, questions, showSelect
useEffect(() => { useEffect(() => {
// studentResultsMap is inconsistent with students -- need to update // studentResultsMap is inconsistent with students -- need to update
for (const student of students as UserType[]) { for (const student of students as StudentType[]) {
if (!studentResultsMap.has(student.id)) { if (!studentResultsMap.has(student.id)) {
studentResultsMap.set(student.id, { username: student.name, idUser: student.id, answers: [] }); studentResultsMap.set(student.id, { username: student.name, idUser: student.id, answers: [] });
} }

View file

@ -1,12 +1,12 @@
import { Button, Chip, Grid } from '@mui/material'; import { Button, Chip, Grid } from '@mui/material';
import { UserType } from '../../Types/UserType'; import { StudentType } from '../../Types/StudentType';
import { PlayArrow } from '@mui/icons-material'; import { PlayArrow } from '@mui/icons-material';
import LaunchQuizDialog from '../LaunchQuizDialog/LaunchQuizDialog'; import LaunchQuizDialog from '../LaunchQuizDialog/LaunchQuizDialog';
import { useState } from 'react'; import { useState } from 'react';
import './userWaitPage.css'; import './userWaitPage.css';
interface Props { interface Props {
users: UserType[]; users: StudentType[];
launchQuiz: () => void; launchQuiz: () => void;
setQuizMode: (mode: 'student' | 'teacher') => void; setQuizMode: (mode: 'student' | 'teacher') => void;
} }

View file

@ -11,7 +11,7 @@ import { QuizType } from '../../../Types/QuizType';
import './manageRoom.css'; import './manageRoom.css';
import { ENV_VARIABLES } from '../../../constants'; import { ENV_VARIABLES } from '../../../constants';
import { UserType } from '../../../Types/UserType'; import { StudentType } from '../../../Types/StudentType';
import { Button } from '@mui/material'; import { Button } from '@mui/material';
import LoadingCircle from '../../../components/LoadingCircle/LoadingCircle'; import LoadingCircle from '../../../components/LoadingCircle/LoadingCircle';
import { Refresh, Error } from '@mui/icons-material'; import { Refresh, Error } from '@mui/icons-material';
@ -25,7 +25,7 @@ const ManageRoom: React.FC = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const [roomName, setRoomName] = useState<string>(''); const [roomName, setRoomName] = useState<string>('');
const [socket, setSocket] = useState<Socket | null>(null); const [socket, setSocket] = useState<Socket | null>(null);
const [students, setStudents] = useState<UserType[]>([]); const [students, setStudents] = useState<StudentType[]>([]);
const quizId = useParams<{ id: string }>(); const quizId = useParams<{ id: string }>();
const [quizQuestions, setQuizQuestions] = useState<QuestionType[] | undefined>(); const [quizQuestions, setQuizQuestions] = useState<QuestionType[] | undefined>();
const [quiz, setQuiz] = useState<QuizType | null>(null); const [quiz, setQuiz] = useState<QuizType | null>(null);
@ -96,7 +96,7 @@ const ManageRoom: React.FC = () => {
socket.on('create-failure', () => { socket.on('create-failure', () => {
console.log('Error creating room.'); console.log('Error creating room.');
}); });
socket.on('user-joined', (student: UserType) => { socket.on('user-joined', (student: StudentType) => {
setStudents((prevStudents) => [...prevStudents, student]); setStudents((prevStudents) => [...prevStudents, student]);
@ -119,7 +119,7 @@ const ManageRoom: React.FC = () => {
useEffect(() => { useEffect(() => {
// This is here to make sure the correct value is sent when user join // This is here to make sure the correct value is sent when user join
if (socket) { if (socket) {
socket.on('user-joined', (_student: UserType) => { socket.on('user-joined', (_student: StudentType) => {
// setUsers((prevUsers) => [...prevUsers, user]); // setUsers((prevUsers) => [...prevUsers, user]);