Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix route to submission page + fix teacher submissions page if capacity == 1 #248

Merged
merged 3 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions frontend/src/components/submission/SubmissionTeacherCard.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<template>
<v-card v-if="!isLoading" class="parent-card">
<v-card-title>
<v-card-title v-if="capacity > 1">
{{ $t("project.group", { number: group!.num }) }}
</v-card-title>
<v-card-title v-else>
{{ group.members[0].given_name + " " + group.members[0].surname }}
</v-card-title>
<SubmissionCard class="ma-3" :submission="submission" :deadline="deadline" />
<v-divider class="divider" />
<v-card-actions>
<v-btn :to="`/groups/${submission.group_id}`" class="button">
<v-btn :to="`/submissions/${submission.group_id}`" class="button">
{{ $t("project.submissions_list") }}
</v-btn>
</v-card-actions>
Expand All @@ -22,6 +25,7 @@ import { useGroupQuery } from "@/queries/Group";
const props = defineProps<{
submission: Submission;
deadline: Date;
capacity: Number;
}>();
const { submission } = toRefs(props);

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/submission/SubmitForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async function formOnSubmit(event: SubmitEvent) {

try {
await mutateAsync(formData);
await router.push(`/groups/${group.value?.id}`);
await router.push(`/submissions/${group.value?.id}`);
} catch (error) {
if (error instanceof UnmetRequirementsError) {
unmetRequirements.value = error.unmetRequirements;
Expand Down
1 change: 0 additions & 1 deletion frontend/src/composables/useNavigations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const main_navigations: NavigationData[] = [
{ icon: "mdi-school-outline", title: "navigation.subjects", goto: "subjects" },
{ icon: "mdi-book-check-outline", title: "navigation.projects", goto: "projects" },
{ icon: "mdi-information-outline", title: "navigation.about", goto: "about" },
{ icon: "mdi-cog-outline", title: "navigation.settings", goto: "settings" },
];

const admin_navigations: NavigationData[] = [
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default {
myProject: "My projects",
capacity_group: "Capacity: ",
edit: "Edit project",
submissions_list: "All submissions from this group",
submissions_list: "All submissions from this person/group",
submissions_list_teacher: "All submissions for this project",
submissions_zip: "Download all submissions",
not_found: "No projects found.",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/i18n/locales/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default {
myProject: "Mijn projecten",
capacity_group: "Capaciteit: ",
edit: "Bewerk project",
submissions_list: "Alle indieningen van deze groep",
submissions_list: "Alle indieningen van deze persoon/groep",
submissions_list_teacher: "Alle indieningen voor dit project",
submissions_zip: "Download alle indieningen",
not_found: "Geen projecten teruggevonden.",
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,6 @@ const router = createRouter({
component: () => import("../views/SubjectRegisterView.vue"),
props: (route) => ({ uuid: String(route.params.uuid) }),
},
{
path: "/settings",
name: "settings",
component: () => import("../views/SettingsView.vue"),
},
{
path: "/admin",
name: "admin",
Expand Down Expand Up @@ -205,7 +200,7 @@ router.beforeEach(async (to, from, next) => {
}

let new_next = next;
for (let middleware of middlewares) {
for (const middleware of middlewares) {
const context: MiddlewareContext = { to, from, next: new_next, router };
const { next: returned_next, final } = await middleware(context);
if (final) {
Expand Down
90 changes: 46 additions & 44 deletions frontend/src/views/GroupView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,52 @@
</h1>
<v-row v-else>
<v-col class="col-sm-12 col-md-6 col-lg-8">
<h1>{{ $t("project.group", { number: group!.num }) }}</h1>
<h2>{{ "Project: " + project!.name }}</h2>
<v-card variant="flat">
<v-card-item :title="$t('group.members')">
<div v-if="group!.members.length" class="members">
<v-row
v-for="(member, index) in group!.members"
:key="index"
align="center"
>
<v-col>{{ member.given_name + " " + member.surname }}</v-col>
<v-col>
<v-btn
v-if="isTeacher"
prepend-icon="mdi-close"
color="red"
variant="flat"
@click="
() =>
removeStudent({
groupId: group!.id,
uid: member.uid,
})
"
>
{{ $t("group.remove") }}</v-btn
>
</v-col>
</v-row>
</div>
<div v-else class="members">
{{ $t("group.no_members_found") }}
</div>
</v-card-item>
<v-card-actions>
<GroupButtons
:amountOfMembers="amountOfMembers"
:group="group!"
:project="project!"
:user="user!"
:isTeacher="isTeacher!"
/>
</v-card-actions>
</v-card>
<div v-if="project!.capacity > 1">
<h1>{{ $t("project.group", { number: group!.num }) }}</h1>
<h2>{{ "Project: " + project!.name }}</h2>
<v-card variant="flat">
<v-card-item :title="$t('group.members')">
<div v-if="group!.members.length" class="members">
<v-row
v-for="(member, index) in group!.members"
:key="index"
align="center"
>
<v-col>{{ member.given_name + " " + member.surname }}</v-col>
<v-col>
<v-btn
v-if="isTeacher"
prepend-icon="mdi-close"
color="red"
variant="flat"
@click="
() =>
removeStudent({
groupId: group!.id,
uid: member.uid,
})
"
>
{{ $t("group.remove") }}</v-btn
>
</v-col>
</v-row>
</div>
<div v-else class="members">
{{ $t("group.no_members_found") }}
</div>
</v-card-item>
<v-card-actions>
<GroupButtons
:amountOfMembers="amountOfMembers"
:group="group!"
:project="project!"
:user="user!"
:isTeacher="isTeacher!"
/>
</v-card-actions>
</v-card>
</div>
<v-card variant="outlined" class="submissions">
<SubmissionList :groupId="groupId" />
</v-card>
Expand Down
27 changes: 12 additions & 15 deletions frontend/src/views/ProjectsView.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<template>
<div class="projects">
<TitleContainer :title="$t('project.myProject')" class="titlecontainer">
<v-btn-toggle v-model="activeButton" class="button">
<v-btn value="finished">{{ $t("project.finished") }}</v-btn>
</v-btn-toggle>
</TitleContainer>
<h1 v-if="isLoading">{{ $t("default.loading.loading_page") }}</h1>
<h1 v-else-if="isError || noProjectsFound" class="welcome">
<h1 v-else-if="isError || noProjectsFound" class="projectInfo">
{{ $t("project.not_found") }}
</h1>
<div v-else class="projectInfo">
<TitleContainer :title="$t('project.myProject')">
<v-btn-toggle v-model="activeButton" class="button">
<v-btn value="finished">{{ $t("project.finished") }}</v-btn>
</v-btn-toggle>
</TitleContainer>
<v-divider class="divider" />
<ProjectMiniCard
v-for="project in filteredProjects"
:key="project.id"
Expand All @@ -31,8 +30,6 @@ const { data: projects, isLoading, isError } = useProjectsQuery();
const allProjects = computed(() =>
isLoading.value ? [] : [...projects.value!.as_student, ...projects.value!.as_instructor]
);
const noProjectsFound = computed(() => allProjects.value.length === 0);

const activeButton = ref("notFinished");

const filteredProjects = computed(() => {
Expand All @@ -51,11 +48,15 @@ const filteredProjects = computed(() => {
return sortedProjects.filter((project: Project) => new Date(project.deadline) > now);
}
});

const noProjectsFound = computed(() => filteredProjects.value.length === 0);
</script>

<style scoped>
.project-card {
margin-top: 10px;
.titlecontainer {
margin-top: 40px;
margin-left: 40px;
margin-right: 40px;
}

.projectInfo {
Expand All @@ -72,8 +73,4 @@ const filteredProjects = computed(() => {
.projects {
margin: 15px;
}

.divider {
margin-bottom: 30px;
}
</style>
3 changes: 0 additions & 3 deletions frontend/src/views/SettingsView.vue

This file was deleted.

1 change: 1 addition & 0 deletions frontend/src/views/SubmissionsTeacherView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
:key="submission.id"
:submission="submission"
:deadline="project.deadline"
:capacity="project.capacity"
/>
</v-skeleton-loader>
</v-col>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ describe("DeadlineItem",() => {
deadline: new Date(2024, 10, 15),
id: 1
})
},
global: {
stubs: ['router-link']
}
})
it("render item", () => {
expect(wrapper.text()).toContain("testproject")
expect(wrapper.text()).toContain("testsubject")
expect(wrapper.findComponent({name: "router-link"}).exists()).toBeTruthy()
});
})
19 changes: 6 additions & 13 deletions frontend/tests/components/home/listcontent/SubjectItem.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import {ref} from "vue";

const testSubjectInstructorsQuery = {
data: ref([{given_name: "test", surname: "instructor"}]),
isLoading: ref(true),
setLoading(value){
this.isLoading.value = value
}
isLoading: ref(false),
}

vi.mock("@/queries/Subject", () => ({
Expand All @@ -19,16 +16,12 @@ describe("SubjectItem", () => {
const wrapper = mount(SubjectItem, {
props: {
subject: ref({name: "testsubject"})
},
global: {
stubs: ['router-link']
}
})
it("render if loading", () => {
expect(wrapper.text()).toContain("testsubject")
expect(wrapper.findComponent({name: "VSkeletonLoader"}))
});
it("render subject item", async () => {
testSubjectInstructorsQuery.setLoading(false)
await wrapper.vm.$nextTick()
expect(wrapper.text()).toContain("testsubject")
expect(wrapper.text()).toContain("test instructor")
it("render", () => {
expect(wrapper.findComponent({name: 'router-link'}).exists()).toBeTruthy()
});
})
3 changes: 0 additions & 3 deletions frontend/tests/components/navigation/NavBar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ describe("NavBar", () => {
expect(wrapper.find('[data-test="navigation.home"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test="navigation.subjects"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test="navigation.projects"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test="navigation.settings"]').exists()).toBeTruthy();

expect(wrapper.find('[data-test="navigation.admin"]').exists()).toBeFalsy();
expect(wrapper.find('[data-test="navigation.login"]').exists()).toBeFalsy();
Expand All @@ -65,7 +64,6 @@ describe("NavBar", () => {
expect(wrapper.find('[data-test="navigation.home"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test="navigation.subjects"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test="navigation.projects"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test="navigation.settings"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test="navigation.admin"]').exists()).toBeTruthy();

expect(wrapper.find('[data-test="navigation.login"]').exists()).toBeFalsy();
Expand All @@ -85,7 +83,6 @@ describe("NavBar", () => {
expect(wrapper.find('[data-test="navigation.home"]').exists()).toBeFalsy();
expect(wrapper.find('[data-test="navigation.courses"]').exists()).toBeFalsy();
expect(wrapper.find('[data-test="navigation.projects"]').exists()).toBeFalsy();
expect(wrapper.find('[data-test="navigation.settings"]').exists()).toBeFalsy();
expect(wrapper.find('[data-test="navigation.admin"]').exists()).toBeFalsy();
});
});
27 changes: 26 additions & 1 deletion frontend/tests/components/user/SearchTable.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
import { mount } from "@vue/test-utils";
import {expect, describe, it, vi} from "vitest";
import SearchTable from "@/components/user/SearchTable.vue"
import {ref} from "vue";

const mockRouter = {
push: vi.fn(),
};

vi.mock("vue-router", () => ({
useRouter: () => mockRouter,
}));

const testAuthStore = {
isLoggedIn: ref(true),
setLoggedIn(value) {
this.isLoggedIn.value = value;
},
};

vi.mock("@/stores/auth-store", () => ({
useAuthStore: vi.fn(() => testAuthStore),
}));

describe("SearchTable", async () => {
const ResizeObserverMock = vi.fn(() => ({
Expand All @@ -9,7 +29,12 @@ describe("SearchTable", async () => {
disconnect: vi.fn(),
}));
vi.stubGlobal("ResizeObserver", ResizeObserverMock);
const wrapper = mount(SearchTable, {});
const wrapper = mount(SearchTable, {
props: {
search: "test",
users: []
}
});
it("sorts booleans true first", () => {
const instance = wrapper.vm;
const sortBoolFunction = (instance as any).sortBool;
Expand Down
2 changes: 1 addition & 1 deletion frontend/tests/views/GroupView.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ vi.mock("@/queries/Group", () => ({
}))

const testProjectQuery = {
data: ref({subject_id: 1, name: "testproject"}),
data: ref({subject_id: 1, name: "testproject", capacity: 2}),
isLoading: ref(false),
isError: ref(false)
}
Expand Down
11 changes: 11 additions & 0 deletions frontend/tests/views/GroupsView.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ import {expect, describe, it, vi} from "vitest";
import GroupsView from "@/views/GroupsView.vue"
import {ref} from "vue";

const mockRouter = {
push: vi.fn(),
};

vi.mock("vue-router", () => ({
useRouter: () => mockRouter,
}));

const mockProject = {
name: "testproject"
}
Expand Down Expand Up @@ -95,6 +103,9 @@ describe("GroupsView", () => {
const wrapper = mount(GroupsView, {
props: {
projectId: 1
},
global: {
stubs: ['router-link']
}
});

Expand Down
Loading