Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/break actions #562

Merged
merged 31 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
957766b
convert SongSync / Plink into Trials
BeritJanssen Sep 26, 2023
75eafb0
use config to skip rounds
BeritJanssen Sep 26, 2023
c974cb2
implement SongSync views as Trials
BeritJanssen Sep 26, 2023
8d63549
change default of BooleanQuestion
BeritJanssen Sep 26, 2023
bbfb17a
Toontjehoger adjustments
BeritJanssen Sep 26, 2023
9606bdf
implement SongSync scoring
BeritJanssen Oct 3, 2023
6a7701a
change song sync actions in thats_my_song
BeritJanssen Oct 3, 2023
0f4c625
correct scoring
BeritJanssen Oct 10, 2023
4914001
remove round_modifier
BeritJanssen Oct 10, 2023
1f97043
update Hooked rules files and tests
BeritJanssen Oct 17, 2023
4d4d1b7
delete separate ScoreTest file
BeritJanssen Oct 17, 2023
b525c8a
fix result/score view tests
BeritJanssen Oct 17, 2023
b924174
Merge branch 'develop' into feature/break-actions
BeritJanssen Oct 31, 2023
778ad18
song sync working
BeritJanssen Oct 31, 2023
028e0ef
delete SongSync / Plink views
BeritJanssen Oct 31, 2023
861ce8f
remove equation error
BeritJanssen Oct 31, 2023
270d387
remove Plink and SongSync imports
BeritJanssen Oct 31, 2023
477efc1
add check if section has been loaded to webAudio
BeritJanssen Oct 31, 2023
f67e1b3
skip Preload if section was loaded in previous action
BeritJanssen Oct 31, 2023
15667d1
correct round numbers huang / thats_my_song
BeritJanssen Oct 31, 2023
977ba80
await the result/score call to backend
BeritJanssen Oct 31, 2023
a3797ac
correct round counting plink
BeritJanssen Oct 31, 2023
1ee7da2
add tests for previous section and last song
BeritJanssen Oct 31, 2023
b0a0a07
add section info to SongSync results
BeritJanssen Oct 31, 2023
282422d
adjust Plink score title
BeritJanssen Oct 31, 2023
99c2bad
fix problem with external files
BeritJanssen Nov 6, 2023
6ad1253
add play_method for test sounds
BeritJanssen Nov 7, 2023
20b099a
outfactor color-schemes
BeritJanssen Nov 13, 2023
ce825b1
plink: only show extra question explainer once
BeritJanssen Nov 14, 2023
6aef9b3
visual / textual fixes Plink
BeritJanssen Nov 14, 2023
83e635b
Merge branch 'develop' into feature/break-actions
BeritJanssen Nov 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions backend/experiment/actions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from .consent import Consent
from .explainer import Explainer, Step
from .form import *
from .final import Final
from .score import Score
from .song_sync import SongSync
from .consent import Consent
from .html import HTML
from .info import Info
from .playback import Playback
from .playlist import Playlist
from .start_session import StartSession
from .trial import Trial
from .info import Info
from .plink import Plink
from .redirect import Redirect
from .html import HTML
from .score import Score
from .start_session import StartSession
from .toontjehoger import ToontjeHoger
from .trial import Trial
7 changes: 4 additions & 3 deletions backend/experiment/actions/form.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.conf import settings
from django.utils.translation import gettext_lazy as _

from .styles import STYLE_NEUTRAL
from .styles import STYLE_NEUTRAL, STYLE_BOOLEAN_NEGATIVE_FIRST
from .base_action import BaseAction

class Question(BaseAction):
Expand Down Expand Up @@ -64,10 +64,11 @@ class BooleanQuestion(Question):
def __init__(self, choices=None, **kwargs):
super().__init__(**kwargs)
self.choices = choices or {
'yes': _('Yes'),
'no': _('No')
'no': _('No'),
'yes': _('Yes')
}
self.view = 'BUTTON_ARRAY'
self.style = STYLE_BOOLEAN_NEGATIVE_FIRST

class ChoiceQuestion(Question):
def __init__(self, choices, min_values=1, **kwargs):
Expand Down
65 changes: 0 additions & 65 deletions backend/experiment/actions/plink.py

This file was deleted.

4 changes: 2 additions & 2 deletions backend/experiment/actions/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Score(BaseAction): # pylint: disable=too-few-public-methods

ID = 'SCORE'

def __init__(self, session, title=None, score_message=None, config=None, icon=None, timer=None, feedback=None):
def __init__(self, session, title=None, score=None, score_message=None, config=None, icon=None, timer=None, feedback=None):
""" Score presents feedback to a participant after a Trial
- session: a Session object
- title: the title of the score page
Expand All @@ -27,7 +27,7 @@ def __init__(self, session, title=None, score_message=None, config=None, icon=No
"""
self.session = session
self.title = title
self.score = session.last_score()
self.score = score or session.last_score()
self.score_message = score_message or self.default_score_message
self.feedback = feedback
self.config = {
Expand Down
75 changes: 0 additions & 75 deletions backend/experiment/actions/song_sync.py

This file was deleted.

4 changes: 1 addition & 3 deletions backend/experiment/actions/trial.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ def __init__(self, playback=None, html=None, feedback_form=None, title='', confi
- response_time: how long to wait until stopping the player / proceeding to the next view
- auto_advance: proceed to next view after player has stopped
- listen_first: whether participant can submit before end of sound
- time_pass_break: when time has passed, submit the result immediately; skipping any subsequent actions (e.g. a certainty question)
- Can not be combined with listen_first (True)
- Can not be combined with auto_advance (False)
- break_round_on: result values upon which consecutive rounds in the current next_round array will be skipped
- continue_label: if there is no form, how to label a button to proceed to next view
- style: style class to add to elements in form and playback
- neutral: first element is blue, second is yellow, third is teal
Expand Down
66 changes: 65 additions & 1 deletion backend/experiment/actions/wrappers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import random

from django.utils.translation import gettext as _

from .form import ChoiceQuestion, Form
from .form import BooleanQuestion, ChoiceQuestion, Form
from .playback import Playback
from .trial import Trial

from result.utils import prepare_result

from experiment.actions.styles import STYLE_BOOLEAN_NEGATIVE_FIRST


def two_alternative_forced(session, section, choices, expected_response=None, style={}, comment='', scoring_rule=None, title='', config=None):
"""
Expand Down Expand Up @@ -37,3 +41,63 @@ def two_alternative_forced(session, section, choices, expected_response=None, st
feedback_form = Form([question])
trial = Trial(playback=playback, feedback_form=feedback_form, title=title, config=config)
return trial

def song_sync(session, section, title, response_time=15):
trial_config = {
'response_time': response_time,
'auto_advance': True
}
recognize = Trial(
feedback_form=Form([BooleanQuestion(
key='recognize',
result_id=prepare_result('recognize', session, section=section, scoring_rule='SONG_SYNC_RECOGNITION'),
submits=True
)]),
playback=Playback([section], 'AUTOPLAY', play_config={
'ready_time': 3,
'show_animation': True
},
preload_message=_('Get ready!'),
instruction=_('Do you recognize the song?'),
),
config={**trial_config, 'break_round_on': {'EQUALS': ['TIMEOUT', 'no']}},
title=title
)
silence_time = 4
silence = Trial(
playback=Playback([section], 'AUTOPLAY',
instruction=_('Keep imagining the music'),
play_config={
'mute': True,
'ready_time': 0,
'show_animation': True,
}),
config={
'response_time': silence_time,
'auto_advance': True,
'show_continue_button': False
},
title=title
)
continuation_correctness = random.randint(0, 1) == 1
correct_place = Trial(
feedback_form=Form([BooleanQuestion(
key='correct_place',
submits=True,
result_id=prepare_result('correct_place',
session,
section=section,
scoring_rule='SONG_SYNC_CONTINUATION',
expected_response='yes' if continuation_correctness else 'no')
)]),
playback=Playback([section], 'AUTOPLAY',
instruction=_('Did the track come back in the right place?'),
play_config={
'ready_time': 0,
'playhead': silence_time + (random.randint(100, 150) / 10 if not continuation_correctness else 0),
'show_animation': True
}),
config=trial_config,
title=title
)
return [recognize, silence, correct_place]
2 changes: 2 additions & 0 deletions backend/experiment/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .h_bat import HBat
from .h_bat_bfit import HBatBFIT
from .hbat_bst import BST
from .hooked import Hooked
from .huang_2022 import Huang2022
from .kuiper_2020 import Kuiper2020
from .listening_conditions import ListeningConditions
Expand Down Expand Up @@ -41,6 +42,7 @@
HBat.ID: HBat,
HBatBFIT.ID: HBatBFIT,
BST.ID: BST,
Hooked.ID: Hooked,
MatchingPairs.ID: MatchingPairs,
MatchingPairsICMPC.ID: MatchingPairsICMPC,
MusicalPreferences.ID: MusicalPreferences,
Expand Down
Loading