-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgh_gradingservice.py
46 lines (40 loc) · 1.28 KB
/
gh_gradingservice.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
import shelve
from datetime import date
from flask import make_response, current_app
from flask_restful import Resource, reqparse
from grade import Grade
class GradingService(Resource):
def post(self, owner, repo, points, max):
"""
adds the points from GitHub autograding to the db
:param owner:
:param repo:
:param points:
:param max:
:return:
"""
parts = repo.split('-', 1)
if len(parts) > 1:
with shelve.open(
filename=current_app.config['GRADES'],
flag='c'
) as grades_db:
key = parts[1] + '/' + parts[0]
if key in grades_db:
grade = Grade()
grade.from_dict(grades_db[key])
grade.points = points
else:
grade = Grade(
actor=parts[1],
repo=parts[0],
courseid=0,
assignmentid=0,
userid=0,
points=points
)
grade.updated = date.today()
grades_db[key] = grade.to_dict()
return make_response(
'done', 200
)