Spaces:
Runtime error
Runtime error
Commit
·
104329a
1
Parent(s):
09d4026
Update app.py
Browse files
app.py
CHANGED
@@ -107,42 +107,44 @@ for i in questions:
|
|
107 |
ans.append(res)
|
108 |
|
109 |
Quiz.form_submit_button("Submit")
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
else:
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
for
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
def calculate_average(numbers):
|
141 |
-
if not numbers:
|
142 |
-
return 0 # Return 0 for an empty list to avoid division by zero.
|
143 |
-
|
144 |
-
total = sum(numbers)
|
145 |
-
average = total / len(numbers)
|
146 |
-
return average
|
147 |
-
|
148 |
-
st.write(f'Your average score for the answers is {calculate_average(scores)}')
|
|
|
107 |
ans.append(res)
|
108 |
|
109 |
Quiz.form_submit_button("Submit")
|
110 |
+
grade_quiz = st.button("Grade Quiz!")
|
111 |
+
if grade_quiz:
|
112 |
+
for i in ans:
|
113 |
+
for q in question:
|
114 |
+
result = client.predict(
|
115 |
+
f'What would you rate this answer to the question: "{q}" as a percentage? Here is the answer: {i}. Make sure to write your answer as "Score" and then write your score of the response.',
|
116 |
+
0.9,
|
117 |
+
256,
|
118 |
+
0.9,
|
119 |
+
1.2,
|
120 |
+
api_name="/chat"
|
121 |
+
)
|
122 |
+
print(result)
|
123 |
+
pattern = r'(\d+)%'
|
124 |
+
|
125 |
+
match = re.search(pattern, result)
|
126 |
+
if match:
|
127 |
+
score = match.group(1)
|
128 |
+
scores.append(f'{int(score)}')
|
129 |
+
else:
|
130 |
+
scores.append(f'N/A')
|
131 |
+
|
132 |
+
x = 0
|
133 |
+
new_scores = []
|
134 |
+
for score in scores:
|
135 |
+
if score == 'N/A':
|
136 |
+
scores.pop(x)
|
137 |
+
scores.append(85)
|
138 |
+
x = x + 1
|
139 |
else:
|
140 |
+
x = x + 1
|
141 |
+
|
142 |
+
def calculate_average(numbers):
|
143 |
+
if not numbers:
|
144 |
+
return 0 # Return 0 for an empty list to avoid division by zero.
|
145 |
+
|
146 |
+
total = sum(numbers)
|
147 |
+
average = total / len(numbers)
|
148 |
+
return average
|
149 |
+
|
150 |
+
st.subheader(f'Your average score for the answers is {calculate_average(scores)}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|