}, 2: { 'QUESTION_FACTOR_KEY': '/alg/%s/question_factor/%s/%s', # qtype, qid 'CARD_FACTOR_KEY': '/alg/%s/card_factor/%s/%s', # card_type, card_id # 自适应出题从 concept_graph 到 item 索引 # 参数为系数矩阵坐标 x:id, x = k 知识点, x = m 解题方法 # 值为 kind:id 列表, 比如 qtype:qid 或者 card_type:card_id 'CONCEPT_QUESTION_INDEX': '/alg/%s/concept_inv_index/question/%s/%s', 'CONCEPT_CARD_INDEX': '/alg/%s/concept_inv_index/card/%s/%s' } } _MathMeta = construct_meta('_MathMeta', 'math', SCIENCE_CONSTS, math_meta_info, consts_info, kind_map_info, subject_name2id) class MathMeta(_MathMeta): def get_all_question_factor_keys(self): keys = set() fields = self.redis_db.hkeys(self.QUESTION_INV_INDEX) for field in fields: _, qtype, _ = field.split(':') qids = self.redis_db.hget(self.QUESTION_INV_INDEX, field) if not qids: continue for qid in qids.split('|'): keys.add(self.QUESTION_FACTOR_KEY % (qtype, qid)) return list(keys)
'QUESTION_FACTOR_KEY': '/alg/%s/question_factor/%s/%s' } } consts_info = { 'K_CHOICE': 'K_%s_CHOICE', 'K_MATERIAL': 'K_%s_MATERIAL', 'K_MATERIAL_QUESTION': 'K_%s_MATERIAL_QUESTION', 'K_READING': 'K_%s_READING', 'K_READING_QUESTION': 'K_%s_READING_QUESTION', } kind_map_info = { 'QUESTION_KIND_MAP': { 'K_%s_CHOICE': 'K_%s_CHOICE', 'K_%s_MATERIAL_QUESTION': 'K_%s_MATERIAL', 'K_%s_READING_QUESTION': 'K_%s_READING' } } ChineseMeta = construct_meta('ChineseMeta', 'chinese', ART_CONSTS, meta_info, consts_info, kind_map_info, subject_name2id) HistoryMeta = construct_meta('HistoryMeta', 'history', ART_CONSTS, meta_info, consts_info, kind_map_info, subject_name2id) GeographyMeta = construct_meta('GeographyMeta', 'geography', ART_CONSTS, meta_info, consts_info, kind_map_info, subject_name2id) PoliticsMeta = construct_meta('PoliticsMeta', 'politics', ART_CONSTS, meta_info, consts_info, kind_map_info, subject_name2id)
'K_BLANK': 'K_%s_BLANK', 'K_BLANK_QUESTION': 'K_%s_BLANK_QUESTION', 'K_BLANK_ANALYSIS': 'K_%s_BLANK_ANALYSIS', 'K_RESPONSE': 'K_%s_RESPONSE', 'K_RESPONSE_QUESTION': 'K_%s_RESPONSE_QUESTION', 'K_RESPONSE_ANALYSIS': 'K_%s_RESPONSE_ANALYSIS', } kind_map_info = { 'QUESTION_KIND_MAP': { 'K_%s_CHOICE': 'K_%s_CHOICE', 'K_%s_BLANK_QUESTION': 'K_%s_BLANK', 'K_%s_RESPONSE_QUESTION': 'K_%s_RESPONSE' }, 'ANALYSIS_KIND_MAP': { 'K_%s_CHOICE_ANALYSIS': 'K_%s_CHOICE', 'K_%s_BLANK_ANALYSIS': 'K_%s_BLANK', 'K_%s_RESPONSE_ANALYSIS': 'K_%s_RESPONSE' } } PhysicsMeta = construct_meta('PhysicsMeta', 'physics', SCIENCE_CONSTS, meta_info, consts_info, kind_map_info, subject_name2id) ChemistryMeta = construct_meta('ChemistryMeta', 'chemistry', SCIENCE_CONSTS, meta_info, consts_info, kind_map_info, subject_name2id) BiologyMeta = construct_meta('BiologyMeta', 'biology', SCIENCE_CONSTS, meta_info, consts_info, kind_map_info, subject_name2id)
} consts_info = { 'K_CHOICE': 'K_%s_CHOICE', 'K_MATERIAL': 'K_%s_MATERIAL', 'K_MATERIAL_QUESTION': 'K_%s_MATERIAL_QUESTION', 'K_READING': 'K_%s_READING', 'K_READING_QUESTION': 'K_%s_READING_QUESTION', } kind_map_info = { 'QUESTION_KIND_MAP': { 'K_%s_CHOICE': 'K_%s_CHOICE', 'K_%s_MATERIAL_QUESTION': 'K_%s_MATERIAL', 'K_%s_READING_QUESTION': 'K_%s_READING' } } ChineseMeta = construct_meta('ChineseMeta', 'chinese', ART_CONSTS, meta_info, consts_info, kind_map_info, subject_name2id) HistoryMeta = construct_meta('HistoryMeta', 'history', ART_CONSTS, meta_info, consts_info, kind_map_info, subject_name2id) GeographyMeta = construct_meta('GeographyMeta', 'geography', ART_CONSTS, meta_info, consts_info, kind_map_info, subject_name2id) PoliticsMeta = construct_meta('PoliticsMeta', 'politics', ART_CONSTS, meta_info, consts_info, kind_map_info, subject_name2id)