Skip to content

Commit 284fac9

Browse files
committed
added correct count, branch count
1 parent a040e43 commit 284fac9

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

lessonitemstats.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def getOnscreenText(text,style):
141141

142142
text = text.replace(u'\u2019',"'")
143143
text = text.encode('ascii','ignore')
144-
if style == 'Onscreen':
144+
if not re.match('[A-Z][0-9]+',text):
145145
text = re.sub('[A-Z][0-9,]+','',text).split('//')[0]
146146

147147
bc = 0
@@ -178,6 +178,7 @@ def getlessonitemstats(itemfn):
178178
avgbranchlength = 0
179179
totalbranchlength = 0
180180
branchcount = 0
181+
corrcount = 0
181182
gotoNR = True
182183
inBranch = False
183184
branchnum = 0
@@ -186,6 +187,7 @@ def getlessonitemstats(itemfn):
186187
longcount = 0
187188
nonstandardsubmittime = 0.
188189
longcustomtime = 0.
190+
avgcorrcount = 0.
189191

190192
for par in doc.paragraphs:
191193
style = par.style
@@ -194,6 +196,8 @@ def getlessonitemstats(itemfn):
194196
for run in par.runs:
195197
if not run.strike:
196198
text += run.text
199+
print style,
200+
print text.encode('ascii','ignore')
197201

198202
if style == 'NoResponse' or style == 'SecondaryNoResponse': inNR = True
199203
elif style in mainlinestyles: inNR = False
@@ -203,7 +207,9 @@ def getlessonitemstats(itemfn):
203207
elif inNR: inBranch = False
204208

205209
if re.match('^correct',text.lower()) or re.match('^incorrect',text.lower()) or re.match('^no response',text.lower()):
206-
branchcount += 1
210+
branchcount += 1
211+
if re.match('^correct',text.lower()):
212+
corrcount += 1
207213
if inBranch or inNR or not style in mainlinestyles:
208214
if re.match('[A-Z][0-9]+',text):
209215
btext = text.replace(u'\u2019',"'")
@@ -235,6 +241,7 @@ def getlessonitemstats(itemfn):
235241
branchnum += 1
236242
totalbranchlength = getLength(branchtext,itemfn.replace('.docx',"-branch" + str(branchnum) + ".wav"))
237243
avgbranchlength += totalbranchlength/branchcount
244+
avgcorrcount += corrcount
238245
branchtext = ''
239246
branchcount = 0
240247

@@ -257,6 +264,7 @@ def getlessonitemstats(itemfn):
257264
MLtext += temp[0]
258265
NRtext += temp[1]
259266

267+
if branchnum > 0: avgcorrcount /= branchnum
260268
TTStime = getLength(doctext,wavfn)
261269
MLtime = getLength(MLtext,wavfn.replace('.wav','-main.wav'))
262270
NRtime = getLength(NRtext,wavfn.replace('.wav','-NR.wav'))
@@ -278,5 +286,7 @@ def getlessonitemstats(itemfn):
278286
'medium count': medcount,
279287
'long count': longcount,
280288
'nonstandard submit time': nonstandardsubmittime,
281-
'long submit time': longcustomtime
289+
'long submit time': longcustomtime,
290+
'corrects per branch': avgcorrcount,
291+
'branch count': branchnum,
282292
}

parseallitems.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from lessonitemstats import getlessonitemstats
22
import os,sys
33

4-
print "item\twc\tsubmittime\twtd count\tnext count\ttotal time\tmain time\tNR time\tavg branch time\tonscreen wc\tshort count\tmedium count\tlong count\tnonstandard submit time"
4+
print "item\twc\tsubmittime\twtd count\tnext count\ttotal time\tmain time\tNR time\tavg branch time\tonscreen wc\tshort count\tmedium count\tlong count\tnonstandard submit time\tlong submit time\tcorrects per branch\tbranch count"
55
for l in os.listdir("../scripts"):
66
for fn in [f for f in os.listdir("../scripts/" + l) if '.docx' in f and '-' in f]:
77
stats = getlessonitemstats("../scripts/" + l + "/" + fn)
8-
print fn.replace(".docx","") + "\t" + str(stats["word count"]) + "\t" + str(stats["submit time"]) + "\t" + str(stats["WTD count"]) + "\t" + str(stats["next count"]) + "\t" + str(stats["dialogue time (total)"]) + "\t" + str(stats["dialogue time (main branch)"]) + "\t" + str(stats["dialogue time (NR branch)"]) + "\t" + str(stats["average branch time"]) + "\t" + str(stats["onscreen text word count"]) + "\t" + str(stats['short count']) + "\t" + str(stats['medium count']) + "\t" + str(stats['long count']) + "\t" + str(stats['nonstandard submit time']) + "\t" + str(stats['long submit time'])
8+
print fn.replace(".docx","") + "\t" + str(stats["word count"]) + "\t" + str(stats["submit time"]) + "\t" + str(stats["WTD count"]) + "\t" + str(stats["next count"]) + "\t" + str(stats["dialogue time (total)"]) + "\t" + str(stats["dialogue time (main branch)"]) + "\t" + str(stats["dialogue time (NR branch)"]) + "\t" + str(stats["average branch time"]) + "\t" + str(stats["onscreen text word count"]) + "\t" + str(stats['short count']) + "\t" + str(stats['medium count']) + "\t" + str(stats['long count']) + "\t" + str(stats['nonstandard submit time']) + "\t" + str(stats['long submit time']) + "\t" + str(stats['corrects per branch']) + "\t" + str(stats['branch count'])
99
sys.stdout.flush()

0 commit comments

Comments
 (0)