|
|
|
@ -23,30 +23,33 @@ def query_all_questions():
|
|
|
|
|
# 遍历每个试题
|
|
|
|
|
for record in question_ids:
|
|
|
|
|
qid = record['question_id']
|
|
|
|
|
# 执行查询
|
|
|
|
|
# 修改查询部分
|
|
|
|
|
data = graph.run("""
|
|
|
|
|
MATCH (q:Question {id: $qid})
|
|
|
|
|
OPTIONAL MATCH (q)-[:REQUIRES_KNOWLEDGE]->(kp:KnowledgePoint)
|
|
|
|
|
OPTIONAL MATCH (q)-[:DEVELOPS_LITERACY]->(lp:LiteracyNode)
|
|
|
|
|
RETURN
|
|
|
|
|
q.content AS content,
|
|
|
|
|
collect(DISTINCT kp.name) AS knowledge_points,
|
|
|
|
|
collect(DISTINCT lp.title) AS literacy_points
|
|
|
|
|
""", qid=qid).data()
|
|
|
|
|
MATCH (q:Question {id: $qid})
|
|
|
|
|
OPTIONAL MATCH (q)-[:REQUIRES_KNOWLEDGE]->(kp:KnowledgePoint)
|
|
|
|
|
OPTIONAL MATCH (q)-[:DEVELOPS_LITERACY]->(lp:LiteracyNode)
|
|
|
|
|
RETURN
|
|
|
|
|
q.content AS content,
|
|
|
|
|
collect(DISTINCT {id: kp.id, name: kp.name}) AS knowledge_points,
|
|
|
|
|
collect(DISTINCT {id: lp.value, title: lp.title}) AS literacy_points
|
|
|
|
|
""", qid=qid).data()
|
|
|
|
|
|
|
|
|
|
if data:
|
|
|
|
|
result = {
|
|
|
|
|
"question_id": qid,
|
|
|
|
|
"content": data[0]['content'],
|
|
|
|
|
"knowledge_points": data[0]['knowledge_points'],
|
|
|
|
|
"literacy_points": data[0]['literacy_points']
|
|
|
|
|
# 保留原有结构
|
|
|
|
|
"knowledge_points": data[0]['knowledge_points'], # 现在每个元素包含id+name
|
|
|
|
|
"literacy_points": data[0]['literacy_points'] # 现在每个元素包含id+title
|
|
|
|
|
}
|
|
|
|
|
results.append(result)
|
|
|
|
|
# 实时打印结果
|
|
|
|
|
|
|
|
|
|
# 增强版输出展示
|
|
|
|
|
print(f"\n试题ID: {qid}")
|
|
|
|
|
print(f"内容: {result['content'][:50]}...")
|
|
|
|
|
print(f"知识点: {result['knowledge_points']}")
|
|
|
|
|
print(f"素养点: {result['literacy_points']}")
|
|
|
|
|
print(f"知识点: {[kp['name'] for kp in result['knowledge_points']]}")
|
|
|
|
|
print(f"知识点ID: {[kp['id'] for kp in result['knowledge_points']]}")
|
|
|
|
|
print(f"素养点: {[lp['title'] for lp in result['literacy_points']]}")
|
|
|
|
|
print(f"素养点ID: {[lp['id'] for lp in result['literacy_points']]}")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(f"❌ 查询失败: {str(e)}")
|
|
|
|
|
|
|
|
|
|