129
def handle_test(req, exercise, code, fields):
130
def handle_test(req, exercisesrc, code, fields):
130
131
"""Handles a test action."""
132
exercisefile = util.open_exercise_file(exercise)
133
exercisefile = util.open_exercise_file(exercisesrc)
133
134
if exercisefile is None:
134
135
req.throw_error(req.HTTP_NOT_FOUND,
135
136
"The exercise was not found.")
150
151
# Close the console
154
# Get the Exercise from the database
155
exercise = ivle.database.Exercise.get_by_name(req.store, exercisesrc)
155
159
conn.insert_problem_attempt(
156
160
login = req.user.login,
157
exercisename = exercise,
161
exercisename = exercisesrc,
158
162
date = time.localtime(),
159
163
complete = test_results['passed'],
162
# Query the DB to get an updated score on whether or not this problem
163
# has EVER been completed (may be different from "passed", if it has
164
# been completed before), and the total number of attempts.
165
completed, attempts = conn.get_problem_status(req.user.login,
167
test_results["completed"] = completed
168
test_results["attempts"] = attempts
170
req.write(cjson.encode(test_results))
168
# Query the DB to get an updated score on whether or not this problem
169
# has EVER been completed (may be different from "passed", if it has
170
# been completed before), and the total number of attempts.
171
completed, attempts = ivle.worksheet.get_exercise_status(req.store,
173
test_results["completed"] = completed
174
test_results["attempts"] = attempts
176
req.write(cjson.encode(test_results))
174
178
def handle_getattempts(req, exercise):
175
179
"""Handles a getattempts action."""