Skip to content

Commit

Permalink
feat: init entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MHajoha committed Nov 27, 2023
1 parent 2c6c08e commit 364f1de
Show file tree
Hide file tree
Showing 10 changed files with 412 additions and 560 deletions.
57 changes: 57 additions & 0 deletions example/python/local/example/__init__.py
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[MyModel], ExampleAttempt]):
def export(self) -> QuestionModel:
return QuestionModel(scoring_method=ScoringMethod.AUTOMATICALLY_SCORABLE)


class ExampleQuestionType(QuestionType[MyModel, ExampleQuestion]):
pass


def init() -> ExampleQuestionType:
return ExampleQuestionType()
57 changes: 0 additions & 57 deletions example/python/local/example/main.py

This file was deleted.

1 change: 0 additions & 1 deletion example/qpy_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ author: Maximilian Haye <[email protected]>
name:
de: Beispiel
en: Example
entrypoint: main
languages: [de, en]
Loading

0 comments on commit 364f1de

Please sign in to comment.