test-platform/server/cgi/db/response_option.py

44 lines
995 B
Python

from 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
class ResponceOptionPool:
def __init__(self):
self.object_pool = ObjectPool("response_option", ResponseOption)
if db:
self.object_pool.load_from_db(db)
'''
class ResponceOptionPool:
def __init__(self):
self.pool = []
def load_from_db(self, cur):
db.execute("SELECT * FROM response_option;")
self.pool = [ResponseOption().init_from_data(i) for i in cur]
return self
'''