Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pysamples
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2012-09-28 16:02:41 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-09-28 16:02:41 (GMT)
commit47bd94ec66cc92ac182d86108c5627c960a3d959 (patch)
tree9d6cd903c2b0c7a7fc694dc9b72bb135765b5c93 /pysamples
parent8dfd4d827349750dbba6d4660a236be8a468e4e5 (diff)
show score by palette
Diffstat (limited to 'pysamples')
-rwxr-xr-xpysamples/ta-stats.py35
1 files changed, 21 insertions, 14 deletions
diff --git a/pysamples/ta-stats.py b/pysamples/ta-stats.py
index f8002a7..c4305ac 100755
--- a/pysamples/ta-stats.py
+++ b/pysamples/ta-stats.py
@@ -39,6 +39,9 @@ def myblock(tw, x): # ignore second argument
for dsobj in dsobjs:
if not isactivity(dsobj) == 'TurtleArtActivity':
continue
+ if hascomponent(dsobj, 'mime_type') != \
+ 'application/x-turtle-art':
+ continue
score = hasturtleblocks(dsobj)
if score:
self._score.append(score)
@@ -92,7 +95,7 @@ def myblock(tw, x): # ignore second argument
'ifelse': 'ifthen', 'while': 'ifthen', 'until': 'ifthen',
'hat': 'action', 'stack': 'action', 'storein': 'box', 'box': 'box',
'luminance': 'sensor', 'mousex': 'sensor', 'mousey': 'sensor',
- 'moousebutton2': 'sensor', 'keyboard': 'sensor', 'kbinput': 'sensor',
+ 'mousebutton2': 'sensor', 'keyboard': 'sensor', 'kbinput': 'sensor',
'readpixel': 'sensor', 'see': 'sensor', 'time': 'sensor',
'sound': 'sensor', 'volume': 'sensor', 'pitch': 'sensor',
'resistance': 'sensor', 'voltage': 'sensor', 'video': 'media',
@@ -105,13 +108,12 @@ def myblock(tw, x): # ignore second argument
'clearheap':'extras', 'isheapempty2':'extras', 'chr':'extras',
'int':'extras', 'myfunction': 'python', 'userdefined': 'python',
'loadblock': 'python', 'loadpalette': 'python'}
-
TAPAL = {'forward': 'turtlep', 'arc': 'turtlep', 'coord': 'turtlep',
'setxy': 'turtlep', 'pen': 'penp', 'fill': 'penp', 'number': 'numberp',
- 'boolean': 'numberp', 'repeat': 'flowp', 'ifthen': 'flowp',
- 'action': 'boxp', 'box': 'boxp', 'sensor': 'sensorp',
- 'media': 'mediap', 'extras': 'extrasp', 'python': 'extrasp'}
-
+ 'random': 'numberp', 'boolean': 'numberp', 'repeat': 'flowp',
+ 'ifthen': 'flowp', 'action': 'boxp', 'box': 'boxp',
+ 'sensor': 'sensorp', 'media': 'mediap', 'extras': 'extrasp',
+ 'python': 'extrasp'}
TASCORE = {'forward': 3, 'arc': 3, 'setxy': 2.5, 'coord': 4, 'turtlep': 5,
'pen': 2.5, 'fill': 2.5, 'penp': 5,
'number': 2.5, 'boolean': 2.5, 'random': 2.5, 'numberp': 0,
@@ -120,7 +122,8 @@ def myblock(tw, x): # ignore second argument
'media': 5, 'mediap': 0,
'python': 5, 'extras': 5, 'extrasp': 0,
'sensor': 5, 'sensorp': 0}
-
+ PALS = ['turtlep', 'penp', 'numberp', 'flowp', 'boxp', 'sensorp', 'mediap',
+ 'extrasp']
def hasturtleblocks(path):
''' Parse turtle block data and generate score based on rubric '''
@@ -136,7 +139,9 @@ def myblock(tw, x): # ignore second argument
token = tokens[1].strip('" [')
blocks.append(token)
- score = 0
+ score = []
+ for i in range(len(PALS)):
+ score.append(0)
cats = []
pals = []
@@ -151,17 +156,19 @@ def myblock(tw, x): # ignore second argument
for c in cats:
if c in TASCORE:
- score += TASCORE[c]
+ score[PALS.index(TAPAL[c])] += TASCORE[c]
for p in pals:
if p in TASCORE:
- score += TASCORE[p]
+ score[PALS.index(p)] += TASCORE[p]
- return str(score)
+ return score
data = ParseJournal()
- for a in data._score:
- tw.lc.heap.append(float(a))
+ n = min(40, len(data._score) / len(PALS))
+ for i in range(n):
+ for j in range(len(PALS)):
+ tw.lc.heap.append(data._score[(n - i - 1)][len(PALS) - j - 1])
- tw.lc.heap.append(len(data._score))
+ tw.lc.heap.append(n)
return