quizcomp.converter.converter
1import abc 2import typing 3 4import quizcomp.model.question 5import quizcomp.model.quiz 6 7class Converter(abc.ABC): 8 """ 9 The base class for converting quizzes (variants) to different formats (e.g., HTML). 10 """ 11 12 def __init__(self, answer_key: bool = False, **kwargs: typing.Any) -> None: 13 super().__init__() 14 15 self.answer_key: bool = answer_key 16 """ If the generated output should be an answer key. """ 17 18 @abc.abstractmethod 19 def convert_variant(self, variant: quizcomp.model.quiz.Variant, **kwargs: typing.Any) -> str: 20 """ Convert the given variant to the converter's target format and return the converted artifact. """ 21 22 def convert_question(self, question: quizcomp.model.question.Question, **kwargs: typing.Any) -> str: 23 """ 24 Convert a single question using a dummy quiz layout. 25 """ 26 27 variant = quizcomp.model.quiz.Variant.get_dummy(question) 28 return self.convert_variant(variant, **kwargs)
class
Converter(abc.ABC):
8class Converter(abc.ABC): 9 """ 10 The base class for converting quizzes (variants) to different formats (e.g., HTML). 11 """ 12 13 def __init__(self, answer_key: bool = False, **kwargs: typing.Any) -> None: 14 super().__init__() 15 16 self.answer_key: bool = answer_key 17 """ If the generated output should be an answer key. """ 18 19 @abc.abstractmethod 20 def convert_variant(self, variant: quizcomp.model.quiz.Variant, **kwargs: typing.Any) -> str: 21 """ Convert the given variant to the converter's target format and return the converted artifact. """ 22 23 def convert_question(self, question: quizcomp.model.question.Question, **kwargs: typing.Any) -> str: 24 """ 25 Convert a single question using a dummy quiz layout. 26 """ 27 28 variant = quizcomp.model.quiz.Variant.get_dummy(question) 29 return self.convert_variant(variant, **kwargs)
The base class for converting quizzes (variants) to different formats (e.g., HTML).
@abc.abstractmethod
def
convert_variant(self, variant: quizcomp.model.quiz.Variant, **kwargs: Any) -> str:
19 @abc.abstractmethod 20 def convert_variant(self, variant: quizcomp.model.quiz.Variant, **kwargs: typing.Any) -> str: 21 """ Convert the given variant to the converter's target format and return the converted artifact. """
Convert the given variant to the converter's target format and return the converted artifact.
23 def convert_question(self, question: quizcomp.model.question.Question, **kwargs: typing.Any) -> str: 24 """ 25 Convert a single question using a dummy quiz layout. 26 """ 27 28 variant = quizcomp.model.quiz.Variant.get_dummy(question) 29 return self.convert_variant(variant, **kwargs)
Convert a single question using a dummy quiz layout.