-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* goeie styling yallah * pls werk * werkt hopelijk * linter --------- Co-authored-by: Siebe Vlietinck <[email protected]>
- Loading branch information
Showing
13 changed files
with
297 additions
and
33 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
24 changes: 24 additions & 0 deletions
24
backend/project/endpoints/projects/project_last_submission.py
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,24 @@ | ||
""" | ||
This module gives the last submission for a project for every user | ||
""" | ||
|
||
from os import getenv | ||
from urllib.parse import urljoin | ||
from flask_restful import Resource | ||
from project.endpoints.projects.project_submissions_download import get_last_submissions_per_user | ||
|
||
API_HOST = getenv("API_HOST") | ||
UPLOAD_FOLDER = getenv("UPLOAD_FOLDER") | ||
BASE_URL = urljoin(f"{API_HOST}/", "/projects") | ||
|
||
class SubmissionPerUser(Resource): | ||
""" | ||
Recourse to get all the submissions for users | ||
""" | ||
|
||
def get(self, project_id: int): | ||
""" | ||
Download all submissions for a project as a zip file. | ||
""" | ||
|
||
return get_last_submissions_per_user(project_id) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"submissionOverview": { | ||
"submissionOverviewHeader": "Project status overview", | ||
"downloadButton": "DOWNLOAD ALL PROJECTS" | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"submissionOverview": { | ||
"submissionOverviewHeader": "Project status overzicht", | ||
"downloadButton": "DOWNLOAD ALLE PROJECTEN" | ||
} | ||
} |
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
64 changes: 64 additions & 0 deletions
64
frontend/src/components/ProjectSubmissionOverview/ProjectSubmissionOverview.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,64 @@ | ||
import {Box, Button, Typography} from "@mui/material"; | ||
import {useEffect, useState} from "react"; | ||
import {useParams} from "react-router-dom"; | ||
import ProjectSubmissionsOverviewDatagrid from "./ProjectSubmissionOverviewDatagrid.tsx"; | ||
import download from 'downloadjs'; | ||
import {useTranslation} from "react-i18next"; | ||
const apiUrl = import.meta.env.VITE_API_HOST | ||
const user = "teacher" | ||
|
||
/** | ||
* @returns Overview page for submissions | ||
*/ | ||
export default function ProjectSubmissionOverview() { | ||
|
||
const { t } = useTranslation('submissionOverview', { keyPrefix: 'submissionOverview' }); | ||
|
||
useEffect(() => { | ||
fetchProject(); | ||
}); | ||
|
||
const fetchProject = async () => { | ||
const response = await fetch(`${apiUrl}/projects/${projectId}`, { | ||
headers: { | ||
"Authorization": user | ||
}, | ||
}) | ||
const jsonData = await response.json(); | ||
setProjectTitle(jsonData["data"].title); | ||
|
||
} | ||
|
||
const downloadProjectSubmissions = async () => { | ||
await fetch(`${apiUrl}/projects/${projectId}/submissions-download`, { | ||
headers: { | ||
"Authorization": user | ||
}, | ||
}) | ||
.then(res => { | ||
return res.blob(); | ||
}) | ||
.then(blob => { | ||
download(blob, 'submissions.zip'); | ||
}); | ||
} | ||
|
||
const [projectTitle, setProjectTitle] = useState<string>("") | ||
const { projectId } = useParams<{ projectId: string }>(); | ||
|
||
return ( | ||
<Box | ||
display="flex" | ||
flexDirection="column" | ||
alignItems="center" | ||
justifyContent="center" | ||
paddingTop="50px" | ||
> | ||
<Box width="40%"> | ||
<Typography minWidth="440px" variant="h6" align="left">{projectTitle}</Typography> | ||
<ProjectSubmissionsOverviewDatagrid /> | ||
</Box> | ||
<Button onClick={downloadProjectSubmissions} variant="contained">{t("downloadButton")}</Button> | ||
</Box> | ||
) | ||
} |
Oops, something went wrong.