From ff23e3b4f7821e4469e567a4efac105c41d1e8bd Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Wed, 8 Jun 2022 12:38:15 +0200 Subject: [PATCH] Refactor circle data model --- .../components/circle/LearningSequence.vue | 15 +- client/src/views/CircleView.vue | 47 ++--- .../learnpath/migrations/0001_initial.py | 56 ++++-- server/vbv_lernwelt/learnpath/models.py | 88 ++++++--- .../learnpath/models_learning_unit_content.py | 9 +- server/vbv_lernwelt/learnpath/serializers.py | 5 +- .../tests/create_default_learning_path.py | 179 ++++++++---------- .../tests/learning_path_factories.py | 26 +-- server/vbv_lernwelt/learnpath/views.py | 2 +- .../learnpath/{icons.js => icons.html} | 0 10 files changed, 226 insertions(+), 201 deletions(-) rename server/vbv_lernwelt/templates/learnpath/{icons.js => icons.html} (100%) diff --git a/client/src/components/circle/LearningSequence.vue b/client/src/components/circle/LearningSequence.vue index 3dd68457..1d5a2405 100644 --- a/client/src/components/circle/LearningSequence.vue +++ b/client/src/components/circle/LearningSequence.vue @@ -16,21 +16,20 @@ defineProps(['learningSequence'])
-
-
{{ learningPackage.title }}
-
{{ learningPackage.minutes }} Minuten
+
+
{{ learningUnit.title }}
+
{{ learningUnit.minutes }} Minuten
- - -
{{ learningUnit.contents[0].type }}: {{ learningUnit.title }}
+ +
{{ learningContent.contents[0].type }}: {{ learningContent.title }}

diff --git a/client/src/views/CircleView.vue b/client/src/views/CircleView.vue index 1edf5a73..f8d26c7e 100644 --- a/client/src/views/CircleView.vue +++ b/client/src/views/CircleView.vue @@ -24,44 +24,45 @@ export default { log.debug(response.data); this.circleData = response.data; - // aggregate wagtail data into LearningSequence > LearningPackages > LearningUnit hierarchy + // aggregate wagtail data into LearningSequence > LearningUnit > LearningPackage hierarchy let learningSequence = null; - let learningPackageIndex = 0; + let learningUnit = null; this.circleData.children.forEach((child) => { + // FIXME add error detection if the data does not conform to expectations if (child.type === 'learnpath.LearningSequence') { if (learningSequence) { + if (learningUnit) { + learningSequence.learningUnits.push(learningUnit); + } this.learningSequences.push(learningSequence); } - learningSequence = Object.assign(child, { learningPackages: [] }); - learningPackageIndex = 0; + learningSequence = Object.assign(child, { learningUnits: [] }); + learningUnit = {id: null, title: '', learningContents: []}; + } else if(child.type === 'learnpath.LearningUnit') { + if (learningUnit && learningUnit.learningContents.length) { + learningSequence.learningUnits.push(learningUnit); + } + learningUnit = Object.assign(child, { learningContents: [] }); } else { - if (learningSequence.learningPackages.length === 0) { - learningSequence.learningPackages.push({ - title: child.package, - learningUnits: [], - }) - } - if (learningSequence.learningPackages[learningPackageIndex].title !== child.package) { - learningPackageIndex += 1; - learningSequence.learningPackages.push({ - title: child.package, - learningUnits: [], - }) - } - learningSequence.learningPackages[learningPackageIndex].learningUnits.push(child); + // must be a LearningContent + learningUnit.learningContents.push(child); } }); + + if (learningUnit) { + learningSequence.learningUnits.push(learningUnit); + } this.learningSequences.push(learningSequence); // sum minutes this.learningSequences.forEach((learningSequence) => { learningSequence.minutes = 0; - learningSequence.learningPackages.forEach((learningPackage) => { - learningPackage.minutes = 0; - learningPackage.learningUnits.forEach((learningUnit) => { - learningPackage.minutes += learningUnit.minutes; + learningSequence.learningUnits.forEach((learningUnit) => { + learningUnit.minutes = 0; + learningUnit.learningContents.forEach((learningContent) => { + learningUnit.minutes += learningContent.minutes; }); - learningSequence.minutes += learningPackage.minutes; + learningSequence.minutes += learningUnit.minutes; }); }); diff --git a/server/vbv_lernwelt/learnpath/migrations/0001_initial.py b/server/vbv_lernwelt/learnpath/migrations/0001_initial.py index 01356b00..25ad92f0 100644 --- a/server/vbv_lernwelt/learnpath/migrations/0001_initial.py +++ b/server/vbv_lernwelt/learnpath/migrations/0001_initial.py @@ -1,10 +1,11 @@ -# Generated by Django 3.2.12 on 2022-06-08 08:34 +# Generated by Django 3.2.13 on 2022-06-08 12:08 from django.db import migrations, models import django.db.models.deletion import modelcluster.fields import wagtail.blocks import wagtail.fields +import wagtail.images.blocks class Migration(migrations.Migration): @@ -12,22 +13,10 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('wagtailcore', '0066_collection_management_permissions'), + ('wagtailcore', '0069_log_entry_jsonfield'), ] operations = [ - migrations.CreateModel( - name='Circle', - 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')), - ('description', models.TextField(blank=True, default='')), - ('goals', models.TextField(blank=True, default='')), - ], - options={ - 'verbose_name': 'Circle', - }, - bases=('wagtailcore.page',), - ), migrations.CreateModel( name='Competence', fields=[ @@ -50,6 +39,18 @@ class Migration(migrations.Migration): }, bases=('wagtailcore.page',), ), + migrations.CreateModel( + name='LearningContent', + 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)), + ('contents', wagtail.fields.StreamField([('video', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('web_based_training', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('podcast', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('competence', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())])), ('exercise', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())])), ('document', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())])), ('knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())]))], use_json_field=None)), + ], + options={ + 'verbose_name': 'Learning Unit', + }, + bases=('wagtailcore.page',), + ), migrations.CreateModel( name='LearningPath', fields=[ @@ -64,7 +65,7 @@ class Migration(migrations.Migration): name='LearningSequence', 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')), - ('icon', models.CharField(default='IconLsStart', max_length=255)), + ('icon', models.CharField(default='it-icon-ls-start', max_length=255)), ], options={ 'verbose_name': 'Learning Sequence', @@ -75,9 +76,7 @@ class Migration(migrations.Migration): name='LearningUnit', 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)), - ('package', models.CharField(blank=True, default='', max_length=255)), - ('contents', wagtail.fields.StreamField([('video', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('rise_training', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('podcast', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock()), ('url', wagtail.blocks.URLBlock())])), ('competence', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())])), ('exercise', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())])), ('self_evaluation', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())])), ('document', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())])), ('knowledge', wagtail.blocks.StructBlock([('description', wagtail.blocks.TextBlock())]))])), + ('questions', wagtail.fields.StreamField([('question', wagtail.blocks.CharBlock())], use_json_field=True)), ], options={ 'verbose_name': 'Learning Unit', @@ -87,13 +86,15 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Topic', 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')), + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('sort_order', models.IntegerField(blank=True, editable=False, null=True)), + ('title', models.TextField(default='')), ('is_visible', models.BooleanField(default=True)), + ('learning_path', modelcluster.fields.ParentalKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='topics', to='learnpath.learningpath')), ], options={ 'verbose_name': 'Topic', }, - bases=('wagtailcore.page',), ), migrations.CreateModel( name='FullfillmentCriteria', @@ -112,4 +113,19 @@ class Migration(migrations.Migration): name='competence_page', field=modelcluster.fields.ParentalKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='competences', to='learnpath.competencepage'), ), + migrations.CreateModel( + name='Circle', + 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')), + ('description', models.TextField(blank=True, default='')), + ('goals', wagtail.fields.StreamField([('goal', wagtail.blocks.TextBlock())], use_json_field=True)), + ('job_situations', wagtail.fields.StreamField([('job_situation', wagtail.blocks.CharBlock())], use_json_field=True)), + ('experts', wagtail.fields.StreamField([('person', wagtail.blocks.StructBlock([('first_name', wagtail.blocks.CharBlock()), ('last_name', wagtail.blocks.CharBlock()), ('email', wagtail.blocks.EmailBlock()), ('photo', wagtail.images.blocks.ImageChooserBlock(required=False)), ('biography', wagtail.blocks.RichTextBlock(required=False))]))], use_json_field=True)), + ('topic', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='circles', to='learnpath.topic')), + ], + options={ + 'verbose_name': 'Circle', + }, + bases=('wagtailcore.page',), + ), ] diff --git a/server/vbv_lernwelt/learnpath/models.py b/server/vbv_lernwelt/learnpath/models.py index 2dc2ecd8..c65e867f 100644 --- a/server/vbv_lernwelt/learnpath/models.py +++ b/server/vbv_lernwelt/learnpath/models.py @@ -1,14 +1,16 @@ # Create your models here. from django.utils.text import slugify +from wagtail import blocks from wagtail.api import APIField from wagtail.blocks import StreamBlock from wagtail.fields import StreamField +from wagtail.images.blocks import ImageChooserBlock from wagtail.models import Page, Orderable from vbv_lernwelt.learnpath.models_competences import * -from vbv_lernwelt.learnpath.models_learning_unit_content import RiseTrainingBlock, VideoBlock, PodcastBlock, \ - CompetenceBlock, ExerciseBlock, SelfEvaluationBlock, DocumentBlock, KnowledgeBlock +from vbv_lernwelt.learnpath.models_learning_unit_content import WebBasedTrainingBlock, VideoBlock, PodcastBlock, \ + CompetenceBlock, ExerciseBlock, DocumentBlock, KnowledgeBlock from vbv_lernwelt.learnpath.serializer_helpers import get_it_serializer_class @@ -65,9 +67,28 @@ class Topic(Page): return f"{self.title}" +class PersonBlock(blocks.StructBlock): + first_name = blocks.CharBlock() + last_name = blocks.CharBlock() + email = blocks.EmailBlock() + photo = ImageChooserBlock(required=False) + biography = blocks.RichTextBlock(required=False) + + class Meta: + icon = 'user' + + class Circle(Page): description = models.TextField(default="", blank=True) - goals = models.TextField(default="", blank=True) + goals = StreamField([ + ('goal', blocks.TextBlock()), + ], use_json_field=True) + job_situations = StreamField([ + ('job_situation', blocks.CharBlock()), + ], use_json_field=True) + experts = StreamField([ + ('person', PersonBlock()), + ], use_json_field=True) parent_page_types = ['learnpath.LearningPath'] subpage_types = ['learnpath.LearningSequence', 'learnpath.LearningUnit'] @@ -75,11 +96,8 @@ class Circle(Page): content_panels = Page.content_panels + [ FieldPanel('description'), FieldPanel('goals'), - ] - - api_fields = [ - APIField('title'), - APIField('description'), + FieldPanel('job_situations'), + FieldPanel('experts'), APIField('learning_sequences'), ] @@ -103,12 +121,12 @@ class Circle(Page): class LearningSequence(Page): - icon = models.CharField(max_length=255, default="IconLsStart") - parent_page_types = ['learnpath.Circle'] + subpage_types = [] - panels = [ - FieldPanel('title'), + icon = models.CharField(max_length=255, default="it-icon-ls-start") + + content_panels = Page.content_panels + [ FieldPanel('icon'), ] @@ -120,7 +138,7 @@ class LearningSequence(Page): @classmethod def get_serializer_class(cls): - return get_it_serializer_class(cls, field_names=['id', 'title', 'icon', 'slug', 'type', 'translation_key']) + return get_it_serializer_class(cls, field_names=['id', 'title', 'slug', 'type', 'translation_key', 'icon']) def get_admin_display_title(self): return f'{self.icon} {self.draft_title}' @@ -130,23 +148,40 @@ class LearningSequence(Page): class LearningUnit(Page): - """ - This is a group of contents, with the übung and test it is one unit. ... more of a structural charactacter. - - """ - # TODO: Review model architecture, is the stream field the right thing here? parent_page_types = ['learnpath.Circle'] subpage_types = [] + + questions = StreamField([ + ('question', blocks.CharBlock()), + ], use_json_field=True) + + content_panels = Page.content_panels + [ + FieldPanel('questions'), + ] + + class Meta: + verbose_name = "Learning Unit" + + def __str__(self): + return f"{self.title}" + + @classmethod + def get_serializer_class(cls): + return get_it_serializer_class(cls, field_names=['id', 'title', 'slug', 'type', 'translation_key', 'questions']) + + +class LearningContent(Page): + parent_page_types = ['learnpath.Circle'] + subpage_types = [] + minutes = models.PositiveIntegerField(default=15) - package = models.CharField(max_length=255, default="", blank=True) content_blocks = [ ('video', VideoBlock()), - ('rise_training', RiseTrainingBlock()), + ('web_based_training', WebBasedTrainingBlock()), ('podcast', PodcastBlock()), ('competence', CompetenceBlock()), ('exercise', ExerciseBlock()), - ('self_evaluation', SelfEvaluationBlock()), ('document', DocumentBlock()), ('knowledge', KnowledgeBlock()), ] @@ -164,9 +199,6 @@ class LearningUnit(Page): def get_admin_display_title(self): display_title = '' - if self.package: - display_title += f'{self.package}: ' - if len(self.contents) > 0: display_title += f'{self.contents[0].block_type.capitalize()}: ' @@ -178,14 +210,14 @@ class LearningUnit(Page): verbose_name = "Learning Unit" def full_clean(self, *args, **kwargs): - self.slug = find_available_slug(LearningUnit, slugify(self.title, allow_unicode=True)) - super(LearningUnit, self).full_clean(*args, **kwargs) + self.slug = find_available_slug(LearningContent, slugify(self.title, allow_unicode=True)) + super(LearningContent, self).full_clean(*args, **kwargs) @classmethod def get_serializer_class(cls): return get_it_serializer_class(cls, - field_names=['id', 'title', 'minutes', 'package', 'contents', 'slug', 'type', - 'translation_key']) + field_names=['id', 'title', 'slug', 'type', + 'translation_key', 'minutes', 'contents']) def __str__(self): return f"{self.title}" diff --git a/server/vbv_lernwelt/learnpath/models_learning_unit_content.py b/server/vbv_lernwelt/learnpath/models_learning_unit_content.py index b14742f9..62825fe4 100644 --- a/server/vbv_lernwelt/learnpath/models_learning_unit_content.py +++ b/server/vbv_lernwelt/learnpath/models_learning_unit_content.py @@ -10,7 +10,7 @@ class VideoBlock(blocks.StructBlock): icon = 'media' -class RiseTrainingBlock(blocks.StructBlock): +class WebBasedTrainingBlock(blocks.StructBlock): description = blocks.TextBlock() url = blocks.URLBlock() @@ -40,13 +40,6 @@ class ExerciseBlock(blocks.StructBlock): icon = 'media' -class SelfEvaluationBlock(blocks.StructBlock): - description = blocks.TextBlock() - - class Meta: - icon = 'media' - - class DocumentBlock(blocks.StructBlock): description = blocks.TextBlock() diff --git a/server/vbv_lernwelt/learnpath/serializers.py b/server/vbv_lernwelt/learnpath/serializers.py index 70dde5b5..8bae0dba 100644 --- a/server/vbv_lernwelt/learnpath/serializers.py +++ b/server/vbv_lernwelt/learnpath/serializers.py @@ -17,7 +17,10 @@ class CircleSerializer(get_it_serializer_class(Circle, [])): class Meta: model = Circle - fields = ['id', 'title', 'slug', 'children', 'type'] + fields = [ + 'id', 'title', 'slug', 'type', 'translation_key', + 'children', 'description', 'job_situations', 'goals', 'experts', + ] class LearningPathSerializer(get_it_serializer_class(LearningPath, [])): diff --git a/server/vbv_lernwelt/learnpath/tests/create_default_learning_path.py b/server/vbv_lernwelt/learnpath/tests/create_default_learning_path.py index 8caab45c..c57591e3 100644 --- a/server/vbv_lernwelt/learnpath/tests/create_default_learning_path.py +++ b/server/vbv_lernwelt/learnpath/tests/create_default_learning_path.py @@ -3,10 +3,10 @@ from django.conf import settings from wagtail.models import Site, Page from vbv_lernwelt.core.admin import User -from vbv_lernwelt.learnpath.models import LearningPath, Topic, Circle, LearningSequence, LearningUnit +from vbv_lernwelt.learnpath.models import LearningPath, Topic, Circle, LearningSequence, LearningContent from vbv_lernwelt.learnpath.tests.learning_path_factories import LearningPathFactory, TopicFactory, CircleFactory, \ - LearningSequenceFactory, LearningUnitFactory, VideoBlockFactory, PodcastBlockFactory, CompetenceBlockFactory, \ - ExerciseBlockFactory, SelfEvaluationBlockFactory, DocumentBlockFactory + LearningSequenceFactory, LearningContentFactory, VideoBlockFactory, PodcastBlockFactory, CompetenceBlockFactory, \ + ExerciseBlockFactory, DocumentBlockFactory, LearningUnitFactory def create_default_learning_path(user=None): @@ -28,194 +28,175 @@ def create_default_learning_path(user=None): tp = TopicFactory(title="Basissdf", is_visible=False, parent=lp) - circle_1 = CircleFactory(title="Basis", parent=lp, description=""" + circle_1 = CircleFactory( + title="Basis", + parent=lp, + + description=""" In diesem Circle erklären wir dir, wie der Lehrgang Versicherungsvermittler / in " aufgebaut ist. Zudem vermitteln wir dir die wichtigsten Grundlagen, -damit erfolgreich mit deinem Lernpfad starten kannst.""") +damit erfolgreich mit deinem Lernpfad starten kannst. +""") tp = TopicFactory(title="Gewinnen von Kunden", parent=lp) - circle_2 = CircleFactory(title="Gewinnen", parent=lp, description="""Versicherungsvermittlerinnen und -vermittler verfügen über + circle_2 = CircleFactory( + title="Gewinnen", + parent=lp, + description=""" +Versicherungsvermittlerinnen und -vermittler verfügen über ein starkes Netzwerk, das sie gezielt pflegen und ausbauen. Sie beraten und betreuen ihre bestehenden Kundinnen und Kunden professionell und gewinnen so ihr Vertrauen. Dadurch schaffen sie die Basis für das Gewinnen von neuen Kundinnen und Kunden. Versicherungsvermittlerinnen und -vermittler sprechen ihre bestehenden Kundinnen und Kunden auf Weiterempfehlung an. So nutzen sie ihre bestehenden Kontakte geschickt für das Anwerben von -Neukundinnen und -kunden. - """, goals="""— Bestehende Kunden so zu beraten, dass -sie von diesen weiterempfohlen werden -— Geeignete Personen wie z.B. Garagisten, Architekten, Treuhänder auf die -Vermittlung/Zusammenarbeit anzusprechen -— Verschiedene Datenquellen wie Internet, Telefonbuch, Handelszeitung, Baugesuche etc. Gezielt für die Gewinnung -von Neukunden zu benützen -— Ein beliebiges Gespräch resp. Einen bestehenden Kontakt in die Richtung -«Versicherung» zu lenken -— Das Thema Risiko und Sicherheit in einem Gespräch gezielt und auf die Situation des jeweiligen Gesprächspartners bezogen einfliessen zu lassen -— Im täglichen Kontakt potenzielle Kundinnen und Kunden zu erkennen""") +Neukundinnen und -kunden.""", + goals=[ + ('goal', '... Bestehende Kunden so zu beraten, dass sie von diesen weiterempfohlen werden'), + ('goal', '... Geeignete Personen wie z.B. Garagisten, Architekten, Treuhänder auf die Vermittlung / Zusammenarbeit anzusprechen'), + ('goal', '... Verschiedene Datenquellen wie Internet, Telefonbuch, Handelszeitung, Baugesuche etc. Gezielt für die Gewinnung von Neukunden zu benützen'), + ('goal', '... Ein beliebiges Gespräch resp. Einen bestehenden Kontakt in die Richtung «Versicherung» zu lenken'), + ('goal', '... Das Thema Risiko und Sicherheit in einem Gespräch gezielt und auf die Situation des jeweiligen Gesprächspartners bezogen einfliessen zu lassen'), + ('goal', '... Im täglichen Kontakt potenzielle Kundinnen und Kunden zu erkennen'), + ], + ) tp = TopicFactory(title="Beraten der Kunden", parent=lp) circle_3 = CircleFactory(title="Einstieg", parent=lp) - circe_analyse = CircleFactory(title="Analyse", parent=lp, - description="""Nach dem Gespräch werten sie die Analyse aus und erstellen mit den - zur Verfügung stehenden Systemen formal korrekte Lösungsvorschläge bzw. - Ausschreibungen. Je nach Komplexität der Situation ziehen sie die nötigen - Fachspezialisten bei.""", - goals=""" - — Aus dem IST-Zustand (aus der durchgeführten Analyse) individuelle, risikogewichtete und finanzierbare Lösungsvorschläge zu erarbeiten - — Eine Unterversicherung, eine Doppeloder Überversicherung oder einen fehlenden Versicherungsschutz festzustellen - — Mögliches Optimierungspotential unter Berücksichtigung der finanziellen - Situation des Kunden zu erkennen - — Lösungsvorschläge zu skizzieren und - zu visualisieren""") + circe_analyse = CircleFactory( + title="Analyse", + parent=lp, - LearningSequenceFactory(title='Starten', parent=circe_analyse) - LearningUnitFactory( + description=""" +Nach dem Gespräch werten sie die Analyse aus und erstellen mit den +zur Verfügung stehenden Systemen formal korrekte Lösungsvorschläge bzw. +Ausschreibungen. Je nach Komplexität der Situation ziehen sie die nötigen +Fachspezialisten bei. + """, + job_situations=[ + ('job_situation', 'Absicherung der Familie'), + ('job_situation', 'Prämien einsparen'), + ('job_situation', 'Deckung optimieren'), + ('job_situation', 'Auto kaufen'), + ('job_situation', 'Fahrzeugwechsel'), + ('job_situation', 'Pensionerung inklusive Variante Frühpensionierung'), + ('job_situation', 'Reisen'), + ], + goals=[ + ('goal', '... die heutige Versicherungssituation von Privat- oder Geschäftskunden einzuschätzen.'), + ('goal', '... deinem Kunden einen ungenügenden oder übermässigen Versicherungsschutz aufzuzeigen.'), + ('goal', '... deinem Kunden zu helfen, sein Optimierungspotential voll auszuschöpfen.'), + ('goal', '... deinem Kunden seine optimale Lösung aufzuzeigen'), + ], + experts=[ + ('person', {'last_name': 'Huggel', 'first_name': 'Patrizia', 'email': 'patrizia.huggel@example.com'}), + ] + ) + + LearningSequenceFactory(title='Starten', parent=circe_analyse, icon='it-icon-ls-start') + LearningContentFactory( title='Einleitung Circle "Anlayse"', parent=circe_analyse, minutes=15, contents=[('video', VideoBlockFactory())] ) - LearningSequenceFactory(title='Beobachten', parent=circe_analyse, icon='IconLsWatch') - LearningUnitFactory( + LearningSequenceFactory(title='Beobachten', parent=circe_analyse, icon='it-icon-ls-watch') + LearningUnitFactory(title='Abischerung der Familie', parent=circe_analyse) + LearningContentFactory( title='Ermittlung des Kundenbedarfs', parent=circe_analyse, - package='Absicherung der Familie', minutes=30, contents=[('podcast', PodcastBlockFactory())] ) - LearningUnitFactory( + LearningContentFactory( title='Kundenbedürfnisse erkennen', parent=circe_analyse, - package='Absicherung der Familie', minutes=30, contents=[('competence', CompetenceBlockFactory())] ) - LearningUnitFactory( + LearningContentFactory( title='Was braucht eine Familie?', parent=circe_analyse, - package='Absicherung der Familie', minutes=60, contents=[('exercise', ExerciseBlockFactory())] ) - LearningUnitFactory( - title='Selbsteinschätzung', - parent=circe_analyse, - package='Absicherung der Familie', - minutes=0, - contents=[('self_evaluation', SelfEvaluationBlockFactory())] - ) - LearningSequenceFactory(title='Anwenden', parent=circe_analyse, icon='IconLsApply') - LearningUnitFactory( + LearningSequenceFactory(title='Anwenden', parent=circe_analyse, icon='it-icon-ls-apply') + LearningUnitFactory(title='Prämien einsparen', parent=circe_analyse) + LearningContentFactory( title='Versicherungsbedarf für Familien', parent=circe_analyse, - package='Prämien einsparen', minutes=60, contents=[('exercise', ExerciseBlockFactory())] ) - LearningUnitFactory( + LearningContentFactory( title='Alles klar?', parent=circe_analyse, - package='Prämien einsparen', minutes=60, contents=[('exercise', ExerciseBlockFactory())] ) - LearningUnitFactory( - title='Selbsteinschätzung', - parent=circe_analyse, - package='Prämien einsparen', - minutes=0, - contents=[('self_evaluation', SelfEvaluationBlockFactory())] - ) - LearningUnitFactory( + LearningUnitFactory(title='Sich selbständig machen', parent=circe_analyse) + LearningContentFactory( title='GmbH oder AG', parent=circe_analyse, - package='Sich selbständig machen', minutes=120, contents=[('video', VideoBlockFactory())] ) - LearningUnitFactory( + LearningContentFactory( title='Tiertherapie Patrizia Feller', parent=circe_analyse, - package='Sich selbständig machen', minutes=120, contents=[('exercise', ExerciseBlockFactory())] ) - LearningUnitFactory( - title='Selbsteinschätzung', - parent=circe_analyse, - package='Sich selbständig machen', - minutes=0, - contents=[('self_evaluation', SelfEvaluationBlockFactory())] - ) - LearningUnitFactory( + LearningUnitFactory(title='Auto verkaufen', parent=circe_analyse) + LearningContentFactory( title='Motorfahrzeugversicherung', parent=circe_analyse, - package='Auto verkaufen', minutes=240, contents=[('competence', CompetenceBlockFactory())] ) - LearningUnitFactory( + LearningContentFactory( title='Nora kauft sich ein neues Auto', parent=circe_analyse, - package='Auto verkaufen', minutes=60, contents=[('podcast', PodcastBlockFactory())] ) - LearningUnitFactory( + LearningContentFactory( title='Ermittlung des Kundenbedarfs', parent=circe_analyse, - package='Auto verkaufen', minutes=120, contents=[('document', DocumentBlockFactory())] ) - LearningUnitFactory( + LearningContentFactory( title='Motorfahrzeug kaufen', parent=circe_analyse, - package='Auto verkaufen', minutes=120, contents=[('exercise', ExerciseBlockFactory())] ) - LearningUnitFactory( - title='Selbsteinschätzung', - parent=circe_analyse, - package='Auto verkaufen', - minutes=0, - contents=[('self_evaluation', SelfEvaluationBlockFactory())] - ) - LearningSequenceFactory(title='Üben', parent=circe_analyse, icon='IconLsPractice') - LearningUnitFactory( + LearningSequenceFactory(title='Üben', parent=circe_analyse, icon='it-icon-ls-practice') + LearningUnitFactory(title='Kind zieht von zu Hause aus', parent=circe_analyse) + LearningContentFactory( title='Hausrat', parent=circe_analyse, - package='Kind zieht von zu Hause aus', minutes=120, contents=[('competence', CompetenceBlockFactory())] ) - LearningUnitFactory( + LearningContentFactory( title='Privathaftpflicht', parent=circe_analyse, - package='Kind zieht von zu Hause aus', minutes=60, contents=[('competence', CompetenceBlockFactory())] ) - LearningUnitFactory( - title='Kind zieht von zu Hause aus', + LearningContentFactory( + title='Kind zieht von zu Hause wirklich aus', parent=circe_analyse, - package='Kind zieht von zu Hause aus', minutes=60, contents=[('competence', CompetenceBlockFactory())] ) - LearningUnitFactory( - title='Selbsteinschätzung', - parent=circe_analyse, - package='Kind zieht von zu Hause aus', - minutes=0, - contents=[('self_evaluation', SelfEvaluationBlockFactory())] - ) # learning_unit = LearningUnitFactory.create(title='** Einstieg Video"', parent=circle_4) # video_url = "https://www.vbv.ch/fileadmin/vbv/Videos/Statements_Externe/Janos_M/Testimonial_Janos_Mischler_PositiveEffekte.mp4" @@ -285,7 +266,7 @@ von Neukunden zu benützen def delete_default_learning_path(): - LearningUnit.objects.all().delete() + LearningContent.objects.all().delete() LearningSequence.objects.all().delete() Circle.objects.all().delete() Topic.objects.all().delete() diff --git a/server/vbv_lernwelt/learnpath/tests/learning_path_factories.py b/server/vbv_lernwelt/learnpath/tests/learning_path_factories.py index 417b7d08..9518358f 100644 --- a/server/vbv_lernwelt/learnpath/tests/learning_path_factories.py +++ b/server/vbv_lernwelt/learnpath/tests/learning_path_factories.py @@ -1,9 +1,9 @@ import factory import wagtail_factories -from vbv_lernwelt.learnpath.models import LearningPath, Topic, Circle, LearningSequence, LearningUnit -from vbv_lernwelt.learnpath.models_learning_unit_content import VideoBlock, RiseTrainingBlock, PodcastBlock, \ - CompetenceBlock, ExerciseBlock, SelfEvaluationBlock, DocumentBlock, KnowledgeBlock +from vbv_lernwelt.learnpath.models import LearningPath, Topic, Circle, LearningSequence, LearningContent, LearningUnit +from vbv_lernwelt.learnpath.models_learning_unit_content import VideoBlock, WebBasedTrainingBlock, PodcastBlock, \ + CompetenceBlock, ExerciseBlock, DocumentBlock, KnowledgeBlock class LearningPathFactory(wagtail_factories.PageFactory): @@ -36,12 +36,19 @@ class LearningSequenceFactory(wagtail_factories.PageFactory): class LearningUnitFactory(wagtail_factories.PageFactory): - title = "Herzlich Willkommen" + title = 'Lerneinheit' class Meta: model = LearningUnit +class LearningContentFactory(wagtail_factories.PageFactory): + title = "Herzlich Willkommen" + + class Meta: + model = LearningContent + + class VideoBlockFactory(wagtail_factories.StructBlockFactory): url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam" @@ -50,12 +57,12 @@ class VideoBlockFactory(wagtail_factories.StructBlockFactory): model = VideoBlock -class RiseTrainingBlockFactory(wagtail_factories.StructBlockFactory): +class WebBasedTrainingBlockFactory(wagtail_factories.StructBlockFactory): url = "https://www.example.com" description = "Beispiel Rise Modul" class Meta: - model = RiseTrainingBlock + model = WebBasedTrainingBlock class PodcastBlockFactory(wagtail_factories.StructBlockFactory): @@ -80,13 +87,6 @@ class ExerciseBlockFactory(wagtail_factories.StructBlockFactory): model = ExerciseBlock -class SelfEvaluationBlockFactory(wagtail_factories.StructBlockFactory): - description = "Beispiel Selbsteinschätzung" - - class Meta: - model = SelfEvaluationBlock - - class DocumentBlockFactory(wagtail_factories.StructBlockFactory): description = "Beispiel Dokument" diff --git a/server/vbv_lernwelt/learnpath/views.py b/server/vbv_lernwelt/learnpath/views.py index de62763c..066d43c9 100644 --- a/server/vbv_lernwelt/learnpath/views.py +++ b/server/vbv_lernwelt/learnpath/views.py @@ -36,7 +36,7 @@ def generate_web_component_icons(request): 'classname': filename.replace('-', '_'), }) return render( - request, "learnpath/icons.js", + request, "learnpath/icons.html", context={'svg_files': svg_files}, content_type="application/javascript" ) diff --git a/server/vbv_lernwelt/templates/learnpath/icons.js b/server/vbv_lernwelt/templates/learnpath/icons.html similarity index 100% rename from server/vbv_lernwelt/templates/learnpath/icons.js rename to server/vbv_lernwelt/templates/learnpath/icons.html