-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
359 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,60 @@ | ||
# This file is part of the QuestionPy SDK. (https://questionpy.org) | ||
# The QuestionPy SDK is free software released under terms of the MIT license. See LICENSE.md. | ||
# (c) Technische Universität Berlin, innoCampus <[email protected]> | ||
from importlib.resources import files | ||
|
||
from questionpy_common.models import QuestionModel, ScoringMethod, AttemptModel, AttemptUi | ||
|
||
from questionpy import QuestionType, Attempt, Question, BaseQuestionState, BaseAttemptState | ||
from questionpy.form import * | ||
|
||
|
||
class NameGroup(FormModel): | ||
first_name = text_input("First Name") | ||
last_name = text_input("Last Name") | ||
|
||
|
||
class MyOptions(OptionEnum): | ||
OPT_1 = option("Option 1", selected=True) | ||
OPT_2 = option("Option 2") | ||
|
||
|
||
class Participants(FormModel): | ||
role = select("Role:", MyOptions) | ||
name = group("Name", NameGroup) | ||
|
||
|
||
class MyModel(FormModel): | ||
static = static_text("Some static text", """Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam | ||
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam | ||
et justo duo dolores et ea rebum.""") | ||
input = text_input("My second Input", required=True, hide_if=[is_checked("chk")]) | ||
chk = checkbox("Left label", None, help="""Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam | ||
nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.""") | ||
radio = radio_group("My Radio Group", MyOptions) | ||
my_select = select("My select box", MyOptions, multiple=True) | ||
my_hidden = hidden("foo") | ||
my_repetition = repeat(Participants) | ||
|
||
has_name = checkbox(None, "I have a name.") | ||
name_group = group("Name", NameGroup, disable_if=[is_not_checked("has_name")]) | ||
|
||
|
||
class ExampleAttempt(Attempt["ExampleQuestion", BaseAttemptState]): | ||
def export(self) -> AttemptModel: | ||
return AttemptModel(variant=1, ui=AttemptUi( | ||
content=(files(__package__) / "multiple-choice.xhtml").read_text() | ||
)) | ||
|
||
|
||
class ExampleQuestion(Question[BaseQuestionState, ExampleAttempt]): | ||
def export(self) -> QuestionModel: | ||
return QuestionModel(scoring_method=ScoringMethod.AUTOMATICALLY_SCORABLE) | ||
|
||
|
||
class ExampleQuestionType(QuestionType[MyModel, ExampleQuestion]): | ||
pass | ||
|
||
|
||
def init() -> ExampleQuestionType: | ||
return ExampleQuestionType() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,4 @@ author: Maximilian Haye <[email protected]> | |
name: | ||
de: Beispiel | ||
en: Example | ||
entrypoint: main | ||
languages: [de, en] |
Oops, something went wrong.