Muthuraja18 commited on
Commit
6fb1d96
·
verified ·
1 Parent(s): 893a0bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -982,7 +982,10 @@ def play_page():
982
  if st.button("Next", key=f"next_{gid}_{idx}"):
983
  # Record answer and time
984
  st.session_state['answers'][idx] = choice
985
- st.session_state['answer_times'][idx] = time.time() - st.session_state['question_started_at']
 
 
 
986
  # Move to next question
987
  st.session_state['current_index'] = idx + 1
988
  st.session_state['question_started_at'] = time.time()
@@ -994,7 +997,7 @@ def play_page():
994
  if st.button("Submit All Answers", key=f"submit_{gid}_{idx}"):
995
  # Record last question
996
  st.session_state['answers'][idx] = choice
997
- st.session_state['answer_times'][idx] = time.time() - st.session_state['question_started_at']
998
 
999
  answers = st.session_state['answers']
1000
  times = st.session_state['answer_times']
 
982
  if st.button("Next", key=f"next_{gid}_{idx}"):
983
  # Record answer and time
984
  st.session_state['answers'][idx] = choice
985
+ start_time = st.session_state.get('question_started_at') or time.time()
986
+ st.session_state['answer_times'][idx] = time.time() - start_time
987
+
988
+ # st.session_state['answer_times'][idx] = time.time() - st.session_state['question_started_at']
989
  # Move to next question
990
  st.session_state['current_index'] = idx + 1
991
  st.session_state['question_started_at'] = time.time()
 
997
  if st.button("Submit All Answers", key=f"submit_{gid}_{idx}"):
998
  # Record last question
999
  st.session_state['answers'][idx] = choice
1000
+ st.session_state['answer_times'][idx] = time.time() - (st.session_state.get('question_started_at') or time.time())
1001
 
1002
  answers = st.session_state['answers']
1003
  times = st.session_state['answer_times']