-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding course phase participation table to the shared library * adding support to also download scores or other meta data * supporting reupload * finish matching phase * aligning button
- Loading branch information
1 parent
484499e
commit cbaf602
Showing
26 changed files
with
1,129 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...onsole/applicationAdministration/pages/ApplicationAssessment/components/table/columns.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
}, | ||
"packageManager": "[email protected]", | ||
"dependencies": { | ||
"papaparse": "^5.5.2", | ||
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
import { Puzzle } from 'lucide-react' | ||
import { SidebarMenuItemProps } from '@/interfaces/sidebar' | ||
import { Role } from '@tumaet/prompt-shared-state' | ||
|
||
const sidebarItems: SidebarMenuItemProps = { | ||
title: 'TemplateComponent', | ||
icon: <Puzzle />, | ||
requiredPermissions: [Role.PROMPT_ADMIN, Role.COURSE_LECTURER], | ||
goToPath: '', | ||
subitems: [], | ||
subitems: [ | ||
{ | ||
title: 'Participants', | ||
goToPath: '/participants', | ||
requiredPermissions: [Role.PROMPT_ADMIN, Role.COURSE_LECTURER], | ||
}, | ||
], | ||
} | ||
|
||
export default sidebarItems |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
clients/matching_component/src/matching/hooks/useUploadAndParseCSV.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import Papa from 'papaparse' | ||
import { useMatchingStore } from '../zustand/useMatchingStore' | ||
import { UploadedStudent } from '../interfaces/UploadedStudent' | ||
|
||
/** | ||
* This hook returns a function that, when called with a CSV File, | ||
* parses it and updates the Zustand store with the uploaded data. | ||
*/ | ||
export const useUploadAndParseCSV = () => { | ||
const { setUploadedData } = useMatchingStore() | ||
|
||
/** | ||
* Parses a CSV file expecting the following headers: | ||
* "Students first name", "Students last name", "Students matriculation number" | ||
* | ||
* Returns a Promise of the parsed data. Will throw an error if: | ||
* - The file is empty or cannot be read | ||
* - The header row is missing or incorrect | ||
* - Required data fields in rows are missing | ||
*/ | ||
const parseFileCSV = async (file: File): Promise<void> => { | ||
try { | ||
// 1. Parse the CSV using Papa Parse in 'header' mode | ||
// Setting `dynamicTyping: false` ensures all values are treated as strings | ||
// so leading zeros are preserved. | ||
const result = await new Promise<Papa.ParseResult>((resolve, reject) => { | ||
Papa.parse(file, { | ||
header: true, | ||
skipEmptyLines: true, | ||
dynamicTyping: false, // ensures leading zeros remain as strings | ||
complete: resolve, | ||
error: reject, | ||
}) | ||
}) | ||
|
||
// 2. Basic validations | ||
if (!result || !result.data || result.data.length === 0) { | ||
throw new Error('No data found in the CSV file.') | ||
} | ||
|
||
// 3. Validate the header row | ||
const expectedHeaders = [ | ||
'Students first name', | ||
'Students last name', | ||
'Students matriculation number', | ||
] | ||
const missingHeaders = expectedHeaders.filter((h) => !result.meta.fields?.includes(h)) | ||
if (missingHeaders.length > 0) { | ||
throw new Error(`Missing headers: ${missingHeaders.join(', ')}`) | ||
} | ||
|
||
// 4. Parse each row and map it to the UploadedStudent interface | ||
const parsedData: UploadedStudent[] = result.data.map( | ||
(row: Record<string, unknown>, rowIndex: number) => { | ||
const firstName = row['Students first name'] | ||
const lastName = row['Students last name'] | ||
const matriculationNumber = row['Students matriculation number'] | ||
|
||
if (!firstName || !lastName || !matriculationNumber) { | ||
throw new Error( | ||
`Row ${rowIndex + 2} is missing required fields (first name, last name, or matriculation number).`, | ||
) | ||
} | ||
|
||
return { | ||
firstName: String(firstName), | ||
lastName: String(lastName), | ||
matriculationNumber: String(matriculationNumber), | ||
} | ||
}, | ||
) | ||
|
||
// 5. Update Zustand store with parsed data | ||
setUploadedData(parsedData) | ||
} catch (error) { | ||
console.error('Error uploading and parsing CSV file:', error) | ||
throw error // Re-throw to let the caller handle it | ||
} | ||
} | ||
|
||
return { parseFileCSV } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.