Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2012-10-16 18:49:27 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-10-16 18:49:27 (GMT)
commit4c12b34363163822bc05cefc4a39bd4f9534c058 (patch)
tree95d820dae97fc1a97ee29f832f2b0f9de0e4f182
parentcd0fbc3a7d072d248b7d1ec3e7e4590dda5f0412 (diff)
add Write scoring
-rwxr-xr-xdsparse.py41
-rwxr-xr-xolpcdsparse.py41
2 files changed, 82 insertions, 0 deletions
diff --git a/dsparse.py b/dsparse.py
index 38f1b1b..9b8671a 100755
--- a/dsparse.py
+++ b/dsparse.py
@@ -47,6 +47,11 @@ class ParseMain():
if score:
self._dsdict[os.path.basename(path)][-1][
'score'] = score
+ if activity == 'AbiWordActivity':
+ score = hasmenuitems(dsobj)
+ if score:
+ self._dsdict[os.path.basename(path)][-1][
+ 'score'] = score
mime_type = hascomponent(dsobj, 'mime_type')
if mime_type:
self._dsdict[os.path.basename(path)][-1][
@@ -192,6 +197,42 @@ def hasturtleblocks(path):
return str(score)
+WRITEMENUS = {'image': 0, 'table': 1, 'font-style': 2, 'font-color': 2,
+ 'font': 2, 'fontsize': 2, 'bold': 2, 'italic': 2, 'underline': 2,
+ 'Heading': 4, 'List': 4, 'style-name': 2, 'Text': 4,
+ 'left-align': 3, 'right-align': 3, 'center-align': 3,
+ 'justify-align': 3}
+WRITEPOINTS = [15, 15, 20, 10, 10]
+
+
+def hasmenuitems(path):
+ ''' Parse Write data and generate score based on rubric '''
+
+ if not os.path.exists(os.path.join(path, 'metadata', 'menu items')):
+ return None
+ fd = open(os.path.join(path, 'metadata', 'menu items'))
+ menuitems = []
+ for line in fd:
+ tokens = line.split(' ')
+ if len(tokens) > 0:
+ for token in tokens:
+ menuitems.append(token)
+
+ scores = []
+ for i in range(len(WRITEMENUS)):
+ scores.append(0)
+
+ for i in menuitems:
+ if i in WRITEMENUS:
+ scores[WRITEMENUS[i]] = WRITEPOINTS[WRITEMENUS[i]]
+
+ score = 0
+ for i in scores:
+ score += i
+
+ return score
+
+
def isactivity(path):
''' Return activity name '''
activity = hascomponent(path, 'activity')
diff --git a/olpcdsparse.py b/olpcdsparse.py
index cfc71a5..178ffca 100755
--- a/olpcdsparse.py
+++ b/olpcdsparse.py
@@ -47,6 +47,11 @@ class ParseMain():
if score:
self._dsdict[os.path.basename(path)][-1][
'score'] = score
+ if activity == 'AbiWordActivity':
+ score = hasmenuitems(dsobj)
+ if score:
+ self._dsdict[os.path.basename(path)][-1][
+ 'score'] = score
mime_type = hascomponent(dsobj, 'mime_type')
if mime_type:
self._dsdict[os.path.basename(path)][-1][
@@ -191,6 +196,42 @@ def hasturtleblocks(path):
return str(score)
+WRITEMENUS = {'image': 0, 'table': 1, 'font-style': 2, 'font-color': 2,
+ 'font': 2, 'fontsize': 2, 'bold': 2, 'italic': 2, 'underline': 2,
+ 'Heading': 4, 'List': 4, 'style-name': 2, 'Text': 4,
+ 'left-align': 3, 'right-align': 3, 'center-align': 3,
+ 'justify-align': 3}
+WRITEPOINTS = [15, 15, 20, 10, 10]
+
+
+def hasmenuitems(path):
+ ''' Parse Write data and generate score based on rubric '''
+
+ if not os.path.exists(os.path.join(path, 'metadata', 'menu items')):
+ return None
+ fd = open(os.path.join(path, 'metadata', 'menu items'))
+ menuitems = []
+ for line in fd:
+ tokens = line.split(' ')
+ if len(tokens) > 0:
+ for token in tokens:
+ menuitems.append(token)
+
+ scores = []
+ for i in range(len(WRITEMENUS)):
+ scores.append(0)
+
+ for i in menuitems:
+ if i in WRITEMENUS:
+ scores[WRITEMENUS[i]] = WRITEPOINTS[WRITEMENUS[i]]
+
+ score = 0
+ for i in scores:
+ score += i
+
+ return score
+
+
def isactivity(path):
''' Return activity name '''
activity = hascomponent(path, 'activity')