Skip to content

Commit

Permalink
Merge branch 'develop' into feat/1069-th-1-validator
Browse files Browse the repository at this point in the history
  • Loading branch information
drikusroor committed Jun 10, 2024
2 parents bb0150b + ccf8854 commit 534f183
Show file tree
Hide file tree
Showing 83 changed files with 1,114 additions and 489 deletions.
1 change: 1 addition & 0 deletions backend/aml/base_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
'session',
'section',
'theme',
'question'
]

MIDDLEWARE = [
Expand Down
1 change: 1 addition & 0 deletions backend/aml/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# Urls patterns
urlpatterns = [
path('experiment/', include('experiment.urls')),
path('question/', include('question.urls')),
path('participant/', include('participant.urls')),
path('result/', include('result.urls')),
path('section/', include('section.urls')),
Expand Down
35 changes: 22 additions & 13 deletions backend/experiment/actions/playback.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ class Playback(BaseAction):
- resume_play: if the playback should resume from where a previous view left off
'''

def __init__(self,
sections,
preload_message='',
instruction='',
play_from=0,
show_animation=False,
mute=False,
timeout_after_playback=None,
stop_audio_after=None,
resume_play=False,
style=FrontendStyle()
):
def __init__(
self,
sections,
preload_message='',
instruction='',
play_from=0,
show_animation=False,
mute=False,
timeout_after_playback=None,
stop_audio_after=None,
resume_play=False,
style=FrontendStyle()
):
self.sections = [{'id': s.id, 'url': s.absolute_url(), 'group': s.group}
for s in sections]
self.play_method = determine_play_method(sections[0])
Expand Down Expand Up @@ -89,10 +90,18 @@ class Multiplayer(PlayButton):
- labels: pass list of strings if players should have custom labels
'''

def __init__(self, sections, stop_audio_after=5, labels=[], **kwargs):
def __init__(
self,
sections,
stop_audio_after=5,
labels=[],
style=FrontendStyle(),
**kwargs,
):
super().__init__(sections, **kwargs)
self.ID = TYPE_MULTIPLAYER
self.stop_audio_after = stop_audio_after
self.style = style
if labels:
if len(labels) != len(self.sections):
raise UserWarning(
Expand Down
3 changes: 2 additions & 1 deletion backend/experiment/actions/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
STYLE_PINK = 'pink'
STYLE_BOOLEAN = 'boolean'
STYLE_BOOLEAN_NEGATIVE_FIRST = 'boolean-negative-first'
STYLE_GRADIENT_7 = 'gradient-7'
STYLE_GRADIENT_7 = 'gradient-7'
STYLE_TOONTJEHOGER = 'toontjehoger'
7 changes: 4 additions & 3 deletions backend/experiment/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
from django.urls import reverse
from django.utils.html import format_html
from experiment.models import Experiment, ExperimentCollection, ExperimentCollectionGroup, Feedback, GroupedExperiment
from experiment.forms import ExperimentCollectionForm, ExperimentForm, ExportForm, TemplateForm, EXPORT_TEMPLATES
from question.admin import QuestionSeriesInline
from experiment.forms import ExperimentCollectionForm, ExperimentForm, ExportForm, TemplateForm, EXPORT_TEMPLATES, QuestionSeriesAdminForm
from section.models import Section, Song
from result.models import Result
from participant.models import Participant
Expand All @@ -43,8 +44,8 @@ class ExperimentAdmin(InlineActionsModelAdminMixin, admin.ModelAdmin):
'slug', 'url', 'hashtag', 'theme_config',
'language', 'active', 'rules',
'rounds', 'bonus_points', 'playlists',
'consent', 'questions']
inlines = [FeedbackInline]
'consent']
inlines = [QuestionSeriesInline, FeedbackInline]
form = ExperimentForm

# make playlists fields a list of checkboxes
Expand Down
6 changes: 0 additions & 6 deletions backend/experiment/fixtures/experiment.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,6 @@
13,
2,
1
],
"questions": [
"msi_01_music_activities", "msi_03_writing", "msi_08_intrigued_styles", "msi_15_internet_search_music", "msi_21_spend_income", "msi_24_music_addiction", "msi_28_track_new", "msi_34_attended_events", "msi_38_listen_music", "msi_05_good_singer", "msi_06_song_first_time", "msi_11_spot_mistakes", "msi_12_performance_diff", "msi_13_trouble_recognising", "msi_18_out_of_beat", "msi_22_out_of_tune", "msi_23_no_idea_in_tune", "msi_26_genre", "msi_14_never_complimented", "msi_27_consider_musician", "msi_32_practice_years", "msi_33_practice_daily", "msi_35_theory_training", "msi_36_instrumental_training", "msi_37_play_instruments", "msi_04_sing_along", "msi_07_from_memory", "msi_10_sing_with_recording", "msi_17_not_sing_harmony", "msi_25_sing_public", "msi_29_sing_after_hearing", "msi_30_sing_back", "msi_02_shivers", "msi_09_rarely_emotions", "msi_16_motivate", "msi_19_identify_special", "msi_20_talk_emotions", "msi_31_memories", "msi_39_best_instrument", "dgf_genre_preference_zh", "dgf_generation", "dgf_education", "dgf_highest_qualification_expectation", "dgf_occupational_status", "dgf_region_of_origin", "dgf_region_of_residence", "dgf_gender_identity_zh", "contact"
]
}
},
Expand Down Expand Up @@ -280,9 +277,6 @@
"language": "",
"playlists": [
18
],
"questions": [
"dgf_generation", "dgf_gender_identity", "P01_1", "P01_2", "P01_3", "P02_1", "P02_2", "P02_3", "P03_1", "P03_2", "P03_3", "P04_1", "P04_2", "P04_3", "P04_4", "P05_1", "P05_2", "P05_3", "P05_4", "P05_5", "P06_1", "P06_2", "P06_3", "P06_4", "P07_1", "P07_2", "P07_3", "P08_1", "P08_2", "P08_3", "P09_1", "P09_2", "P09_3", "P10_1", "P10_2", "P10_3", "P11_1", "P11_2", "P11_3", "P12_1", "P12_2", "P12_3", "P13_1", "P13_2", "P13_3", "P14_1", "P14_2", "P14_3", "P14_4", "P15_1", "P15_2", "P15_3", "P15_4", "P16_1", "P16_2", "P16_3", "P17_1", "P17_2", "P17_3"
]
}
}
Expand Down
12 changes: 5 additions & 7 deletions backend/experiment/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from experiment.models import ExperimentCollection, Experiment
from experiment.rules import EXPERIMENT_RULES

from .questions import QUESTIONS_CHOICES

# session_keys for Export CSV
SESSION_CHOICES = [('experiment_id', 'Experiment ID'),
Expand Down Expand Up @@ -164,12 +163,6 @@ def __init__(self, *args, **kwargs):
choices=sorted(choices)
)

self.fields['questions'] = TypedMultipleChoiceField(
choices=QUESTIONS_CHOICES,
widget=CheckboxSelectMultiple,
required=False
)

def clean_playlists(self):

# Check if there is a rules id selected and key exists
Expand Down Expand Up @@ -239,3 +232,8 @@ class TemplateForm(Form):
select_template = ChoiceField(
widget=Select,
choices=TEMPLATE_CHOICES)


class QuestionSeriesAdminForm(ModelForm):
class Media:
js = ["questionseries_admin.js"]
Empty file.
5 changes: 5 additions & 0 deletions backend/experiment/management/commands/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@

from experiment.models import Experiment
from section.models import Playlist
from question.questions import create_default_questions


class Command(BaseCommand):
""" Command for creating a superuser and an experiment if they do not yet exist """

def handle(self, *args, **options):

create_default_questions()

if User.objects.count() == 0:
management.call_command('createsuperuser', '--no-input')
print('Created superuser')
Expand All @@ -23,5 +27,6 @@ def handle(self, *args, **options):
slug='gold-msi',
)
experiment.playlists.add(playlist)
experiment.add_default_question_series()
print('Created default experiment')

23 changes: 14 additions & 9 deletions backend/experiment/management/commands/templates/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from experiment.actions import Consent, BooleanQuestion, Explainer, Final, Form, Playlist, Step, Trial
from experiment.actions.playback import Autoplay
from experiment.questions.demographics import EXTRA_DEMOGRAPHICS
from experiment.questions.utils import question_by_key
from question.demographics import EXTRA_DEMOGRAPHICS
from question.utils import question_by_key
from experiment.rules.base import Base
from result.utils import prepare_result

Expand All @@ -18,13 +18,18 @@ class NewExperimentRuleset(Base):
def __init__(self):

# Add your questions here
self.questions = [
question_by_key('dgf_gender_identity'),
question_by_key('dgf_generation'),
question_by_key('dgf_musical_experience', EXTRA_DEMOGRAPHICS),
question_by_key('dgf_country_of_origin'),
question_by_key('dgf_education', drop_choices=[
'isced-2', 'isced-5'])
self.question_series = [
{
"name": "Demographics",
"keys": [
'dgf_gender_identity',
'dgf_generation',
'dgf_musical_experience',
'dgf_country_of_origin',
'dgf_education_matching_pairs'
],
"randomize": False
},
]

def first_round(self, experiment):
Expand Down
2 changes: 0 additions & 2 deletions backend/experiment/management/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ def test_output_csv(self):





Loading

0 comments on commit 534f183

Please sign in to comment.