-
Notifications
You must be signed in to change notification settings - Fork 1
/
mammalStepCheck.py
57 lines (53 loc) · 2.04 KB
/
mammalStepCheck.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
from __future__ import print_function
from collections import Counter
from kelp.kelpplugin import KelpPlugin
from snapshotplugin import SnapshotPlugin
import os
import sys
import kurt
class MammalStepCheck(SnapshotPlugin):
def __init__(self):
super(MammalStepCheck,self).__init__()
#module name and description
self._modulename = "MammalGame"
self._description = "Attempts to determine the time it takes to figure out the grid"
def analyze (self, Path):
results = []
dirname = os.path.dirname(Path)
for file in os.listdir(Path):
if file.endswith(".oct"):
# get file name
base = os.path.basename(file)
filename = os.path.splitext(base)[0]
# set up kurt project
oct = kurt.Project.load(os.path.abspath(os.path.join(Path, file)))
results = self.stepCheck(oct)
sum = 0
for item in results:
sum += int(item)
if "50" in results or sum%50 ==0:
results.append("Student figured out grid")
#results.append(self.stepCheck(oct))
return {dirname:results}
def stepCheck(self, scratch):
blockargs = []
for sprite in scratch.sprites:
if sprite.name == "Net":
for script in sprite.scripts:
for block in script.blocks:
if "steps" in block.stringify():
blockargs.append(str(block.args[0]))
print (blockargs)
return (blockargs)
def check_display(results):
output = {}
figured = False
count = 1
for title, list in results.items():
htmlout = '<h2>' + 'Project #' + str(count) + '</h2>' + '<p>' + ','.join(list) + '</p>'
if("figured" in list[-1] and figured == False):
htmlout = htmlout +('It took ' + str(count) + ' tries to figure out')
figured = True
output[count] = ''.join(htmlout)
count+=1
return output