From 2edde5b9ee6d4875722447ca677a474978f37988 Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Wed, 24 May 2023 21:08:51 -0400 Subject: [PATCH 01/17] Create assignment group list placeholder file --- .../General/AssignmentGroupList/AssignmentGroupList.jsx | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx diff --git a/frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx b/frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx new file mode 100644 index 00000000..3744d9fe --- /dev/null +++ b/frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx @@ -0,0 +1,7 @@ +import React from "react" + +const AssignmentGroupList = ({props}) => { + return ( +

placeholder

+ ) +} \ No newline at end of file From d5cdb05258a0c0d1d5854cfb13b72d074e15f2bf Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Fri, 26 May 2023 00:36:17 -0400 Subject: [PATCH 02/17] Create assignment group list page --- .../Page/Instructor/AssignmentGroupListPage.jsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx diff --git a/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx b/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx new file mode 100644 index 00000000..40b34b86 --- /dev/null +++ b/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx @@ -0,0 +1,14 @@ +import React, { useState, useEffect } from 'react'; +import { useNavigate, useParams } from 'react-router-dom'; +import { toast } from 'react-toastify'; +import InstructorApi from '../../../api/instructor_api'; +import { Grid } from '@mui/material'; + +const AssignmentGroupListPage = () => { + + return ( + + + + ) +} \ No newline at end of file From 758c433a6597739fa86de66d9c61a1a0ceec427a Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Fri, 26 May 2023 01:15:39 -0400 Subject: [PATCH 03/17] Add api call to get all groups for a certain task --- frontend/src/api/instructor_api.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frontend/src/api/instructor_api.js b/frontend/src/api/instructor_api.js index b4efe9f7..f53696b6 100644 --- a/frontend/src/api/instructor_api.js +++ b/frontend/src/api/instructor_api.js @@ -94,11 +94,26 @@ let impersonate = async (course_id, username) => { // } // }; +let all_groups = async (course_id, task) => { + let token = sessionStorage.getItem("token"); + + let config = { + headers: { Authorization: `Bearer ${token}` } + }; + + try { + return await axios.get(process.env.REACT_APP_API_URL + "/instructor/course/" + course_id + "/group/all?task=" + task, config); + } catch (err) { + return err.response; + } +} + let InstructorApi = { // Task related all_tasks, impersonate, + all_groups // // // Group related // check_group, From 9902004577a32c9755e18b373d78a0dd4cff23bb Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Fri, 26 May 2023 01:15:51 -0400 Subject: [PATCH 04/17] Get all groups per task per course --- .../Instructor/AssignmentGroupListPage.jsx | 46 +++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx b/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx index 40b34b86..9d62e33c 100644 --- a/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx +++ b/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx @@ -4,11 +4,49 @@ import { toast } from 'react-toastify'; import InstructorApi from '../../../api/instructor_api'; import { Grid } from '@mui/material'; + const AssignmentGroupListPage = () => { + // How to get all courses an instructor takes?? + // Will this require an overhaul of the backend? + const instructorCourses = [1]; + + // Get all groups per task per course + // {"courseId1": [Group 1, Group 2, ...]} + let groupsPerTaskPerCourse = {} + instructorCourses.forEach(course => { + let tasksPerCourse = InstructorApi.all_tasks(course); + + let courseId = course.toString() + + groupsPerTaskPerCourse[courseId] = []; + let allGroupsPerTask = tasksPerCourse.map(task => { + return InstructorApi.all_groups(course, task); + }) + groupsPerTaskPerCourse[courseId].push(allGroupsPerTask); + }) + return ( - - + + + + {roles.map((data, index) => ( + + + + ))} + - ) -} \ No newline at end of file + ); +} + +export default AssignmentGroupListPage; \ No newline at end of file From 1fb95425a93125ae84d3de6430c71380496bc459 Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Sun, 28 May 2023 18:13:10 -0400 Subject: [PATCH 05/17] Fix api call --- .../Instructor/AssignmentGroupListPage.jsx | 51 ++++++++++++++----- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx b/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx index 9d62e33c..0493bea6 100644 --- a/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx +++ b/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx @@ -3,14 +3,22 @@ import { useNavigate, useParams } from 'react-router-dom'; import { toast } from 'react-toastify'; import InstructorApi from '../../../api/instructor_api'; import { Grid } from '@mui/material'; +import { TextField } from '@mui/material'; +import Autocomplete from '@mui/material/Autocomplete'; +import ComboBoxAutocomplete from '../../FlexyMainComponents/forms/autoComplete/ComboBoxAutocomplete'; const AssignmentGroupListPage = () => { - // How to get all courses an instructor takes?? - // Will this require an overhaul of the backend? + const [courseId, setCourseId] = useState(''); const instructorCourses = [1]; + const courseInfoPerRole = JSON.parse(sessionStorage.getItem("roles")); + let courseOptions = [] + courseInfoPerRole.forEach(course => { + courseOptions.push({ label: course.course_code, course_id: course.course_id }) + }) + // Get all groups per task per course // {"courseId1": [Group 1, Group 2, ...]} let groupsPerTaskPerCourse = {} @@ -28,25 +36,40 @@ const AssignmentGroupListPage = () => { return ( - - + + +
+ ( + + )} + onChange={value => setCourseId(value)} + + /> +
+ + - {roles.map((data, index) => ( - - - - ))} - + {roles.map((data, index) => ( + + + + ))} +
- ); + ); } export default AssignmentGroupListPage; \ No newline at end of file From 1748a7ff73443eee1b38975e5afa734541224ecc Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Thu, 1 Jun 2023 00:01:36 -0400 Subject: [PATCH 06/17] Create util and constants directories with base files for organization --- frontend/src/Constants/roles.js | 5 +++++ frontend/src/Util/courses.js | 23 +++++++++++++++++++++++ frontend/src/Util/groups.js | 25 +++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 frontend/src/Constants/roles.js create mode 100644 frontend/src/Util/courses.js create mode 100644 frontend/src/Util/groups.js diff --git a/frontend/src/Constants/roles.js b/frontend/src/Constants/roles.js new file mode 100644 index 00000000..79fd281b --- /dev/null +++ b/frontend/src/Constants/roles.js @@ -0,0 +1,5 @@ +export const ROLE = "role"; +export const STUDENT = "student" +export const TA = "ta" +export const INSTRUCTOR = "instructor" +export const ADMIN = "admin" diff --git a/frontend/src/Util/courses.js b/frontend/src/Util/courses.js new file mode 100644 index 00000000..24e3c64c --- /dev/null +++ b/frontend/src/Util/courses.js @@ -0,0 +1,23 @@ +export const getCourses = roles => { + /** Gets all courses that a user belongs to with respect to the roles that they are in. + * + * @param roles An optional array of roles to validate whether a user belongs to a course + * with a given role. + * + * @returns An array of courses that the user belongs to: [{courseLabel: CSC108, courseId: 1}] + */ + const lowerCaseRoles = roles.map(role => role.toLowerCase()); + const courses = JSON.parse(sessionStorage.getItem("roles")); + let courseOptions = [] + + courses.forEach(course => { + // Filter for role specific courses + if (lowerCaseRoles && lowerCaseRoles.includes(course.role.toLowerCase())) { + courseOptions.push({ label: course.course_code, course_id: course.course_id }) + } else { + courseOptions.push({ label: course.course_code, course_id: course.course_id }) + } + }) + return courseOptions; +} + diff --git a/frontend/src/Util/groups.js b/frontend/src/Util/groups.js new file mode 100644 index 00000000..bdb97b2e --- /dev/null +++ b/frontend/src/Util/groups.js @@ -0,0 +1,25 @@ +import { getCourses } from "./courses"; +import TaApi from "../api/ta_api"; +import { INSTRUCTOR } from "../Constants/roles"; + +export const getGroups = task => { + /** Gets all groups for a particular task + * + * @returns An object of lists containing groups: {groups: [[student1, student2, student3], ...]} + */ + let groupsPerTask = {} + let instructorCourses = getCourses(INSTRUCTOR) + instructorCourses.forEach(course => { + let tasksPerCourse = TaApi.all_tasks(course); + + let courseId = course.toString() + + //TODO what is the format of all_tasks? + //TODO what is the format of all_groups? + groupsPerTask[courseId] = []; + let allGroupsPerTask = tasksPerCourse.map(task => { + return + }) + groupsPerTaskPerCourse[courseId].push(allGroupsPerTask); + }) +} \ No newline at end of file From 4a81add7d108d98010630c3efc722097c55d38c5 Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Thu, 1 Jun 2023 00:02:18 -0400 Subject: [PATCH 07/17] Revert instructor API and add group related endpoints to TA api --- frontend/src/api/instructor_api.js | 19 ++----------------- frontend/src/api/ta_api.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/frontend/src/api/instructor_api.js b/frontend/src/api/instructor_api.js index f53696b6..0f674592 100644 --- a/frontend/src/api/instructor_api.js +++ b/frontend/src/api/instructor_api.js @@ -1,19 +1,5 @@ import axios from "axios"; -let all_tasks = async (course_id) => { - let token = sessionStorage.getItem("token"); - - let config = { - headers: { Authorization: `Bearer ${token}` } - }; - - try { - return await axios.get(process.env.REACT_APP_API_URL + "/instructor/course/" + course_id + "/task/all", config); - } catch (err) { - return err.response; - } -}; - let impersonate = async (course_id, username) => { let token = sessionStorage.getItem("token"); @@ -94,7 +80,7 @@ let impersonate = async (course_id, username) => { // } // }; -let all_groups = async (course_id, task) => { +let taskGroups = async (course_id, task) => { let token = sessionStorage.getItem("token"); let config = { @@ -111,9 +97,8 @@ let all_groups = async (course_id, task) => { let InstructorApi = { // Task related - all_tasks, impersonate, - all_groups + taskGroups // // // Group related // check_group, diff --git a/frontend/src/api/ta_api.js b/frontend/src/api/ta_api.js index cc983d9b..3aa4069e 100644 --- a/frontend/src/api/ta_api.js +++ b/frontend/src/api/ta_api.js @@ -28,6 +28,20 @@ let check_group = async (course_id, group_id) => { } }; +let get_group = async (course_id, task) => { + let token = sessionStorage.getItem("token") + + let config = { + headers: { Authorization: `Bearer ${token}` } + }; + + try { + return await axios.get(process.env.REACT_APP_API_URL + "/ta/course/" + course_id + "/group/all?task=" + task, config); + } catch (err) { + return err.response; + } +} + let all_interviews = async (course_id, curr_task) => { let token = sessionStorage.getItem("token"); @@ -83,6 +97,7 @@ let TaApi = { // Group related check_group, + get_group, // Interview related all_interviews, From c98ec7fb638cc2eaa01c81028995038e68a1569d Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Thu, 1 Jun 2023 00:02:49 -0400 Subject: [PATCH 08/17] Update imports and base structure of the page with dropdowns --- .../Instructor/AssignmentGroupListPage.jsx | 63 +++++++++---------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx b/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx index 0493bea6..44bc3454 100644 --- a/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx +++ b/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx @@ -5,34 +5,13 @@ import InstructorApi from '../../../api/instructor_api'; import { Grid } from '@mui/material'; import { TextField } from '@mui/material'; import Autocomplete from '@mui/material/Autocomplete'; -import ComboBoxAutocomplete from '../../FlexyMainComponents/forms/autoComplete/ComboBoxAutocomplete'; +import { getCourses } from '../../../Util/courses'; const AssignmentGroupListPage = () => { - const [courseId, setCourseId] = useState(''); - const instructorCourses = [1]; - - const courseInfoPerRole = JSON.parse(sessionStorage.getItem("roles")); - let courseOptions = [] - courseInfoPerRole.forEach(course => { - courseOptions.push({ label: course.course_code, course_id: course.course_id }) - }) - - // Get all groups per task per course - // {"courseId1": [Group 1, Group 2, ...]} - let groupsPerTaskPerCourse = {} - instructorCourses.forEach(course => { - let tasksPerCourse = InstructorApi.all_tasks(course); - - let courseId = course.toString() - - groupsPerTaskPerCourse[courseId] = []; - let allGroupsPerTask = tasksPerCourse.map(task => { - return InstructorApi.all_groups(course, task); - }) - groupsPerTaskPerCourse[courseId].push(allGroupsPerTask); - }) + const [courseId, setCourseId] = useState(null); + const [task, setTask] = useState(null); return ( {
- ( - - )} - onChange={value => setCourseId(value)} +
+ ( + + )} + onChange={value => setCourseId(value)} + + /> +
+
+ ( + + )} + onChange={value => setTask(value)} + + /> +
- />
Date: Thu, 1 Jun 2023 00:05:38 -0400 Subject: [PATCH 09/17] Add files to existing util folder --- frontend/utilities/courses.js | 23 +++++++++++++++++++++++ frontend/utilities/groups.js | 25 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 frontend/utilities/courses.js create mode 100644 frontend/utilities/groups.js diff --git a/frontend/utilities/courses.js b/frontend/utilities/courses.js new file mode 100644 index 00000000..24e3c64c --- /dev/null +++ b/frontend/utilities/courses.js @@ -0,0 +1,23 @@ +export const getCourses = roles => { + /** Gets all courses that a user belongs to with respect to the roles that they are in. + * + * @param roles An optional array of roles to validate whether a user belongs to a course + * with a given role. + * + * @returns An array of courses that the user belongs to: [{courseLabel: CSC108, courseId: 1}] + */ + const lowerCaseRoles = roles.map(role => role.toLowerCase()); + const courses = JSON.parse(sessionStorage.getItem("roles")); + let courseOptions = [] + + courses.forEach(course => { + // Filter for role specific courses + if (lowerCaseRoles && lowerCaseRoles.includes(course.role.toLowerCase())) { + courseOptions.push({ label: course.course_code, course_id: course.course_id }) + } else { + courseOptions.push({ label: course.course_code, course_id: course.course_id }) + } + }) + return courseOptions; +} + diff --git a/frontend/utilities/groups.js b/frontend/utilities/groups.js new file mode 100644 index 00000000..d01353c6 --- /dev/null +++ b/frontend/utilities/groups.js @@ -0,0 +1,25 @@ +import { getCourses } from "./courses"; +import TaApi from "../src/api/ta_api"; +import { INSTRUCTOR } from "../src/Constants/roles"; + +export const getGroups = task => { + /** Gets all groups for a particular task + * + * @returns An object of lists containing groups: {groups: [[student1, student2, student3], ...]} + */ + let groupsPerTask = {} + let instructorCourses = getCourses(INSTRUCTOR) + instructorCourses.forEach(course => { + let tasksPerCourse = TaApi.all_tasks(course); + + let courseId = course.toString() + + //TODO what is the format of all_tasks? + //TODO what is the format of all_groups? + groupsPerTask[courseId] = []; + let allGroupsPerTask = tasksPerCourse.map(task => { + return + }) + groupsPerTaskPerCourse[courseId].push(allGroupsPerTask); + }) +} \ No newline at end of file From 7fe5d7326139e329c31f35f80c4fdb82758b66c3 Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Sun, 4 Jun 2023 12:55:52 -0400 Subject: [PATCH 10/17] Add dynamic dropdowns to assignment group page and complete task --- frontend/src/App.js | 7 +++ frontend/src/Util/courses.js | 23 -------- frontend/src/Util/groups.js | 25 -------- frontend/src/api/instructor_api.js | 36 +++++++++++- frontend/src/api/ta_api.js | 4 +- .../AssignmentGroupList.jsx | 7 --- .../AssignmentGroupListPage.jsx | 58 +++++++++++++------ .../AssignmentGroupsList.jsx | 29 ++++++++++ 8 files changed, 113 insertions(+), 76 deletions(-) delete mode 100644 frontend/src/Util/courses.js delete mode 100644 frontend/src/Util/groups.js delete mode 100644 frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx rename frontend/src/components/{Page/Instructor => General/AssignmentGroupList}/AssignmentGroupListPage.jsx (56%) create mode 100644 frontend/src/components/General/AssignmentGroupList/AssignmentGroupsList.jsx diff --git a/frontend/src/App.js b/frontend/src/App.js index 02ec6abe..4d99e3ef 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -26,6 +26,7 @@ import ThemeSettings from './layouts/full-layout/customizer/ThemeSettings'; import { useSelector } from 'react-redux'; import RTL from './layouts/full-layout/customizer/RTL'; import StudentListPage from './components/Page/Student/StudentListPage'; +import AssignmentGroupListPage from './components/General/AssignmentGroupList/AssignmentGroupListPage'; function App() { const theme = ThemeSettings(); @@ -75,6 +76,12 @@ function App() { path="/instructor/course/:course_id/task" element={} > + + } + /> + } diff --git a/frontend/src/Util/courses.js b/frontend/src/Util/courses.js deleted file mode 100644 index 24e3c64c..00000000 --- a/frontend/src/Util/courses.js +++ /dev/null @@ -1,23 +0,0 @@ -export const getCourses = roles => { - /** Gets all courses that a user belongs to with respect to the roles that they are in. - * - * @param roles An optional array of roles to validate whether a user belongs to a course - * with a given role. - * - * @returns An array of courses that the user belongs to: [{courseLabel: CSC108, courseId: 1}] - */ - const lowerCaseRoles = roles.map(role => role.toLowerCase()); - const courses = JSON.parse(sessionStorage.getItem("roles")); - let courseOptions = [] - - courses.forEach(course => { - // Filter for role specific courses - if (lowerCaseRoles && lowerCaseRoles.includes(course.role.toLowerCase())) { - courseOptions.push({ label: course.course_code, course_id: course.course_id }) - } else { - courseOptions.push({ label: course.course_code, course_id: course.course_id }) - } - }) - return courseOptions; -} - diff --git a/frontend/src/Util/groups.js b/frontend/src/Util/groups.js deleted file mode 100644 index bdb97b2e..00000000 --- a/frontend/src/Util/groups.js +++ /dev/null @@ -1,25 +0,0 @@ -import { getCourses } from "./courses"; -import TaApi from "../api/ta_api"; -import { INSTRUCTOR } from "../Constants/roles"; - -export const getGroups = task => { - /** Gets all groups for a particular task - * - * @returns An object of lists containing groups: {groups: [[student1, student2, student3], ...]} - */ - let groupsPerTask = {} - let instructorCourses = getCourses(INSTRUCTOR) - instructorCourses.forEach(course => { - let tasksPerCourse = TaApi.all_tasks(course); - - let courseId = course.toString() - - //TODO what is the format of all_tasks? - //TODO what is the format of all_groups? - groupsPerTask[courseId] = []; - let allGroupsPerTask = tasksPerCourse.map(task => { - return - }) - groupsPerTaskPerCourse[courseId].push(allGroupsPerTask); - }) -} \ No newline at end of file diff --git a/frontend/src/api/instructor_api.js b/frontend/src/api/instructor_api.js index 0f674592..6ca36733 100644 --- a/frontend/src/api/instructor_api.js +++ b/frontend/src/api/instructor_api.js @@ -80,7 +80,38 @@ let impersonate = async (course_id, username) => { // } // }; +let allTasks = async (course_id) => { + let token = sessionStorage.getItem("token"); + + let config = { + headers: { Authorization: `Bearer ${token}` } + }; + + try { + return await axios.get(process.env.REACT_APP_API_URL + "/instructor/course/" + course_id + "/task/all", config); + } catch (err) { + return err.response; + } +}; + +let allGroups = async (course_id, task) => { + let token = sessionStorage.getItem("token") + + let config = { + headers: { Authorization: `Bearer ${token}` } + }; + + try { + return await axios.get(process.env.REACT_APP_API_URL + "/instructor/course/" + course_id + "/group/all?task=" + task, config); + } catch (err) { + return err.response; + } +} + let taskGroups = async (course_id, task) => { + /** + * Gets all groups for a particular task within a course. + */ let token = sessionStorage.getItem("token"); let config = { @@ -96,12 +127,15 @@ let taskGroups = async (course_id, task) => { let InstructorApi = { + //Course related + allTasks, // Task related impersonate, - taskGroups + taskGroups, // // // Group related // check_group, + allGroups, // // // Interview related // all_interviews, diff --git a/frontend/src/api/ta_api.js b/frontend/src/api/ta_api.js index 3aa4069e..38a68b45 100644 --- a/frontend/src/api/ta_api.js +++ b/frontend/src/api/ta_api.js @@ -28,7 +28,7 @@ let check_group = async (course_id, group_id) => { } }; -let get_group = async (course_id, task) => { +let allGroups = async (course_id, task) => { let token = sessionStorage.getItem("token") let config = { @@ -97,7 +97,7 @@ let TaApi = { // Group related check_group, - get_group, + allGroups, // Interview related all_interviews, diff --git a/frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx b/frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx deleted file mode 100644 index 3744d9fe..00000000 --- a/frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react" - -const AssignmentGroupList = ({props}) => { - return ( -

placeholder

- ) -} \ No newline at end of file diff --git a/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx b/frontend/src/components/General/AssignmentGroupList/AssignmentGroupListPage.jsx similarity index 56% rename from frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx rename to frontend/src/components/General/AssignmentGroupList/AssignmentGroupListPage.jsx index 44bc3454..cc55f4bc 100644 --- a/frontend/src/components/Page/Instructor/AssignmentGroupListPage.jsx +++ b/frontend/src/components/General/AssignmentGroupList/AssignmentGroupListPage.jsx @@ -5,13 +5,41 @@ import InstructorApi from '../../../api/instructor_api'; import { Grid } from '@mui/material'; import { TextField } from '@mui/material'; import Autocomplete from '@mui/material/Autocomplete'; -import { getCourses } from '../../../Util/courses'; +import { getCourses } from '../../../../utilities/courses'; +import NavBar from '../../Module/Navigation/NavBar'; +import { makeStyles } from '@mui/styles'; +import { AssignmentGroupList } from './AssignmentGroupsList'; +const useStyles = makeStyles({ + container: { + display: 'flex', + flexWrap: 'wrap', + alignItems: 'flex-start', + justifyContent: 'flex-start', + margin: '16px', + padding: '16px', + }, + + dropdown: { + display: 'inline-block' + }, +}); const AssignmentGroupListPage = () => { - const [courseId, setCourseId] = useState(null); - const [task, setTask] = useState(null); + const classes = useStyles(); + const [courseOptions, setCourseOptions] = useState([]); + const [taskOptions, setTaskOptions] = useState([]); + + useEffect(() => { + const courses = getCourses(); + setCourseOptions(courses); + }, []) + + const handleCourseChange = (event, value) => { + let tasks = InstructorApi.allTasks(value.courseId) + setTaskOptions(tasks); + } return ( { wrap="nowrap"> -
+
( - + )} - onChange={value => setCourseId(value)} + options={courseOptions} + onChange={(event, value) => handleCourseChange(event, value)} />
@@ -39,15 +66,11 @@ const AssignmentGroupListPage = () => { disablePortal id="task-selection-dropdown" options={taskOptions} - fullWidth renderInput={(params) => ( - + )} - onChange={value => setTask(value)} - />
-
{ alignContent="center" justify="center" flex="1 1 auto"> - {roles.map((data, index) => ( - - - - ))} +
); diff --git a/frontend/src/components/General/AssignmentGroupList/AssignmentGroupsList.jsx b/frontend/src/components/General/AssignmentGroupList/AssignmentGroupsList.jsx new file mode 100644 index 00000000..5d86646c --- /dev/null +++ b/frontend/src/components/General/AssignmentGroupList/AssignmentGroupsList.jsx @@ -0,0 +1,29 @@ +import React, { Children } from "react" +import BaseCard from "../../FlexyMainComponents/base-card/BaseCard" +import { getAllGroups } from "../../../../utilities/groups" +import InstructorApi from "../../../api/instructor_api" +import { useEffect, useState } from 'react'; +import { useNavigate, useParams } from "react-router"; + + +const AssignmentGroupsTable = ({ courseId, task }) => { + + const allGroups = InstructorApi.allGroups(courseId, task); + + return ( + + {allGroups.map(groupName => ( + + ))} + + ) +}; From 8d6eb62e454240a7168c8bb70f55c72534ca1004 Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Sun, 4 Jun 2023 19:32:40 -0400 Subject: [PATCH 11/17] Rename component, fix api calls, and add new helper file to get tasks --- frontend/src/App.js | 2 +- .../AssignmentGroupList.jsx | 52 +++++++++++++++++++ .../AssignmentGroupListPage.jsx | 52 +++++++++++-------- .../AssignmentGroupsList.jsx | 29 ----------- 4 files changed, 83 insertions(+), 52 deletions(-) create mode 100644 frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx delete mode 100644 frontend/src/components/General/AssignmentGroupList/AssignmentGroupsList.jsx diff --git a/frontend/src/App.js b/frontend/src/App.js index 4d99e3ef..673e1280 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -78,7 +78,7 @@ function App() { >
} /> diff --git a/frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx b/frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx new file mode 100644 index 00000000..0aef0740 --- /dev/null +++ b/frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx @@ -0,0 +1,52 @@ +import React, { Children } from "react" +import BaseCard from "../../FlexyMainComponents/base-card/BaseCard" +import { getAllGroups } from "../../../../utilities/groups" +import InstructorApi from "../../../api/instructor_api" +import { useEffect, useState } from 'react'; +import { useNavigate, useParams } from "react-router"; + + +const AssignmentGroupList = ({ courseId, task }) => { + + const res = await InstructorApi.allGroups(courseId, task); + let groups = []; + res.groups.forEach(group => { + groups.push({"id": group.id, "members": group.users}); + }) + + return ( + + {groups.map(group => ( + + ))} + + ) +}; + +export default AssignmentGroupCard; +// all groups +{ + "count": 1, + "groups": [ + { + "group_id": 1, + "task": "A1", + "extension": null, + "gitlab_group_id": null, + "gitlab_project_id": null, + "gitlab_url": null, + "users": [ + "shab" + ] + } + ] +} \ No newline at end of file diff --git a/frontend/src/components/General/AssignmentGroupList/AssignmentGroupListPage.jsx b/frontend/src/components/General/AssignmentGroupList/AssignmentGroupListPage.jsx index cc55f4bc..b3aba42a 100644 --- a/frontend/src/components/General/AssignmentGroupList/AssignmentGroupListPage.jsx +++ b/frontend/src/components/General/AssignmentGroupList/AssignmentGroupListPage.jsx @@ -8,7 +8,7 @@ import Autocomplete from '@mui/material/Autocomplete'; import { getCourses } from '../../../../utilities/courses'; import NavBar from '../../Module/Navigation/NavBar'; import { makeStyles } from '@mui/styles'; -import { AssignmentGroupList } from './AssignmentGroupsList'; +import { AssignmentGroupList } from './AssignmentGroupList'; const useStyles = makeStyles({ container: { @@ -17,35 +17,34 @@ const useStyles = makeStyles({ alignItems: 'flex-start', justifyContent: 'flex-start', margin: '16px', - padding: '16px', + padding: '16px' }, dropdown: { display: 'inline-block' - }, + } }); const AssignmentGroupListPage = () => { - const classes = useStyles(); const [courseOptions, setCourseOptions] = useState([]); const [taskOptions, setTaskOptions] = useState([]); + const [course, setCourse] = useState(''); + const [task, setTask] = useState(''); + useEffect(() => { const courses = getCourses(); setCourseOptions(courses); - }, []) + }, []); const handleCourseChange = (event, value) => { - let tasks = InstructorApi.allTasks(value.courseId) + let tasks = InstructorApi.allTasks(value.courseId); setTaskOptions(tasks); - } + }; return ( - +
@@ -54,11 +53,15 @@ const AssignmentGroupListPage = () => { disablePortal id="course-selection-dropdown" renderInput={(params) => ( - + )} options={courseOptions} onChange={(event, value) => handleCourseChange(event, value)} - />
@@ -67,26 +70,31 @@ const AssignmentGroupListPage = () => { id="task-selection-dropdown" options={taskOptions} renderInput={(params) => ( - + )} />
- - + flex="1 1 auto" + > +
); -} +}; -export default AssignmentGroupListPage; \ No newline at end of file +export default AssignmentGroupListPage; diff --git a/frontend/src/components/General/AssignmentGroupList/AssignmentGroupsList.jsx b/frontend/src/components/General/AssignmentGroupList/AssignmentGroupsList.jsx deleted file mode 100644 index 5d86646c..00000000 --- a/frontend/src/components/General/AssignmentGroupList/AssignmentGroupsList.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import React, { Children } from "react" -import BaseCard from "../../FlexyMainComponents/base-card/BaseCard" -import { getAllGroups } from "../../../../utilities/groups" -import InstructorApi from "../../../api/instructor_api" -import { useEffect, useState } from 'react'; -import { useNavigate, useParams } from "react-router"; - - -const AssignmentGroupsTable = ({ courseId, task }) => { - - const allGroups = InstructorApi.allGroups(courseId, task); - - return ( - - {allGroups.map(groupName => ( - - ))} - - ) -}; From c59e4b9e60a73ba8d1258dfb364119675c42a6c1 Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Sun, 4 Jun 2023 19:48:36 -0400 Subject: [PATCH 12/17] Rename assignment to task for consistency and async calls --- frontend/src/App.js | 2 +- .../AssignmentGroupList.jsx | 52 ----------------- .../General/TaskGroupList/TaskGroupCard.jsx | 0 .../General/TaskGroupList/TaskGroupList.jsx | 38 ++++++++++++ .../TaskGroupListPage.jsx} | 58 +++++++++---------- 5 files changed, 68 insertions(+), 82 deletions(-) delete mode 100644 frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx create mode 100644 frontend/src/components/General/TaskGroupList/TaskGroupCard.jsx create mode 100644 frontend/src/components/General/TaskGroupList/TaskGroupList.jsx rename frontend/src/components/General/{AssignmentGroupList/AssignmentGroupListPage.jsx => TaskGroupList/TaskGroupListPage.jsx} (65%) diff --git a/frontend/src/App.js b/frontend/src/App.js index 673e1280..220eac6f 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -26,7 +26,7 @@ import ThemeSettings from './layouts/full-layout/customizer/ThemeSettings'; import { useSelector } from 'react-redux'; import RTL from './layouts/full-layout/customizer/RTL'; import StudentListPage from './components/Page/Student/StudentListPage'; -import AssignmentGroupListPage from './components/General/AssignmentGroupList/AssignmentGroupListPage'; +import AssignmentGroupListPage from './components/General/TaskGroupList/TaskGroupListPage'; function App() { const theme = ThemeSettings(); diff --git a/frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx b/frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx deleted file mode 100644 index 0aef0740..00000000 --- a/frontend/src/components/General/AssignmentGroupList/AssignmentGroupList.jsx +++ /dev/null @@ -1,52 +0,0 @@ -import React, { Children } from "react" -import BaseCard from "../../FlexyMainComponents/base-card/BaseCard" -import { getAllGroups } from "../../../../utilities/groups" -import InstructorApi from "../../../api/instructor_api" -import { useEffect, useState } from 'react'; -import { useNavigate, useParams } from "react-router"; - - -const AssignmentGroupList = ({ courseId, task }) => { - - const res = await InstructorApi.allGroups(courseId, task); - let groups = []; - res.groups.forEach(group => { - groups.push({"id": group.id, "members": group.users}); - }) - - return ( - - {groups.map(group => ( - - ))} - - ) -}; - -export default AssignmentGroupCard; -// all groups -{ - "count": 1, - "groups": [ - { - "group_id": 1, - "task": "A1", - "extension": null, - "gitlab_group_id": null, - "gitlab_project_id": null, - "gitlab_url": null, - "users": [ - "shab" - ] - } - ] -} \ No newline at end of file diff --git a/frontend/src/components/General/TaskGroupList/TaskGroupCard.jsx b/frontend/src/components/General/TaskGroupList/TaskGroupCard.jsx new file mode 100644 index 00000000..e69de29b diff --git a/frontend/src/components/General/TaskGroupList/TaskGroupList.jsx b/frontend/src/components/General/TaskGroupList/TaskGroupList.jsx new file mode 100644 index 00000000..51d224bf --- /dev/null +++ b/frontend/src/components/General/TaskGroupList/TaskGroupList.jsx @@ -0,0 +1,38 @@ +import React, { Children } from 'react'; +import BaseCard from '../../FlexyMainComponents/base-card/BaseCard'; +import { getAllGroups } from '../../../../utilities/groups'; +import InstructorApi from '../../../api/instructor_api'; +import { useEffect, useState } from 'react'; +import { useNavigate, useParams } from 'react-router'; + +const AssignmentGroupList = ({ courseId, task }) => { + let groups = []; + InstructorApi.allGroups(courseId, task) + .then((res) => { + res.groups.forEach((group) => { + groups.push({ id: group.id, members: group.users }); + }); + }) + .catch((err) => { + console.log(err); + }); + + return ( + + {groups.map((group) => ( + + ))} + + ); +}; + +export default AssignmentGroupCard; diff --git a/frontend/src/components/General/AssignmentGroupList/AssignmentGroupListPage.jsx b/frontend/src/components/General/TaskGroupList/TaskGroupListPage.jsx similarity index 65% rename from frontend/src/components/General/AssignmentGroupList/AssignmentGroupListPage.jsx rename to frontend/src/components/General/TaskGroupList/TaskGroupListPage.jsx index b3aba42a..14664e1b 100644 --- a/frontend/src/components/General/AssignmentGroupList/AssignmentGroupListPage.jsx +++ b/frontend/src/components/General/TaskGroupList/TaskGroupListPage.jsx @@ -8,7 +8,8 @@ import Autocomplete from '@mui/material/Autocomplete'; import { getCourses } from '../../../../utilities/courses'; import NavBar from '../../Module/Navigation/NavBar'; import { makeStyles } from '@mui/styles'; -import { AssignmentGroupList } from './AssignmentGroupList'; +import { AssignmentGroupList } from './TaskGroupList'; +import { getTasks } from '../../../../utilities/tasks'; const useStyles = makeStyles({ container: { @@ -27,21 +28,18 @@ const useStyles = makeStyles({ const AssignmentGroupListPage = () => { const classes = useStyles(); - const [courseOptions, setCourseOptions] = useState([]); - const [taskOptions, setTaskOptions] = useState([]); + const courseOptions = getCourses(); const [course, setCourse] = useState(''); const [task, setTask] = useState(''); + const [taskOptions, setTaskOptions] = useState([]); useEffect(() => { - const courses = getCourses(); - setCourseOptions(courses); - }, []); - - const handleCourseChange = (event, value) => { - let tasks = InstructorApi.allTasks(value.courseId); - setTaskOptions(tasks); - }; + if (course) { + const tasks = getTasks(); + setTaskOptions(tasks); + } + }, [course]); return ( @@ -57,30 +55,32 @@ const AssignmentGroupListPage = () => { {...params} size="small" placeholder="Select Course" - aria-label="Select course" + aria-label="Select Course" /> )} options={courseOptions} - onChange={(event, value) => handleCourseChange(event, value)} - /> - -
- ( - - )} + onChange={(value) => setCourse(value)} />
+ {task && ( +
+ ( + + )} + onChange={(value) => setTask(value)} + /> +
+ )} - Date: Sun, 4 Jun 2023 19:49:18 -0400 Subject: [PATCH 13/17] Update labels for helpers in utils --- frontend/utilities/courses.js | 23 +++++++++++------------ frontend/utilities/groups.js | 25 ------------------------- frontend/utilities/tasks.js | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 37 deletions(-) delete mode 100644 frontend/utilities/groups.js create mode 100644 frontend/utilities/tasks.js diff --git a/frontend/utilities/courses.js b/frontend/utilities/courses.js index 24e3c64c..67c08305 100644 --- a/frontend/utilities/courses.js +++ b/frontend/utilities/courses.js @@ -1,23 +1,22 @@ -export const getCourses = roles => { +export const getCourses = (roles) => { /** Gets all courses that a user belongs to with respect to the roles that they are in. - * + * * @param roles An optional array of roles to validate whether a user belongs to a course * with a given role. - * + * * @returns An array of courses that the user belongs to: [{courseLabel: CSC108, courseId: 1}] */ - const lowerCaseRoles = roles.map(role => role.toLowerCase()); - const courses = JSON.parse(sessionStorage.getItem("roles")); - let courseOptions = [] + const lowerCaseRoles = roles.map((role) => role.toLowerCase()); + const courses = JSON.parse(sessionStorage.getItem('roles')); + let courseOptions = []; - courses.forEach(course => { + courses.forEach((course) => { // Filter for role specific courses if (lowerCaseRoles && lowerCaseRoles.includes(course.role.toLowerCase())) { - courseOptions.push({ label: course.course_code, course_id: course.course_id }) + courseOptions.push({ label: course.course_code, course_id: course.course_id }); } else { - courseOptions.push({ label: course.course_code, course_id: course.course_id }) + courseOptions.push({ label: course.course_code, course_id: course.course_id }); } - }) + }); return courseOptions; -} - +}; diff --git a/frontend/utilities/groups.js b/frontend/utilities/groups.js deleted file mode 100644 index d01353c6..00000000 --- a/frontend/utilities/groups.js +++ /dev/null @@ -1,25 +0,0 @@ -import { getCourses } from "./courses"; -import TaApi from "../src/api/ta_api"; -import { INSTRUCTOR } from "../src/Constants/roles"; - -export const getGroups = task => { - /** Gets all groups for a particular task - * - * @returns An object of lists containing groups: {groups: [[student1, student2, student3], ...]} - */ - let groupsPerTask = {} - let instructorCourses = getCourses(INSTRUCTOR) - instructorCourses.forEach(course => { - let tasksPerCourse = TaApi.all_tasks(course); - - let courseId = course.toString() - - //TODO what is the format of all_tasks? - //TODO what is the format of all_groups? - groupsPerTask[courseId] = []; - let allGroupsPerTask = tasksPerCourse.map(task => { - return - }) - groupsPerTaskPerCourse[courseId].push(allGroupsPerTask); - }) -} \ No newline at end of file diff --git a/frontend/utilities/tasks.js b/frontend/utilities/tasks.js new file mode 100644 index 00000000..b5713501 --- /dev/null +++ b/frontend/utilities/tasks.js @@ -0,0 +1,22 @@ +import InstructorApi from '../src/api/instructor_api'; +export const getTasks = (courseId) => { + /** Gets all tasks in a course + * + * @param courseId The id of a course + * + * @return An array of objects containing the course code and id: [{courseCode: 'CSC108', courseId: '1'}] + */ + + let tasks = []; + InstructorApi.allTasks(courseId) + .then((res) => { + res.task.forEach((task) => { + tasks.push({ label: task.task }); + }); + }) + .catch((err) => { + console.log(err); + }); + + return tasks; +}; From fc359610ce184aa7ff15dc77cd2020def4e65a72 Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Fri, 9 Jun 2023 16:45:43 -0400 Subject: [PATCH 14/17] Fix import issues --- .../General/TaskGroupList/TaskGroupCard.jsx | 43 +++++++++++++++++++ .../General/TaskGroupList/TaskGroupList.jsx | 3 +- .../TaskGroupList/TaskGroupListPage.jsx | 2 +- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/General/TaskGroupList/TaskGroupCard.jsx b/frontend/src/components/General/TaskGroupList/TaskGroupCard.jsx index e69de29b..9875a17e 100644 --- a/frontend/src/components/General/TaskGroupList/TaskGroupCard.jsx +++ b/frontend/src/components/General/TaskGroupList/TaskGroupCard.jsx @@ -0,0 +1,43 @@ +import React from 'react'; +import { Card, CardActionArea, CardContent, CardMedia, Typography } from '@mui/material'; +import { Link } from 'react-router-dom'; +import HomeCardLink from './HomeCardLink'; + +const Homecard = ({ data }) => { + const role = data.role === undefined || data.role === 'student' ? '' : data.role; + const staffRoles = ['admin', 'ta', 'instructor']; + + const coursePageLink = (role ? '/' + role : '') + '/course/' + data.course_id + '/task'; + const courseStudentListPageLink = `/course/${data.course_id}/student-list`; + + return ( + + + + + + {data.course_code} + +
+ + {data.course_session.replaceAll('_', ' ')} + + + {data?.role?.charAt(0)?.toUpperCase() + data?.role?.slice(1)} + +
+
+
+ {staffRoles.includes(data.role) && ( + + )} +
+ ); +}; + +export default Homecard; diff --git a/frontend/src/components/General/TaskGroupList/TaskGroupList.jsx b/frontend/src/components/General/TaskGroupList/TaskGroupList.jsx index 51d224bf..da99482b 100644 --- a/frontend/src/components/General/TaskGroupList/TaskGroupList.jsx +++ b/frontend/src/components/General/TaskGroupList/TaskGroupList.jsx @@ -1,6 +1,5 @@ import React, { Children } from 'react'; import BaseCard from '../../FlexyMainComponents/base-card/BaseCard'; -import { getAllGroups } from '../../../../utilities/groups'; import InstructorApi from '../../../api/instructor_api'; import { useEffect, useState } from 'react'; import { useNavigate, useParams } from 'react-router'; @@ -35,4 +34,4 @@ const AssignmentGroupList = ({ courseId, task }) => { ); }; -export default AssignmentGroupCard; +export default AssignmentGroupList; diff --git a/frontend/src/components/General/TaskGroupList/TaskGroupListPage.jsx b/frontend/src/components/General/TaskGroupList/TaskGroupListPage.jsx index 14664e1b..50e42376 100644 --- a/frontend/src/components/General/TaskGroupList/TaskGroupListPage.jsx +++ b/frontend/src/components/General/TaskGroupList/TaskGroupListPage.jsx @@ -8,7 +8,7 @@ import Autocomplete from '@mui/material/Autocomplete'; import { getCourses } from '../../../../utilities/courses'; import NavBar from '../../Module/Navigation/NavBar'; import { makeStyles } from '@mui/styles'; -import { AssignmentGroupList } from './TaskGroupList'; +import AssignmentGroupList from './TaskGroupList'; import { getTasks } from '../../../../utilities/tasks'; const useStyles = makeStyles({ From 25c2a0e95c46cdd481336968177be2452baf81c6 Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Fri, 9 Jun 2023 16:47:14 -0400 Subject: [PATCH 15/17] Update package --- package-lock.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..9cf0bffb --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "IBS", + "lockfileVersion": 2, + "requires": true, + "packages": {} +} From 2d3d6f3d6d54057eb75b80bdf2ad65ada38109e6 Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Sun, 11 Jun 2023 14:24:14 -0400 Subject: [PATCH 16/17] Change assignment to task for verbosityy --- frontend/src/App.js | 8 +++---- .../General/TaskGroupList/TaskGroupList.jsx | 5 +++-- .../TaskGroupList/TaskGroupListPage.jsx | 18 ++++++++++----- frontend/utilities/courses.js | 22 ++++++++++++++++++- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/frontend/src/App.js b/frontend/src/App.js index 220eac6f..587dca1d 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -26,7 +26,7 @@ import ThemeSettings from './layouts/full-layout/customizer/ThemeSettings'; import { useSelector } from 'react-redux'; import RTL from './layouts/full-layout/customizer/RTL'; import StudentListPage from './components/Page/Student/StudentListPage'; -import AssignmentGroupListPage from './components/General/TaskGroupList/TaskGroupListPage'; +import TaskGroupListPage from './components/General/TaskGroupList/TaskGroupListPage'; function App() { const theme = ThemeSettings(); @@ -77,11 +77,11 @@ function App() { element={} >
- } + element={} /> - + } diff --git a/frontend/src/components/General/TaskGroupList/TaskGroupList.jsx b/frontend/src/components/General/TaskGroupList/TaskGroupList.jsx index da99482b..1eeef721 100644 --- a/frontend/src/components/General/TaskGroupList/TaskGroupList.jsx +++ b/frontend/src/components/General/TaskGroupList/TaskGroupList.jsx @@ -3,8 +3,9 @@ import BaseCard from '../../FlexyMainComponents/base-card/BaseCard'; import InstructorApi from '../../../api/instructor_api'; import { useEffect, useState } from 'react'; import { useNavigate, useParams } from 'react-router'; +import { Grid } from '@mui/material'; -const AssignmentGroupList = ({ courseId, task }) => { +const TaskGroupList = ({ courseId, task }) => { let groups = []; InstructorApi.allGroups(courseId, task) .then((res) => { @@ -34,4 +35,4 @@ const AssignmentGroupList = ({ courseId, task }) => { ); }; -export default AssignmentGroupList; +export default TaskGroupList; diff --git a/frontend/src/components/General/TaskGroupList/TaskGroupListPage.jsx b/frontend/src/components/General/TaskGroupList/TaskGroupListPage.jsx index 50e42376..b7c8a04d 100644 --- a/frontend/src/components/General/TaskGroupList/TaskGroupListPage.jsx +++ b/frontend/src/components/General/TaskGroupList/TaskGroupListPage.jsx @@ -8,7 +8,7 @@ import Autocomplete from '@mui/material/Autocomplete'; import { getCourses } from '../../../../utilities/courses'; import NavBar from '../../Module/Navigation/NavBar'; import { makeStyles } from '@mui/styles'; -import AssignmentGroupList from './TaskGroupList'; +import TaskGroupList from './TaskGroupList'; import { getTasks } from '../../../../utilities/tasks'; const useStyles = makeStyles({ @@ -26,14 +26,20 @@ const useStyles = makeStyles({ } }); -const AssignmentGroupListPage = () => { +const TaskGroupListPage = () => { const classes = useStyles(); const courseOptions = getCourses(); const [course, setCourse] = useState(''); + const [courseId, setCourseId] = useState(null); const [task, setTask] = useState(''); const [taskOptions, setTaskOptions] = useState([]); + const handleCourseChange = (option) => { + setCourse(option.label); + setCourseId(option.course_id); + }; + useEffect(() => { if (course) { const tasks = getTasks(); @@ -59,7 +65,7 @@ const AssignmentGroupListPage = () => { /> )} options={courseOptions} - onChange={(value) => setCourse(value)} + onChange={(event, value) => handleCourseChange(value)} /> {task && ( @@ -76,7 +82,7 @@ const AssignmentGroupListPage = () => { aria-label="Select Task" /> )} - onChange={(value) => setTask(value)} + onChange={(event, value) => setTask(value)} /> )} @@ -91,10 +97,10 @@ const AssignmentGroupListPage = () => { justify="center" flex="1 1 auto" > - +
); }; -export default AssignmentGroupListPage; +export default TaskGroupListPage; diff --git a/frontend/utilities/courses.js b/frontend/utilities/courses.js index 67c08305..518d9db4 100644 --- a/frontend/utilities/courses.js +++ b/frontend/utilities/courses.js @@ -1,4 +1,4 @@ -export const getCourses = (roles) => { +export const getCourses = (roles = []) => { /** Gets all courses that a user belongs to with respect to the roles that they are in. * * @param roles An optional array of roles to validate whether a user belongs to a course @@ -20,3 +20,23 @@ export const getCourses = (roles) => { }); return courseOptions; }; + +export const getCourseIdFromName = (courseName) => { + /** + * Gets the course id associated with courseName + * + * @param courseName: The name of the course whos id to find + * + * @returns An int representing the course id or null if none exist. + */ + + const courses = getCourses(); + console.log(courseName); + + courses.forEach((course) => { + if (courseName.toLowerCase() === course.label.toLowerCase()) { + return course.course_id; + } + }); + return null; +}; From f5d69b582b14ddbf2945d896fb91fd429768c4a5 Mon Sep 17 00:00:00 2001 From: joshuamenezes Date: Thu, 15 Jun 2023 11:33:52 -0400 Subject: [PATCH 17/17] .