Skip to content
Snippets Groups Projects
Commit 613b009e authored by Kris Hu's avatar Kris Hu
Browse files

update some logic

parent a0235106
No related branches found
No related tags found
No related merge requests found
......@@ -12,3 +12,8 @@ flask --app wsgi run --debug
## update requirements.txt:
pip freeze > requirements.txt
git stash # push your code inside the staged area like a virtual drawer
git pull # then pull
git stash apply # return your
\ No newline at end of file
......@@ -871,13 +871,15 @@ def attemptFormative(id):
'C': row.option_c,
'D': row.option_d
}
user_option_value = options_map.get(user_answer.strip().upper(), '')
is_correct = user_answer.strip().upper() == row.answer.strip().upper()
# keep original option letter
user_letter = user_answer.strip().upper()
user_option_value = options_map.get(user_letter, '')
is_correct = user_letter == row.answer.strip().upper()
result["mcq"].append({
"question_id": qid,
"your_answer": user_option_value,
"your_answer_letter": user_letter, # save the option letter
"answer": options_map.get(row.answer.strip().upper(), ''),
"is_correct": is_correct,
"feedback": row.feedback if row.feedback != '' else ''
......@@ -925,7 +927,7 @@ def attemptFormative(id):
for mcq_data in result["mcq"]:
qa = QuestionAttempt(
test_attempt_id=latest_attempt.id,
student_answer=mcq_data["your_answer"],
student_answer=mcq_data["your_answer_letter"], # 存入原始選項字母 (A/B/C/D)
mcq_id=mcq_data["question_id"]
)
db.session.add(qa)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment