Add course session to feedback model
This commit is contained in:
parent
8f1509d40c
commit
9d848c3f9b
|
|
@ -1,9 +1,8 @@
|
||||||
# Generated by Django 3.2.13 on 2022-12-08 15:59
|
# Generated by Django 3.2.13 on 2022-12-27 14:58
|
||||||
|
|
||||||
import django.core.validators
|
import django.core.validators
|
||||||
import django.db.models.deletion
|
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -12,95 +11,28 @@ class Migration(migrations.Migration):
|
||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
("learnpath", "0009_alter_learningcontent_contents"),
|
('learnpath', '0009_alter_learningcontent_contents'),
|
||||||
|
('course', '0007_coursesessionuser_role'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name="FeedbackResponse",
|
name='FeedbackResponse',
|
||||||
fields=[
|
fields=[
|
||||||
(
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
"id",
|
('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)])),
|
||||||
models.BigAutoField(
|
('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)])),
|
||||||
auto_created=True,
|
('proficiency', models.IntegerField(null=True)),
|
||||||
primary_key=True,
|
('received_materials', models.BooleanField(null=True)),
|
||||||
serialize=False,
|
('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)])),
|
||||||
verbose_name="ID",
|
('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)])),
|
||||||
),
|
('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)])),
|
||||||
),
|
('instructor_open_feedback', models.TextField(blank=True)),
|
||||||
(
|
('would_recommend', models.BooleanField(null=True)),
|
||||||
"satisfaction",
|
('course_positive_feedback', models.TextField(blank=True)),
|
||||||
vbv_lernwelt.feedback.models.FeedbackIntegerField(
|
('course_negative_feedback', models.TextField(blank=True)),
|
||||||
null=True,
|
('circle', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='learnpath.circle')),
|
||||||
validators=[
|
('course_session', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='course.coursesession')),
|
||||||
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)),
|
|
||||||
("received_materials", models.BooleanField(null=True)),
|
|
||||||
(
|
|
||||||
"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),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"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),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"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),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
("instructor_open_feedback", models.TextField(blank=True)),
|
|
||||||
("would_recommend", models.BooleanField(null=True)),
|
|
||||||
("course_positive_feedback", models.TextField(blank=True)),
|
|
||||||
("course_negative_feedback", models.TextField(blank=True)),
|
|
||||||
(
|
|
||||||
"circle",
|
|
||||||
models.ForeignKey(
|
|
||||||
on_delete=django.db.models.deletion.PROTECT,
|
|
||||||
to="learnpath.circle",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -50,3 +50,4 @@ class FeedbackResponse(models.Model):
|
||||||
course_negative_feedback = models.TextField(blank=True)
|
course_negative_feedback = models.TextField(blank=True)
|
||||||
|
|
||||||
circle = models.ForeignKey("learnpath.Circle", models.PROTECT)
|
circle = models.ForeignKey("learnpath.Circle", models.PROTECT)
|
||||||
|
course_session = models.ForeignKey("course.CourseSession", models.PROTECT)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import structlog
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from wagtail.models import Page
|
from wagtail.models import Page
|
||||||
|
|
||||||
|
from vbv_lernwelt.course.models import CourseSession
|
||||||
from vbv_lernwelt.feedback.models import FeedbackResponse
|
from vbv_lernwelt.feedback.models import FeedbackResponse
|
||||||
|
|
||||||
logger = structlog.get_logger(__name__)
|
logger = structlog.get_logger(__name__)
|
||||||
|
|
@ -9,6 +10,7 @@ logger = structlog.get_logger(__name__)
|
||||||
|
|
||||||
class FeedbackResponseSerializer(serializers.ModelSerializer):
|
class FeedbackResponseSerializer(serializers.ModelSerializer):
|
||||||
page = serializers.CharField(write_only=True)
|
page = serializers.CharField(write_only=True)
|
||||||
|
course_session = serializers.CharField(write_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = FeedbackResponse
|
model = FeedbackResponse
|
||||||
|
|
@ -18,9 +20,13 @@ class FeedbackResponseSerializer(serializers.ModelSerializer):
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
logger.info("creating feedback")
|
logger.info("creating feedback")
|
||||||
page_key = validated_data.pop("page")
|
page_key = validated_data.pop("page")
|
||||||
|
course_session_id = validated_data.pop("course_session")
|
||||||
|
|
||||||
learning_content = Page.objects.get(
|
learning_content = Page.objects.get(
|
||||||
translation_key=page_key, locale__language_code="de-CH"
|
translation_key=page_key, locale__language_code="de-CH"
|
||||||
)
|
)
|
||||||
circle = learning_content.get_parent().specific
|
circle = learning_content.get_parent().specific
|
||||||
return FeedbackResponse.objects.create(**validated_data, circle=circle)
|
course_session = CourseSession.objects.get(id=course_session_id)
|
||||||
|
return FeedbackResponse.objects.create(
|
||||||
|
**validated_data, circle=circle, course_session=course_session
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue