VBV-355: Inhaltstyp Test
This commit is contained in:
parent
2d58cdd9fe
commit
1fa420a11b
|
|
@ -1,6 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import LearningContentContainer from "@/pages/learningPath/learningContentPage/LearningContentContainer.vue";
|
||||
import DocumentListBlock from "@/pages/learningPath/learningContentPage/blocks/DocumentListBlock.vue";
|
||||
import TestBlock from "@/pages/learningPath/learningContentPage/blocks/TestBlock.vue";
|
||||
import { useCircleStore } from "@/stores/circle";
|
||||
import type { LearningContent, LearningContentType } from "@/types";
|
||||
import eventBus from "@/utils/eventBus";
|
||||
|
|
@ -34,7 +35,7 @@ const COMPONENTS: Record<LearningContentType, Component> = {
|
|||
"learnpath.LearningContentMediaLibrary": MediaLibraryBlock,
|
||||
"learnpath.LearningContentPlaceholder": PlaceholderBlock,
|
||||
"learnpath.LearningContentRichText": RichTextBlock,
|
||||
"learnpath.LearningContentTest": IframeBlock,
|
||||
"learnpath.LearningContentTest": TestBlock,
|
||||
"learnpath.LearningContentVideo": VideoBlock,
|
||||
};
|
||||
const DEFAULT_BLOCK = PlaceholderBlock;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
<script setup lang="ts">
|
||||
import ItCheckbox from "@/components/ui/ItCheckbox.vue";
|
||||
import LearningContentSimpleLayout from "@/pages/learningPath/learningContentPage/layouts/LearningContentSimpleLayout.vue";
|
||||
import type { LearningContentTest } from "@/types";
|
||||
import { ref } from "vue";
|
||||
|
||||
const props = defineProps<{
|
||||
content: LearningContentTest;
|
||||
}>();
|
||||
|
||||
const checked = ref(false);
|
||||
|
||||
function toggleChecked() {
|
||||
checked.value = !checked.value;
|
||||
}
|
||||
|
||||
function startTest() {
|
||||
window.open(props.content.content_url, "_blank");
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<LearningContentSimpleLayout
|
||||
:title="props.content.title"
|
||||
:learning-content="props.content"
|
||||
>
|
||||
<!-- eslint-disable vue/no-v-html -->
|
||||
<div class="container-medium">
|
||||
<p
|
||||
v-if="props.content.description"
|
||||
class="default-wagtail-rich-text text-large my-4"
|
||||
v-html="props.content.description"
|
||||
></p>
|
||||
|
||||
<div class="my-8">
|
||||
<ItCheckbox
|
||||
v-if="props.content.checkbox_text"
|
||||
:checkbox-item="{
|
||||
label: props.content.checkbox_text,
|
||||
value: checked,
|
||||
checked: checked,
|
||||
}"
|
||||
@toggle="toggleChecked()"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="my-8">
|
||||
<button
|
||||
:disabled="!checked"
|
||||
class="btn-primary inline-flex items-center"
|
||||
@click="startTest()"
|
||||
>
|
||||
Test starten
|
||||
<it-icon-external-link class="it-icon ml-2 h-5 w-5"></it-icon-external-link>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</LearningContentSimpleLayout>
|
||||
</template>
|
||||
|
|
@ -85,11 +85,12 @@ export interface LearningContentPlaceholder extends LearningContentInterface {
|
|||
|
||||
export interface LearningContentRichText extends LearningContentInterface {
|
||||
readonly content_type: "learnpath.LearningContentRichText";
|
||||
text: string;
|
||||
readonly text: string;
|
||||
}
|
||||
|
||||
export interface LearningContentTest extends LearningContentInterface {
|
||||
readonly content_type: "learnpath.LearningContentTest";
|
||||
readonly checkbox_text: string;
|
||||
}
|
||||
|
||||
export interface LearningContentVideo extends LearningContentInterface {
|
||||
|
|
|
|||
|
|
@ -44,5 +44,7 @@ export function learningContentTypeData(
|
|||
return { title: "In Umsetzung", icon: "it-icon-lc-document" };
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
return assertUnreachable(`did not handle ${lc.content_type}`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,14 +14,15 @@ from vbv_lernwelt.learnpath.tests.learning_path_factories import (
|
|||
CircleFactory,
|
||||
LearningContentAssignmentFactory,
|
||||
LearningContentAttendanceCourseFactory,
|
||||
LearningContentDocumentListFactory,
|
||||
LearningContentFeedbackFactory,
|
||||
LearningContentMediaLibraryFactory,
|
||||
LearningContentPlaceholderFactory,
|
||||
LearningContentTestFactory,
|
||||
LearningPathFactory,
|
||||
LearningSequenceFactory,
|
||||
LearningUnitFactory,
|
||||
TopicFactory,
|
||||
LearningContentDocumentListFactory,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -226,7 +227,7 @@ In diesem Circle erfährst du wie die überbetrieblichen Kurse aufgebaut sind. Z
|
|||
)
|
||||
LearningUnitFactory(title="Vorbereitung", parent=circle)
|
||||
LearningContentMediaLibraryFactory(
|
||||
title=f"Handlungsfeld «{title}»",
|
||||
title=f"Allgemeines zu Versicherungen",
|
||||
parent=circle,
|
||||
description=RichText(
|
||||
f"<p>In der Mediathek unter dem Handlungsfeld «{title}» findest du alle relevanten Ressourcen für deine Fachkompetenzen.</p>"
|
||||
|
|
@ -298,9 +299,14 @@ In diesem Circle lernst du die wichtigsten Grundlagen bezüglich Versicherungswi
|
|||
parent=circle,
|
||||
)
|
||||
LearningUnitFactory(title="Kompetenznachweis", parent=circle)
|
||||
LearningContentPlaceholderFactory(
|
||||
LearningContentTestFactory(
|
||||
title="Wissens- und Verständnisfragen",
|
||||
parent=circle,
|
||||
description=RichText(
|
||||
"<p>Folgender Test mit Wissens- und Verständnisfragen ist Teil des Kompetenznachweises. Der Test kann nur einmal durchgeführt werden und ist notenrelevant.</p>"
|
||||
),
|
||||
checkbox_text="Hiermit bestätige ich, dass ich die Anweisungen verstanden habe und den Test durchführen möchte.",
|
||||
content_url="http://example.com",
|
||||
)
|
||||
LearningContentFeedbackFactory(
|
||||
parent=circle,
|
||||
|
|
|
|||
|
|
@ -1,31 +1,85 @@
|
|||
# Generated by Django 3.2.13 on 2023-05-26 10:34
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import wagtail.blocks
|
||||
import wagtail.fields
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wagtailcore', '0083_workflowcontenttype'),
|
||||
('learnpath', '0004_learningcontentassignment_assignment_type'),
|
||||
("wagtailcore", "0083_workflowcontenttype"),
|
||||
("learnpath", "0004_learningcontentassignment_assignment_type"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='LearningContentDocumentList',
|
||||
name="LearningContentDocumentList",
|
||||
fields=[
|
||||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
|
||||
('minutes', models.PositiveIntegerField(default=15)),
|
||||
('description', wagtail.fields.RichTextField(blank=True)),
|
||||
('content_url', models.TextField(blank=True)),
|
||||
('documents', wagtail.fields.StreamField([('document', wagtail.blocks.StructBlock([('title', wagtail.blocks.TextBlock()), ('description', wagtail.blocks.TextBlock(default='', required=False)), ('icon_url', wagtail.blocks.TextBlock(default='', required=False)), ('link_display_text', wagtail.blocks.CharBlock(default='Link öffnen', max_length=255)), ('url', wagtail.blocks.TextBlock(default='', required=False)), ('open_window', wagtail.blocks.BooleanBlock(default=False))]))], blank=True, use_json_field=True)),
|
||||
(
|
||||
"page_ptr",
|
||||
models.OneToOneField(
|
||||
auto_created=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
parent_link=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
to="wagtailcore.page",
|
||||
),
|
||||
),
|
||||
("minutes", models.PositiveIntegerField(default=15)),
|
||||
("description", wagtail.fields.RichTextField(blank=True)),
|
||||
("content_url", models.TextField(blank=True)),
|
||||
(
|
||||
"documents",
|
||||
wagtail.fields.StreamField(
|
||||
[
|
||||
(
|
||||
"document",
|
||||
wagtail.blocks.StructBlock(
|
||||
[
|
||||
("title", wagtail.blocks.TextBlock()),
|
||||
(
|
||||
"description",
|
||||
wagtail.blocks.TextBlock(
|
||||
default="", required=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"icon_url",
|
||||
wagtail.blocks.TextBlock(
|
||||
default="", required=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"link_display_text",
|
||||
wagtail.blocks.CharBlock(
|
||||
default="Link öffnen", max_length=255
|
||||
),
|
||||
),
|
||||
(
|
||||
"url",
|
||||
wagtail.blocks.TextBlock(
|
||||
default="", required=False
|
||||
),
|
||||
),
|
||||
(
|
||||
"open_window",
|
||||
wagtail.blocks.BooleanBlock(default=False),
|
||||
),
|
||||
]
|
||||
),
|
||||
)
|
||||
],
|
||||
blank=True,
|
||||
use_json_field=True,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
"abstract": False,
|
||||
},
|
||||
bases=('wagtailcore.page',),
|
||||
bases=("wagtailcore.page",),
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.13 on 2023-05-26 14:31
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("learnpath", "0005_learningcontentdocumentlist"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="learningcontenttest",
|
||||
name="checkbox_text",
|
||||
field=models.TextField(blank=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -307,9 +307,18 @@ class LearningContentMediaLibrary(LearningContent):
|
|||
|
||||
|
||||
class LearningContentTest(LearningContent):
|
||||
serialize_field_names = LearningContent.serialize_field_names + [
|
||||
"checkbox_text",
|
||||
]
|
||||
parent_page_types = ["learnpath.Circle"]
|
||||
subpage_types = []
|
||||
|
||||
checkbox_text = models.TextField(blank=True)
|
||||
|
||||
content_panels = LearningContent.content_panels + [
|
||||
FieldPanel("checkbox_text", classname="Text"),
|
||||
]
|
||||
|
||||
|
||||
class LearningContentRichText(LearningContent):
|
||||
text = RichTextField(blank=True, features=DEFAULT_RICH_TEXT_FEATURES_WITH_HEADER)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from vbv_lernwelt.learnpath.models import (
|
|||
Circle,
|
||||
LearningContentAssignment,
|
||||
LearningContentAttendanceCourse,
|
||||
LearningContentDocumentList,
|
||||
LearningContentFeedback,
|
||||
LearningContentLearningModule,
|
||||
LearningContentMediaLibrary,
|
||||
|
|
@ -16,7 +17,6 @@ from vbv_lernwelt.learnpath.models import (
|
|||
LearningSequence,
|
||||
LearningUnit,
|
||||
Topic,
|
||||
LearningContentDocumentList,
|
||||
)
|
||||
from vbv_lernwelt.media_library.tests.media_library_factories import (
|
||||
LearnMediaBlockFactory,
|
||||
|
|
|
|||
Loading…
Reference in New Issue