Skip to content

Instantly share code, notes, and snippets.

@yosephbernandus
Created December 15, 2021 13:29
Show Gist options
  • Select an option

  • Save yosephbernandus/2adbe852840be9602aa534271766eea5 to your computer and use it in GitHub Desktop.

Select an option

Save yosephbernandus/2adbe852840be9602aa534271766eea5 to your computer and use it in GitHub Desktop.
Check answers premium tryout
import csv
tkp = Category.objects.get(id=3)
tryouts = PremiumTryout.objects.get(id=19)
premium_tryout_answers = PremiumTryoutAnswer.objects.filter(premium_tryout=tryouts, subcategory__category=tkp)
rows = []
headers = ['id', 'answer', 'question_id', 'question_answer', 'score_a', 'score_b',
'score_c', 'score_d', 'score_e', 'subcategory', 'score']
rows.append(headers)
for tryout in premium_tryout_answers:
rows.append([tryout.id, tryout.answer, tryout.question.id, tryout.question.answer, tryout.question.score_a,
tryout.question.score_b, tryout.question.score_c, tryout.question.score_d, tryout.question.score_e, tryout.subcategory,
tryout.get_score_answer])
with open(f"/Users/yoseph/Downloads/tryout.csv", 'w') as csv_file:
writer = csv.writer(csv_file)
writer.writerows(rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment