comparison scripts/generate_report.py @ 1073:522a2ed8afa2

Scripts: generate_report.py: show which fragments not moved and played
author Brecht De Man <BrechtDeMan@users.noreply.github.com>
date Fri, 04 Sep 2015 12:22:55 +0200
parents 2ea78697aadf
children 7576a4957680
comparison
equal deleted inserted replaced
1072:2ea78697aadf 1073:522a2ed8afa2
27 folder_name = sys.argv[1] # First command line argument is folder 27 folder_name = sys.argv[1] # First command line argument is folder
28 assert sys.argv[2] in ('no_render','-nr'), "Second argument not recognised. \n" +\ 28 assert sys.argv[2] in ('no_render','-nr'), "Second argument not recognised. \n" +\
29 "Use: python generate_report.py [results_folder] [no_render | -nr]" 29 "Use: python generate_report.py [results_folder] [no_render | -nr]"
30 # Second command line argument is [no_render | -nr] 30 # Second command line argument is [no_render | -nr]
31 render_figures = False 31 render_figures = False
32
33
34 #TODO add 'skip regenerating figures'
35 32
36 # Turn number of seconds (int) to '[minutes] min [seconds] s' (string) 33 # Turn number of seconds (int) to '[minutes] min [seconds] s' (string)
37 def seconds2timestr(time_in_seconds): 34 def seconds2timestr(time_in_seconds):
38 time_in_minutes = int(time_in_seconds/60) 35 time_in_minutes = int(time_in_seconds/60)
39 remaining_seconds = int(time_in_seconds%60) 36 remaining_seconds = int(time_in_seconds%60)
149 print "WARNING: " + file + " contains empty audio holder. (evaluation_stats.py)" 146 print "WARNING: " + file + " contains empty audio holder. (evaluation_stats.py)"
150 break # move on to next 147 break # move on to next
151 148
152 number_of_comments = 0 # for this page 149 number_of_comments = 0 # for this page
153 number_of_missing_comments = 0 # for this page 150 number_of_missing_comments = 0 # for this page
154 not_played = 0 # for this page 151 not_played = [] # for this page
155 not_moved = 0 # for this page 152 not_moved = [] # for this page
156 153
157 # 'testTime' keeps total duration: subtract time so far for duration of this audioholder 154 # 'testTime' keeps total duration: subtract time so far for duration of this audioholder
158 duration = float(audioholder.find("./metric/metricresult[@id='testTime']").text) - total_duration 155 duration = float(audioholder.find("./metric/metricresult[@id='testTime']").text) - total_duration
159 156
160 # total duration of test 157 # total duration of test
172 if response.text is not None and len(response.text) > 1: 169 if response.text is not None and len(response.text) > 1:
173 number_of_comments += 1 170 number_of_comments += 1
174 else: 171 else:
175 number_of_missing_comments += 1 172 number_of_missing_comments += 1
176 if was_played is not None and was_played.text == 'false': 173 if was_played is not None and was_played.text == 'false':
177 not_played += 1 174 not_played.append(audioelement.get('id'))
178 if was_moved is not None and was_moved.text == 'false': 175 if was_moved is not None and was_moved.text == 'false':
179 not_moved += 1 176 not_moved.append(audioelement.get('id'))
180 177
181 # update global counters 178 # update global counters
182 total_empty_comments += number_of_missing_comments 179 total_empty_comments += number_of_missing_comments
183 total_not_played += not_played 180 total_not_played += len(not_played)
184 total_not_moved += not_moved 181 total_not_moved += len(not_moved)
185 182
186 # PRINT alerts when elements not played or markers not moved 183 # PRINT alerts when elements not played or markers not moved
187 # number of audio elements not played 184 # number of audio elements not played
188 if not_played > 1: 185 if len(not_played) > 1:
189 body += '\\emph{\\textbf{ATTENTION: '+str(not_played)+' fragments were not listened to in '+page_name+'!}} \\\\ \n' 186 body += '\\emph{\\textbf{ATTENTION: '+str(len(not_played))+\
190 if not_played == 1: 187 ' fragments were not listened to in '+page_name+'! }}'+\
191 body += '\\emph{\\textbf{ATTENTION: one fragment was not listened to in '+page_name+'!}} \\\\ \n ' 188 ', '.join(not_played)+'\\\\ \n'
189 if len(not_played) == 1:
190 body += '\\emph{\\textbf{ATTENTION: one fragment was not listened to in '+page_name+'! }}'+\
191 not_played[0]+'\\\\ \n'
192 192
193 # number of audio element markers not moved 193 # number of audio element markers not moved
194 if not_moved > 1: 194 if len(not_moved) > 1:
195 body += '\\emph{\\textbf{ATTENTION: '+str(not_moved)+' markers were not moved in '+page_name+'!}} \\\\ \n' 195 body += '\\emph{\\textbf{ATTENTION: '+str(len(not_moved))+\
196 if not_moved == 1: 196 ' markers were not moved in '+page_name+'! }}'+\
197 body += '\\emph{\\textbf{ATTENTION: one marker was not moved in '+page_name+'!}} \\\\ \n' 197 ', '.join(not_moved)+'\\\\ \n'
198 #TODO which one not moved/listened to? 198 if len(not_moved) == 1:
199 body += '\\emph{\\textbf{ATTENTION: one marker was not moved in '+page_name+'! }}'+\
200 not_moved[0]+'\\\\ \n'
199 201
200 # PRINT song-specific statistic 202 # PRINT song-specific statistic
201 individual_table += page_name+'&'+\ 203 individual_table += page_name+'&'+\
202 str(number_of_comments) + '/' +\ 204 str(number_of_comments) + '/' +\
203 str(number_of_comments+number_of_missing_comments)+'&'+\ 205 str(number_of_comments+number_of_missing_comments)+'&'+\