forms.py 7.26 KB
Newer Older
Timo Heikkilä's avatar
Timo Heikkilä committed
1
2
3
4
5
6
7
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField, SelectField
from wtforms.validators import DataRequired, InputRequired
from wtforms_sqlalchemy.fields import QuerySelectField
from flask_bootstrap import Bootstrap
from app.models import background_question
from wtforms import Form, TextField, TextAreaField, SubmitField, FieldList, FormField
Timo Heikkilä's avatar
Timo Heikkilä committed
8
from wtforms import Form, BooleanField, StringField, PasswordField, validators, RadioField, IntegerField
Timo Heikkilä's avatar
Timo Heikkilä committed
9
from flask_wtf.file import FileField, FileAllowed, FileRequired
Timo Heikkilä's avatar
Timo Heikkilä committed
10
11
from flask_babel import _
from flask_babel import lazy_gettext as _l
Timo Heikkilä's avatar
Timo Heikkilä committed
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35


class LoginForm(FlaskForm):
    username = StringField('Username', validators=[DataRequired()])
    password = PasswordField('Password', validators=[DataRequired()])
    remember_me = BooleanField('Remember Me')
    submit = SubmitField('Sign In')


class RegisterForm(Form):
    
    questions1 = FieldList(SelectField([validators.InputRequired()]))
    submit = SubmitField("Send")


class TaskForm(Form):
    
    categories1 = FieldList(SelectField([validators.InputRequired()]))
    submit = SubmitField("Send")


class ContinueTaskForm(FlaskForm):
    
    participant_id = StringField('participant_id', validators=[DataRequired()])
Timo Heikkilä's avatar
Timo Heikkilä committed
36
    submit = SubmitField( _l('Continue rating') )
Timo Heikkilä's avatar
Timo Heikkilä committed
37
38
39
40

class StartWithIdForm(FlaskForm):
    
    participant_id = StringField('participant_id', validators=[DataRequired()])
Timo Heikkilä's avatar
Timo Heikkilä committed
41
    submit = SubmitField( _l('Start rating') )
Timo Heikkilä's avatar
Timo Heikkilä committed
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 

class Questions(FlaskForm):
    
    questions = StringField()


class Answers(FlaskForm):
    
    background_question_idbackground_question = SelectField(coerce=int, validators=[InputRequired])


class BackgroundQuestionForm(Form):
    
    idbackground_question_option = StringField()
    background_question_idbackground_question = StringField()
    option = StringField()
    submit = SubmitField('Register')


class TestForm(Form):
    
    question_name = StringField()
    options1 = SelectField()


class TestForm1(Form):
    
    questions1 = FieldList(SelectField([validators.InputRequired()]))
    submit = SubmitField("Send")


class TestForm2(Form):

    questions1 = SelectField()

#Forms for editing functions
    
    
class CreateExperimentForm(Form):

    name = StringField('Name', [validators.DataRequired()])
Timo Heikkilä's avatar
Timo Heikkilä committed
84
85
86
87
88
    creator_name = StringField('Creator_name', [validators.DataRequired()])     
    single_sentence_instruction = StringField('Single_sentence_instruction', [validators.DataRequired()])
    short_instruction = TextAreaField('Short_instruction', [validators.DataRequired()])
    instruction = TextAreaField('Instruction', [validators.DataRequired()])
    consent_text = TextAreaField('Instruction', [validators.DataRequired()])
Timo Heikkilä's avatar
Timo Heikkilä committed
89
90
91
92
93
94
95
    language = StringField('Language', [validators.DataRequired()])
    submit = SubmitField('Send')


class EditExperimentForm(Form):

    name = StringField('Name', [validators.DataRequired()])
Timo Heikkilä's avatar
Timo Heikkilä committed
96
97
98
99
100
    creator_name = StringField('Creator_name', [validators.DataRequired()])
    instruction = TextAreaField('Instruction', [validators.DataRequired()])
    consent_text = TextAreaField('Instruction', [validators.DataRequired()])
    short_instruction = TextAreaField('Short_instruction', [validators.DataRequired()])
    single_sentence_instruction = StringField('Single_sentece_instruction', [validators.DataRequired()])
Timo Heikkilä's avatar
Timo Heikkilä committed
101
102
    language = SelectField('Language', choices=[
            ('Afrikanns', 'Afrikanns'), ('Albanian', 'Albanian'), ('Arabic', 'Arabic'), ('Armenian', 'Armenian'), ('Basque', 'Basque'), ('Bengali', 'Bengali'), ('Bulgarian', 'Bulgarian'),
Timo Heikkilä's avatar
Timo Heikkilä committed
103
            ('Catalan', 'Catalan'), ('Cambodian', 'Cambodian'), ('Chinese', 'Chinese'), ('Croation', 'Croation'), ('Czech', 'Czech'), ('Danish', 'Danish'),
Timo Heikkilä's avatar
Timo Heikkilä committed
104
105
106
107
108
109
110
111
112
            ('Dutch', 'Dutch'), ('English', 'English'), ('Estonian', 'Estonian'), ('Fiji', 'Fiji'), ('Finnish', 'Finnish'), ('French', 'French'), ('Georgian', 'Georgian'),
            ('German', 'German'), ('Greek', 'Greek'), ('Gujarati', 'Gujarati'), ('Hebrew', 'Hebrew'), ('Hindi', 'Hindi'), ('Hungarian', 'Hungarian'), ('Icelandic', 'Icelandic'),
            ('Indonesian', 'Indonesian'), ('Irish', 'Irish'), ('Italian', 'Italian'), ('Japanese', 'Japanese'), ('Javanese', 'Javanese'), ('Korean', 'Korean'), ('Latin', 'Latin'),
            ('Latvian', 'Latvian'), ('Lithuanian', 'Lithuanian'), ('Macedonian', 'Macedonian'), ('Malay', 'Malay'), ('Malayalam', 'Malayalam'), ('Maltese', 'Maltese'), ('Maori', 'Maori'),
            ('Marathi', 'Marathi'), ('Mongolian', 'Mongolian'), ('Nepali', 'Nepali'), ('Norwegian', 'Norwegian'), ('Persian', 'Persian'), ('Polish', 'Polish'), ('Portuguese', 'Portuguese'),
            ('Punjabi', 'Punjabi'), ('Quechua', 'Quechua'), ('Romanian', 'Romanian'), ('Russian', 'Russian'), ('Samoan', 'Samoan'), ('Serbian', 'Serbian'), ('Slovak', 'Slovak'),
            ('Slovenian', 'Slovenian'), ('Spanish', 'Spanish'), ('Swahili', 'Swahili'), ('Swedish ', 'Swedish '), ('Tamil', 'Tamil'), ('Tatar', 'Tatar'), ('Telugu', 'Telugu'),
            ('Thai', 'Thai'), ('Tibetan', 'Tibetan'), ('Tonga', 'Tonga'), ('Turkish', 'Turkish'), ('Ukranian', 'Ukranian'), ('Urdu', 'Urdu'), ('Uzbek', 'Uzbek'), ('Vietnamese', 'Vietnamese'),
            ('Welsh', 'Welsh'), ('Xhosa', 'Xhosa')])
Timo Heikkilä's avatar
Timo Heikkilä committed
113
114
115
    stimulus_size = SelectField('Stimulus_size', choices=[
            ('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8'), ('9', '9'), ('10', '10'), ('11', '11'), ('12', '12')])
            
Timo Heikkilä's avatar
Timo Heikkilä committed
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
    submit = SubmitField('Send')


class CreateBackgroundQuestionForm(Form):
    
    bg_questions_and_options = TextAreaField('Background questions and options', [validators.DataRequired()])
    submit = SubmitField('Send')

    
class EditBackgroundQuestionForm(Form):
    
    bg_questions_and_options = TextAreaField('Background questions and options')
    new_values = TextAreaField('New values', [validators.DataRequired()])
    submit = SubmitField('Send')


class CreateQuestionForm(Form):
    
    questions_and_options = TextAreaField('Questions and options', [validators.DataRequired()])
    submit = SubmitField('Send')


class EditQuestionForm(Form): 

    left = StringField('left_scale', [validators.DataRequired()])
    right = StringField('right_scale', [validators.DataRequired()])
    question = StringField('question', [validators.DataRequired()])


class UploadStimuliForm(Form):
    
    type = RadioField('type', choices=[('text', 'text'), ('picture', 'picture'), ('video', 'video'), ('audio', 'audio')])
    text = TextAreaField('Text stimulus')
    media = TextAreaField('Media filename')
    file = FileField('Upload file')
    submit = SubmitField('Send')
Timo Heikkilä's avatar
Timo Heikkilä committed
152
153
154
155
156
157
158


class UploadResearchBulletinForm(Form):
    
    file = FileField('Upload file')
    submit = SubmitField('Send')

Timo Heikkilä's avatar
Timo Heikkilä committed
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
    

class EditPageForm(Form):
    
    type = RadioField('type', choices=[('text', 'text'), ('picture', 'picture'), ('video', 'video'), ('audio', 'audio')])
    text = TextAreaField('Text stimulus')
    media = TextAreaField('Media filename')
    file = FileField('Upload file')
    submit = SubmitField('Send')
    
    
class RemoveExperimentForm(Form):
    remove = TextAreaField('Remove')
    submit = SubmitField('Send')

Timo Heikkilä's avatar
Timo Heikkilä committed
174
175
176
177
178
179
class GenerateIdForm(Form): 

    number = IntegerField('number', [validators.DataRequired()])
    string = StringField('string', [validators.DataRequired()])
    submit = SubmitField('Submit')