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

Questions in database #946

Merged
merged 22 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1240cc9
Add Question model
albertas-jn Apr 11, 2024
3363c21
Update tests for Question model
albertas-jn Apr 12, 2024
28bcfad
Fix linter errors
albertas-jn Apr 12, 2024
fd8a6c9
Fix linter errors 2
albertas-jn Apr 12, 2024
07f0199
Fix linter errors 3
albertas-jn Apr 12, 2024
ce73f21
Merge develop
albertas-jn Apr 16, 2024
9805400
Fix migration conflicts
albertas-jn Apr 16, 2024
0455b1e
Modify button text, Add rules' default and save
albertas-jn Apr 17, 2024
8074536
Do not add default questions to experiment if question_series does no…
albertas-jn Apr 22, 2024
0b96862
Move question to own app
albertas-jn May 10, 2024
ce1ba2d
Merge develop
albertas-jn May 10, 2024
dc264c8
First createquestions then boostrap, add default question series to b…
albertas-jn May 10, 2024
8ff247a
Convert indentation to spaces in experiment_admin.js and questionseri…
albertas-jn May 10, 2024
65375bf
Randomize MSI_F3 questions in rhythm_battery_final.py (former gold_ms…
albertas-jn May 10, 2024
a52f9f2
Add tests for createquestions command
albertas-jn May 10, 2024
0fc8474
Cleanup: remove get_default_question_keys()
albertas-jn May 10, 2024
64d1692
Add docstrings to question app
albertas-jn May 10, 2024
a323cfe
Move createquestions command tests to question app
albertas-jn May 12, 2024
3dc7bda
Merge develop
albertas-jn Jun 8, 2024
64f08fc
Move create_default_questions() to bootstrap.py
albertas-jn Jun 8, 2024
529810b
Data migration: add default questions to experiment only if rules exist
albertas-jn Jun 8, 2024
89b0b33
Remove call_command() from test_createquestions()
albertas-jn Jun 8, 2024
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
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
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
Loading