diff --git a/client/src/components/ContentBlock.vue b/client/src/components/ContentBlock.vue
index 68e4f529..96de4b8d 100644
--- a/client/src/components/ContentBlock.vue
+++ b/client/src/components/ContentBlock.vue
@@ -44,6 +44,7 @@
import SubtitleBlock from '@/components/content-blocks/SubtitleBlock';
import ContentListBlock from '@/components/content-blocks/ContentListBlock';
import Assignment from '@/components/content-blocks/assignment/Assignment';
+ import Survey from '@/components/content-blocks/SurveyBlock';
import Solution from '@/components/content-blocks/Solution';
import AddContentBlockButton from '@/components/AddContentBlockButton';
import VisibilityAction from '@/components/visibility/VisibilityAction';
@@ -76,6 +77,7 @@
'genially_block': GeniallyBlock,
'subtitle': SubtitleBlock,
'content_list': ContentListBlock,
+ Survey,
Solution,
Assignment,
Task,
diff --git a/client/src/components/content-blocks/SurveyBlock.vue b/client/src/components/content-blocks/SurveyBlock.vue
new file mode 100644
index 00000000..aebb695f
--- /dev/null
+++ b/client/src/components/content-blocks/SurveyBlock.vue
@@ -0,0 +1,21 @@
+
+
+ Übung anzeigen
+
+
+
+
+
+
+
diff --git a/client/src/components/content-blocks/assignment/Assignment.vue b/client/src/components/content-blocks/assignment/Assignment.vue
index f0ff281c..cd734dc1 100644
--- a/client/src/components/content-blocks/assignment/Assignment.vue
+++ b/client/src/components/content-blocks/assignment/Assignment.vue
@@ -43,7 +43,7 @@
- Zu den Ergebnissen
+ Zu den Ergebnissen
diff --git a/client/src/router/index.js b/client/src/router/index.js
index 0d101a35..1b2f2a5b 100644
--- a/client/src/router/index.js
+++ b/client/src/router/index.js
@@ -90,6 +90,7 @@ const routes = [
{
path: '/survey/:id',
component: surveyPage,
+ name: 'survey',
props: true
},
{path: '/styleguide', component: styleGuidePage},
diff --git a/server/api/graphene_wagtail.py b/server/api/graphene_wagtail.py
index ff87dc5c..a01eccf5 100644
--- a/server/api/graphene_wagtail.py
+++ b/server/api/graphene_wagtail.py
@@ -10,6 +10,7 @@ from wagtail.images.models import Image
from assignments.models import Assignment
from basicknowledge.models import BasicKnowledge
+from surveys.models import Survey
logger = logging.getLogger(__name__)
@@ -49,6 +50,18 @@ def augment_fields(stream_data):
data['value'] = value
except Assignment.DoesNotExist:
logger.error('Assignment {} does not exist'.format(assignment_id))
+ if _type == 'survey':
+ _value = data['value']
+ survey_id = _value['survey_id']
+ try:
+ survey = Survey.objects.get(pk=survey_id)
+ value = {
+ 'title': survey.title,
+ 'id': to_global_id('SurveyNode', survey.pk)
+ }
+ data['value'] = value
+ except Survey.DoesNotExist:
+ logger.error('Survey {} does not exist'.format(survey_id))
if _type == 'basic_knowledge' or _type == 'instrument':
_value = data['value']
basic_knowledge = BasicKnowledge.objects.get(pk=_value['basic_knowledge'])
diff --git a/server/books/blocks.py b/server/books/blocks.py
index a9383b0a..585157fc 100644
--- a/server/books/blocks.py
+++ b/server/books/blocks.py
@@ -2,10 +2,12 @@ from wagtail.core import blocks
from wagtail.snippets.blocks import SnippetChooserBlock
from assignments.models import Assignment
+from surveys.models import Survey
DEFAULT_RICH_TEXT_FEATURES = ['ul']
INSTRUMENTS_RICH_TEXT_FEATURES = ['bold', 'ul']
+
# link_block
class LinkBlock(blocks.StructBlock):
class Meta:
@@ -49,6 +51,14 @@ class AssignmentBlock(blocks.StructBlock):
assignment_id = SnippetChooserBlock(Assignment)
+# 'survey'
+class SurveyBlock(blocks.StructBlock):
+ class Meta:
+ icon = 'form'
+
+ survey_id = SnippetChooserBlock(Survey)
+
+
# 'video_block'
class VideoBlock(blocks.StructBlock):
class Meta:
diff --git a/server/books/models/contentblock.py b/server/books/models/contentblock.py
index e59427e3..95a3ef80 100644
--- a/server/books/models/contentblock.py
+++ b/server/books/models/contentblock.py
@@ -7,7 +7,7 @@ from wagtail.core.fields import StreamField
from wagtail.images.blocks import ImageChooserBlock
from books.blocks import TextBlock, BasicKnowledgeBlock, LinkBlock, VideoBlock, DocumentBlock, \
- ImageUrlBlock, AssignmentBlock, InfogramBlock, GeniallyBlock, SubtitleBlock
+ ImageUrlBlock, AssignmentBlock, InfogramBlock, GeniallyBlock, SubtitleBlock, SurveyBlock
from core.wagtail_utils import StrictHierarchyPage
from users.models import SchoolClass
@@ -39,6 +39,7 @@ class ContentBlock(StrictHierarchyPage):
('text_block', TextBlock()),
('basic_knowledge', BasicKnowledgeBlock()),
('assignment', AssignmentBlock()),
+ ('survey', SurveyBlock()),
('image_block', ImageChooserBlock()),
('image_url_block', ImageUrlBlock()),
('link_block', LinkBlock()),
diff --git a/server/surveys/models.py b/server/surveys/models.py
index 1f137f71..4ce0e4e7 100644
--- a/server/surveys/models.py
+++ b/server/surveys/models.py
@@ -1,8 +1,10 @@
from django.contrib.auth import get_user_model
from django.db import models
from django.contrib.postgres.fields import JSONField
+from wagtail.snippets.models import register_snippet
+@register_snippet
class Survey(models.Model):
title = models.CharField(max_length=255)
data = JSONField()