diff --git a/server/vbv_lernwelt/competence/create_default_competence_profile.py b/server/vbv_lernwelt/competence/create_default_competence_profile.py index df2f37ab..42366a34 100644 --- a/server/vbv_lernwelt/competence/create_default_competence_profile.py +++ b/server/vbv_lernwelt/competence/create_default_competence_profile.py @@ -15,20 +15,20 @@ def create_default_competence_profile(): PerformanceCriteriaFactory( parent=competence_profile_page, - title='B1.3 Fahrzeug', - text='Innerhalb des Handlungsfelds «Fahrzeug» bin ich fähig, die Ziele und Pläne des Kunden zu ergründen (SOLL).', + pc_id='B1.3 Fahrzeug', + title='Innerhalb des Handlungsfelds «Fahrzeug» bin ich fähig, die Ziele und Pläne des Kunden zu ergründen (SOLL).', learning_unit=LearningUnit.objects.get(slug='versicherungsvermittlerin-lp-circle-analyse-lu-fahrzeug'), ) PerformanceCriteriaFactory( parent=competence_profile_page, - title='B2.1 Fahrzeug', - text='Innerhalb des Handlungsfelds «Fahrzeug» bin ich fähig, die IST-Situation des Kunden mit der geeigneten Gesprächs-/Fragetechnik zu erfassen.', + pc_id='B2.1 Fahrzeug', + title='Innerhalb des Handlungsfelds «Fahrzeug» bin ich fähig, die IST-Situation des Kunden mit der geeigneten Gesprächs-/Fragetechnik zu erfassen.', learning_unit=LearningUnit.objects.get(slug='versicherungsvermittlerin-lp-circle-analyse-lu-fahrzeug'), ) PerformanceCriteriaFactory( parent=competence_profile_page, - title='B2.2 Fahrzeug', - text='Innerhalb des Handlungsfelds «Fahrzeug» bin ich fähig, die Risiken aufzuzeigen.', + pc_id='B2.2 Fahrzeug', + title='Innerhalb des Handlungsfelds «Fahrzeug» bin ich fähig, die Risiken aufzuzeigen.', learning_unit=LearningUnit.objects.get(slug='versicherungsvermittlerin-lp-circle-analyse-lu-fahrzeug'), ) diff --git a/server/vbv_lernwelt/competence/factories.py b/server/vbv_lernwelt/competence/factories.py index 1a3f918a..1bdbac04 100644 --- a/server/vbv_lernwelt/competence/factories.py +++ b/server/vbv_lernwelt/competence/factories.py @@ -11,8 +11,8 @@ class CompetenceProfilePageFactory(wagtail_factories.PageFactory): class PerformanceCriteriaFactory(wagtail_factories.PageFactory): - title = 'A.1' - text = 'Bestehende Kunden so zu beraten, dass sie von diesen weiterempfohlen werden' + pc_id = 'A.1' + title = 'Bestehende Kunden so zu beraten, dass sie von diesen weiterempfohlen werden' class Meta: model = PerformanceCriteria diff --git a/server/vbv_lernwelt/competence/migrations/0001_initial.py b/server/vbv_lernwelt/competence/migrations/0001_initial.py index 0532aa27..d985a274 100644 --- a/server/vbv_lernwelt/competence/migrations/0001_initial.py +++ b/server/vbv_lernwelt/competence/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.2.13 on 2022-09-27 14:26 +# Generated by Django 3.2.13 on 2022-09-27 15:49 from django.db import migrations, models import django.db.models.deletion @@ -9,6 +9,7 @@ class Migration(migrations.Migration): initial = True dependencies = [ + ('learnpath', '0001_initial'), ('wagtailcore', '0069_log_entry_jsonfield'), ] @@ -27,7 +28,8 @@ class Migration(migrations.Migration): name='PerformanceCriteria', 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')), - ('text', models.TextField(default='')), + ('pc_id', models.TextField(default='')), + ('learning_unit', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='learnpath.learningunit')), ], options={ 'abstract': False, diff --git a/server/vbv_lernwelt/competence/migrations/0002_performancecriteria_learning_unit.py b/server/vbv_lernwelt/competence/migrations/0002_performancecriteria_learning_unit.py deleted file mode 100644 index 766a04e9..00000000 --- a/server/vbv_lernwelt/competence/migrations/0002_performancecriteria_learning_unit.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by Django 3.2.13 on 2022-09-27 14:26 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ('learnpath', '0001_initial'), - ('competence', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='performancecriteria', - name='learning_unit', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='learnpath.learningunit'), - ), - ] diff --git a/server/vbv_lernwelt/competence/models.py b/server/vbv_lernwelt/competence/models.py index a6660fc1..18c95d8f 100644 --- a/server/vbv_lernwelt/competence/models.py +++ b/server/vbv_lernwelt/competence/models.py @@ -32,7 +32,7 @@ class CompetenceProfilePage(Page): class PerformanceCriteria(Page): parent_page_types = ['competence.CompetenceProfilePage'] - text = models.TextField(default='') + pc_id = models.TextField(default='') learning_unit = models.ForeignKey( 'learnpath.LearningUnit', null=True, @@ -42,7 +42,7 @@ class PerformanceCriteria(Page): content_panels = [ FieldPanel('title'), - FieldPanel('text'), + FieldPanel('pc_id'), FieldPanel('learning_unit'), ] @@ -52,5 +52,8 @@ class PerformanceCriteria(Page): @classmethod def get_serializer_class(cls): - from vbv_lernwelt.competence.serializers import PerfomanceCriteriaSerializer - return PerfomanceCriteriaSerializer + from vbv_lernwelt.competence.serializers import PerformanceCriteriaSerializer + return PerformanceCriteriaSerializer + + def get_admin_display_title(self): + return f'{self.pc_id} {self.draft_title[:30]}' diff --git a/server/vbv_lernwelt/competence/serializers.py b/server/vbv_lernwelt/competence/serializers.py index 9280f338..8e6d4c83 100644 --- a/server/vbv_lernwelt/competence/serializers.py +++ b/server/vbv_lernwelt/competence/serializers.py @@ -1,19 +1,28 @@ from rest_framework import serializers from vbv_lernwelt.competence.models import PerformanceCriteria +from vbv_lernwelt.learnpath.models import LearningUnit from vbv_lernwelt.learnpath.serializer_helpers import get_it_serializer_class -class PerfomanceCriteriaSerializer(get_it_serializer_class(PerformanceCriteria, [ +class PerformanceCriteriaSerializer(get_it_serializer_class(PerformanceCriteria, [ 'id', 'title', 'slug', 'type', 'translation_key', - 'text', 'learning_unit', 'circle', + 'pc_id', 'learning_unit', 'circle', ])): learning_unit = serializers.SerializerMethodField() circle = serializers.SerializerMethodField() def get_learning_unit(self, obj): - learning_unit_serializer = obj.learning_unit.get_serializer_class() + learning_unit_serializer = get_it_serializer_class(LearningUnit, [ + 'id', 'title', 'slug', 'type', 'translation_key', + ]) return learning_unit_serializer(obj.learning_unit).data def get_circle(self, obj): return obj.learning_unit.get_parent().specific.title + + +class PerformanceCriteriaLearningPathSerializer(get_it_serializer_class(PerformanceCriteria, [ + 'id', 'title', 'slug', 'type', 'translation_key', 'pc_id', +])): + pass diff --git a/server/vbv_lernwelt/learnpath/create_default_learning_path.py b/server/vbv_lernwelt/learnpath/create_default_learning_path.py index 75fe36e9..db3440d5 100644 --- a/server/vbv_lernwelt/learnpath/create_default_learning_path.py +++ b/server/vbv_lernwelt/learnpath/create_default_learning_path.py @@ -7,12 +7,11 @@ from wagtail_localize.models import LocaleSynchronization from vbv_lernwelt.core.admin import User from vbv_lernwelt.course.consts import COURSE_VERSICHERUNGSVERMITTLERIN from vbv_lernwelt.course.models import CoursePage, CourseCategory -from vbv_lernwelt.learnpath.models import LearningPath, Topic, Circle, LearningSequence, LearningContent, LearningUnit, \ - LearningUnitQuestion +from vbv_lernwelt.learnpath.models import LearningPath, Topic, Circle, LearningSequence, LearningContent, LearningUnit from vbv_lernwelt.learnpath.tests.learning_path_factories import LearningPathFactory, TopicFactory, CircleFactory, \ LearningSequenceFactory, LearningContentFactory, VideoBlockFactory, ResourceBlockFactory, \ - ExerciseBlockFactory, DocumentBlockFactory, LearningUnitFactory, LearningUnitQuestionFactory, \ - AssignmentBlockFactory, BookBlockFactory, MediaLibraryBlockFactory, OnlineTrainingBlockFactory, TestBlockFactory + ExerciseBlockFactory, DocumentBlockFactory, LearningUnitFactory, AssignmentBlockFactory, BookBlockFactory, \ + MediaLibraryBlockFactory, OnlineTrainingBlockFactory, TestBlockFactory def create_circle(title, learning_path): @@ -65,14 +64,6 @@ def create_circle_children(circle, title): parent=circle, course_category=CourseCategory.objects.get(course_id=COURSE_VERSICHERUNGSVERMITTLERIN, title='Einkommenssicherung') ) - LearningUnitQuestionFactory( - title="Ich bin in der Lage, mit geeigneten Fragestellungen die Deckung von Versicherungen zu erfassen.", - parent=lu - ) - LearningUnitQuestionFactory( - title="Zweite passende Frage zu 'Absicherung der Familie'", - parent=lu - ) LearningContentFactory( title='Ermittlung des Kundenbedarfs', parent=circle, @@ -127,10 +118,6 @@ def create_circle_children(circle, title): title='Prämien einsparen', parent=circle, ) - LearningUnitQuestionFactory( - title="Passende Frage zu Anwenden", - parent=lu - ) LearningContentFactory( title='Versicherungsbedarf für Familien', parent=circle, @@ -149,10 +136,6 @@ def create_circle_children(circle, title): parent=circle, course_category=CourseCategory.objects.get(course_id=COURSE_VERSICHERUNGSVERMITTLERIN, title='Selbständigkeit') ) - LearningUnitQuestionFactory( - title="Passende Frage zu 'Sich selbständig machen'", - parent=lu - ) LearningContentFactory( title='GmbH oder AG', parent=circle, @@ -171,10 +154,6 @@ def create_circle_children(circle, title): parent=circle, course_category=CourseCategory.objects.get(course_id=COURSE_VERSICHERUNGSVERMITTLERIN, title='Fahrzeug') ) - LearningUnitQuestionFactory( - title='Passende Frage zu "Auto verkaufen"', - parent=lu - ) LearningContentFactory( title='Motorfahrzeugversicherung', parent=circle, @@ -205,10 +184,6 @@ def create_circle_children(circle, title): parent=circle, course_category=CourseCategory.objects.get(course_id=COURSE_VERSICHERUNGSVERMITTLERIN, title='Pensionierung') ) - LearningUnitQuestionFactory( - title='Passende Frage zu "Pensionierung"', - parent=lu - ) LearningContentFactory( title='3-Säulen-Prinzip', parent=circle, @@ -239,10 +214,6 @@ def create_circle_children(circle, title): parent=circle, course_category=CourseCategory.objects.get(course_id=COURSE_VERSICHERUNGSVERMITTLERIN, title='Reisen') ) - LearningUnitQuestionFactory( - title='Passende Frage zu "Reisen"', - parent=lu - ) LearningContentFactory( title='Reiseversicherung', parent=circle, @@ -262,10 +233,6 @@ def create_circle_children(circle, title): parent=circle, course_category=CourseCategory.objects.get(course_id=COURSE_VERSICHERUNGSVERMITTLERIN, title='Haushalt') ) - LearningUnitQuestionFactory( - title='Passende Frage zu "Haushalt"', - parent=lu - ) LearningContentFactory( title='Privathaftpflicht', parent=circle, @@ -291,10 +258,6 @@ def create_circle_children(circle, title): parent=circle, course_category=CourseCategory.objects.get(course_id=COURSE_VERSICHERUNGSVERMITTLERIN, title='Einkommenssicherung') ) - LearningUnitQuestionFactory( - title='Passende Frage zu "Kind zieht von zu Hause aus"', - parent=lu - ) LearningContentFactory( title='Hausrat', parent=circle, @@ -320,10 +283,6 @@ def create_circle_children(circle, title): parent=circle, course_category=CourseCategory.objects.get(course_id=COURSE_VERSICHERUNGSVERMITTLERIN, title='Einkommenssicherung') ) - LearningUnitQuestionFactory( - title='Passende Frage zu "Kind zieht von zu Hause aus"', - parent=lu - ) LearningContentFactory( title='Das erwartet dich im Test', parent=circle, @@ -488,7 +447,6 @@ Neukundinnen und -kunden.""", def delete_default_learning_path(): LearningContent.objects.all().delete() - LearningUnitQuestion.objects.all().delete() LearningUnit.objects.all().delete() LearningSequence.objects.all().delete() Circle.objects.all().delete() diff --git a/server/vbv_lernwelt/learnpath/migrations/0001_initial.py b/server/vbv_lernwelt/learnpath/migrations/0001_initial.py index 417cba6f..0e40237c 100644 --- a/server/vbv_lernwelt/learnpath/migrations/0001_initial.py +++ b/server/vbv_lernwelt/learnpath/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.2.13 on 2022-09-27 14:26 +# Generated by Django 3.2.13 on 2022-09-27 15:23 from django.db import migrations, models import django.db.models.deletion @@ -64,16 +64,6 @@ class Migration(migrations.Migration): }, bases=('wagtailcore.page',), ), - migrations.CreateModel( - name='LearningUnitQuestion', - 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')), - ], - options={ - 'verbose_name': 'Learning Unit Question', - }, - bases=('wagtailcore.page',), - ), migrations.CreateModel( name='Topic', fields=[ diff --git a/server/vbv_lernwelt/learnpath/models.py b/server/vbv_lernwelt/learnpath/models.py index 74d47540..131485fe 100644 --- a/server/vbv_lernwelt/learnpath/models.py +++ b/server/vbv_lernwelt/learnpath/models.py @@ -195,34 +195,13 @@ class LearningUnit(Page): @classmethod def get_serializer_class(cls): - return get_it_serializer_class(cls, field_names=[ - 'id', 'title', 'slug', 'type', 'translation_key', 'children', - 'course_category', - ]) + from vbv_lernwelt.learnpath.serializers import LearningUnitSerializer + return LearningUnitSerializer def get_admin_display_title_html(self): return f'{self.draft_title}' -class LearningUnitQuestion(Page): - parent_page_types = ['learnpath.LearningUnit'] - subpage_types = [] - - class Meta: - verbose_name = "Learning Unit Question" - - def __str__(self): - return f"{self.title}" - - def full_clean(self, *args, **kwargs): - self.slug = find_slug_with_parent_prefix(self, 'luq') - super(LearningUnitQuestion, self).full_clean(*args, **kwargs) - - @classmethod - def get_serializer_class(cls): - return get_it_serializer_class(cls, field_names=['id', 'title', 'slug', 'type', 'translation_key', ]) - - class LearningContent(Page): parent_page_types = ['learnpath.Circle'] subpage_types = [] diff --git a/server/vbv_lernwelt/learnpath/serializers.py b/server/vbv_lernwelt/learnpath/serializers.py index e69de29b..7225b990 100644 --- a/server/vbv_lernwelt/learnpath/serializers.py +++ b/server/vbv_lernwelt/learnpath/serializers.py @@ -0,0 +1,14 @@ +from vbv_lernwelt.competence.serializers import PerformanceCriteriaLearningPathSerializer +from vbv_lernwelt.learnpath.models import LearningUnit +from vbv_lernwelt.learnpath.serializer_helpers import get_it_serializer_class + + +class LearningUnitSerializer(get_it_serializer_class(LearningUnit, [ + 'id', 'title', 'slug', 'type', 'translation_key', + 'course_category', 'children', +])): + def get_children(self, obj): + return [ + PerformanceCriteriaLearningPathSerializer(child).data + for child in obj.performancecriteria_set.all() + ] diff --git a/server/vbv_lernwelt/learnpath/tests/create_simple_test_learning_path.py b/server/vbv_lernwelt/learnpath/tests/create_simple_test_learning_path.py index 439627c6..3e1b378a 100644 --- a/server/vbv_lernwelt/learnpath/tests/create_simple_test_learning_path.py +++ b/server/vbv_lernwelt/learnpath/tests/create_simple_test_learning_path.py @@ -1,11 +1,11 @@ import wagtail_factories from django.conf import settings from wagtail.models import Site, Page + from vbv_lernwelt.core.admin import User from vbv_lernwelt.learnpath.tests.learning_path_factories import LearningPathFactory, TopicFactory, CircleFactory, \ LearningSequenceFactory, LearningContentFactory, \ - ExerciseBlockFactory, LearningUnitFactory, LearningUnitQuestionFactory, \ - DocumentBlockFactory, TestBlockFactory, OnlineTrainingBlockFactory + ExerciseBlockFactory, LearningUnitFactory, DocumentBlockFactory, TestBlockFactory, OnlineTrainingBlockFactory def create_circle(title, learning_path): @@ -41,14 +41,6 @@ def create_circle_children(circle, title): title='Absicherung der Familie', parent=circle, ) - LearningUnitQuestionFactory( - title="Ich bin in der Lage, mit geeigneten Fragestellungen die Deckung von Versicherungen zu erfassen.", - parent=lu - ) - LearningUnitQuestionFactory( - title="Zweite passende Frage zu 'Absicherung der Familie'", - parent=lu - ) LearningContentFactory( title='Ermittlung des Kundenbedarfs', parent=circle, @@ -74,10 +66,6 @@ def create_circle_children(circle, title): ) lu = LearningUnitFactory(title='Reisen', parent=circle) - LearningUnitQuestionFactory( - title='Passende Frage zu "Reisen"', - parent=lu - ) LearningContentFactory( title='Reiseversicherung', parent=circle, diff --git a/server/vbv_lernwelt/learnpath/tests/learning_path_factories.py b/server/vbv_lernwelt/learnpath/tests/learning_path_factories.py index 483b75fc..2a817a22 100644 --- a/server/vbv_lernwelt/learnpath/tests/learning_path_factories.py +++ b/server/vbv_lernwelt/learnpath/tests/learning_path_factories.py @@ -1,7 +1,6 @@ import wagtail_factories -from vbv_lernwelt.learnpath.models import LearningPath, Topic, Circle, LearningSequence, LearningContent, LearningUnit, \ - LearningUnitQuestion +from vbv_lernwelt.learnpath.models import LearningPath, Topic, Circle, LearningSequence, LearningContent, LearningUnit from vbv_lernwelt.learnpath.models_learning_unit_content import VideoBlock, OnlineTrainingBlock, \ ExerciseBlock, DocumentBlock, ResourceBlock, TestBlock, BookBlock, MediaLibraryBlock, AssignmentBlock @@ -42,12 +41,6 @@ class LearningUnitFactory(wagtail_factories.PageFactory): model = LearningUnit -class LearningUnitQuestionFactory(wagtail_factories.PageFactory): - title = 'Frage zu Lerneinheit' - - class Meta: - model = LearningUnitQuestion - class LearningContentFactory(wagtail_factories.PageFactory): title = 'Lerninhalt' @@ -62,30 +55,35 @@ class VideoBlockFactory(wagtail_factories.StructBlockFactory): class Meta: model = VideoBlock + class AssignmentBlockFactory(wagtail_factories.StructBlockFactory): description = "Beispiel Auftrag" class Meta: model = AssignmentBlock + class BookBlockFactory(wagtail_factories.StructBlockFactory): description = "Beispiel Buch" class Meta: model = BookBlock + class DocumentBlockFactory(wagtail_factories.StructBlockFactory): description = "Beispiel Dokument" class Meta: model = DocumentBlock + class ExerciseBlockFactory(wagtail_factories.StructBlockFactory): description = "Beispiel Übung" class Meta: model = ExerciseBlock + class OnlineTrainingBlockFactory(wagtail_factories.StructBlockFactory): url = "/static/media/web_based_trainings/rise_cmi5_test_export/scormcontent/index.html" description = "Beispiel Rise Modul" @@ -93,20 +91,23 @@ class OnlineTrainingBlockFactory(wagtail_factories.StructBlockFactory): class Meta: model = OnlineTrainingBlock + class TestBlockFactory(wagtail_factories.StructBlockFactory): description = "Beispiel Test" class Meta: model = TestBlock + class ResourceBlockFactory(wagtail_factories.StructBlockFactory): description = "Beispiel Hilfsmittel" class Meta: model = ResourceBlock + class MediaLibraryBlockFactory(wagtail_factories.StructBlockFactory): description = "Beispiel Mediathekeninhalt" class Meta: - model = MediaLibraryBlock \ No newline at end of file + model = MediaLibraryBlock diff --git a/server/vbv_lernwelt/media_library/migrations/0001_initial.py b/server/vbv_lernwelt/media_library/migrations/0001_initial.py index cd117f5b..2bf8dc2c 100644 --- a/server/vbv_lernwelt/media_library/migrations/0001_initial.py +++ b/server/vbv_lernwelt/media_library/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.2.13 on 2022-09-27 14:26 +# Generated by Django 3.2.13 on 2022-09-27 15:23 from django.conf import settings from django.db import migrations, models @@ -17,10 +17,10 @@ class Migration(migrations.Migration): initial = True dependencies = [ + ('taggit', '0004_alter_taggeditem_content_type_alter_taggeditem_tag'), + ('wagtailcore', '0069_log_entry_jsonfield'), ('course', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('wagtailcore', '0069_log_entry_jsonfield'), - ('taggit', '0004_alter_taggeditem_content_type_alter_taggeditem_tag'), ] operations = [