This repository has been archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Project overview #219
Merged
Merged
Project overview #219
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7a55c36
goeie styling yallah
Gerwoud 442a58c
pls werk
Gerwoud b2af653
werkt hopelijk
Gerwoud 931917e
Merge branch 'development' into enhancement/frontend/submission-overv…
Gerwoud 631dbb6
linter
Gerwoud 643bfdf
Merge branch 'development' into enhancement/frontend/submission-overv…
Vucis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recourse -> Resource