Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:SELab-2/UGent-1 into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ReinhardDP committed May 22, 2024
2 parents 4cff058 + b6cadea commit d58d6af
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 31 deletions.
53 changes: 36 additions & 17 deletions frontend/app/[locale]/components/ProjectDetailsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'
import React, { useEffect, useState } from "react";
import {checkGroup, getGroup, getProject, fetchUserData, Project, UserData} from "@lib/api";
import {checkGroup, getGroup, getProject, getUserData, Project, UserData} from "@lib/api";
import { useTranslation } from "react-i18next";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
Expand Down Expand Up @@ -154,22 +154,37 @@ const ProjectDetailsPage: React.FC<ProjectDetailsPageProps> = ({
/>
))) : (
<>
{user?.role !== 3 && (
<Button
variant="contained"
color="secondary"
startIcon={<EditIcon />}
href={`/${locale}/project/${project_id}/edit`}
sx={{
fontSize: "0.75rem",
py: 1,
marginRight: 1,
marginY: 1,
}}
>
{t("edit_project")}
</Button>
)}
{user?.role !== 3 && (
<>
<Button
variant="contained"
color="secondary"
href={`/${locale}/project/${project_id}/submissions`}
sx={{
fontSize: "0.75rem",
py: 1,
marginRight: 1,
marginY: 1,
}}
>
{t("submissions")}
</Button>
<Button
variant="contained"
color="secondary"
startIcon={<EditIcon />}
href={`/${locale}/project/${project_id}/edit`}
sx={{
fontSize: "0.75rem",
py: 1,
marginRight: 1,
marginY: 1,
}}
>
{t("edit_project")}
</Button>
</>
)}
<Button
variant="contained"
color="secondary"
Expand Down Expand Up @@ -287,6 +302,10 @@ const ProjectDetailsPage: React.FC<ProjectDetailsPageProps> = ({

function buildTree(paths) {
const tree = {};
if (!paths) {
return tree;
}

const paths_list = paths.split(',');
paths_list.forEach(path => {
const parts = path.split('/');
Expand Down
10 changes: 5 additions & 5 deletions frontend/app/[locale]/components/SubmissionDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import DownloadIcon from "@mui/icons-material/CloudDownload";

const backend_url = process.env['NEXT_PUBLIC_BACKEND_URL'];

interface ProjectDetailsPageProps {
interface SubmissionDetailsPageProps {
locale: any,
submission_id: number;
}

const ProjectDetailsPage: React.FC<ProjectDetailsPageProps> = ({ locale, submission_id }) => {
const SubmissionDetailsPage: React.FC<SubmissionDetailsPageProps> = ({ locale, submission_id }) => {
const { t } = useTranslation();

const [submission, setSubmission] = useState<Submission>();
Expand Down Expand Up @@ -67,7 +67,7 @@ const ProjectDetailsPage: React.FC<ProjectDetailsPageProps> = ({ locale, submiss
<ThemeProvider theme={baseTheme}>
<Grid container justifyContent="center" alignItems="flex-start" style={{ width: '100%', padding: '20px' }}>
<Grid item xs={12} style={{paddingBottom: '20px'}}>
<ProjectReturnButton locale={locale} project_id={project?.project_id} />
<ProjectReturnButton locale={locale} project_id={projectId} />
</Grid>
<Grid item xs={12}>
<Card raised style={{ width: '100%' }}>
Expand Down Expand Up @@ -107,7 +107,7 @@ const ProjectDetailsPage: React.FC<ProjectDetailsPageProps> = ({ locale, submiss
startIcon={<DownloadIcon />}
href={`${backend_url}/submissions/${submission_id}/download`}
download
size="small" // Adjust button size
size="small"
>
{t("download_file")}
</Button>
Expand All @@ -121,4 +121,4 @@ const ProjectDetailsPage: React.FC<ProjectDetailsPageProps> = ({ locale, submiss
);
};

export default ProjectDetailsPage;
export default SubmissionDetailsPage;
50 changes: 50 additions & 0 deletions frontend/app/[locale]/project/[project_id]/submissions/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import initTranslations from "@app/i18n";
import TranslationsProvider from "@app/[locale]/components/TranslationsProvider";
import NavBar from "@app/[locale]/components/NavBar";
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
import {Box, Button} from "@mui/material";
import React from "react";
import ProjectSubmissionsList from "@app/[locale]/components/ProjectSubmissionsList";
import Typography from "@mui/material/Typography";

const i18nNamespaces = ['common']

export default async function SubmissionsPage({params}: { params: { locale: any, project_id: number } }) {
const {locale, project_id: projectId} = params;
const {t, resources} = await initTranslations(locale, i18nNamespaces);

return (
<TranslationsProvider
resources={resources}
locale={locale}
namespaces={i18nNamespaces}
>
<NavBar/>
<Box width={'100%'} style={{padding: 20}}>
<Button
variant="outlined"
color="primary"
startIcon={<ArrowBackIcon/>}
href={`/${locale}/project/${projectId}`}
>
{t("return_project")}
</Button>
<Typography
variant="h3"
sx={{
fontWeight: 'medium',
marginTop: 2,
marginBottom: 2
}}
>
{t('all_submissions')}
</Typography>
<ProjectSubmissionsList
project_id={projectId}
page_size={10}
search={t("submission_search")}
/>
</Box>
</TranslationsProvider>
);
}
1 change: 1 addition & 0 deletions frontend/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"edit_user_details": "Edit user details",
"status_button_tooltip": "Required, optional or forbidden file",
"no_deadline": "No deadline",
"all_submissions": "All submissions",
"students": "Students",
"teachers": "Teachers",
"courses_archive": "Courses archive",
Expand Down
1 change: 1 addition & 0 deletions frontend/locales/nl/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"edit_user_details": "Gebruiker bewerken",
"status_button_tooltip": "Verplicht, optioneel of verboden bestand",
"no_deadline": "Geen deadline",
"all_submissions": "Alle indieningen",
"students": "Studenten",
"teachers": "Docenten",
"courses_archive": "Gearchiveerde cursussen",
Expand Down
20 changes: 11 additions & 9 deletions scripts/mockdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ def run():
description=lorem_ipsum,
course_id=course_5,
deadline='2021-12-12 12:12:14',
file_structure='+src/*.py,+extra/verslag.pdf',
visible=True,
number_of_groups=1,
group_size=8
Expand Down Expand Up @@ -305,7 +306,8 @@ def run():
deadline='2021-12-12 12:12:14',
visible=True,
number_of_groups=10,
group_size=2
group_size=2,
file_structure='+extra/verslag.pdf,+src/*.py'
)

# Create groups
Expand Down Expand Up @@ -400,55 +402,55 @@ def run():
Submissions.objects.get_or_create(
group_id=group_1,
submission_nr=1,
file_urls=lorem_ipsum_file,
file_urls='src/main.py, extra/verslag.pdf',
timestamp='2021-12-12 12:12:12'
)

Submissions.objects.get_or_create(
group_id=group_1,
submission_nr=2,
file_urls=lorem_ipsum_file,
file_urls='src/main.py, extra/verslag.pdf',
timestamp='2021-12-12 12:12:13'
)

Submissions.objects.get_or_create(
group_id=group_1,
submission_nr=3,
file_urls=lorem_ipsum_file,
file_urls='src/main.py, extra/verslag.pdf',
timestamp='2021-12-12 12:12:15'
)

Submissions.objects.get_or_create(
group_id=group_1,
submission_nr=4,
file_urls=lorem_ipsum_file,
file_urls='src/main.py, extra/verslag.pdf',
timestamp='2021-12-12 12:12:16'
)

Submissions.objects.get_or_create(
group_id=group_2,
submission_nr=1,
file_urls=lorem_ipsum_file,
file_urls='src/main.py, extra/verslag.pdf',
timestamp='2021-12-12 12:12:12'
)

Submissions.objects.get_or_create(
group_id=group_3,
submission_nr=1,
file_urls=lorem_ipsum_file,
file_urls='src/main.py, extra/verslag.pdf',
timestamp='2021-12-12 12:12:13'
)

Submissions.objects.get_or_create(
group_id=group_4,
submission_nr=1,
file_urls=lorem_ipsum_file,
file_urls='src/main.py, extra/verslag.pdf',
timestamp='2021-12-12 12:12:15'
)

Submissions.objects.get_or_create(
group_id=group_5,
submission_nr=1,
file_urls=lorem_ipsum_file,
file_urls='src/main.py, extra/verslag.pdf',
timestamp='2021-12-12 12:12:16'
)

0 comments on commit d58d6af

Please sign in to comment.