Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
MHajoha committed Nov 27, 2023
1 parent f02a6f1 commit 25a68a5
Show file tree
Hide file tree
Showing 5 changed files with 288 additions and 246 deletions.
12 changes: 10 additions & 2 deletions example/python/local/example/question_type.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
from importlib.resources import files

from questionpy_common.models import AttemptModel, AttemptUi, QuestionModel, ScoringMethod
from questionpy_common.api.attempt import Responses, AttemptUi, AttemptModel
from questionpy_common.api.attempt_scored import BaseAttemptScored
from questionpy_common.api.question import QuestionModel, ScoringMethod

from questionpy import Attempt, BaseAttemptState, Question, BaseQuestionState, QuestionType
from questionpy import Attempt, BaseAttemptState, Question, BaseQuestionState, QuestionType, SimpleScore
from .form import MyModel


class ExampleAttempt(Attempt["ExampleQuestion", BaseAttemptState]):
def score_attempt(self, responses: Responses) -> BaseAttemptScored:
if "answer" in responses and responses.latest["answer"] == 42:
return SimpleScore(1)

return SimpleScore(0)

def export(self) -> AttemptModel:
return AttemptModel(variant=1, ui=AttemptUi(
content=(files(__package__) / "multiple-choice.xhtml").read_text()
Expand Down
Loading

0 comments on commit 25a68a5

Please sign in to comment.