Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
shull4 authored Jul 13, 2018
1 parent 90a13ed commit d63b395
Show file tree
Hide file tree
Showing 2 changed files with 179 additions and 9 deletions.
33 changes: 33 additions & 0 deletions FillZero.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class FillZero:
import datetime
from xlrd import open_workbook
from xlutils.copy import copy

rb = open_workbook("StatsForResearch.xls")
wb = copy(rb)
date = datetime.date.today()

maxDay = date.day
maxMonth = date.month
counter = 0
for sheet in rb.sheets():
s = wb.get_sheet(counter)
if(counter == 3):
break
for row in range(sheet.nrows):
for column in range(sheet.ncols):
if(row == 0 and column == 0):
continue
else:
day = sheet.cell(0, column).value
if(day == ""):
continue
month = day[0:1]
start = day.find("/") + 1
end = day.find("/", start)
day = day[start:end]
if(int(month) <= int(maxMonth) and int(day) <= int(maxDay)):
if(sheet.cell(row,column).value == ''):
s.write(row, column, 0)
counter += 1
wb.save('StatsForResearch.xls')
155 changes: 146 additions & 9 deletions LogScript.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,105 @@
class LogScript:
import json
import xlwt
import csv

from collections import defaultdict
print("here")

countDebug = 0
countReuse = 0
countDebugComplete = 0
countReuseComplete = 0
countDebugAgain = 0
countReuseAgain = 0

EventCounterDebug = {}
EventCounterReuse = {}
googleIDs = {}
use = defaultdict(list)
inclassDict = defaultdict(list)
data = json.loads(open("strategytracker-export.json", "r").read())
ID = data["users"]

studentDict = {}

with open('Data - Students.csv', 'r') as fp:
reader1 = csv.reader(fp, delimiter=',', quotechar='"')
student_read = [row for row in reader1]

x = 0
for data in student_read:
if x == 0:
x += 1
else:
studentDict[data[0].strip()] = data[3].strip()
for line in ID:
print(line, " is assigned to ", ID[line]['userInfo']['Name'])
googleIDs[line] = ID[line]['userInfo']['Name']
temp = ID[line]['userInfo']['Email']
if temp in studentDict.values():
googleIDs[line] = ID[line]['userInfo']['Email']

for holder in ID[line]['session']:
temp = json.dumps(ID[line]['session'][holder]['strategy'])
date = json.dumps(ID[line]['session'][holder]['date']).strip('"')
if date not in use[googleIDs[line]]:
hold = ID[line]['userInfo']['Email']
if hold in studentDict.values():
if date not in use[googleIDs[line]]:
use[googleIDs[line]].append(date)

for person in use:
print(person, " was active on ", use[person])
if(str(temp)[1:-1] == "debugCode"):
if "Events" in ID[line]['session'][holder]:
for events in ID[line]['session'][holder]["Events"]:
if (holder in EventCounterDebug.keys()):
EventCounterDebug[holder] += 1
else:
EventCounterDebug[holder] = 1
temp = json.dumps(ID[line]['session'][holder]["Events"][events])
if "Success" in temp:
countDebugComplete += 1
if "Reset" in temp:
countDebugAgain += 1
countDebug += 1

elif(temp[1:-1] == "LearnToCode"):
if "Events" in ID[line]['session'][holder]:
for events in ID[line]['session'][holder]["Events"]:
if (holder in EventCounterReuse.keys()):
EventCounterReuse[holder] += 1
else:
EventCounterReuse[holder] = 1
temp = json.dumps(ID[line]['session'][holder]["Events"][events])
if "Success" in temp:
countReuseComplete += 1
if "Reset" in temp:
countReuseAgain += 1

countReuse += 1

totalDebug = 0
for number in EventCounterDebug.values():
totalDebug += int(number)

totalReuse = 0
for number in EventCounterReuse.values():
totalReuse += int(number)
book = xlwt.Workbook(encoding="utf-8")
sheet1 = book.add_sheet("Sheet 1")
sheet1 = book.add_sheet("Log Data")
sheet2 = book.add_sheet("In Class Data")
sheet3 = book.add_sheet("Overall Combo")
sheet4 = book.add_sheet("Stats")

for x in range(9,32):
outNumber = x-8
output = "7/"+str(x)+"/18"
sheet1.write(0, outNumber, output)
sheet2.write(0, outNumber, output)
sheet3.write(0, outNumber, output)

for x in range(1,3):
outNumber = x + 23
output = "8/"+str(x)+"/18"
sheet1.write(0, outNumber, output)
sheet2.write(0, outNumber, output)
sheet3.write(0, outNumber, output)


i = 1
Expand All @@ -51,7 +119,76 @@ class LogScript:

if(index != -1):
if(index + int(day) >= 0):
sheet1.write(i, index + int(day), "1")
sheet1.write(i, index + int(day), 1)
i += 1




with open('Data - Help requests.csv', 'r') as csvfile:
reader = csv.reader(csvfile, delimiter=',', quotechar='"')
data_read = [row for row in reader]

i = 1
for x in studentDict:
sheet2.write(i, 0, studentDict[x])
sheet3.write(i, 0, studentDict[x])
i += 1

x = 0
for data in data_read:
if x == 0:
x += 1
else:
if (data[6].strip() == 'DEBUG' or data[6].strip() == 'Reuse'):
indexR = -8
indexC = 1
for temp in studentDict:
date = "7/" + str(data[2]) + "/18"
if(studentDict[temp] == studentDict[data[1].strip()]):
if date not in inclassDict[studentDict[temp]]:
inclassDict[studentDict[temp]].append(date)
sheet2.write(indexC, indexR + int(data[2].strip()), 1)

indexC += 1
i = 1
for x in studentDict.values():
for day in use[x]:
month = day[0:1]
start = day.find("/") + 1
end = day.find("/", start)
day = day[start:end]

index = -8;
if(month == '8'):
index = 23
if(month == "6"):
index = -1

if(index != -1):
if(index + int(day) >= 0):
sheet3.write(i, index + int(day), 1)
else:
for temp in studentDict:
if (studentDict[temp] == studentDict[data[1].strip()]):
if (index + int(day) >= 0):
sheet3.write(i, index + int(day), 1)
i += 1

book.save("trial.xls")
sheet4.write(0, 1, "Uses")
sheet4.write(1, 0, "Debug")
sheet4.write(2, 0, "Reuse")
sheet4.write(0,2, "Complete")
sheet4.write(0,3, "Try Again")
sheet4.write(0,4, "Average Events")

sheet4.write(1, 1, countDebug)
sheet4.write(1, 2, countDebugComplete)
sheet4.write(1, 3, countDebugAgain)
sheet4.write(1, 4, round((totalDebug / len(EventCounterDebug)), 2))

sheet4.write(2, 1, countReuse)
sheet4.write(2, 2, countReuseComplete)
sheet4.write(2, 3, countReuseAgain)
sheet4.write(2, 4, round((totalReuse / len(EventCounterReuse)), 2))
book.save("StatsForResearch.xls")

0 comments on commit d63b395

Please sign in to comment.