def add_question_to_db(question, variants, right_variant_index, chapter_num, href=None): server = redis.Redis(REDIS_HOST, REDIS_PORT) question = PddQuestion(question, variants, right_variant_index, chapter_num, href=href) return server.sadd('chapter.{}.question'.format(int(float(chapter_num))), question.to_dict())
def add_question_to_db(question_str, variants, right_variant_index, chapter_num, href=None): from pddtest.resource import PddQuestion server = redis.Redis(REDIS_HOST, REDIS_PORT) question = PddQuestion(question_str, variants, right_variant_index, chapter_num, href=href) chapter_num_int = int(float(chapter_num)) return server.sadd('chapter.{}.question'.format(get_part(chapter_num_int)), question.to_dict())