def get_next_response(user_id, exercise_id):
"""
Get a random ungraded response or throw an exception
Parameters
----------
user_id : int
exercise_id: int
Returns
-------
response
The response object from a list of responses
"""
response = Response.get_random_ungraded_response(user_id, exercise_id,
active=True)
grades = ResponseGrade.get_grades(user_id, exercise_id, active=True)
labels = [int(grade[1]) if grade[1] else grade[1] for grade in grades]
labels_array = np.array(labels, dtype=float)
unique, counts = np.unique(labels_array[~np.isnan(labels_array)], return_counts=True)
stats = dict(zip(unique, counts))
stats['Total:'] = len(labels)
log.info(stats)
if response:
return response
else:
raise ResponsesNotFound()
评论列表
文章目录