Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -101,7 +101,7 @@ def test_progress(test):
|
|
101 |
progress_text = f"You have completed {total_completed_tests} tests. {total_remaining_tests} tests are remaining"
|
102 |
return progress_text, completed_tests_text
|
103 |
|
104 |
-
# Tests
|
105 |
import random
|
106 |
|
107 |
# Global set to store all available tests
|
@@ -116,7 +116,7 @@ def assign_tests(categories_and_tests, num_tests):
|
|
116 |
# Shuffle tests
|
117 |
random.shuffle(tests)
|
118 |
|
119 |
-
#
|
120 |
if num_tests > len(remaining_tests):
|
121 |
selected_tests = remaining_tests
|
122 |
|
@@ -137,6 +137,28 @@ def assign_tests(categories_and_tests, num_tests):
|
|
137 |
|
138 |
return assigned_tests
|
139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
# Authentication function
|
141 |
def update_message(request: gr.Request):
|
142 |
return f"Welcome, {request.username}"
|
@@ -213,10 +235,9 @@ with demo :
|
|
213 |
)
|
214 |
|
215 |
# Function to get the corresponding values of correct, close and wrong text and image for each test
|
216 |
-
num_tests = 10
|
217 |
assigned_tests = assign_tests(data_list, num_tests)
|
218 |
-
|
219 |
-
|
220 |
# Assign value to each step
|
221 |
def get_test_text(test):
|
222 |
correct, close, wrong, image = get_values_image_for_test(data_list, test)
|
|
|
101 |
progress_text = f"You have completed {total_completed_tests} tests. {total_remaining_tests} tests are remaining"
|
102 |
return progress_text, completed_tests_text
|
103 |
|
104 |
+
# Tests distribution over users
|
105 |
import random
|
106 |
|
107 |
# Global set to store all available tests
|
|
|
116 |
# Shuffle tests
|
117 |
random.shuffle(tests)
|
118 |
|
119 |
+
# Last remaining tests are assigned to the last user
|
120 |
if num_tests > len(remaining_tests):
|
121 |
selected_tests = remaining_tests
|
122 |
|
|
|
137 |
|
138 |
return assigned_tests
|
139 |
|
140 |
+
# Tracking user progress
|
141 |
+
def test_progress(test):
|
142 |
+
global completed_tests_list
|
143 |
+
|
144 |
+
# Get total completed tests
|
145 |
+
total_completed_tests, completed_tests_list = completed_tests(test)
|
146 |
+
completed_tests_text = "\n".join(completed_tests_list)
|
147 |
+
|
148 |
+
# Test completed to be displayed to the user
|
149 |
+
len_assigned_test = assign_tests(categories_and_tests, num_tests)
|
150 |
+
|
151 |
+
# Calculate how many tests are remaining
|
152 |
+
total_remaining_tests = len_assigned_test - total_completed_tests
|
153 |
+
|
154 |
+
if total_remaining_tests == 0:
|
155 |
+
completed_tests_list.clear()
|
156 |
+
progress_text = f"Congratulations! You have completed all tests"
|
157 |
+
else:
|
158 |
+
progress_text = f"You have completed {total_completed_tests} tests. {total_remaining_tests} tests are remaining"
|
159 |
+
return progress_text, completed_tests_text
|
160 |
+
|
161 |
+
|
162 |
# Authentication function
|
163 |
def update_message(request: gr.Request):
|
164 |
return f"Welcome, {request.username}"
|
|
|
235 |
)
|
236 |
|
237 |
# Function to get the corresponding values of correct, close and wrong text and image for each test
|
238 |
+
num_tests = 10 # number of tests assigned per user
|
239 |
assigned_tests = assign_tests(data_list, num_tests)
|
240 |
+
|
|
|
241 |
# Assign value to each step
|
242 |
def get_test_text(test):
|
243 |
correct, close, wrong, image = get_values_image_for_test(data_list, test)
|