class MTurkCreateHITForm(forms.Form): use_sandbox = forms.BooleanField( required=False, label='Use MTurk Sandbox (for development and testing)', help_text=("If this box is checked, your HIT will not be published to " "the MTurk live site, but rather to the MTurk Sandbox, " "so you can test how it will look to MTurk workers.")) title = forms.CharField() description = forms.CharField() keywords = forms.CharField() money_reward = forms.RealWorldCurrencyField( # it seems that if this is omitted, the step defaults to an integer, # meaninng fractional inputs are not accepted widget=widgets._RealWorldCurrencyInput(attrs={'step': 0.01})) assignments = forms.IntegerField( label="Number of assignments", help_text="How many unique Workers do you want to work on the HIT?") minutes_allotted_per_assignment = forms.IntegerField( label="Minutes allotted per assignment", help_text=("Number of minutes, that a Worker has to " "complete the HIT after accepting it.")) expiration_hours = forms.FloatField( label="Hours until HIT expiration", help_text=("Number of hours after which the HIT " "is no longer available for users to accept. ")) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['assignments'].widget.attrs['readonly'] = True
class SessionCreateHitForm(forms.Form): in_sandbox = forms.BooleanField( required=False, help_text="Do you want HIT published on MTurk sandbox?") title = forms.CharField() description = forms.CharField() keywords = forms.CharField() money_reward = forms.RealWorldCurrencyField() assignments = forms.IntegerField( label="Number of assignments", help_text="How many unique Workers do you want to work on the HIT?") minutes_allotted_per_assignment = forms.IntegerField( label="Minutes allotted per assignment", required=False, help_text=("Number of minutes, that a Worker has to " "complete the HIT after accepting it." "Leave it blank if you don't want to specify it.")) expiration_hours = forms.IntegerField( label="Hours until HIT expiration", required=False, help_text=("Number of hours after which the HIT " "is no longer available for users to accept. " "Leave it blank if you don't want to specify it.")) def __init__(self, *args, **kwargs): super(SessionCreateHitForm, self).__init__(*args, **kwargs) self.fields['assignments'].widget.attrs['readonly'] = True
class WidgetDemoForm(forms.Form): char = forms.CharField(required=False) text = forms.CharField(required=False, widget=forms.Textarea) radio_select = forms.ChoiceField(choices=default_choices, widget=forms.RadioSelect) radio_select_horizontal = forms.ChoiceField( choices=default_choices, widget=forms.RadioSelectHorizontal) checkbox_select = forms.MultipleChoiceField( choices=default_choices, widget=forms.CheckboxSelectMultiple) checkbox_select_horizontal = forms.MultipleChoiceField( choices=default_choices, widget=forms.CheckboxSelectMultipleHorizontal) currency = forms.CurrencyField() currency_choice = forms.CurrencyChoiceField( choices=[(m, m) for m in currency_range(0, 0.75, 0.05)]) slider = forms.IntegerField(widget=widgets.SliderInput()) unprecise_slider = forms.IntegerField(widget=widgets.SliderInput( show_value=False)) precise_slider = forms.FloatField(widget=widgets.SliderInput(attrs={ 'min': 1, 'max': 50, 'step': 0.01 }))
class MTurkCreateHITForm(forms.Form): in_sandbox = forms.BooleanField( required=False, help_text="Do you want HIT published on MTurk sandbox?") title = forms.CharField() description = forms.CharField() keywords = forms.CharField() money_reward = forms.RealWorldCurrencyField( # it seems that if this is omitted, the step defaults to an integer, # meaninng fractional inputs are not accepted widget=widgets.RealWorldCurrencyInput(attrs={'step': 0.01}) ) assignments = forms.IntegerField( label="Number of assignments", help_text="How many unique Workers do you want to work on the HIT?") minutes_allotted_per_assignment = forms.IntegerField( label="Minutes allotted per assignment", help_text=( "Number of minutes, that a Worker has to " "complete the HIT after accepting it." )) expiration_hours = forms.FloatField( label="Hours until HIT expiration", help_text=( "Number of hours after which the HIT " "is no longer available for users to accept. " )) def __init__(self, *args, **kwargs): super(MTurkCreateHITForm, self).__init__(*args, **kwargs) self.fields['assignments'].widget.attrs['readonly'] = True
class SessionEditPropertiesForm(forms.Form): participation_fee = forms.RealWorldCurrencyField( required=False, # it seems that if this is omitted, the step defaults to an integer, # meaninng fractional inputs are not accepted widget=widgets._RealWorldCurrencyInput(attrs={'step': 0.01}), ) real_world_currency_per_point = forms.FloatField(required=False) label = forms.CharField(required=False) comment = forms.CharField(required=False)
class CreateSessionForm(forms.Form): session_configs = SESSION_CONFIGS_DICT.values() session_config_choices = ( # use '' instead of None. '' seems to immediately invalidate the choice, # rather than None which seems to be coerced to 'None'. [('', '-----')] + [(s['name'], s['display_name']) for s in session_configs]) session_config = forms.ChoiceField( choices=session_config_choices, required=True) num_participants = forms.IntegerField(required=False) is_mturk = forms.BooleanField( widget=widgets.HiddenInput, initial=False, required=False ) room_name = forms.CharField( initial=None, widget=widgets.HiddenInput, required=False ) def __init__(self, *args, is_mturk=False, room_name=None, **kwargs): super().__init__(*args, **kwargs) self.fields['room_name'].initial = room_name if is_mturk: self.fields['is_mturk'].initial = True self.fields['num_participants'].label = "Number of MTurk workers (assignments)" self.fields['num_participants'].help_text = ( 'Since workers can return an assignment or drop out, ' 'some "spare" participants will be created: ' f'the oTree session will have {settings.MTURK_NUM_PARTICIPANTS_MULTIPLE}' '{} times more participant objects than the number you enter here.' ) else: self.fields['num_participants'].label = "Number of participants" def clean(self): super().clean() if self.errors: return session_config_name = self.cleaned_data['session_config'] config = SESSION_CONFIGS_DICT[session_config_name] lcm = config.get_lcm() num_participants = self.cleaned_data.get('num_participants') if num_participants is None or num_participants % lcm: raise forms.ValidationError( 'Please enter a valid number of participants.' )
class CreateRoomForm(forms.ModelForm): name = forms.CharField(required=True, label="", error_messages={"unique": "Dette klassenavn findes allerede. Venligst benyt et andet."}, widget=forms.TextInput(attrs={ 'spellcheck': "false", "class": "room_name_input", 'placeholder': "Navngiv dit klasserum"}), ) class Meta: model = RoomsStorage fields = ["name"] def __str__(self): return self.name