Link courseSessionAssignmentDetails to AssignmentView
This commit is contained in:
parent
d92b324f8e
commit
80cd70ace6
|
|
@ -1,27 +1,25 @@
|
|||
<template>
|
||||
<div class="container-medium">
|
||||
<div v-if="assignment" class="lg:mt-12">
|
||||
<h2>Einleitung</h2>
|
||||
|
||||
<h3 class="mt-8">Ausgangslage</h3>
|
||||
<p>{{ assignment.starting_position }}</p>
|
||||
|
||||
<pre class="mt-16">
|
||||
{{ assignment }}
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useAssignmentStore } from "@/stores/assignmentStore";
|
||||
import type { Assignment, LearningContent } from "@/types";
|
||||
import { useCourseSessionsStore } from "@/stores/courseSessions";
|
||||
import type {
|
||||
Assignment,
|
||||
CourseSessionAssignmentDetails,
|
||||
LearningContent,
|
||||
} from "@/types";
|
||||
import * as log from "loglevel";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { onMounted, reactive } from "vue";
|
||||
|
||||
const assignmentStore = useAssignmentStore();
|
||||
|
||||
const assignment = ref<Assignment>();
|
||||
interface State {
|
||||
assignment: Assignment | undefined;
|
||||
courseSessionAssignmentDetails: CourseSessionAssignmentDetails | undefined;
|
||||
}
|
||||
|
||||
const state: State = reactive({
|
||||
assignment: undefined,
|
||||
courseSessionAssignmentDetails: undefined,
|
||||
});
|
||||
|
||||
const props = defineProps<{
|
||||
assignmentId: number;
|
||||
|
|
@ -31,10 +29,36 @@ const props = defineProps<{
|
|||
onMounted(async () => {
|
||||
log.debug("AssignmentView mounted", props.assignmentId, props.learningContent);
|
||||
|
||||
const courseSessionsStore = useCourseSessionsStore();
|
||||
|
||||
try {
|
||||
assignment.value = await assignmentStore.loadAssignment(props.assignmentId);
|
||||
state.assignment = await assignmentStore.loadAssignment(props.assignmentId);
|
||||
state.courseSessionAssignmentDetails = courseSessionsStore.findAssignmentDetails(
|
||||
props.learningContent.id
|
||||
);
|
||||
} catch (error) {
|
||||
log.error(error);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="container-medium">
|
||||
<div v-if="state.assignment" class="lg:mt-12">
|
||||
<h2>Einleitung</h2>
|
||||
|
||||
<h3 class="mt-8">Ausgangslage</h3>
|
||||
<p>{{ state.assignment.starting_position }}</p>
|
||||
|
||||
<h3 class="mt-8">Abgabetermin</h3>
|
||||
<p v-if="state.courseSessionAssignmentDetails">
|
||||
{{ state.courseSessionAssignmentDetails }}
|
||||
</p>
|
||||
<p v-else>Keine Abgabedaten erfasst für diese Durchführung</p>
|
||||
|
||||
<pre class="mt-16">
|
||||
{{ state.assignment }}
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { deleteCircleDocument } from "@/services/files";
|
|||
import type {
|
||||
CircleDocument,
|
||||
CourseSession,
|
||||
CourseSessionAssignmentDetails,
|
||||
CourseSessionAttendanceDay,
|
||||
CourseSessionUser,
|
||||
ExpertSessionUser,
|
||||
|
|
@ -224,6 +225,16 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
|||
}
|
||||
}
|
||||
|
||||
function findAssignmentDetails(
|
||||
contentId: number
|
||||
): CourseSessionAssignmentDetails | undefined {
|
||||
if (currentCourseSession.value) {
|
||||
return currentCourseSession.value.assignment_details_list.find(
|
||||
(assignmentDetails) => assignmentDetails.learningContentId === contentId
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
uniqueCourseSessionsByCourse,
|
||||
currentCourseSession,
|
||||
|
|
@ -238,6 +249,7 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
|||
startUpload,
|
||||
removeDocument,
|
||||
findAttendanceDay,
|
||||
findAssignmentDetails,
|
||||
|
||||
// TODO: only used to be changed by router.afterEach
|
||||
currentCourseSlug,
|
||||
|
|
|
|||
|
|
@ -405,6 +405,11 @@ export interface CourseSessionAttendanceDay {
|
|||
trainer: string;
|
||||
}
|
||||
|
||||
export interface CourseSessionAssignmentDetails {
|
||||
learningContentId: number;
|
||||
deadlineDateTimeUtc: string;
|
||||
}
|
||||
|
||||
export interface CourseSession {
|
||||
id: number;
|
||||
created_at: string;
|
||||
|
|
@ -418,6 +423,7 @@ export interface CourseSession {
|
|||
course_url: string;
|
||||
media_library_url: string;
|
||||
attendance_days: CourseSessionAttendanceDay[];
|
||||
assignment_details_list: CourseSessionAssignmentDetails[];
|
||||
documents: CircleDocument[];
|
||||
users: CourseSessionUser[];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,6 +158,14 @@ def create_course_uk_de():
|
|||
"trainer": "Roland Grossenbacher, roland.grossenbacher@helvetia.ch",
|
||||
}
|
||||
],
|
||||
assignment_details_list=[
|
||||
{
|
||||
"learningContentId": LearningContent.objects.get(
|
||||
slug="überbetriebliche-kurse-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice"
|
||||
).id,
|
||||
"deadlineDateTimeUtc": "2023-05-30T19:00:00Z",
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
# figma demo users and data
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ from vbv_lernwelt.core.admin import User
|
|||
from vbv_lernwelt.course.consts import COURSE_UK, COURSE_UK_FR
|
||||
from vbv_lernwelt.course.models import CoursePage
|
||||
from vbv_lernwelt.learnpath.tests.learning_path_factories import (
|
||||
AssignmentBlockFactory,
|
||||
AttendanceDayBlockFactory,
|
||||
CircleFactory,
|
||||
FeedbackBlockFactory,
|
||||
|
|
@ -19,7 +20,6 @@ from vbv_lernwelt.learnpath.tests.learning_path_factories import (
|
|||
LearningUnitFactory,
|
||||
MediaLibraryBlockFactory,
|
||||
TopicFactory,
|
||||
AssignmentBlockFactory,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.13 on 2023-04-06 09:19
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("course", "0003_auto_20230404_0837"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="coursesession",
|
||||
name="assignment_details_list",
|
||||
field=models.JSONField(blank=True, default=list),
|
||||
),
|
||||
]
|
||||
|
|
@ -186,6 +186,7 @@ class CourseSession(models.Model):
|
|||
end_date = models.DateField(null=True, blank=True)
|
||||
|
||||
attendance_days = models.JSONField(default=list, blank=True)
|
||||
assignment_details_list = models.JSONField(default=list, blank=True)
|
||||
|
||||
additional_json_data = models.JSONField(default=dict, blank=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ class CourseSessionSerializer(serializers.ModelSerializer):
|
|||
"end_date",
|
||||
"additional_json_data",
|
||||
"attendance_days",
|
||||
"assignment_details_list",
|
||||
"learning_path_url",
|
||||
"competence_url",
|
||||
"media_library_url",
|
||||
|
|
|
|||
Loading…
Reference in New Issue