Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -119,24 +119,28 @@ def count_answers_per_space(country: str):
|
|
119 |
|
120 |
answered_questions = 0
|
121 |
total_answers = 0
|
122 |
-
answers_per_user = {}
|
123 |
|
124 |
for record in records:
|
125 |
-
|
|
|
|
|
|
|
|
|
126 |
if "answer_1" in responses:
|
127 |
-
|
128 |
-
total_answers += len(
|
129 |
|
130 |
-
for
|
131 |
-
|
132 |
-
|
133 |
|
134 |
-
percentage_complete = (
|
135 |
|
136 |
return {
|
137 |
"name": country,
|
138 |
"total_questions": total_questions,
|
139 |
-
"answered_questions":
|
140 |
"total_answers": total_answers,
|
141 |
"percent": round(percentage_complete, 2),
|
142 |
"documents": total_answers * 10
|
|
|
119 |
|
120 |
answered_questions = 0
|
121 |
total_answers = 0
|
122 |
+
# answers_per_user = {}
|
123 |
|
124 |
for record in records:
|
125 |
+
record = record.to_dict()
|
126 |
+
responses = record["responses"]
|
127 |
+
if record["status"] == "completed":
|
128 |
+
# +1 completed questions
|
129 |
+
completed_questions += 1
|
130 |
if "answer_1" in responses:
|
131 |
+
answers = responses["answer_1"]
|
132 |
+
total_answers += len(answers)
|
133 |
|
134 |
+
# for answer in answers:
|
135 |
+
# user_id = answer["user_id"]
|
136 |
+
# answers_per_user[user_id] = answers_per_user.get(user_id, 0) + 1
|
137 |
|
138 |
+
percentage_complete = (completed_questions / total_questions * 100) if total_questions > 0 else 0
|
139 |
|
140 |
return {
|
141 |
"name": country,
|
142 |
"total_questions": total_questions,
|
143 |
+
"answered_questions": completed_questions,
|
144 |
"total_answers": total_answers,
|
145 |
"percent": round(percentage_complete, 2),
|
146 |
"documents": total_answers * 10
|