Skip to content

Commit 74e6f13

Browse files
authored
Merge pull request #25 from Jing27540/pr-52
FInish review with everyone! Pr 52: Improvement + Reimplementation
2 parents bf6e4b3 + 8201d5e commit 74e6f13

File tree

13 files changed

+832
-40
lines changed

13 files changed

+832
-40
lines changed

public/assets/icons/info.png

1007 Bytes
Loading

src/App.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import Questionnaire from "pages/EditQuestionnaire/Questionnaire";
2727
import Courses from "pages/Courses/Course";
2828
import CourseEditor from "pages/Courses/CourseEditor";
2929
import { loadCourseInstructorDataAndInstitutions } from "pages/Courses/CourseUtil";
30+
import StudentTasks from "./pages/StudentTasks/StudentTasks";
3031
import TA from "pages/TA/TA";
3132
import TAEditor from "pages/TA/TAEditor";
3233
import { loadTAs } from "pages/TA/TAUtil";
@@ -59,6 +60,10 @@ function App() {
5960
path: "edit-questionnaire",
6061
element: <ProtectedRoute element={<Questionnaire />} />,
6162
},
63+
{
64+
path: "student_tasks",
65+
element: <ProtectedRoute element={<StudentTasks />} leastPrivilegeRole={ROLE.STUDENT} />,
66+
},
6267
{
6368
path: "assignments/edit/:id/createteams",
6469
element: <CreateTeams />,
@@ -297,4 +302,4 @@ function App() {
297302
return <RouterProvider router={router} />;
298303
}
299304

300-
export default App;
305+
export default App;

src/components/Table/Table.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const Table: React.FC<TableProps> = ({
4545
tableSize = { span: 12, offset: 0 },
4646
renderSubComponent,
4747
getRowCanExpand,
48-
disableGlobalFilter = false, // // Disable the Global Search
48+
disableGlobalFilter = false, // Disable the Global Search
4949
}) => {
5050
const [rowSelection, setRowSelection] = useState({});
5151
const [sorting, setSorting] = useState<SortingState>([]);
@@ -200,6 +200,13 @@ const Table: React.FC<TableProps> = ({
200200
}}
201201
>
202202
{flexRender(header.column.columnDef.header, header.getContext())}
203+
{header.column.columnDef.comment ? (
204+
<img
205+
src="assets/icons/info.png"
206+
alt="Review Grade"
207+
title={header.column.columnDef.comment}
208+
/>
209+
) : null}
203210
{{
204211
asc: " 🔼",
205212
desc: " 🔽",
@@ -255,4 +262,4 @@ const Table: React.FC<TableProps> = ({
255262
);
256263
};
257264

258-
export default Table;
265+
export default Table;

src/pages/Assignments/AssignmentColumns.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ export const assignmentColumns = (handleEdit: Fn, handleDelete: Fn) => [
1010
columnHelper.accessor("name", {
1111
header: "Name",
1212
}),
13-
columnHelper.accessor("courseName", {
14-
header: "Course Name",
15-
}),
1613
columnHelper.accessor("created_at", {
1714
header: "Creation Date",
1815
}),
@@ -41,4 +38,4 @@ export const assignmentColumns = (handleEdit: Fn, handleDelete: Fn) => [
4138
</>
4239
),
4340
}),
44-
];
41+
];

src/pages/Courses/Course.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ const Courses = () => {
139139
created_at: formatDate(item.created_at),
140140
updated_at: formatDate(item.updated_at),
141141
}));
142-
143142
return (
144143
<>
145144
<Outlet />

src/pages/Courses/CourseAssignments.tsx

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Row as TRow } from "@tanstack/react-table";
22
import Table from "components/Table/Table";
33
import React from "react";
44
import { assignmentColumns as getBaseAssignmentColumns } from "../Assignments/AssignmentColumns";
5+
import { capitalizeFirstWord, formatDate } from "utils/dataFormatter";
56

67
interface ActionHandler {
78
icon: string;
@@ -99,22 +100,18 @@ const CourseAssignments: React.FC<CourseAssignmentsProps> = ({ courseId, courseN
99100
},
100101
];
101102

103+
// TODO: update it with actual api calls to get assignment list
102104
const generateFakeAssignments = () => {
103105
const numAssignments = 3 + Math.floor(Math.random() * 3);
104106
return Array.from({ length: numAssignments }, (_, idx) => ({
105107
id: parseInt(`${courseId}${idx}`),
106-
name: `Assignment ${idx + 1} for ${courseName}`,
107-
courseName: courseName,
108+
name: `Assignment ${idx + 1}`,
108109
description: "This is a fake assignment",
109110
created_at: new Date(Date.now() - Math.random() * 10000000000).toISOString(),
110111
updated_at: new Date().toISOString(),
111112
}));
112113
};
113114

114-
const capitalizeSentence = (str: string) => {
115-
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
116-
};
117-
118115
const getAssignmentColumns = (actions: ActionHandler[]) => {
119116
const baseColumns = getBaseAssignmentColumns(
120117
() => {},
@@ -144,35 +141,22 @@ const CourseAssignments: React.FC<CourseAssignmentsProps> = ({ courseId, courseN
144141
return [...baseColumns, actionsColumn];
145142
};
146143

147-
// Helper function to format the dates
148-
const formatDate = (dateString: string): string => {
149-
const date = new Date(dateString);
150-
const options: Intl.DateTimeFormatOptions = {
151-
month: 'short',
152-
day: 'numeric',
153-
year: 'numeric',
154-
hour: 'numeric',
155-
minute: 'numeric',
156-
hour12: true
157-
};
158-
return date.toLocaleString('en-US', options);
159-
};
160-
161-
162144
const assignments = generateFakeAssignments();
163145
const columns = getAssignmentColumns(actionHandlers);
164146

165-
// Remove the 'Course Name' column from column definitions to hide it.
166-
const filteredColumns = columns.filter((col) => col.header !== "Course Name");
167-
// Remove 'courseName' field from assignment data to hide it and Format date fields.
168-
const filteredAssignments = assignments.map(
169-
({ name, courseName, created_at, updated_at, ...rest }) => ({
170-
...rest,
171-
name: capitalizeSentence(name),
172-
created_at: formatDate(created_at), // Format 'created_at' date
173-
updated_at: formatDate(updated_at), // Format 'updated_at' date
174-
})
175-
);
147+
// Format all heading data fields.
148+
const filteredColumns = columns.map(({ header, ...rest }) => ({
149+
...rest,
150+
header: capitalizeFirstWord(header as string),
151+
}));
152+
153+
// Format some assignment data fields.
154+
const filteredAssignments = assignments.map(({ name, created_at, updated_at, ...rest }) => ({
155+
...rest,
156+
name: capitalizeFirstWord(name),
157+
created_at: formatDate(created_at), // Format 'created_at' date
158+
updated_at: formatDate(updated_at), // Format 'updated_at' date
159+
}));
176160

177161
return (
178162
<div className="px-4 py-2 bg-light">
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import { useParams } from 'react-router-dom';
3+
4+
const StudentTaskDetail: React.FC = () => {
5+
const { id } = useParams(); // To grab the ID from the URL
6+
7+
return (
8+
<div>
9+
<h2>Assignment Title: {id}</h2>
10+
{/* Details about the assignment could be fetched and displayed here */}
11+
</div>
12+
);
13+
};
14+
15+
export default StudentTaskDetail;
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
/* Base container styling */
2+
.container {
3+
font-family: Arial, sans-serif;
4+
margin: 20px;
5+
}
6+
7+
/* Header 1 styling */
8+
h1 {
9+
text-align: left;
10+
padding-top: 5px;
11+
padding-left: 15px;
12+
margin-bottom: 0px;
13+
padding-bottom: 0px;
14+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
15+
font-size: 14px;
16+
line-height: 1.428571429;
17+
color: #333333;
18+
}
19+
20+
/* Table base styling */
21+
table {
22+
width: 100%;
23+
border-collapse: collapse;
24+
margin-top: 20px;
25+
}
26+
27+
/* Table, th, and td shared border styling */
28+
table,
29+
th,
30+
td {
31+
border: 1px solid #ddd;
32+
}
33+
34+
/* Table header styling */
35+
th {
36+
background-color: #f8f8f8;
37+
color: #333;
38+
text-align: left;
39+
padding: 8px;
40+
}
41+
42+
/* Table data cell styling */
43+
td {
44+
padding: 8px;
45+
text-align: left;
46+
}
47+
48+
/* First child of th and td border styling */
49+
th:first-child,
50+
td:first-child {
51+
border-left: none;
52+
}
53+
54+
/* Last child of th and td border styling */
55+
th:last-child,
56+
td:last-child {
57+
border-right: none;
58+
}
59+
60+
/* Table row striping for even rows */
61+
tr:nth-child(even) {
62+
background-color: #f2f2f2;
63+
}
64+
65+
/* Badge info icon and publishing rights checkbox styling */
66+
.badge-info-icon,
67+
.publishing-rights-checkbox {
68+
cursor: pointer;
69+
margin-left: 5px;
70+
}
71+
72+
/* Checked state styling for publishing rights checkbox */
73+
.publishing-rights-checkbox:checked {
74+
accent-color: #009688;
75+
}
76+
77+
/* Table header row font styling */
78+
thead tr {
79+
font-weight: bold;
80+
}
81+
82+
/* Status indicator icons styling */
83+
.status-indicator {
84+
color: #009688;
85+
margin-left: 5px;
86+
}
87+
88+
/* Disabled state styling for checkboxes */
89+
input[type="checkbox"][disabled] {
90+
opacity: 0.6;
91+
cursor: not-allowed;
92+
}
93+
94+
/* Information icon styling in table */
95+
.info-icon {
96+
font-style: normal;
97+
color: #017bff;
98+
cursor: help;
99+
}
100+
101+
/* Side information section styling */
102+
.side-info {
103+
color: #333;
104+
padding: 10px 0;
105+
}
106+
107+
/* Number styling in side information section */
108+
.side-info .number {
109+
font-weight: bold;
110+
color: #d9534f; /* Red color for the number badge */
111+
}
112+
113+
/* Page layout styling */
114+
.pageLayout {
115+
display: flex;
116+
margin: 16px;
117+
}
118+
119+
/* Sidebar styling */
120+
.sidebar {
121+
width: 250px;
122+
margin-right: 20px;
123+
padding-top: 20px;
124+
}
125+
126+
/* Main content area styling */
127+
.mainContent {
128+
flex-grow: 1;
129+
overflow: hidden;
130+
}
131+
132+
/* Header below pageLayout styling */
133+
.header {
134+
margin-bottom: 20px;
135+
}
136+
137+
/* Tasks table styling */
138+
.tasksTable {
139+
width: 100%;
140+
}
141+
142+
/* Page assignments styling */
143+
.assignments-page {
144+
font-family: 'Arial', sans-serif;
145+
}
146+
147+
/* Title in assignments page styling */
148+
.assignments-title {
149+
color: #333;
150+
text-align: left;
151+
padding: 20px;
152+
font-size: 24px;
153+
}
154+
155+
/* Footer section styling */
156+
.footer {
157+
display: flex;
158+
justify-content: center;
159+
padding: 20px 0;
160+
}
161+
162+
/* Footer link styling */
163+
.footerLink {
164+
margin: 0 10px;
165+
color: #986633;
166+
text-decoration: none;
167+
}
168+
169+
/* Footer link hover styling */
170+
.footerLink:hover {
171+
color: #000000;
172+
text-decoration: underline;
173+
}
174+
175+
/* Center checkbox in table data cell styling */
176+
.centerCheckbox {
177+
text-align: center;
178+
vertical-align: middle;
179+
}

0 commit comments

Comments
 (0)