Create test assignment with tasks in code
This commit is contained in:
parent
539ddbeaf9
commit
13b580468d
|
|
@ -540,7 +540,7 @@ wagtail==3.0.1
|
|||
# wagtail-grapple
|
||||
# wagtail-headless-preview
|
||||
# wagtail-localize
|
||||
wagtail-factories==2.0.1
|
||||
wagtail-factories==4.0.0
|
||||
# via -r requirements.in
|
||||
wagtail-grapple==0.18.0
|
||||
# via -r requirements.in
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ python-json-logger
|
|||
concurrent-log-handler
|
||||
|
||||
wagtail>=3,<4
|
||||
wagtail-factories
|
||||
wagtail-factories>=4
|
||||
wagtail-localize
|
||||
wagtail_grapple
|
||||
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ wagtail==3.0.1
|
|||
# wagtail-grapple
|
||||
# wagtail-headless-preview
|
||||
# wagtail-localize
|
||||
wagtail-factories==2.0.1
|
||||
wagtail-factories==4.0.0
|
||||
# via -r requirements.in
|
||||
wagtail-grapple==0.18.0
|
||||
# via -r requirements.in
|
||||
|
|
|
|||
|
|
@ -1,11 +1,17 @@
|
|||
from wagtail_factories import StreamFieldFactory
|
||||
from wagtail.blocks import StreamValue
|
||||
|
||||
from vbv_lernwelt.assignment.models import (
|
||||
TaskContentStreamBlock,
|
||||
)
|
||||
from vbv_lernwelt.assignment.tests.assignment_factories import (
|
||||
PerformanceObjectiveBlockFactory,
|
||||
AssignmentListPageFactory,
|
||||
AssignmentFactory,
|
||||
TaskBlockFactory,
|
||||
ExplanationBlockFactory,
|
||||
UserTextInputBlockFactory,
|
||||
)
|
||||
from vbv_lernwelt.core.utils import replace_whitespace
|
||||
from vbv_lernwelt.course.consts import COURSE_UK
|
||||
from vbv_lernwelt.course.models import CoursePage
|
||||
|
||||
|
|
@ -15,15 +21,268 @@ def create_assignments():
|
|||
assignment_page = AssignmentListPageFactory(
|
||||
parent=course_page,
|
||||
)
|
||||
AssignmentFactory(
|
||||
|
||||
assignment = AssignmentFactory(
|
||||
parent=assignment_page,
|
||||
title="Auftrag 1",
|
||||
performance_objectives=StreamFieldFactory(
|
||||
{
|
||||
"performance_objective": PerformanceObjectiveBlockFactory(),
|
||||
}
|
||||
title="Überprüfen einer Motorfahrzeugs-Versicherungspolice",
|
||||
effort_required="ca. 5 Stunden",
|
||||
starting_position=replace_whitespace(
|
||||
"""
|
||||
Jemand aus deiner Familie oder aus deinem Freundeskreis möchte sein
|
||||
Versicherungspolice überprüfen lassen. Diese Person kommt nun mit ihrer Police auf dich zu
|
||||
und bittet dich als Versicherungsprofi, diese kritisch zu überprüfen und ihr ggf. Anpassungsvorschläge
|
||||
zu unterbreiten. In diesem Kompetenznachweis kannst du nun dein Wissen und Können im Bereich
|
||||
der Motorfahrzeugversicherung unter Beweis stellen.
|
||||
"""
|
||||
),
|
||||
effort_required="1 - 2 Stunden",
|
||||
performance_objectives=[
|
||||
(
|
||||
"performance_objective",
|
||||
PerformanceObjectiveBlockFactory(
|
||||
text="Sie erläutern die Leistungen und Produkte im Versicherungsbereich."
|
||||
),
|
||||
),
|
||||
(
|
||||
"performance_objective",
|
||||
PerformanceObjectiveBlockFactory(
|
||||
text="Sie beurteilen gängige Versicherungslösungen fachkundig."
|
||||
),
|
||||
),
|
||||
],
|
||||
assessment_document_url="https://www.vbv.ch",
|
||||
tasks=StreamFieldFactory({"task": TaskBlockFactory()}),
|
||||
assessment_description="Diese geleitete Fallarbeit wird auf Grund des folgenden Beurteilungsintrument bewertet.",
|
||||
)
|
||||
|
||||
assignment.tasks = []
|
||||
assignment.tasks.append(
|
||||
(
|
||||
"task",
|
||||
TaskBlockFactory(
|
||||
title="Teilaufgabe 1: Beispiel einer Versicherungspolice finden",
|
||||
# it is hard to create a StreamValue programmatically, we have to
|
||||
# create a `StreamValue` manually. Ask the Daniel and/or Ramon
|
||||
content=StreamValue(
|
||||
TaskContentStreamBlock(),
|
||||
stream_data=[
|
||||
(
|
||||
"explanation",
|
||||
ExplanationBlockFactory(text="Dies ist ein Beispieltext."),
|
||||
),
|
||||
(
|
||||
"user_confirmation",
|
||||
ExplanationBlockFactory(
|
||||
text="Ja, ich habe Motorfahrzeugversicherungspolice von jemandem aus meiner Familie oder meinem Freundeskreis erhalten."
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
assignment.tasks.append(
|
||||
(
|
||||
"task",
|
||||
TaskBlockFactory(
|
||||
title="Teilaufgabe 2: Kundensituation und Ausgangslage",
|
||||
content=StreamValue(
|
||||
TaskContentStreamBlock(),
|
||||
stream_data=[
|
||||
(
|
||||
"explanation",
|
||||
ExplanationBlockFactory(
|
||||
text=replace_whitespace(
|
||||
"""
|
||||
Erläutere die Kundensituation und die Ausgangslage.
|
||||
* Hast du alle Informationen, die du für den Policen-Check benötigst?
|
||||
* Halte die wichtigsten Eckwerte des aktuellen Versicherungsverhältnisse in deiner Dokumentation fest (z.B wie lang wo versichert, Alter des Fahrzeugs, Kundenprofil, etc.)
|
||||
"""
|
||||
)
|
||||
),
|
||||
),
|
||||
("user_text_input", UserTextInputBlockFactory()),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
assignment.tasks.append(
|
||||
(
|
||||
"task",
|
||||
TaskBlockFactory(
|
||||
title="Teilaufgabe 3: Aktuelle Versicherung",
|
||||
# TODO: add document upload
|
||||
content=StreamValue(
|
||||
TaskContentStreamBlock(),
|
||||
stream_data=[
|
||||
(
|
||||
"explanation",
|
||||
ExplanationBlockFactory(
|
||||
text=replace_whitespace(
|
||||
"""
|
||||
Zeige nun detailliert auf, wie dein Kundenbeispiel momentan versichert ist.
|
||||
"""
|
||||
)
|
||||
),
|
||||
),
|
||||
("user_text_input", UserTextInputBlockFactory()),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
assignment.tasks.append(
|
||||
(
|
||||
"task",
|
||||
TaskBlockFactory(
|
||||
title="Teilaufgabe 4: Deine Empfehlungen",
|
||||
content=StreamValue(
|
||||
TaskContentStreamBlock(),
|
||||
stream_data=[
|
||||
(
|
||||
"explanation",
|
||||
ExplanationBlockFactory(
|
||||
text=replace_whitespace(
|
||||
"""
|
||||
Erarbeite nun basierend auf deinen Erkenntnissen eine Empfehlung für die Person.
|
||||
"""
|
||||
)
|
||||
),
|
||||
),
|
||||
(
|
||||
"user_text_input",
|
||||
UserTextInputBlockFactory(
|
||||
text=replace_whitespace(
|
||||
"""
|
||||
Gibt es zusätzliche Deckungen, die du der Person empfehlen würdest? Begründe deine Empfehlung
|
||||
"""
|
||||
)
|
||||
),
|
||||
),
|
||||
(
|
||||
"user_text_input",
|
||||
UserTextInputBlockFactory(
|
||||
text=replace_whitespace(
|
||||
"""
|
||||
Gibt es Deckungen, die du streichen würdest? Begründe deine Empfehlung.
|
||||
"""
|
||||
)
|
||||
),
|
||||
),
|
||||
(
|
||||
"user_text_input",
|
||||
UserTextInputBlockFactory(
|
||||
text=replace_whitespace(
|
||||
"""
|
||||
Wenn die Person gemäss deiner Einschätzung genau richtig versichert ist, argumentiere, warum dies der Fall ist.
|
||||
"""
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
assignment.tasks.append(
|
||||
(
|
||||
"task",
|
||||
TaskBlockFactory(
|
||||
title="Teilaufgabe 5: Reflexion",
|
||||
content=StreamValue(
|
||||
TaskContentStreamBlock(),
|
||||
stream_data=[
|
||||
(
|
||||
"explanation",
|
||||
ExplanationBlockFactory(
|
||||
text=replace_whitespace(
|
||||
"""
|
||||
Reflektiere dein Handeln und halte deine Erkenntnisse fest. Frage dich dabei:
|
||||
"""
|
||||
)
|
||||
),
|
||||
),
|
||||
(
|
||||
"user_text_input",
|
||||
UserTextInputBlockFactory(
|
||||
text=replace_whitespace(
|
||||
"""
|
||||
War die Bearbeitung dieser geleiteten Fallarbeit erfolgreich? Begründe deine Einschätzung.
|
||||
"""
|
||||
)
|
||||
),
|
||||
),
|
||||
(
|
||||
"user_text_input",
|
||||
UserTextInputBlockFactory(
|
||||
text=replace_whitespace(
|
||||
"""
|
||||
Was ist dir bei der Bearbeitung des Auftrags gut gelungen?
|
||||
"""
|
||||
)
|
||||
),
|
||||
),
|
||||
(
|
||||
"user_text_input",
|
||||
UserTextInputBlockFactory(
|
||||
text=replace_whitespace(
|
||||
"""
|
||||
Was ist dir bei der Bearbeitung des Auftrags weniger gut gelungen?
|
||||
"""
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
assignment.tasks.append(
|
||||
(
|
||||
"task",
|
||||
TaskBlockFactory(
|
||||
title="Teilaufgabe 6: Learnings",
|
||||
content=StreamValue(
|
||||
TaskContentStreamBlock(),
|
||||
stream_data=[
|
||||
(
|
||||
"explanation",
|
||||
ExplanationBlockFactory(
|
||||
text=replace_whitespace(
|
||||
"""
|
||||
Leite aus der Teilaufgabe 5 deine persönlichen Learnings ab.
|
||||
"""
|
||||
)
|
||||
),
|
||||
),
|
||||
(
|
||||
"user_text_input",
|
||||
UserTextInputBlockFactory(
|
||||
text=replace_whitespace(
|
||||
"""
|
||||
Was würdest du beim nächsten Mal anders machen?
|
||||
"""
|
||||
)
|
||||
),
|
||||
),
|
||||
(
|
||||
"user_text_input",
|
||||
UserTextInputBlockFactory(
|
||||
text=replace_whitespace(
|
||||
"""
|
||||
Was hast du beim Bearbeiten des Auftrags Neues gelernt?
|
||||
"""
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
assignment.save()
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ class PerformanceObjectiveBlock(blocks.StructBlock):
|
|||
|
||||
|
||||
class UserTextInputBlock(blocks.StaticBlock):
|
||||
text = blocks.TextBlock(blank=True)
|
||||
|
||||
class Meta:
|
||||
icon = "edit"
|
||||
|
||||
|
|
@ -35,15 +37,16 @@ class UserConfirmationBlock(blocks.StructBlock):
|
|||
icon = "tick-inverse"
|
||||
|
||||
|
||||
class TaskContentStreamBlock(blocks.StreamBlock):
|
||||
explanation = ExplanationBlock()
|
||||
user_text_input = UserTextInputBlock()
|
||||
user_confirmation = UserConfirmationBlock()
|
||||
|
||||
|
||||
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()),
|
||||
],
|
||||
content = TaskContentStreamBlock(
|
||||
blank=True,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,23 @@
|
|||
import wagtail_factories
|
||||
from factory import SubFactory
|
||||
|
||||
from vbv_lernwelt.assignment.models import Assignment, TaskBlock, AssignmentListPage
|
||||
from vbv_lernwelt.assignment.models import (
|
||||
Assignment,
|
||||
TaskBlock,
|
||||
AssignmentListPage,
|
||||
TaskContentStreamBlock,
|
||||
UserTextInputBlock,
|
||||
)
|
||||
from vbv_lernwelt.assignment.models import (
|
||||
ExplanationBlock,
|
||||
UserConfirmationBlock,
|
||||
PerformanceObjectiveBlock,
|
||||
)
|
||||
from vbv_lernwelt.core.utils import replace_whitespace
|
||||
|
||||
|
||||
class ExplanationBlockFactory(wagtail_factories.StructBlockFactory):
|
||||
text = """Erläutere die Kundensituation und die Ausgangslage.
|
||||
Hast du alle Informationen, die du für den Policen-Check benötigst?
|
||||
Halte die wichtigsten Eckwerte des aktuellen Versicherungsverhältnisse in deiner Dokumentation fest (z.B wie lang wo versichert, Alter des Fahrzeugs, Kundenprofil, etc.)
|
||||
"""
|
||||
text = "Dies ist ein Beispieltext."
|
||||
|
||||
class Meta:
|
||||
model = ExplanationBlock
|
||||
|
|
@ -25,17 +30,23 @@ class UserConfirmationBlockFactory(wagtail_factories.StructBlockFactory):
|
|||
model = UserConfirmationBlock
|
||||
|
||||
|
||||
class TaskContentStreamBlockFactory(wagtail_factories.StreamBlockFactory):
|
||||
explanation = SubFactory(ExplanationBlockFactory)
|
||||
user_confirmation = SubFactory(UserConfirmationBlockFactory)
|
||||
|
||||
class Meta:
|
||||
model = TaskContentStreamBlock
|
||||
|
||||
|
||||
class UserTextInputBlockFactory(wagtail_factories.StructBlockFactory):
|
||||
class Meta:
|
||||
model = UserTextInputBlock
|
||||
|
||||
|
||||
class TaskBlockFactory(wagtail_factories.StructBlockFactory):
|
||||
title = "Teilauftrag"
|
||||
file_submission_required = False
|
||||
content = wagtail_factories.StreamFieldFactory(
|
||||
[
|
||||
("explanation", ExplanationBlockFactory()),
|
||||
("user_text_input", "static_block"),
|
||||
("user_confirmation", UserConfirmationBlockFactory()),
|
||||
],
|
||||
use_json_field=True,
|
||||
)
|
||||
content = TaskContentStreamBlockFactory()
|
||||
|
||||
class Meta:
|
||||
model = TaskBlock
|
||||
|
|
@ -50,11 +61,15 @@ class PerformanceObjectiveBlockFactory(wagtail_factories.StructBlockFactory):
|
|||
|
||||
class AssignmentFactory(wagtail_factories.PageFactory):
|
||||
title = "Auftrag"
|
||||
starting_position = """Jemand aus deiner Familie oder aus deinem Freundeskreis möchte sein
|
||||
Versicherungspolice überprüfen lassen. Diese Person kommt nun mit ihrer Police auf dich zu
|
||||
und bittet dich als Versicherungsprofi, diese kritisch zu überprüfen und ihr gg. Anpassungsvorschläge
|
||||
zu unterbreiten. In diesem Kompetenznachweis kannst du nun dein Wissen und Können im Bereich
|
||||
der Motorfahrzeugversicherung unter Beweis stellen."""
|
||||
starting_position = replace_whitespace(
|
||||
"""
|
||||
Jemand aus deiner Familie oder aus deinem Freundeskreis möchte sein
|
||||
Versicherungspolice überprüfen lassen. Diese Person kommt nun mit ihrer Police auf dich zu
|
||||
und bittet dich als Versicherungsprofi, diese kritisch zu überprüfen und ihr gg. Anpassungsvorschläge
|
||||
zu unterbreiten. In diesem Kompetenznachweis kannst du nun dein Wissen und Können im Bereich
|
||||
der Motorfahrzeugversicherung unter Beweis stellen.
|
||||
"""
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = Assignment
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import re
|
||||
|
||||
import structlog
|
||||
from django.conf import settings
|
||||
|
|
@ -50,3 +51,7 @@ def first_true(iterable, default=False, pred=None):
|
|||
# first_true([a,b,c], x) --> a or b or c or x
|
||||
# first_true([a,b], x, f) --> a if f(a) else b if f(b) else x
|
||||
return next(filter(pred, iterable), default)
|
||||
|
||||
|
||||
def replace_whitespace(text, replacement=" "):
|
||||
return re.sub(r"\s+", replacement, text).strip()
|
||||
|
|
|
|||
Loading…
Reference in New Issue