-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathprint_results.py
More file actions
38 lines (27 loc) · 936 Bytes
/
print_results.py
File metadata and controls
38 lines (27 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import json
import argparse
def print_results(data):
print("Exam\tFinal")
print("-" * 13)
for i, d in sorted(data['grades'].items(), key=lambda x: x[0]):
exam = i.rjust(4)
final = ("%.2f" % d['total_grade']).rjust(8)
print exam, final
def print_stats(data):
for i, d in sorted(data['stats'].items(), key=lambda x: x[0]):
exam = i
print("{0} (Shown {1} times)".format(exam, d["count"]))
for o, c in sorted(d['options'].items(), key=lambda x: x[0]):
print(" {0}: {1} times".format(o, c))
def main():
parser = argparse.ArgumentParser()
parser.add_argument('results', help="The `results.json` file generated by evaluator.py")
parser.add_argument('-s', '--stats', help="Print stats instead of results.", action='store_true')
args = parser.parse_args()
with open(args.results) as fp:
if args.stats:
print_stats(json.load(fp))
else:
print_results(json.load(fp))
if __name__ == '__main__':
main()