-
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.
refactor: use pydantic.JsonValue instead of own alias
- Loading branch information
Showing
6 changed files
with
157 additions
and
146 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
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
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 |
---|---|---|
|
@@ -3,11 +3,10 @@ | |
# (c) Technische Universität Berlin, innoCampus <[email protected]> | ||
from collections.abc import Callable, Mapping | ||
|
||
from pydantic import ValidationError | ||
from pydantic import JsonValue, ValidationError | ||
|
||
from questionpy import Question | ||
from questionpy._wrappers._question import QuestionWrapper | ||
from questionpy_common.api import PlainMapping | ||
from questionpy_common.api.qtype import InvalidQuestionStateError, QuestionTypeInterface | ||
from questionpy_common.api.question import QuestionInterface | ||
from questionpy_common.elements import OptionsFormDefinition | ||
|
@@ -46,14 +45,14 @@ def _get_question_internal(self, qswv: str) -> Question: | |
|
||
return self._question_class.from_state(parsed_qswv) | ||
|
||
def get_options_form(self, question_state: str | None) -> tuple[OptionsFormDefinition, PlainMapping]: | ||
def get_options_form(self, question_state: str | None) -> tuple[OptionsFormDefinition, dict[str, JsonValue]]: | ||
if question_state is not None: | ||
question = self._get_question_internal(question_state) | ||
return question.get_options_form() | ||
|
||
return self._question_class.get_new_question_options_form(), {} | ||
|
||
def create_question_from_options(self, old_state: str | None, form_data: PlainMapping) -> QuestionInterface: | ||
def create_question_from_options(self, old_state: str | None, form_data: dict[str, JsonValue]) -> QuestionInterface: | ||
parsed_old_state = None | ||
if old_state is not None: | ||
parsed_old_state = self._question_class.question_state_with_version_class.model_validate_json(old_state) | ||
|
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,8 +1,9 @@ | ||
# 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 pydantic import JsonValue | ||
|
||
from questionpy import Attempt, Question | ||
from questionpy_common.api import PlainMapping | ||
from questionpy_common.api.attempt import AttemptModel, AttemptScoredModel, AttemptStartedModel, AttemptUi, ScoreModel | ||
from questionpy_common.api.question import QuestionInterface, QuestionModel | ||
from questionpy_common.environment import get_qpy_environment | ||
|
@@ -82,7 +83,7 @@ def _get_attempt_internal( | |
self, | ||
attempt_state: str, | ||
scoring_state: str | None = None, | ||
response: PlainMapping | None = None, | ||
response: dict[str, JsonValue] | None = None, | ||
*, | ||
compute_score: bool = False, | ||
generate_hint: bool = False, | ||
|
@@ -101,15 +102,15 @@ def _get_attempt_internal( | |
) | ||
|
||
def get_attempt( | ||
self, attempt_state: str, scoring_state: str | None = None, response: PlainMapping | None = None | ||
self, attempt_state: str, scoring_state: str | None = None, response: dict[str, JsonValue] | None = None | ||
) -> AttemptModel: | ||
return _export_attempt(self._get_attempt_internal(attempt_state, scoring_state, response)) | ||
|
||
def score_attempt( | ||
self, | ||
attempt_state: str, | ||
scoring_state: str | None = None, | ||
response: PlainMapping | None = None, | ||
response: dict[str, JsonValue] | None = None, | ||
*, | ||
try_scoring_with_countback: bool = False, | ||
try_giving_hint: bool = False, | ||
|