-
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.
Trivial init functions needn't be written manually by devs.
- Loading branch information
Showing
4 changed files
with
14 additions
and
12 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,7 +1,5 @@ | ||
from questionpy import Package, QuestionTypeWrapper | ||
from questionpy import make_question_type_init | ||
|
||
from .question_type import ExampleQuestion | ||
|
||
|
||
def init(package: Package) -> QuestionTypeWrapper: | ||
return QuestionTypeWrapper(ExampleQuestion, package) | ||
init = make_question_type_init(ExampleQuestion) |
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,10 +1,8 @@ | ||
# 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 questionpy import Package, QuestionTypeWrapper | ||
from questionpy import make_question_type_init | ||
|
||
from .question_type import ExampleQuestion | ||
|
||
|
||
def init(package: Package) -> QuestionTypeWrapper: | ||
return QuestionTypeWrapper(ExampleQuestion, package) | ||
init = make_question_type_init(ExampleQuestion) |
6 changes: 2 additions & 4 deletions
6
examples/static-files/python/local/static_files_example/__init__.py
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,7 +1,5 @@ | ||
from questionpy import Package, QuestionTypeWrapper | ||
from questionpy import make_question_type_init | ||
|
||
from .question_type import ExampleQuestion | ||
|
||
|
||
def init(package: Package) -> QuestionTypeWrapper: | ||
return QuestionTypeWrapper(ExampleQuestion, package) | ||
init = make_question_type_init(ExampleQuestion) |
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,6 +1,7 @@ | ||
# 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 collections.abc import Callable | ||
|
||
from questionpy_common.api.attempt import ( | ||
AttemptFile, | ||
|
@@ -87,5 +88,12 @@ | |
"WorkerResourceLimits", | ||
"create_jinja2_environment", | ||
"get_qpy_environment", | ||
"make_question_type_init", | ||
"set_qpy_environment", | ||
] | ||
|
||
|
||
def make_question_type_init( | ||
question_class: type[Question], *, wrap_question: Callable[[Question], QuestionInterface] = QuestionWrapper | ||
) -> PackageInitFunction: | ||
return lambda package, env: QuestionTypeWrapper(question_class, package, wrap_question=wrap_question) |