Update Feedback model, add Wagtail block
This commit is contained in:
parent
69fc7f7dbb
commit
5e559b66b0
|
|
@ -1,7 +0,0 @@
|
||||||
from vbv_lernwelt.feedback.models import Motivation
|
|
||||||
from django.contrib.admin import ModelAdmin, register
|
|
||||||
|
|
||||||
|
|
||||||
@register(Motivation)
|
|
||||||
class MotivationAdmin(ModelAdmin):
|
|
||||||
pass
|
|
||||||
|
|
@ -1,13 +1,9 @@
|
||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
from vbv_lernwelt.feedback.models import Feedback
|
from vbv_lernwelt.feedback.models import FeedbackResponse
|
||||||
|
|
||||||
|
|
||||||
class FeedbackForm(forms.ModelForm):
|
class FeedbackForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Feedback
|
model = FeedbackResponse
|
||||||
fields = "__all__"
|
fields = "__all__"
|
||||||
|
|
||||||
|
|
||||||
class NameForm(forms.Form):
|
|
||||||
your_name = forms.CharField(label="Your name", max_length=100)
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
from graphene_django.rest_framework.mutation import SerializerMutation
|
from graphene_django.rest_framework.mutation import SerializerMutation
|
||||||
|
import graphene
|
||||||
|
|
||||||
from vbv_lernwelt.feedback.serializers import FeedbackSerializer
|
from vbv_lernwelt.feedback.serializers import FeedbackResponseSerializer
|
||||||
|
|
||||||
|
|
||||||
class SendFeedback(SerializerMutation):
|
class SendFeedback(SerializerMutation):
|
||||||
# feedback = graphene.Field(FeedbackType)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
# form_class = FeedbackForm
|
serializer_class = FeedbackResponseSerializer
|
||||||
serializer_class = FeedbackSerializer
|
model_operations = ["create"]
|
||||||
|
|
||||||
|
|
||||||
class Mutation(object):
|
class Mutation(object):
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
# Generated by Django 3.2.13 on 2022-11-17 16:13
|
# Generated by Django 3.2.13 on 2022-12-08 11:22
|
||||||
|
|
||||||
import django.core.validators
|
import django.core.validators
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
import vbv_lernwelt.feedback.models
|
import vbv_lernwelt.feedback.models
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -10,33 +11,26 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
('learnpath', '0009_alter_learningcontent_contents'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Motivation',
|
name='FeedbackResponse',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('title', models.CharField(max_length=50)),
|
('satisfaction', vbv_lernwelt.feedback.models.FeedbackIntegerField(null=True, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4), django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4)])),
|
||||||
],
|
('goal_attainment', vbv_lernwelt.feedback.models.FeedbackIntegerField(null=True, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4), django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4)])),
|
||||||
),
|
('proficiency', models.IntegerField(null=True)),
|
||||||
migrations.CreateModel(
|
('received_materials', models.NullBooleanField()),
|
||||||
name='Feedback',
|
('materials_rating', vbv_lernwelt.feedback.models.FeedbackIntegerField(null=True, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4), django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4)])),
|
||||||
fields=[
|
('instructor_competence', vbv_lernwelt.feedback.models.FeedbackIntegerField(null=True, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4), django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4)])),
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('instructor_respect', vbv_lernwelt.feedback.models.FeedbackIntegerField(null=True, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4), django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4)])),
|
||||||
('satisfaction', vbv_lernwelt.feedback.models.FeedbackIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4), django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4)])),
|
('instructor_open_feedback', models.TextField(blank=True)),
|
||||||
('goal_attainment', vbv_lernwelt.feedback.models.FeedbackIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4), django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4)])),
|
('would_recommend', models.NullBooleanField()),
|
||||||
('proficiency', models.IntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(5)])),
|
('course_positive_feedback', models.TextField(blank=True)),
|
||||||
('received_materials', models.BooleanField()),
|
('course_negative_feedback', models.TextField(blank=True)),
|
||||||
('materials_rating', vbv_lernwelt.feedback.models.FeedbackIntegerField(blank=True, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4), django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4)])),
|
('circle', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='learnpath.circle')),
|
||||||
('instructor_competence', vbv_lernwelt.feedback.models.FeedbackIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4), django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4)])),
|
|
||||||
('instructor_respect', vbv_lernwelt.feedback.models.FeedbackIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4), django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4)])),
|
|
||||||
('instructor_open_feedback', models.TextField()),
|
|
||||||
('would_recommend', models.BooleanField()),
|
|
||||||
('course_positive_feedback', models.TextField()),
|
|
||||||
('course_negative_feedback', models.TextField()),
|
|
||||||
('how_discovered', models.CharField(choices=[('I', 'Internet'), ('L', 'Leaflet'), ('N', 'Newspaper'), ('R', 'Personal recommendation'), ('E', 'Public event'), ('O', 'Other')], max_length=1)),
|
|
||||||
('motivation', models.ManyToManyField(to='feedback.Motivation')),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -7,20 +7,15 @@ from django.utils.translation import gettext_lazy as _
|
||||||
class FeedbackIntegerField(models.IntegerField):
|
class FeedbackIntegerField(models.IntegerField):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
validators = kwargs.pop("validators", [])
|
validators = kwargs.pop("validators", [])
|
||||||
|
nullable = kwargs.pop("null", True)
|
||||||
super().__init__(
|
super().__init__(
|
||||||
validators=validators + [MinValueValidator(1), MaxValueValidator(4)],
|
validators=validators + [MinValueValidator(1), MaxValueValidator(4)],
|
||||||
|
null=nullable,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Motivation(models.Model):
|
class FeedbackResponse(models.Model):
|
||||||
title = models.CharField(max_length=50)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.title
|
|
||||||
|
|
||||||
|
|
||||||
class Feedback(models.Model):
|
|
||||||
class DiscoveredChoices(models.TextChoices):
|
class DiscoveredChoices(models.TextChoices):
|
||||||
INTERNET = "I", _("Internet")
|
INTERNET = "I", _("Internet")
|
||||||
LEAFLET = "L", _("Leaflet")
|
LEAFLET = "L", _("Leaflet")
|
||||||
|
|
@ -44,14 +39,14 @@ class Feedback(models.Model):
|
||||||
|
|
||||||
satisfaction = FeedbackIntegerField()
|
satisfaction = FeedbackIntegerField()
|
||||||
goal_attainment = FeedbackIntegerField()
|
goal_attainment = FeedbackIntegerField()
|
||||||
proficiency = models.IntegerField()
|
proficiency = models.IntegerField(null=True)
|
||||||
received_materials = models.BooleanField()
|
received_materials = models.NullBooleanField()
|
||||||
materials_rating = FeedbackIntegerField(blank=True)
|
materials_rating = FeedbackIntegerField()
|
||||||
instructor_competence = FeedbackIntegerField()
|
instructor_competence = FeedbackIntegerField()
|
||||||
instructor_respect = FeedbackIntegerField()
|
instructor_respect = FeedbackIntegerField()
|
||||||
instructor_open_feedback = models.TextField()
|
instructor_open_feedback = models.TextField(blank=True)
|
||||||
would_recommend = models.BooleanField()
|
would_recommend = models.NullBooleanField()
|
||||||
course_positive_feedback = models.TextField()
|
course_positive_feedback = models.TextField(blank=True)
|
||||||
course_negative_feedback = models.TextField()
|
course_negative_feedback = models.TextField(blank=True)
|
||||||
how_discovered = models.CharField(max_length=1)
|
|
||||||
motivation = models.ManyToManyField(Motivation)
|
circle = models.ForeignKey("learnpath.Circle", models.PROTECT)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,26 @@
|
||||||
|
import structlog
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
from wagtail.models import Page
|
||||||
|
|
||||||
from vbv_lernwelt.feedback.models import Feedback
|
from vbv_lernwelt.feedback.models import FeedbackResponse
|
||||||
|
|
||||||
|
logger = structlog.get_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class FeedbackSerializer(serializers.ModelSerializer):
|
class FeedbackResponseSerializer(serializers.ModelSerializer):
|
||||||
|
page = serializers.CharField(write_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Feedback
|
model = FeedbackResponse
|
||||||
fields = "__all__"
|
exclude = ["circle"]
|
||||||
|
# extra_kwargs = {"course", {"read_only": True}}
|
||||||
|
|
||||||
|
def create(self, validated_data):
|
||||||
|
logger.info("creating feedback")
|
||||||
|
page_key = validated_data.pop("page")
|
||||||
|
|
||||||
|
learning_content = Page.objects.get(
|
||||||
|
translation_key=page_key, locale__language_code="de-CH"
|
||||||
|
)
|
||||||
|
circle = learning_content.get_parent().specific
|
||||||
|
return FeedbackResponse.objects.create(**validated_data, circle=circle)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 3.2.13 on 2022-12-08 09:55
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
import wagtail.blocks
|
||||||
|
import wagtail.fields
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('learnpath', '0008_alter_learningcontent_contents'),
|
||||||
|
]
|
||||||
|
|
||||||
|
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([]))], use_json_field=None),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -14,7 +14,7 @@ from vbv_lernwelt.learnpath.models_learning_unit_content import (
|
||||||
BookBlock,
|
BookBlock,
|
||||||
DocumentBlock,
|
DocumentBlock,
|
||||||
ExerciseBlock,
|
ExerciseBlock,
|
||||||
LearningModuleBlock,
|
FeedbackBlock, LearningModuleBlock,
|
||||||
MediaLibraryBlock,
|
MediaLibraryBlock,
|
||||||
OnlineTrainingBlock,
|
OnlineTrainingBlock,
|
||||||
PlaceholderBlock,
|
PlaceholderBlock,
|
||||||
|
|
@ -267,6 +267,7 @@ class LearningContent(CourseBasePage):
|
||||||
("book", BookBlock()),
|
("book", BookBlock()),
|
||||||
("assignment", AssignmentBlock()),
|
("assignment", AssignmentBlock()),
|
||||||
("placeholder", PlaceholderBlock()),
|
("placeholder", PlaceholderBlock()),
|
||||||
|
("feedback", FeedbackBlock()),
|
||||||
]
|
]
|
||||||
|
|
||||||
contents = StreamField(
|
contents = StreamField(
|
||||||
|
|
|
||||||
|
|
@ -90,3 +90,8 @@ class PlaceholderBlock(blocks.StructBlock):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
icon = "media"
|
icon = "media"
|
||||||
|
|
||||||
|
|
||||||
|
class FeedbackBlock(blocks.StructBlock):
|
||||||
|
class Meta:
|
||||||
|
icon = "media"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue