Skip to content
Snippets Groups Projects

Review window functionality

Merged Verbeek, J.M. (Janneke) requested to merge review-window-functionality into master
2 files
+ 57
24
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 53
20
@@ -317,6 +317,7 @@ class Controller:
if s.mistake is not None:
source = s.word
onset_src = round(s.onset, 3)
# Add to tree
if s.shadow is None:
shadow = "NA"
onset_shd = "NA"
@@ -327,23 +328,25 @@ class Controller:
mistake.name))
# Handle shadow words
for s in participant.shadow:
if s.source is None: # Without source word
if s.source is None: # Without source word
source = "NA"
onset_src = "NA"
shadow = s.word
onset_shd = round(s.onset, 3)
mistake = s.mistake
# If word has a mistake, add to tree:
if mistake is not None:
tree.insert(part1, "end", text="{}".format(e),
values=(source, onset_src, shadow,
onset_shd, mistake.name,
mistake.name))
else: # Without shadow word
else: # With source word
source = s.source.word
onset_src = s.source.onset
shadow = s.word
onset_shd = round(s.onset, 3)
mistake = s.mistake
# If word has a mistake, add to tree:
if mistake is not None:
tree.insert(part1, "end", text="{}".format(e),
values=(source, onset_src, shadow,
@@ -363,14 +366,14 @@ class Controller:
for child in tree.get_children():
for grandchild in tree.get_children(child):
if tree.item(grandchild)['text'] == e:
src, _, shd, _, _, new_mistake = \
src, onset, shd, onset_shd, _, new_mistake = \
tree.item(grandchild)['values']
mistake = None
for m in Mistake:
# Mistakes are strings, therefore:
if new_mistake.lower() == m.value:
mistake = m
changed.append([src, shd, mistake])
changed.append([src, onset, shd, onset_shd, mistake])
parts = self.retrieve_participants(e)
@@ -378,28 +381,58 @@ class Controller:
for participant in parts:
for s in participant.source:
for c in changed:
if s.word == c[0] and (s.shadow is None):
new_mistake = c[2]
s.mistake = new_mistake
if new_mistake == Mistake.CORRECT:
if s.word == c[0] and round(s.onset, 3) == float(c[1])\
and (s.shadow is None) and c[2] == "NA"\
and s.mistake is Mistake.SKIPPED:
new_mistake = c[4]
# Source mistakes cannot be random
if new_mistake == Mistake.RANDOM:
s.mistake = Mistake.SKIPPED
# Change to correct
elif new_mistake == Mistake.CORRECT:
s.mistake = None
s.shadowed = True
# Change to mistake
else:
s.mistake = new_mistake
# Set mistakes in shadow to new mistake
for s in participant.shadow:
for c in changed:
if s.word == c[1] and s.source is None:
new_mistake = c[2]
s.mistake = new_mistake
elif s.word == c[1] and s.source.word == c[0]:
new_mistake = c[2]
if new_mistake == Mistake.CORRECT:
s.mistake = None
s.correct = True
s.mistake = new_mistake
if s.word == c[2] and s.source is None \
and round(s.onset, 3) == float(c[3]):
new_mistake = c[4]
# Change to correct
if new_mistake == Mistake.CORRECT:
s.mistake = None
s.shadowed = True
# Change to mistake
else:
s.mistake = new_mistake
elif s.source is not None:
if s.word == c[2] and s.source.word == c[0] \
and round(s.onset, 3) == float(c[3]):
new_mistake = c[4]
# Mistakes for shadow words cannot be
# skipped, as shadows are not source words
if new_mistake == Mistake.RANDOM or \
new_mistake == Mistake.SKIPPED:
s.mistake = Mistake.RANDOM
# Change mistake of source word to skipped
if not s.source.shadowed:
s.source.mistake = Mistake.SKIPPED
s.source.shadow = None
# Since the source word is skipped,
# disconnect shadow from source
s.source = None
# Change to correct
elif new_mistake == Mistake.CORRECT:
s.mistake = None
s.shadowed = True
# Change to mistake
else:
s.mistake = new_mistake
# Really change internal data structure
self.reset_participants(parts)
Loading