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 type { Component } from "vue";
import { computed, onUnmounted } from "vue"; import { computed, onUnmounted } from "vue";
import AssignmentBlock from "./blocks/AssignmentBlock.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 FeedbackBlock from "./blocks/FeedbackBlock.vue";
import IframeBlock from "./blocks/IframeBlock.vue"; import IframeBlock from "./blocks/IframeBlock.vue";
import MediaLibraryBlock from "./blocks/MediaLibraryBlock.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 // can't use the type as component name, as some are reserved HTML components, e.g. video
const COMPONENTS: Record<LearningContentType, Component> = { const COMPONENTS: Record<LearningContentType, Component> = {
"learnpath.LearningContentAssignment": AssignmentBlock, "learnpath.LearningContentAssignment": AssignmentBlock,
"learnpath.LearningContentAttendanceDay": AttendanceDayBlock, "learnpath.LearningContentAttendanceCourse": AttendanceCourseBlock,
"learnpath.LearningContentFeedback": FeedbackBlock, "learnpath.LearningContentFeedback": FeedbackBlock,
"learnpath.LearningContentLearningModule": IframeBlock, "learnpath.LearningContentLearningModule": IframeBlock,
"learnpath.LearningContentMediaLibrary": MediaLibraryBlock, "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"> <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" /> <it-icon-calendar class="w-[60px] grid-in-icon" />
<h2 class="text-large font-bold grid-in-title">Datum</h2> <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>
<div class="mb-12 grid grid-cols-icon-card gap-x-4 grid-areas-icon-card"> <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" /> <it-icon-location class="w-[60px] grid-in-icon" />
<h2 class="text-large font-bold grid-in-title">Standort</h2> <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>
<div class="grid grid-cols-icon-card content-between gap-x-4 grid-areas-icon-card"> <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" /> <it-icon-trainer class="w-[60px] grid-in-icon" />
<h2 class="text-large font-bold grid-in-title">Trainer</h2> <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> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type { CourseSessionAttendanceDay } from "@/types"; import type { CourseSessionAttendanceCourse } from "@/types";
export interface Props { export interface Props {
attendanceDay: CourseSessionAttendanceDay; attendanceCourse: CourseSessionAttendanceCourse;
} }
defineProps<Props>(); defineProps<Props>();
</script> </script>

View File

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

View File

@ -153,7 +153,7 @@
"id": 24, "id": 24,
"title": "Pr\u00e4senztag Fahrzeug", "title": "Pr\u00e4senztag Fahrzeug",
"slug": "test-lehrgang-lp-circle-fahrzeug-lc-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", "translation_key": "2441afae-83ea-4fb5-a938-8db4352ed6c5",
"frontend_url": "/course/test-lehrgang/learn/fahrzeug/pr\u00e4senztag-fahrzeug", "frontend_url": "/course/test-lehrgang/learn/fahrzeug/pr\u00e4senztag-fahrzeug",
"minutes": 15, "minutes": 15,

View File

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

View File

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

View File

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

View File

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

View File

@ -12,8 +12,8 @@ export function learningContentTypeData(
switch (t) { switch (t) {
case "learnpath.LearningContentAssignment": case "learnpath.LearningContentAssignment":
return { title: "Transferauftrag", icon: "it-icon-lc-assignment" }; return { title: "Transferauftrag", icon: "it-icon-lc-assignment" };
case "learnpath.LearningContentAttendanceDay": case "learnpath.LearningContentAttendanceCourse":
return { title: "Präsenztag", icon: "it-icon-lc-training" }; return { title: "Präsenzkurs", icon: "it-icon-lc-training" };
case "learnpath.LearningContentLearningModule": case "learnpath.LearningContentLearningModule":
return { title: "Lernmodul", icon: "it-icon-lc-learning-module" }; return { title: "Lernmodul", icon: "it-icon-lc-learning-module" };
case "learnpath.LearningContentMediaLibrary": 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 ( from vbv_lernwelt.learnpath.tests.learning_path_factories import (
CircleFactory, CircleFactory,
LearningContentAssignmentFactory, LearningContentAssignmentFactory,
LearningContentAttendanceDayFactory, LearningContentAttendanceCourseFactory,
LearningContentFeedbackFactory, LearningContentFeedbackFactory,
LearningContentLearningModuleFactory, LearningContentLearningModuleFactory,
LearningContentMediaLibraryFactory, LearningContentMediaLibraryFactory,
@ -249,9 +249,9 @@ damit du erfolgreich mit deinem Lernpfad (durch-)starten kannst.
title="Unterlagen für den Unterricht", title="Unterlagen für den Unterricht",
parent=circle, parent=circle,
) )
LearningUnitFactory(title="Präsenztag", parent=circle) LearningUnitFactory(title="Präsenzkurs", parent=circle)
LearningContentAttendanceDayFactory( LearningContentAttendanceCourseFactory(
title="Präsenztag Fahrzeug", title="Präsenzkurs Fahrzeug",
parent=circle, parent=circle,
) )
LearningUnitFactory(title="Kompetenznachweis", parent=circle) LearningUnitFactory(title="Kompetenznachweis", parent=circle)

View File

@ -39,7 +39,7 @@ from vbv_lernwelt.learnpath.models import (
Circle, Circle,
LearningContent, LearningContent,
LearningContentAssignment, LearningContentAssignment,
LearningContentAttendanceDay, LearningContentAttendanceCourse,
) )
from vbv_lernwelt.media_library.create_default_media_library import ( from vbv_lernwelt.media_library.create_default_media_library import (
create_default_media_library, create_default_media_library,
@ -156,14 +156,13 @@ def create_course_uk_de():
cs = CourseSession.objects.create( cs = CourseSession.objects.create(
course_id=COURSE_UK, course_id=COURSE_UK,
title="Bern 2023 a", title="Bern 2023 a",
attendance_days=[ attendance_courses=[
{ {
"learningContentId": LearningContentAttendanceDay.objects.get( "learningContentId": LearningContentAttendanceCourse.objects.get(
slug="überbetriebliche-kurse-lp-circle-fahrzeug-lc-präsenztag-fahrzeug" slug="überbetriebliche-kurse-lp-circle-fahrzeug-lc-präsenzkurs-fahrzeug"
).id, ).id,
"date": "2023-09-18", "start": "2022-05-23T13:07:23+0000",
"startTime": "08:15", "end": "2022-05-23T20:07:23+0000",
"endTime": "17:00",
"location": "Handelsschule KV Bern, Zimmer 123, Eigerstrasse 16, 3012 Bern", "location": "Handelsschule KV Bern, Zimmer 123, Eigerstrasse 16, 3012 Bern",
"trainer": "Roland Grossenbacher, roland.grossenbacher@helvetia.ch", "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 ( from vbv_lernwelt.learnpath.tests.learning_path_factories import (
CircleFactory, CircleFactory,
LearningContentAssignmentFactory, LearningContentAssignmentFactory,
LearningContentAttendanceDayFactory, LearningContentAttendanceCourseFactory,
LearningContentFeedbackFactory, LearningContentFeedbackFactory,
LearningContentMediaLibraryFactory, LearningContentMediaLibraryFactory,
LearningContentPlaceholderFactory, LearningContentPlaceholderFactory,
@ -253,9 +253,9 @@ damit du erfolgreich mit deinem Lernpfad (durch-)starten kannst.
title="Unterlagen für den Unterricht", title="Unterlagen für den Unterricht",
parent=circle, parent=circle,
) )
LearningUnitFactory(title="Präsenztag", parent=circle) LearningUnitFactory(title="Präsenzkurs", parent=circle)
LearningContentAttendanceDayFactory( LearningContentAttendanceCourseFactory(
title="Präsenztag Fahrzeug", title="Präsenzkurs Fahrzeug",
parent=circle, parent=circle,
) )
LearningUnitFactory(title="Kompetenznachweis", 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 Das anhängen kann via CourseSessionUser oder "Schulklasse (TODO)" geschehen
""" """
ATTENDANCE_DAYS_SCHEMA = { ATTENDANCE_COURSES_SCHEMA = {
"type": "array", "type": "array",
"items": { "items": {
"type": "object", "type": "object",
@ -216,7 +216,9 @@ class CourseSession(models.Model):
start_date = models.DateField(null=True, blank=True) start_date = models.DateField(null=True, blank=True)
end_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) 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)

View File

@ -82,7 +82,7 @@ class CourseSessionSerializer(serializers.ModelSerializer):
"start_date", "start_date",
"end_date", "end_date",
"additional_json_data", "additional_json_data",
"attendance_days", "attendance_courses",
"assignment_details_list", "assignment_details_list",
"learning_path_url", "learning_path_url",
"competence_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.LearningSequence",
"learnpath.LearningUnit", "learnpath.LearningUnit",
"learnpath.LearningContentAssignment", "learnpath.LearningContentAssignment",
"learnpath.LearningContentAttendanceDay", "learnpath.LearningContentAttendanceCourse",
"learnpath.LearningContentFeedback", "learnpath.LearningContentFeedback",
"learnpath.LearningContentLearningModule", "learnpath.LearningContentLearningModule",
"learnpath.LearningContentMediaLibrary", "learnpath.LearningContentMediaLibrary",
@ -271,7 +271,7 @@ class LearningContent(CourseBasePage):
super().save(**kwargs) super().save(**kwargs)
class LearningContentAttendanceDay(LearningContent): class LearningContentAttendanceCourse(LearningContent):
parent_page_types = ["learnpath.Circle"] parent_page_types = ["learnpath.Circle"]
subpage_types = [] subpage_types = []

View File

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