Rename attendance days to attendance courses

This commit is contained in:
Elia Bieri 2023-05-23 14:50:07 +02:00
parent 7112a0e638
commit 132c115e8b
18 changed files with 532 additions and 489 deletions

View File

@ -7,7 +7,7 @@ import log from "loglevel";
import type { Component } from "vue";
import { computed, onUnmounted } from "vue";
import AssignmentBlock from "./blocks/AssignmentBlock.vue";
import AttendanceDayBlock from "./blocks/AttendanceDayBlock.vue";
import AttendanceCourseBlock from "./blocks/AttendanceCourseBlock.vue";
import FeedbackBlock from "./blocks/FeedbackBlock.vue";
import IframeBlock from "./blocks/IframeBlock.vue";
import MediaLibraryBlock from "./blocks/MediaLibraryBlock.vue";
@ -26,7 +26,7 @@ log.debug("LearningContentParent setup", props.learningContent);
// can't use the type as component name, as some are reserved HTML components, e.g. video
const COMPONENTS: Record<LearningContentType, Component> = {
"learnpath.LearningContentAssignment": AssignmentBlock,
"learnpath.LearningContentAttendanceDay": AttendanceDayBlock,
"learnpath.LearningContentAttendanceCourse": AttendanceCourseBlock,
"learnpath.LearningContentFeedback": FeedbackBlock,
"learnpath.LearningContentLearningModule": IframeBlock,
"learnpath.LearningContentMediaLibrary": MediaLibraryBlock,

View File

@ -2,25 +2,26 @@
<div class="mb-12 grid grid-cols-icon-card gap-x-4 grid-areas-icon-card">
<it-icon-calendar class="w-[60px] grid-in-icon" />
<h2 class="text-large font-bold grid-in-title">Datum</h2>
<p class="grid-in-value">{{ attendanceDay.date }}</p>
<p class="grid-in-value">{{ attendanceCourse.date }}</p>
</div>
<div class="mb-12 grid grid-cols-icon-card gap-x-4 grid-areas-icon-card">
<it-icon-location class="w-[60px] grid-in-icon" />
<h2 class="text-large font-bold grid-in-title">Standort</h2>
<p class="grid-in-value">{{ attendanceDay.location }}</p>
<p class="grid-in-value">{{ attendanceCourse.location }}</p>
</div>
<div class="grid grid-cols-icon-card content-between gap-x-4 grid-areas-icon-card">
<it-icon-trainer class="w-[60px] grid-in-icon" />
<h2 class="text-large font-bold grid-in-title">Trainer</h2>
<p class="grid-in-value">{{ attendanceDay.trainer }}</p>
<p class="grid-in-value">{{ attendanceCourse.trainer }}</p>
</div>
</template>
<script setup lang="ts">
import type { CourseSessionAttendanceDay } from "@/types";
import type { CourseSessionAttendanceCourse } from "@/types";
export interface Props {
attendanceDay: CourseSessionAttendanceDay;
attendanceCourse: CourseSessionAttendanceCourse;
}
defineProps<Props>();
</script>

View File

@ -1,18 +1,18 @@
<script setup lang="ts">
import AttendanceDay from "@/pages/learningPath/learningContentPage/attendanceDay/AttendanceDay.vue";
import AttendanceCourse from "@/pages/learningPath/learningContentPage/attendanceCourse/AttendanceCourse.vue";
import { useCourseSessionsStore } from "@/stores/courseSessions";
import type { LearningContentAttendanceDay } from "@/types";
import type { LearningContentAttendanceCourse } from "@/types";
import { computed } from "vue";
import LearningContentSimpleLayout from "../layouts/LearningContentSimpleLayout.vue";
const courseSessionsStore = useCourseSessionsStore();
const props = defineProps<{
content: LearningContentAttendanceDay;
content: LearningContentAttendanceCourse;
}>();
const courseSessionAttendanceDay = computed(() => {
return courseSessionsStore.findAttendanceDay(props.content.id);
const courseSessionAttendanceCourse = computed(() => {
return courseSessionsStore.findAttendanceCourse(props.content.id);
});
</script>
@ -24,8 +24,8 @@ const courseSessionAttendanceDay = computed(() => {
<div class="container-medium">
<div class="lg:mt-8">
<div class="text-large my-4">
<div v-if="courseSessionAttendanceDay">
<AttendanceDay :attendance-day="courseSessionAttendanceDay" />
<div v-if="courseSessionAttendanceCourse">
<AttendanceCourse :attendance-course="courseSessionAttendanceCourse" />
</div>
<div v-else>
Für diese Durchführung {{ content.id }} existieren noch keine Details

View File

@ -153,7 +153,7 @@
"id": 24,
"title": "Pr\u00e4senztag Fahrzeug",
"slug": "test-lehrgang-lp-circle-fahrzeug-lc-pr\u00e4senztag-fahrzeug",
"content_type": "learnpath.LearningContentAttendanceDay",
"content_type": "learnpath.LearningContentAttendanceCourse",
"translation_key": "2441afae-83ea-4fb5-a938-8db4352ed6c5",
"frontend_url": "/course/test-lehrgang/learn/fahrzeug/pr\u00e4senztag-fahrzeug",
"minutes": 15,

View File

@ -18,7 +18,7 @@ import values from "lodash/values";
function isLearningContentType(object: any): object is LearningContent {
return (
object?.content_type === "learnpath.LearningContentAssignment" ||
object?.content_type === "learnpath.LearningContentAttendanceDay" ||
object?.content_type === "learnpath.LearningContentAttendanceCourse" ||
object?.content_type === "learnpath.LearningContentFeedback" ||
object?.content_type === "learnpath.LearningContentLearningModule" ||
object?.content_type === "learnpath.LearningContentMediaLibrary" ||

View File

@ -51,7 +51,7 @@ describe("CourseSession Store", () => {
competence_url: "/course/test-course/competence/",
course_url: "/course/test-course/",
media_library_url: "/course/test-course/media/",
attendance_days: [],
attendance_courses: [],
additional_json_data: {},
documents: [],
},

View File

@ -4,7 +4,7 @@ import type {
CircleDocument,
CourseSession,
CourseSessionAssignmentDetails,
CourseSessionAttendanceDay,
CourseSessionAttendanceCourse,
CourseSessionUser,
ExpertSessionUser,
} from "@/types";
@ -206,12 +206,12 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
);
}
function findAttendanceDay(
function findAttendanceCourse(
contentId: number
): CourseSessionAttendanceDay | undefined {
): CourseSessionAttendanceCourse | undefined {
if (currentCourseSession.value) {
return currentCourseSession.value.attendance_days.find(
(attendanceDay) => attendanceDay.learningContentId === contentId
return currentCourseSession.value.attendance_courses.find(
(attendanceCourse) => attendanceCourse.learningContentId === contentId
);
}
}
@ -238,7 +238,7 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
addDocument,
startUpload,
removeDocument,
findAttendanceDay,
findAttendanceCourse,
findAssignmentDetails,
// use `useCurrentCourseSession` whenever possible

View File

@ -22,7 +22,7 @@ export interface CircleLight {
export type LearningContent =
| LearningContentAssignment
| LearningContentAttendanceDay
| LearningContentAttendanceCourse
| LearningContentFeedback
| LearningContentLearningModule
| LearningContentMediaLibrary
@ -50,8 +50,8 @@ export interface LearningContentAssignment extends LearningContentInterface {
readonly content_assignment_id: number;
}
export interface LearningContentAttendanceDay extends LearningContentInterface {
readonly content_type: "learnpath.LearningContentAttendanceDay";
export interface LearningContentAttendanceCourse extends LearningContentInterface {
readonly content_type: "learnpath.LearningContentAttendanceCourse";
}
export interface LearningContentFeedback extends LearningContentInterface {
@ -391,7 +391,7 @@ export interface CircleDocument {
}
// TODO refactor, when a user can manually create these days
export interface CourseSessionAttendanceDay {
export interface CourseSessionAttendanceCourse {
learningContentId: number;
date: string;
startTime: string;
@ -418,7 +418,7 @@ export interface CourseSession {
competence_url: string;
course_url: string;
media_library_url: string;
attendance_days: CourseSessionAttendanceDay[];
attendance_courses: CourseSessionAttendanceCourse[];
assignment_details_list: CourseSessionAssignmentDetails[];
documents: CircleDocument[];
users: CourseSessionUser[];

View File

@ -12,8 +12,8 @@ export function learningContentTypeData(
switch (t) {
case "learnpath.LearningContentAssignment":
return { title: "Transferauftrag", icon: "it-icon-lc-assignment" };
case "learnpath.LearningContentAttendanceDay":
return { title: "Präsenztag", icon: "it-icon-lc-training" };
case "learnpath.LearningContentAttendanceCourse":
return { title: "Präsenzkurs", icon: "it-icon-lc-training" };
case "learnpath.LearningContentLearningModule":
return { title: "Lernmodul", icon: "it-icon-lc-learning-module" };
case "learnpath.LearningContentMediaLibrary":

View File

@ -34,7 +34,7 @@ from vbv_lernwelt.learnpath.models import Circle
from vbv_lernwelt.learnpath.tests.learning_path_factories import (
CircleFactory,
LearningContentAssignmentFactory,
LearningContentAttendanceDayFactory,
LearningContentAttendanceCourseFactory,
LearningContentFeedbackFactory,
LearningContentLearningModuleFactory,
LearningContentMediaLibraryFactory,
@ -249,9 +249,9 @@ damit du erfolgreich mit deinem Lernpfad (durch-)starten kannst.
title="Unterlagen für den Unterricht",
parent=circle,
)
LearningUnitFactory(title="Präsenztag", parent=circle)
LearningContentAttendanceDayFactory(
title="Präsenztag Fahrzeug",
LearningUnitFactory(title="Präsenzkurs", parent=circle)
LearningContentAttendanceCourseFactory(
title="Präsenzkurs Fahrzeug",
parent=circle,
)
LearningUnitFactory(title="Kompetenznachweis", parent=circle)

View File

@ -39,7 +39,7 @@ from vbv_lernwelt.learnpath.models import (
Circle,
LearningContent,
LearningContentAssignment,
LearningContentAttendanceDay,
LearningContentAttendanceCourse,
)
from vbv_lernwelt.media_library.create_default_media_library import (
create_default_media_library,
@ -156,14 +156,13 @@ def create_course_uk_de():
cs = CourseSession.objects.create(
course_id=COURSE_UK,
title="Bern 2023 a",
attendance_days=[
attendance_courses=[
{
"learningContentId": LearningContentAttendanceDay.objects.get(
slug="überbetriebliche-kurse-lp-circle-fahrzeug-lc-präsenztag-fahrzeug"
"learningContentId": LearningContentAttendanceCourse.objects.get(
slug="überbetriebliche-kurse-lp-circle-fahrzeug-lc-präsenzkurs-fahrzeug"
).id,
"date": "2023-09-18",
"startTime": "08:15",
"endTime": "17:00",
"start": "2022-05-23T13:07:23+0000",
"end": "2022-05-23T20:07:23+0000",
"location": "Handelsschule KV Bern, Zimmer 123, Eigerstrasse 16, 3012 Bern",
"trainer": "Roland Grossenbacher, roland.grossenbacher@helvetia.ch",
}

View File

@ -13,7 +13,7 @@ from vbv_lernwelt.course.models import CoursePage
from vbv_lernwelt.learnpath.tests.learning_path_factories import (
CircleFactory,
LearningContentAssignmentFactory,
LearningContentAttendanceDayFactory,
LearningContentAttendanceCourseFactory,
LearningContentFeedbackFactory,
LearningContentMediaLibraryFactory,
LearningContentPlaceholderFactory,
@ -253,9 +253,9 @@ damit du erfolgreich mit deinem Lernpfad (durch-)starten kannst.
title="Unterlagen für den Unterricht",
parent=circle,
)
LearningUnitFactory(title="Präsenztag", parent=circle)
LearningContentAttendanceDayFactory(
title="Präsenztag Fahrzeug",
LearningUnitFactory(title="Präsenzkurs", parent=circle)
LearningContentAttendanceCourseFactory(
title="Präsenzkurs Fahrzeug",
parent=circle,
)
LearningUnitFactory(title="Kompetenznachweis", parent=circle)

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.13 on 2023-05-23 12:49
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('course', '0002_initial'),
]
operations = [
migrations.RenameField(
model_name='coursesession',
old_name='attendance_days',
new_name='attendance_courses',
),
]

View File

@ -190,7 +190,7 @@ class CourseSession(models.Model):
Das anhängen kann via CourseSessionUser oder "Schulklasse (TODO)" geschehen
"""
ATTENDANCE_DAYS_SCHEMA = {
ATTENDANCE_COURSES_SCHEMA = {
"type": "array",
"items": {
"type": "object",
@ -216,7 +216,9 @@ class CourseSession(models.Model):
start_date = models.DateField(null=True, blank=True)
end_date = models.DateField(null=True, blank=True)
attendance_days = JSONField(schema=ATTENDANCE_DAYS_SCHEMA, blank=True, default=list)
attendance_courses = JSONField(
schema=ATTENDANCE_COURSES_SCHEMA, blank=True, default=list
)
assignment_details_list = models.JSONField(default=list, blank=True)
additional_json_data = models.JSONField(default=dict, blank=True)

View File

@ -82,7 +82,7 @@ class CourseSessionSerializer(serializers.ModelSerializer):
"start_date",
"end_date",
"additional_json_data",
"attendance_days",
"attendance_courses",
"assignment_details_list",
"learning_path_url",
"competence_url",

View File

@ -0,0 +1,23 @@
# Generated by Django 3.2.13 on 2023-05-23 12:49
from django.conf import settings
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('wagtailcore', '0083_workflowcontenttype'),
('wagtailforms', '0005_alter_formsubmission_form_data'),
('wagtailredirects', '0008_add_verbose_name_plural'),
('contenttypes', '0002_remove_content_type_name'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('learnpath', '0002_learningcontentrichtext_text'),
]
operations = [
migrations.RenameModel(
old_name='LearningContentAttendanceDay',
new_name='LearningContentAttendanceCourse',
),
]

View File

@ -66,7 +66,7 @@ class Circle(CourseBasePage):
"learnpath.LearningSequence",
"learnpath.LearningUnit",
"learnpath.LearningContentAssignment",
"learnpath.LearningContentAttendanceDay",
"learnpath.LearningContentAttendanceCourse",
"learnpath.LearningContentFeedback",
"learnpath.LearningContentLearningModule",
"learnpath.LearningContentMediaLibrary",
@ -271,7 +271,7 @@ class LearningContent(CourseBasePage):
super().save(**kwargs)
class LearningContentAttendanceDay(LearningContent):
class LearningContentAttendanceCourse(LearningContent):
parent_page_types = ["learnpath.Circle"]
subpage_types = []

View File

@ -4,7 +4,7 @@ from wagtail.rich_text import RichText
from vbv_lernwelt.learnpath.models import (
Circle,
LearningContentAssignment,
LearningContentAttendanceDay,
LearningContentAttendanceCourse,
LearningContentFeedback,
LearningContentLearningModule,
LearningContentMediaLibrary,
@ -84,14 +84,14 @@ class LearningUnitFactory(wagtail_factories.PageFactory):
model = LearningUnit
class LearningContentAttendanceDayFactory(wagtail_factories.PageFactory):
class LearningContentAttendanceCourseFactory(wagtail_factories.PageFactory):
title = "Platzhalter Inhalt"
minutes = 15
description = RichText("Platzhalter Beschreibung")
content_url = ""
class Meta:
model = LearningContentAttendanceDay
model = LearningContentAttendanceCourse
class LearningContentVideoFactory(wagtail_factories.PageFactory):