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">
|
<script setup lang="ts">
|
||||||
import { useAssignmentStore } from "@/stores/assignmentStore";
|
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 * as log from "loglevel";
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, reactive } from "vue";
|
||||||
|
|
||||||
const assignmentStore = useAssignmentStore();
|
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<{
|
const props = defineProps<{
|
||||||
assignmentId: number;
|
assignmentId: number;
|
||||||
|
|
@ -31,10 +29,36 @@ const props = defineProps<{
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
log.debug("AssignmentView mounted", props.assignmentId, props.learningContent);
|
log.debug("AssignmentView mounted", props.assignmentId, props.learningContent);
|
||||||
|
|
||||||
|
const courseSessionsStore = useCourseSessionsStore();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assignment.value = await assignmentStore.loadAssignment(props.assignmentId);
|
state.assignment = await assignmentStore.loadAssignment(props.assignmentId);
|
||||||
|
state.courseSessionAssignmentDetails = courseSessionsStore.findAssignmentDetails(
|
||||||
|
props.learningContent.id
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</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 {
|
import type {
|
||||||
CircleDocument,
|
CircleDocument,
|
||||||
CourseSession,
|
CourseSession,
|
||||||
|
CourseSessionAssignmentDetails,
|
||||||
CourseSessionAttendanceDay,
|
CourseSessionAttendanceDay,
|
||||||
CourseSessionUser,
|
CourseSessionUser,
|
||||||
ExpertSessionUser,
|
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 {
|
return {
|
||||||
uniqueCourseSessionsByCourse,
|
uniqueCourseSessionsByCourse,
|
||||||
currentCourseSession,
|
currentCourseSession,
|
||||||
|
|
@ -238,6 +249,7 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
||||||
startUpload,
|
startUpload,
|
||||||
removeDocument,
|
removeDocument,
|
||||||
findAttendanceDay,
|
findAttendanceDay,
|
||||||
|
findAssignmentDetails,
|
||||||
|
|
||||||
// TODO: only used to be changed by router.afterEach
|
// TODO: only used to be changed by router.afterEach
|
||||||
currentCourseSlug,
|
currentCourseSlug,
|
||||||
|
|
|
||||||
|
|
@ -405,6 +405,11 @@ export interface CourseSessionAttendanceDay {
|
||||||
trainer: string;
|
trainer: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CourseSessionAssignmentDetails {
|
||||||
|
learningContentId: number;
|
||||||
|
deadlineDateTimeUtc: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface CourseSession {
|
export interface CourseSession {
|
||||||
id: number;
|
id: number;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
|
|
@ -418,6 +423,7 @@ export interface CourseSession {
|
||||||
course_url: string;
|
course_url: string;
|
||||||
media_library_url: string;
|
media_library_url: string;
|
||||||
attendance_days: CourseSessionAttendanceDay[];
|
attendance_days: CourseSessionAttendanceDay[];
|
||||||
|
assignment_details_list: CourseSessionAssignmentDetails[];
|
||||||
documents: CircleDocument[];
|
documents: CircleDocument[];
|
||||||
users: CourseSessionUser[];
|
users: CourseSessionUser[];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,14 @@ def create_course_uk_de():
|
||||||
"trainer": "Roland Grossenbacher, roland.grossenbacher@helvetia.ch",
|
"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
|
# 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.consts import COURSE_UK, COURSE_UK_FR
|
||||||
from vbv_lernwelt.course.models import CoursePage
|
from vbv_lernwelt.course.models import CoursePage
|
||||||
from vbv_lernwelt.learnpath.tests.learning_path_factories import (
|
from vbv_lernwelt.learnpath.tests.learning_path_factories import (
|
||||||
|
AssignmentBlockFactory,
|
||||||
AttendanceDayBlockFactory,
|
AttendanceDayBlockFactory,
|
||||||
CircleFactory,
|
CircleFactory,
|
||||||
FeedbackBlockFactory,
|
FeedbackBlockFactory,
|
||||||
|
|
@ -19,7 +20,6 @@ from vbv_lernwelt.learnpath.tests.learning_path_factories import (
|
||||||
LearningUnitFactory,
|
LearningUnitFactory,
|
||||||
MediaLibraryBlockFactory,
|
MediaLibraryBlockFactory,
|
||||||
TopicFactory,
|
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)
|
end_date = models.DateField(null=True, blank=True)
|
||||||
|
|
||||||
attendance_days = models.JSONField(default=list, 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)
|
additional_json_data = models.JSONField(default=dict, blank=True)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,7 @@ class CourseSessionSerializer(serializers.ModelSerializer):
|
||||||
"end_date",
|
"end_date",
|
||||||
"additional_json_data",
|
"additional_json_data",
|
||||||
"attendance_days",
|
"attendance_days",
|
||||||
|
"assignment_details_list",
|
||||||
"learning_path_url",
|
"learning_path_url",
|
||||||
"competence_url",
|
"competence_url",
|
||||||
"media_library_url",
|
"media_library_url",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue