vbv/server/vbv_lernwelt/assignment/models.py

105 lines
2.5 KiB
Python

from django.db import models
from wagtail import blocks
from wagtail.admin.panels import FieldPanel
from wagtail.fields import StreamField
from wagtail.models import Page
# class AssignmentSubmission(modModel):
# created_at = models.DateTimeField(auto_now_add=True)
class ExplanationBlock(blocks.StructBlock):
text = blocks.TextBlock()
class Meta:
icon = "comment"
class PerformanceObjectiveBlock(blocks.StructBlock):
text = blocks.TextBlock()
class Meta:
icon = "tick"
class UserTextInputBlock(blocks.StaticBlock):
class Meta:
icon = "edit"
class UserConfirmationBlock(blocks.StructBlock):
text = blocks.TextBlock()
class Meta:
icon = "tick-inverse"
class TaskBlock(blocks.StructBlock):
title = blocks.TextBlock()
file_submission_required = blocks.BooleanBlock(required=False)
content = blocks.StreamBlock(
[
("explanation", ExplanationBlock()),
("user_text_input", UserTextInputBlock()),
("user_confirmation", UserConfirmationBlock()),
],
blank=True,
)
class Meta:
icon = "tasks"
label = "Teilauftrag"
class Assignment(Page):
starting_position = models.TextField(help_text="Erläuterung der Ausgangslage")
effort_required = models.CharField(
max_length=100, help_text="Zeitaufwand als Text", blank=True
)
performance_objectives = StreamField(
[
("performance_objective", PerformanceObjectiveBlock()),
],
use_json_field=True,
blank=True,
help_text="Leistungsziele des Auftrags",
)
assessment_description = models.TextField(
blank=True, help_text="Beschreibung der Bewertung"
)
assessment_document_url = models.CharField(
max_length=255,
blank=True,
help_text="URL zum Beeurteilungsinstrument",
)
tasks = StreamField(
[
("task", TaskBlock()),
],
use_json_field=True,
blank=True,
help_text="Teilaufgaben",
)
content_panels = Page.content_panels + [
FieldPanel("starting_position"),
FieldPanel("effort_required"),
FieldPanel("performance_objectives"),
FieldPanel("assessment_description"),
FieldPanel("assessment_document_url"),
FieldPanel("tasks"),
]
subpage_types = []
class Meta:
verbose_name = "Auftrag"
class AssignmentListPage(Page):
subpage_types = ["assignment.Assignment"]
parent_page_types = ["course.CoursePage"]