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-grapple
|
||||||
# wagtail-headless-preview
|
# wagtail-headless-preview
|
||||||
# wagtail-localize
|
# wagtail-localize
|
||||||
wagtail-factories==2.0.1
|
wagtail-factories==4.0.0
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
wagtail-grapple==0.18.0
|
wagtail-grapple==0.18.0
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ python-json-logger
|
||||||
concurrent-log-handler
|
concurrent-log-handler
|
||||||
|
|
||||||
wagtail>=3,<4
|
wagtail>=3,<4
|
||||||
wagtail-factories
|
wagtail-factories>=4
|
||||||
wagtail-localize
|
wagtail-localize
|
||||||
wagtail_grapple
|
wagtail_grapple
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ wagtail==3.0.1
|
||||||
# wagtail-grapple
|
# wagtail-grapple
|
||||||
# wagtail-headless-preview
|
# wagtail-headless-preview
|
||||||
# wagtail-localize
|
# wagtail-localize
|
||||||
wagtail-factories==2.0.1
|
wagtail-factories==4.0.0
|
||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
wagtail-grapple==0.18.0
|
wagtail-grapple==0.18.0
|
||||||
# via -r requirements.in
|
# 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 (
|
from vbv_lernwelt.assignment.tests.assignment_factories import (
|
||||||
PerformanceObjectiveBlockFactory,
|
PerformanceObjectiveBlockFactory,
|
||||||
AssignmentListPageFactory,
|
AssignmentListPageFactory,
|
||||||
AssignmentFactory,
|
AssignmentFactory,
|
||||||
TaskBlockFactory,
|
TaskBlockFactory,
|
||||||
|
ExplanationBlockFactory,
|
||||||
|
UserTextInputBlockFactory,
|
||||||
)
|
)
|
||||||
|
from vbv_lernwelt.core.utils import replace_whitespace
|
||||||
from vbv_lernwelt.course.consts import COURSE_UK
|
from vbv_lernwelt.course.consts import COURSE_UK
|
||||||
from vbv_lernwelt.course.models import CoursePage
|
from vbv_lernwelt.course.models import CoursePage
|
||||||
|
|
||||||
|
|
@ -15,15 +21,268 @@ def create_assignments():
|
||||||
assignment_page = AssignmentListPageFactory(
|
assignment_page = AssignmentListPageFactory(
|
||||||
parent=course_page,
|
parent=course_page,
|
||||||
)
|
)
|
||||||
AssignmentFactory(
|
|
||||||
|
assignment = AssignmentFactory(
|
||||||
parent=assignment_page,
|
parent=assignment_page,
|
||||||
title="Auftrag 1",
|
title="Überprüfen einer Motorfahrzeugs-Versicherungspolice",
|
||||||
performance_objectives=StreamFieldFactory(
|
effort_required="ca. 5 Stunden",
|
||||||
{
|
starting_position=replace_whitespace(
|
||||||
"performance_objective": PerformanceObjectiveBlockFactory(),
|
"""
|
||||||
}
|
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",
|
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):
|
class UserTextInputBlock(blocks.StaticBlock):
|
||||||
|
text = blocks.TextBlock(blank=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
icon = "edit"
|
icon = "edit"
|
||||||
|
|
||||||
|
|
@ -35,15 +37,16 @@ class UserConfirmationBlock(blocks.StructBlock):
|
||||||
icon = "tick-inverse"
|
icon = "tick-inverse"
|
||||||
|
|
||||||
|
|
||||||
|
class TaskContentStreamBlock(blocks.StreamBlock):
|
||||||
|
explanation = ExplanationBlock()
|
||||||
|
user_text_input = UserTextInputBlock()
|
||||||
|
user_confirmation = UserConfirmationBlock()
|
||||||
|
|
||||||
|
|
||||||
class TaskBlock(blocks.StructBlock):
|
class TaskBlock(blocks.StructBlock):
|
||||||
title = blocks.TextBlock()
|
title = blocks.TextBlock()
|
||||||
file_submission_required = blocks.BooleanBlock(required=False)
|
file_submission_required = blocks.BooleanBlock(required=False)
|
||||||
content = blocks.StreamBlock(
|
content = TaskContentStreamBlock(
|
||||||
[
|
|
||||||
("explanation", ExplanationBlock()),
|
|
||||||
("user_text_input", UserTextInputBlock()),
|
|
||||||
("user_confirmation", UserConfirmationBlock()),
|
|
||||||
],
|
|
||||||
blank=True,
|
blank=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,23 @@
|
||||||
import wagtail_factories
|
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 (
|
from vbv_lernwelt.assignment.models import (
|
||||||
ExplanationBlock,
|
ExplanationBlock,
|
||||||
UserConfirmationBlock,
|
UserConfirmationBlock,
|
||||||
PerformanceObjectiveBlock,
|
PerformanceObjectiveBlock,
|
||||||
)
|
)
|
||||||
|
from vbv_lernwelt.core.utils import replace_whitespace
|
||||||
|
|
||||||
|
|
||||||
class ExplanationBlockFactory(wagtail_factories.StructBlockFactory):
|
class ExplanationBlockFactory(wagtail_factories.StructBlockFactory):
|
||||||
text = """Erläutere die Kundensituation und die Ausgangslage.
|
text = "Dies ist ein Beispieltext."
|
||||||
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.)
|
|
||||||
"""
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ExplanationBlock
|
model = ExplanationBlock
|
||||||
|
|
@ -25,17 +30,23 @@ class UserConfirmationBlockFactory(wagtail_factories.StructBlockFactory):
|
||||||
model = UserConfirmationBlock
|
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):
|
class TaskBlockFactory(wagtail_factories.StructBlockFactory):
|
||||||
title = "Teilauftrag"
|
title = "Teilauftrag"
|
||||||
file_submission_required = False
|
file_submission_required = False
|
||||||
content = wagtail_factories.StreamFieldFactory(
|
content = TaskContentStreamBlockFactory()
|
||||||
[
|
|
||||||
("explanation", ExplanationBlockFactory()),
|
|
||||||
("user_text_input", "static_block"),
|
|
||||||
("user_confirmation", UserConfirmationBlockFactory()),
|
|
||||||
],
|
|
||||||
use_json_field=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = TaskBlock
|
model = TaskBlock
|
||||||
|
|
@ -50,11 +61,15 @@ class PerformanceObjectiveBlockFactory(wagtail_factories.StructBlockFactory):
|
||||||
|
|
||||||
class AssignmentFactory(wagtail_factories.PageFactory):
|
class AssignmentFactory(wagtail_factories.PageFactory):
|
||||||
title = "Auftrag"
|
title = "Auftrag"
|
||||||
starting_position = """Jemand aus deiner Familie oder aus deinem Freundeskreis möchte sein
|
starting_position = replace_whitespace(
|
||||||
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
|
Jemand aus deiner Familie oder aus deinem Freundeskreis möchte sein
|
||||||
zu unterbreiten. In diesem Kompetenznachweis kannst du nun dein Wissen und Können im Bereich
|
Versicherungspolice überprüfen lassen. Diese Person kommt nun mit ihrer Police auf dich zu
|
||||||
der Motorfahrzeugversicherung unter Beweis stellen."""
|
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:
|
class Meta:
|
||||||
model = Assignment
|
model = Assignment
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
|
|
||||||
import structlog
|
import structlog
|
||||||
from django.conf import settings
|
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,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
|
# first_true([a,b], x, f) --> a if f(a) else b if f(b) else x
|
||||||
return next(filter(pred, iterable), default)
|
return next(filter(pred, iterable), default)
|
||||||
|
|
||||||
|
|
||||||
|
def replace_whitespace(text, replacement=" "):
|
||||||
|
return re.sub(r"\s+", replacement, text).strip()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue