VBV-304: Add `AssignmentDayBlock`

This commit is contained in:
Daniel Egger 2023-04-03 18:09:22 +02:00
parent e17817b166
commit 1437bc9b53
9 changed files with 88 additions and 3 deletions

View File

@ -3,8 +3,10 @@ import LearningContentContainer from "@/pages/learningPath/learningContentPage/L
import { useCircleStore } from "@/stores/circle"; import { useCircleStore } from "@/stores/circle";
import type { LearningContent, LearningContentType } from "@/types"; import type { LearningContent, LearningContentType } from "@/types";
import log from "loglevel"; import log from "loglevel";
import type { Component } from "vue";
import { computed } from "vue"; import { computed } from "vue";
import AttendanceDayBlock from "@/pages/learningPath/learningContentPage/blocks/AttendanceDayBlock.vue";
import DescriptionBlock from "./blocks/DescriptionBlock.vue"; import DescriptionBlock from "./blocks/DescriptionBlock.vue";
import DescriptionTextBlock from "./blocks/DescriptionTextBlock.vue"; import DescriptionTextBlock from "./blocks/DescriptionTextBlock.vue";
import FeedbackBlock from "./blocks/FeedbackBlock.vue"; import FeedbackBlock from "./blocks/FeedbackBlock.vue";
@ -30,8 +32,7 @@ const block = computed(() => {
}); });
// 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, any> = { const COMPONENTS: Record<LearningContentType, Component> = {
// todo: can we find a better type here than any? ^
placeholder: PlaceholderBlock, placeholder: PlaceholderBlock,
video: VideoBlock, video: VideoBlock,
assignment: DescriptionTextBlock, assignment: DescriptionTextBlock,
@ -44,6 +45,7 @@ const COMPONENTS: Record<LearningContentType, any> = {
document: DescriptionBlock, document: DescriptionBlock,
media_library: MediaLibraryBlock, media_library: MediaLibraryBlock,
online_training: DescriptionBlock, online_training: DescriptionBlock,
attendance_day: AttendanceDayBlock,
}; };
const DEFAULT_BLOCK = DescriptionBlock; const DEFAULT_BLOCK = DescriptionBlock;

View File

@ -0,0 +1,27 @@
<template>
<div class="container-medium">
<div class="lg:mt-8">
<p class="text-large my-4">
<pre>
{{ content.contents }}
{{ content.translation_key }}
{{ content.title }}
{{ content.slug }}
</pre>
</p>
</div>
</div>
</template>
<script setup lang="ts">
import type { LearningContent } from "@/types";
interface Value {
description: string;
}
defineProps<{
value: Value;
content: LearningContent;
}>();
</script>

View File

@ -78,6 +78,10 @@ export interface FeedbackBlock extends BaseLearningContentBlock {
readonly type: "feedback"; readonly type: "feedback";
} }
export interface AttendanceDayBlock extends BaseLearningContentBlock {
readonly type: "attendance_day";
}
export type LearningContentBlock = export type LearningContentBlock =
| AssignmentBlock | AssignmentBlock
| BookBlock | BookBlock
@ -90,7 +94,8 @@ export type LearningContentBlock =
| VideoBlock | VideoBlock
| LearningModuleBlock | LearningModuleBlock
| PlaceholderBlock | PlaceholderBlock
| FeedbackBlock; | FeedbackBlock
| AttendanceDayBlock;
export type LearningContentType = LearningContentBlock["type"]; export type LearningContentType = LearningContentBlock["type"];

View File

@ -28,6 +28,8 @@ export function learningContentTypeData(t: LearningContentType): {
return { title: "Reflexion", icon: "it-icon-lc-resource" }; return { title: "Reflexion", icon: "it-icon-lc-resource" };
case "feedback": case "feedback":
return { title: "Feedback", icon: "it-icon-lc-feedback" }; return { title: "Feedback", icon: "it-icon-lc-feedback" };
case "attendance_day":
return { title: "Feedback", icon: "it-icon-lc-exercise" };
case "placeholder": case "placeholder":
return { title: "In Umsetzung", icon: "it-icon-lc-document" }; return { title: "In Umsetzung", icon: "it-icon-lc-document" };
} }

View File

@ -17,6 +17,7 @@ from vbv_lernwelt.learnpath.tests.learning_path_factories import (
LearningUnitFactory, LearningUnitFactory,
MediaLibraryBlockFactory, MediaLibraryBlockFactory,
TopicFactory, TopicFactory,
AttendanceDayBlockFactory,
) )
@ -259,6 +260,17 @@ 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)
LearningContentFactory(
title="Präsenztag Fahrzeug",
parent=circle,
contents=[
(
"attendance_day",
AttendanceDayBlockFactory(),
)
],
)
LearningUnitFactory(title="Kompetenznachweis", parent=circle) LearningUnitFactory(title="Kompetenznachweis", parent=circle)
LearningContentFactory( LearningContentFactory(
title="Wissens- und Verständnisfragen", title="Wissens- und Verständnisfragen",

View File

@ -0,0 +1,20 @@
# Generated by Django 3.2.13 on 2023-04-03 16:05
from django.db import migrations
import wagtail.blocks
import wagtail.fields
class Migration(migrations.Migration):
dependencies = [
('learnpath', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='learningcontent',
name='contents',
field=wagtail.fields.StreamField([('video', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.TextBlock())])), ('resource', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.TextBlock()), ('text', wagtail.blocks.RichTextBlock(required=False))])), ('exercise', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.TextBlock())])), ('learningmodule', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.TextBlock())])), ('online_training', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.TextBlock())])), ('media_library', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.TextBlock())])), ('document', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.TextBlock())])), ('test', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.TextBlock())])), ('book', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.TextBlock())])), ('assignment', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.TextBlock()), ('text', wagtail.blocks.RichTextBlock(required=False))])), ('placeholder', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.TextBlock())])), ('feedback', wagtail.blocks.StructBlock([])), ('attendance_day', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())]))], use_json_field=None),
),
]

View File

@ -22,6 +22,7 @@ from vbv_lernwelt.learnpath.models_learning_unit_content import (
ResourceBlock, ResourceBlock,
TestBlock, TestBlock,
VideoBlock, VideoBlock,
AttendanceDayBlock,
) )
@ -248,6 +249,7 @@ class LearningContent(CourseBasePage):
("assignment", AssignmentBlock()), ("assignment", AssignmentBlock()),
("placeholder", PlaceholderBlock()), ("placeholder", PlaceholderBlock()),
("feedback", FeedbackBlock()), ("feedback", FeedbackBlock()),
("attendance_day", AttendanceDayBlock()),
] ]
contents = StreamField( contents = StreamField(

View File

@ -95,3 +95,10 @@ class PlaceholderBlock(blocks.StructBlock):
class FeedbackBlock(blocks.StructBlock): class FeedbackBlock(blocks.StructBlock):
class Meta: class Meta:
icon = "media" icon = "media"
class AttendanceDayBlock(blocks.StructBlock):
description = blocks.TextBlock()
class Meta:
icon = "media"

View File

@ -21,6 +21,7 @@ from vbv_lernwelt.learnpath.models_learning_unit_content import (
ResourceBlock, ResourceBlock,
TestBlock, TestBlock,
VideoBlock, VideoBlock,
AttendanceDayBlock,
) )
@ -125,6 +126,13 @@ class MediaLibraryBlockFactory(wagtail_factories.StructBlockFactory):
model = MediaLibraryBlock model = MediaLibraryBlock
class AttendanceDayBlockFactory(wagtail_factories.StructBlockFactory):
description = "Beispiel Präsenztag"
class Meta:
model = AttendanceDayBlock
class CircleFactory(wagtail_factories.PageFactory): class CircleFactory(wagtail_factories.PageFactory):
title = "Basis" title = "Basis"
description = """ description = """