Spaces:
Sleeping
Sleeping
Create quiz_utils.py
Browse files- helpers/quiz_utils.py +16 -0
helpers/quiz_utils.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
import ast
|
3 |
+
|
4 |
+
import streamlit as st
|
5 |
+
|
6 |
+
def string_to_list(s):
|
7 |
+
try:
|
8 |
+
return ast.literal_eval(s)
|
9 |
+
except (SyntaxError, ValueError) as e:
|
10 |
+
st.error(f"Error: The provided input is not correctly formatted. {e}")
|
11 |
+
st.stop()
|
12 |
+
|
13 |
+
def get_randomized_options(options):
|
14 |
+
correct_answer = options[0]
|
15 |
+
random.shuffle(options)
|
16 |
+
return options, correct_answer
|