Spaces:
Runtime error
Runtime error
BillBojangeles2000
commited on
Commit
β’
c79abf3
1
Parent(s):
ffa9454
Update app.py
Browse files
app.py
CHANGED
@@ -117,30 +117,31 @@ submit_button = Quiz.form_submit_button("Submit")
|
|
117 |
|
118 |
if submit_button:
|
119 |
st.toast("Calculating grade", icon='β
')
|
120 |
-
st.spinner(text="Calculating Grade")
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
|
|
|
117 |
|
118 |
if submit_button:
|
119 |
st.toast("Calculating grade", icon='β
')
|
120 |
+
with st.spinner(text="Calculating Grade"):
|
121 |
+
for i, q in enumerate(questions):
|
122 |
+
st.toast(f'iteration {i} has begun', icon='β
')
|
123 |
+
result = client.predict(
|
124 |
+
f'What would you rate this answer to the question: "{q}" as a percentage? Here is the answer: {ans[i]}. Your percentage grade cannot be negative or over 100%. Additionally, you should also assume that the user is of a 5-7th grade level of intellect.',
|
125 |
+
0.9,
|
126 |
+
256,
|
127 |
+
0.9,
|
128 |
+
1.2,
|
129 |
+
api_name="/chat"
|
130 |
+
)
|
131 |
+
|
132 |
+
pattern = r'(\d+)%'
|
133 |
+
|
134 |
+
match = re.search(pattern, result)
|
135 |
+
if match:
|
136 |
+
score = match.group(1)
|
137 |
+
user_scores.append(int(score))
|
138 |
+
else:
|
139 |
+
user_scores.append(85) # You can set a default score if no score is found
|
140 |
+
|
141 |
+
# Calculate the average score using the user_scores list
|
142 |
+
average_score = sum(user_scores) / len(user_scores)
|
143 |
+
|
144 |
+
st.info(f'Your average score for the answers is {average_score}%')
|
145 |
+
st.write(f'Your average score for the answers is {average_score}%')
|
146 |
+
|
147 |
+
st.balloons()
|