-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateEdges.py
More file actions
45 lines (36 loc) · 1.2 KB
/
CreateEdges.py
File metadata and controls
45 lines (36 loc) · 1.2 KB
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
"""
------------------------------------------------------------------------------
This file connects users with their assignment information and store them in
the lists edges. Edges only contains tuples in the format of
(assignment name,userid,score,user name). Run this file to generate edges.json and edges2.json to see
more details.
------------------------------------------------------------------------------
"""
from difflib import SequenceMatcher
from CanvasData import grab_canvas_data
import os.path
from os import path
import json
#data structure initialization
data = {}
grades = {}
gradesList = []
modulesList = []
gradeScores = []
edges = []
def create_edges(repull):
edges = []
# read in JSON file
data, data2 = grab_canvas_data()
# add edges
for d in data:
for d2 in data2:
if d['user_id'] == d2:
score_calc = float(d["score"]) / float(d["total"]) * 100
edges.append((d['assignment'], d2, score_calc, d["user_name"]))
# Pass all the information needed, including assignment name, Ids, scores, userName
f = open("edges.json", "w")
f.write(json.dumps(edges))
f.close()
# print(edges)
return edges