feat(frontend): groups in assignments ophalen
This commit is contained in:
parent
45cb020861
commit
d6009ff878
8 changed files with 182 additions and 126 deletions
|
@ -23,28 +23,12 @@ const {t, locale} = useI18n();
|
|||
const role = ref(auth.authState.activeRole);
|
||||
const username = ref<string>("");
|
||||
|
||||
async function submitForm(assignmentTitle: string,
|
||||
selectedLearningPath: string,
|
||||
selectedClass: string,
|
||||
groups: string[][],
|
||||
deadline: string,
|
||||
description: string,
|
||||
currentLanguage: string): Promise<void> {
|
||||
const assignmentDTO: AssignmentDTO = {
|
||||
id: 0,
|
||||
class: selectedClass,
|
||||
title: assignmentTitle,
|
||||
description: description,
|
||||
learningPath: selectedLearningPath,
|
||||
language: currentLanguage,
|
||||
groups: groups,
|
||||
//deadline: deadline,
|
||||
};
|
||||
|
||||
async function submitForm(assignmentDTO: AssignmentDTO): Promise<void> {
|
||||
//TODO: replace with query function
|
||||
const controller: AssignmentController = new AssignmentController(selectedClass);
|
||||
const controller: AssignmentController = new AssignmentController(assignmentDTO.class);
|
||||
await controller.createAssignment(assignmentDTO);
|
||||
|
||||
// Navigate back to all assignments
|
||||
await router.push('/user/assignment');
|
||||
}
|
||||
|
||||
|
@ -79,22 +63,30 @@ const description = ref('');
|
|||
const groups = ref<string[][]>([]);
|
||||
|
||||
// New group is added to the list
|
||||
const addGroupToList = (students: string[]) => {
|
||||
function addGroupToList(students: string[]): void {
|
||||
if (students.length) {
|
||||
groups.value = [...groups.value, students];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
watch(selectedClass, () => {
|
||||
groups.value = [];
|
||||
});
|
||||
|
||||
const submitFormHandler = async () => {
|
||||
async function submitFormHandler(): Promise<void> {
|
||||
const {valid} = await form.value.validate();
|
||||
// Don't submit the form if all rules don't apply
|
||||
if (!valid) return;
|
||||
await submitForm(assignmentTitle.value, selectedLearningPath.value?.hruid, selectedClass.value.id, groups.value, deadline.value, description.value, locale.value);
|
||||
};
|
||||
const assignmentDTO: AssignmentDTO = {
|
||||
id: 0,
|
||||
class: selectedClass.value?.id || "",
|
||||
title: assignmentTitle.value,
|
||||
description: description.value,
|
||||
learningPath: selectedLearningPath.value?.hruid || "",
|
||||
language: language.value
|
||||
}
|
||||
await submitForm(assignmentDTO);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import type {StudentsResponse} from "@/controllers/students.ts";
|
|||
|
||||
const props = defineProps<{
|
||||
classId: string | undefined
|
||||
groups: string[][], // All groups
|
||||
groups: string[][],
|
||||
}>();
|
||||
const emit = defineEmits(['groupCreated']);
|
||||
const {t} = useI18n();
|
||||
|
@ -16,7 +16,6 @@ const selectedStudents = ref([]);
|
|||
|
||||
const studentQueryResult = useClassStudentsQuery(() => props.classId, true);
|
||||
|
||||
|
||||
function filterStudents(data: StudentsResponse): { title: string, value: string }[] {
|
||||
const students = data.students;
|
||||
const studentsInGroups = props.groups.flat();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue