Skip to content

Commit 51c6ad3

Browse files
authored
Merge pull request #78 from usingbrain/nobrain
feat: individual attendance history
2 parents 95cd22a + 670550e commit 51c6ad3

8 files changed

Lines changed: 38 additions & 15 deletions

File tree

client/src/Components/Calendar/StudentHistory.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ const StudentHistory: React.FC = () => {
2121

2222
if (indivHistory) {
2323
return (
24-
<div>
24+
<div className=" flex flex-row flex-wrap w-5/6 justify-start ">
2525
{indivHistory.map((session) => {
2626
const date = new Date(Number(session!.date));
2727
const UTCdate = date.toUTCString();
2828

2929
return (
30-
<div>
30+
<div className="flex flex-col justify-center p-4 items-center">
31+
{session!.attended ? (
32+
<CheckBoxChecked className="w-10 h-10" />
33+
) : (
34+
<CheckBoxCrossed className="w-10 h-10" />
35+
)}
3136
<p>{moment(UTCdate).format('L')}</p>
32-
{session!.attended ? <CheckBoxChecked /> : <CheckBoxCrossed />}
3337
</div>
3438
);
3539
})}

client/src/Components/ClassView/ClassView.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ const headerStyle =
1212
'bg-black text-white flex flex-row justify-between items-center content-center p-8 h-20 mb-4 text-3xl';
1313
const attendanceStyle =
1414
'flex justify-center bg-black py-4 rounded-sm text-lg w-1/3 text-white mb-4 h-16';
15-
const listHeader =
16-
'w-1/2 bg-green p-2 text-white text-lg rounded-t-sm h-16';
15+
const listHeader = 'w-1/2 bg-green p-2 text-white text-lg rounded-t-sm h-16';
1716

1817
const ClassView: React.FC = () => {
1918
const dispatch = useDispatch();
@@ -45,8 +44,10 @@ const ClassView: React.FC = () => {
4544
<article className="flex flex-col px-10">
4645
<div className="flex flex-row justify-around w-full">
4746
<div className={listHeader}>
48-
Students{' '}
49-
{history && `assigned to this course: ${students.length}`}
47+
<p>
48+
Students{' '}
49+
{history && `assigned to this course: ${students.length}`}
50+
</p>
5051
</div>
5152
<Link to={link} className={attendanceStyle}>
5253
<h3

client/src/Components/ClassView/StudentsList.tsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Session from '../../Types/session';
99
import socketIOClient from 'socket.io-client';
1010
import CheckboxListSession from './CheckboxListSession';
1111
import CheckboxListHistory from '../Calendar/CheckboxListHistory';
12+
import StudentElementHistory from './StudentElementHistory';
1213
const ENDPOINT = 'http://localhost:4000';
1314

1415
const listStyle = 'flex flex-col justify-start items-start shadow-bottom';
@@ -57,15 +58,27 @@ const StudentsList: React.FC<{ courseId: number }> = ({ courseId }) => {
5758
return (
5859
<div className={listStyle}>
5960
{students?.length ? (
60-
<div className='flex flex-row w-full justify-between'>
61+
<div className="flex flex-row w-full justify-between">
6162
<div className="flex flex-col">
6263
{students.map((student) => {
6364
return (
64-
<StudentElement
65-
key={student!.email}
66-
name={student!.name}
67-
lastname={student!.lastname}
68-
/>
65+
<div>
66+
{!history ? (
67+
<StudentElement
68+
key={student!.email}
69+
name={student!.name}
70+
lastname={student!.lastname}
71+
/>
72+
) : (
73+
<StudentElementHistory
74+
key={student!.email}
75+
name={student!.name}
76+
lastname={student!.lastname}
77+
studentId={student!.id}
78+
courseId={courseId}
79+
/>
80+
)}
81+
</div>
6982
);
7083
})}
7184
</div>

client/src/generated/graphql.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ export type SessionResponse = {
220220
export type Student = {
221221
__typename?: 'Student';
222222
email: Scalars['String'];
223+
id: Scalars['Int'];
223224
lastname: Scalars['String'];
224225
name: Scalars['String'];
225226
};
@@ -299,7 +300,7 @@ export type AssignedStudentsQueryVariables = Exact<{
299300
}>;
300301

301302

302-
export type AssignedStudentsQuery = { __typename?: 'Query', getAssignedStudents: { __typename?: 'AssignedStudentsResponse', error?: string | null | undefined, data?: Array<{ __typename?: 'Student', name: string, lastname: string, email: string } | null | undefined> | null | undefined } };
303+
export type AssignedStudentsQuery = { __typename?: 'Query', getAssignedStudents: { __typename?: 'AssignedStudentsResponse', error?: string | null | undefined, data?: Array<{ __typename?: 'Student', id: number, name: string, lastname: string, email: string } | null | undefined> | null | undefined } };
303304

304305
export type CourseOverviewQueryVariables = Exact<{
305306
courseId: Scalars['Int'];
@@ -474,6 +475,7 @@ export const AssignedStudentsDocument = gql`
474475
getAssignedStudents(courseId: $courseId) {
475476
error
476477
data {
478+
id
477479
name
478480
lastname
479481
email

client/src/graphql/queries/assignedStudents.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ query AssignedStudents($courseId: Int!) {
22
getAssignedStudents(courseId: $courseId) {
33
error
44
data {
5+
id
56
name
67
lastname
78
email

server/dist/graphql/assignedCourseModule.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/dist/graphql/assignedCourseModule.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/src/graphql/assignedCourseModule.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const assignedCourseModule = createModule({
2828
}
2929
3030
type Student {
31+
id: Int!
3132
name: String!
3233
lastname: String!
3334
email: String!

0 commit comments

Comments
 (0)