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.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
import django.db.models.deletion
|
||||
import vbv_lernwelt.feedback.models
|
||||
|
||||
|
||||
|
|
@ -12,95 +11,28 @@ class Migration(migrations.Migration):
|
|||
initial = True
|
||||
|
||||
dependencies = [
|
||||
("learnpath", "0009_alter_learningcontent_contents"),
|
||||
('learnpath', '0009_alter_learningcontent_contents'),
|
||||
('course', '0007_coursesessionuser_role'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="FeedbackResponse",
|
||||
name='FeedbackResponse',
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="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),
|
||||
],
|
||||
),
|
||||
),
|
||||
(
|
||||
"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",
|
||||
),
|
||||
),
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='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)])),
|
||||
('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')),
|
||||
('course_session', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='course.coursesession')),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -50,3 +50,4 @@ class FeedbackResponse(models.Model):
|
|||
course_negative_feedback = models.TextField(blank=True)
|
||||
|
||||
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 wagtail.models import Page
|
||||
|
||||
from vbv_lernwelt.course.models import CourseSession
|
||||
from vbv_lernwelt.feedback.models import FeedbackResponse
|
||||
|
||||
logger = structlog.get_logger(__name__)
|
||||
|
|
@ -9,6 +10,7 @@ logger = structlog.get_logger(__name__)
|
|||
|
||||
class FeedbackResponseSerializer(serializers.ModelSerializer):
|
||||
page = serializers.CharField(write_only=True)
|
||||
course_session = serializers.CharField(write_only=True)
|
||||
|
||||
class Meta:
|
||||
model = FeedbackResponse
|
||||
|
|
@ -18,9 +20,13 @@ class FeedbackResponseSerializer(serializers.ModelSerializer):
|
|||
def create(self, validated_data):
|
||||
logger.info("creating feedback")
|
||||
page_key = validated_data.pop("page")
|
||||
course_session_id = validated_data.pop("course_session")
|
||||
|
||||
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)
|
||||
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