Spaces:
Sleeping
Sleeping
Upload workbook_server.py
Browse files- workbook_server.py +3 -4
workbook_server.py
CHANGED
@@ -37,7 +37,7 @@ class ChapterRequest(BaseModel):
|
|
37 |
def get_questions_by_chapter(request: ChapterRequest):
|
38 |
db = get_db()
|
39 |
cursor = db.cursor()
|
40 |
-
cursor.execute("SELECT question, options, answer, explain
|
41 |
questions = cursor.fetchall()
|
42 |
if not questions:
|
43 |
raise HTTPException(status_code=404, detail="Questions not found for the given chapter number")
|
@@ -45,9 +45,8 @@ def get_questions_by_chapter(request: ChapterRequest):
|
|
45 |
{
|
46 |
"question_text": row[0],
|
47 |
"options": row[1],
|
48 |
-
"
|
49 |
-
"
|
50 |
-
"explanation": row[4]
|
51 |
} for row in questions
|
52 |
]
|
53 |
return JSONResponse(content=question_list)
|
|
|
37 |
def get_questions_by_chapter(request: ChapterRequest):
|
38 |
db = get_db()
|
39 |
cursor = db.cursor()
|
40 |
+
cursor.execute("SELECT question, options, answer, explain FROM question WHERE chapter = ? AND kind = '正誤問題'", (request.chapter_number,))
|
41 |
questions = cursor.fetchall()
|
42 |
if not questions:
|
43 |
raise HTTPException(status_code=404, detail="Questions not found for the given chapter number")
|
|
|
45 |
{
|
46 |
"question_text": row[0],
|
47 |
"options": row[1],
|
48 |
+
"answer": row[2],
|
49 |
+
"explanation": row[3]
|
|
|
50 |
} for row in questions
|
51 |
]
|
52 |
return JSONResponse(content=question_list)
|