91 lines
2.1 KiB
Python
91 lines
2.1 KiB
Python
from django.db import models
|
|
from django.db.models import Model, TextField
|
|
from wagtail import blocks
|
|
from wagtail.admin.panels import FieldPanel
|
|
from wagtail.blocks import StreamBlock
|
|
from wagtail.fields import StreamField
|
|
from wagtail.models import Page
|
|
|
|
|
|
class AssignmentSubmission(Model):
|
|
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.CharBlock()
|
|
file_submission_required = blocks.BooleanBlock()
|
|
content = StreamBlock(
|
|
[
|
|
("explanation", ExplanationBlock()),
|
|
("user_text_input", UserTextInputBlock()),
|
|
("user_confirmation", UserConfirmationBlock()),
|
|
],
|
|
use_json_field=True,
|
|
)
|
|
|
|
class Meta:
|
|
icon = "tasks"
|
|
label = "Teilauftrag"
|
|
|
|
|
|
class Assignment(Page):
|
|
starting_position = TextField()
|
|
performance_objectives = StreamField(
|
|
[
|
|
("performance_objective", PerformanceObjectiveBlock()),
|
|
],
|
|
use_json_field=True,
|
|
)
|
|
effort_required = TextField()
|
|
assessment_document_url = TextField()
|
|
tasks = StreamField(
|
|
[
|
|
("task", TaskBlock()),
|
|
],
|
|
use_json_field=True,
|
|
)
|
|
|
|
content_panels = Page.content_panels + [
|
|
FieldPanel("starting_position"),
|
|
FieldPanel("performance_objectives"),
|
|
FieldPanel("effort_required"),
|
|
FieldPanel("assessment_document_url"),
|
|
FieldPanel("tasks"),
|
|
]
|
|
|
|
subpage_types = []
|
|
|
|
class Meta:
|
|
verbose_name = "Auftrag"
|
|
|
|
|
|
class AssignmentPage(Page):
|
|
subpage_types = ["assignment.Assignment"]
|
|
parent_page_types = ["course.CoursePage"]
|