-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelper.py
162 lines (113 loc) · 4.16 KB
/
helper.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import difflib
import getpass
import inspect
import itertools
import json
import os
import shutil
import urllib
from pathlib import Path
import psycopg2
import nbformat
import requests
from bs4 import BeautifulSoup
from nbconvert.preprocessors import ExecutePreprocessor
from app.validator import Validator
from config.config import withErrors, Config, create_check_error_config
from lib.parse_code import load_files, parse_json
from lib.query import get_context_content, proceed_query, proceed_query_full
from lib.response import type_to_response, answers, log
import feedparser
query_get_label_script = ...
query_get_label_no_script = ...
query_rephrase = ...
def check_types():
...
cats, errors = done_lectures(cur, lectures_da+lectures_front+lectures_it_start, lecture_front_names)
cur.execute(sql3)
overall_res = overall(cur, cur1, lectures_da + lectures_front + lectures_it_start)
res = {'cats':cats, 'errors':errors, 'overall':overall_res[0],
'not_published':overall_res[1], 'not_201':overall_res[2]}
def get_name(conn, lecture):
...
def get_flow_report(conn, lecture, version):
...
for row in result:
...
return report
def get_status(row_dict, not_valid_errors):
if ...
return row_dict['payload']['status']
else:
res = []
for f in row_dict['errors_check']:
err = f.replace(';False', '').replace(';True', '')
if err not in not_valid_errors:
res.append(err)
if len(res) > 0:
return 'redirect'
else:
return 'graded'
def get_dataset_report(conn, lecture, version, not_valid_errors):
...
report = {"rows": {"all": cur.rowcount, "errors":0, "declined":0},"errors": {}}
# transform result
...
perfect = {'count': 0, 'count_matched': 0, 'count_unmatched': 0, 'errors':{}}
passed = {'count': 0, 'count_matched': 0, 'count_unmatched': 0, 'count_slight': 0, 'errors':{}}
not_passed = {'count': 0, 'count_matched': 0, 'count_unmatched': 0, 'errors':{}}
for row in result:
row_dict = {}
for i, col in enumerate(columns):
row_dict[col.name] = row[i]
status = get_status(row_dict, not_valid_errors)
if row_dict['tutor_score'] == 100:
perfect['count'] += 1
if status == 'graded':
perfect['count_matched'] += 1
else:
perfect['count_unmatched'] += 1
...
else:
...
if 'group_label' in row_dict.keys() and row_dict['group_label']:
...
for k in perfect["errors"].keys():
perfect["errors"][k] = perfect["errors"][k] / (perfect['count'] / 100)
report['perfect'] = {'count':perfect['count'], 'count_matched':perfect['count_matched'], 'count_unmatched':perfect['count_unmatched'], "errors":dict(sorted(perfect["errors"].items(), key=lambda item: item[1], reverse=True))}
report['passed'] = passed
report['not_passed'] = not_passed
return report
def get_descriptors():
""
def get_overall(report, courses, conn):
res = {}
for c in courses:
...
for c in reported.keys():
...
graded = 0
overall = 0
for c in reported.keys():
...
report[c]['overall'] = {'graded':graded, 'overall':overall, 'percentages':graded/(overall/100)}
return res
def report(lecture, version, conn):
name = get_name(conn, lecture)
report = {}
report[lecture] = {"name":name, "flow report":get_flow_report(conn, lecture, version),
"dataset report":get_dataset_report(conn, lecture, version, []),
"descriptors":get_descriptors(), "version": version}
return report, name['course_id']
def overall_analysis_from_dataset(id, version):
...
output = []
normals = []
ids = []
count = 0
for i in cur.fetchall():
if i[3] not in ids and i[5]:
...
to_send = check_one(val, version, normals, ...)
...
return True, None