37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
class Certificate(object):
|
|
def __init__(self, title, introParsables, exampleParsables, questionParsables, questions):
|
|
self.title = title
|
|
self.introParsables = introParsables
|
|
self.exampleParsables = exampleParsables
|
|
self.questionParsables = questionParsables
|
|
self.questions = questions
|
|
|
|
@staticmethod
|
|
def from_dict(source):
|
|
title = source['Emne:']
|
|
introParsables = source['Introtekst:']
|
|
exampleParsables = source['Opgaveeksempel:']
|
|
questionParsables = source['Opgavetekst:']
|
|
questions = source['questions']
|
|
return Certificate(title, introParsables, exampleParsables, questionParsables, questions)
|
|
|
|
def to_dict(self):
|
|
data = {}
|
|
data['title'] = self.title
|
|
data['introParsables'] = self.introParsables
|
|
data['exampleParsables'] = self.exampleParsables
|
|
data['questionParsables'] = self.questionParsables
|
|
data['questions'] = self.questions
|
|
return data
|
|
|
|
def __repr__(self):
|
|
return(
|
|
f'Certificate(\
|
|
title={self.title},\
|
|
intro={self.introParsables},\
|
|
example={self.exampleParsables},\
|
|
questions_intro={self.questionParsables},\
|
|
questions={self.questions}\
|
|
)'
|
|
)
|