Serialize LearningPath with PerformanceCriteria
This commit is contained in:
parent
5284d6f1cf
commit
9be2fa0d3a
|
|
@ -15,19 +15,19 @@ def create_default_competence_profile():
|
|||
|
||||
PerformanceCriteriaFactory(
|
||||
parent=competence_profile_page,
|
||||
pc_id='B1.3 Fahrzeug',
|
||||
competence_id='B1.3',
|
||||
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,
|
||||
pc_id='B2.1 Fahrzeug',
|
||||
competence_id='B2.1',
|
||||
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,
|
||||
pc_id='B2.2 Fahrzeug',
|
||||
competence_id='B2.2',
|
||||
title='Innerhalb des Handlungsfelds «Fahrzeug» bin ich fähig, die Risiken aufzuzeigen.',
|
||||
learning_unit=LearningUnit.objects.get(slug='versicherungsvermittlerin-lp-circle-analyse-lu-fahrzeug'),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class CompetenceProfilePageFactory(wagtail_factories.PageFactory):
|
|||
|
||||
|
||||
class PerformanceCriteriaFactory(wagtail_factories.PageFactory):
|
||||
pc_id = 'A.1'
|
||||
competence_id = 'A.1'
|
||||
title = 'Bestehende Kunden so zu beraten, dass sie von diesen weiterempfohlen werden'
|
||||
|
||||
class Meta:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 3.2.13 on 2022-09-27 15:49
|
||||
# Generated by Django 3.2.13 on 2022-09-28 10:30
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
|
@ -9,7 +9,6 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('learnpath', '0001_initial'),
|
||||
('wagtailcore', '0069_log_entry_jsonfield'),
|
||||
]
|
||||
|
||||
|
|
@ -28,8 +27,7 @@ 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')),
|
||||
('pc_id', models.TextField(default='')),
|
||||
('learning_unit', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='learnpath.learningunit')),
|
||||
('competence_id', models.TextField(default='')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
# Generated by Django 3.2.13 on 2022-09-28 10:30
|
||||
|
||||
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'),
|
||||
),
|
||||
]
|
||||
|
|
@ -32,7 +32,7 @@ class CompetenceProfilePage(Page):
|
|||
|
||||
class PerformanceCriteria(Page):
|
||||
parent_page_types = ['competence.CompetenceProfilePage']
|
||||
pc_id = models.TextField(default='')
|
||||
competence_id = models.TextField(default='')
|
||||
learning_unit = models.ForeignKey(
|
||||
'learnpath.LearningUnit',
|
||||
null=True,
|
||||
|
|
@ -42,12 +42,16 @@ class PerformanceCriteria(Page):
|
|||
|
||||
content_panels = [
|
||||
FieldPanel('title'),
|
||||
FieldPanel('pc_id'),
|
||||
FieldPanel('competence_id'),
|
||||
FieldPanel('learning_unit'),
|
||||
]
|
||||
|
||||
def full_clean(self, *args, **kwargs):
|
||||
self.slug = find_available_slug(slugify(f"{self.get_parent()}-crit-{self.title}", allow_unicode=True))
|
||||
profile_parent = self.get_ancestors().exact_type(CompetenceProfilePage).last()
|
||||
if self.learning_unit and self.learning_unit.course_category:
|
||||
self.slug = find_available_slug(slugify(f"{profile_parent.slug}-crit-{self.competence_id}-{self.learning_unit.course_category.title}", allow_unicode=True))
|
||||
else:
|
||||
self.slug = find_available_slug(slugify(f"{profile_parent.slug}-crit-{self.competence_id}", allow_unicode=True))
|
||||
super(PerformanceCriteria, self).full_clean(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
|
|
@ -56,4 +60,7 @@ class PerformanceCriteria(Page):
|
|||
return PerformanceCriteriaSerializer
|
||||
|
||||
def get_admin_display_title(self):
|
||||
return f'{self.pc_id} {self.draft_title[:30]}'
|
||||
if self.learning_unit and self.learning_unit.course_category:
|
||||
return f'{self.competence_id} ({self.learning_unit.course_category.title}) {self.draft_title[:30]}'
|
||||
else:
|
||||
return f'{self.competence_id} {self.draft_title[:30]}'
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
from rest_framework import serializers
|
||||
|
||||
from vbv_lernwelt.competence.models import PerformanceCriteria
|
||||
from vbv_lernwelt.course.serializers import CourseCategorySerializer
|
||||
from vbv_lernwelt.learnpath.models import LearningUnit
|
||||
from vbv_lernwelt.learnpath.serializer_helpers import get_it_serializer_class
|
||||
|
||||
|
||||
class PerformanceCriteriaSerializer(get_it_serializer_class(PerformanceCriteria, [
|
||||
'id', 'title', 'slug', 'type', 'translation_key',
|
||||
'pc_id', 'learning_unit', 'circle',
|
||||
'competence_id', 'learning_unit', 'circle', 'course_category',
|
||||
])):
|
||||
learning_unit = serializers.SerializerMethodField()
|
||||
circle = serializers.SerializerMethodField()
|
||||
course_category = serializers.SerializerMethodField()
|
||||
|
||||
def get_learning_unit(self, obj):
|
||||
learning_unit_serializer = get_it_serializer_class(LearningUnit, [
|
||||
|
|
@ -21,8 +23,13 @@ class PerformanceCriteriaSerializer(get_it_serializer_class(PerformanceCriteria,
|
|||
def get_circle(self, obj):
|
||||
return obj.learning_unit.get_parent().specific.title
|
||||
|
||||
def get_course_category(self, obj):
|
||||
if obj.learning_unit:
|
||||
return CourseCategorySerializer(obj.learning_unit.course_category).data
|
||||
return None
|
||||
|
||||
|
||||
class PerformanceCriteriaLearningPathSerializer(get_it_serializer_class(PerformanceCriteria, [
|
||||
'id', 'title', 'slug', 'type', 'translation_key', 'pc_id',
|
||||
'id', 'title', 'slug', 'type', 'translation_key', 'competence_id',
|
||||
])):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 3.2.13 on 2022-09-27 15:23
|
||||
# Generated by Django 3.2.13 on 2022-09-28 10:30
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
|
@ -12,8 +12,8 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('wagtailcore', '0069_log_entry_jsonfield'),
|
||||
('course', '0001_initial'),
|
||||
('wagtailcore', '0069_log_entry_jsonfield'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 3.2.13 on 2022-09-27 15:23
|
||||
# Generated by Django 3.2.13 on 2022-09-28 10:30
|
||||
|
||||
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 = [
|
||||
|
|
|
|||
Loading…
Reference in New Issue