Skip to content

Instantly share code, notes, and snippets.

@harveyslash
Created August 1, 2017 11:42
Show Gist options
  • Save harveyslash/317d8e6cfc22f5e06004bebc13ea8c1f to your computer and use it in GitHub Desktop.
Save harveyslash/317d8e6cfc22f5e06004bebc13ea8c1f to your computer and use it in GitHub Desktop.
def get_highest_score(test_id):
test_attempts = db.session.query(TestAttempt).filter_by(test_id=test_id)
scores = []
if test_attempts.count() < 1:
return {'max_score': 0}
for each in test_attempts:
user_id = each.user_id
test_id = each.test_id
if each.is_complete:
k = get_college_test_attempt_score(test_id, user_id)['score']
scores.append(k)
if len(scores):
max_score = max(scores)
return {'max_score': max_score}
return {'max_score': 0}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment