from db.object_pool import ObjectPool class ResponseOption: def init(self, sID, label, questionID, correctness): self.id = sID self.label = label self.questionID = questionID self.correctness = correctness return self def init_from_data(self, data): return self.init(*data) def get_id(self): return self.id def get_label(self): return self.label def get_question_id(self): return self.questionID def get_correctness(self): return correctness def render_short(self): if self.correctness: c_mark = "+ " else: c_mark = " " return f'{c_mark} {self.label}' def render_full(self): if self.correctness: c_mark = "+" else: c_mark = "-" return f'
{c_mark}{self.label}
РедагуватиВидалити
' class ResponseOptionPool: def __init__(self, db): self.object_pool = ObjectPool("response_option", ResponseOption) if db: self.object_pool.load_from_db(db) def iter(self): return iter(self.object_pool.pool) def select_by_question_id(self, question_id): return [i for i in self.object_pool.pool if i.get_question_id() == int(question_id)]