Beispiel #1
0
	def run(self):

		"""Run the item"""

		# Parse the option list
		option_list = self.var.options.split(u'\n') # split by return
		# Filter out empty options
		option_list = list(filter(lambda option: option != u'', option_list))
		# option_list.pop(len(option_list)-1) # remove last (empty) option
		if len(option_list) == 0:
			raise osexception(
				u'You must specify at least one response option in form_multiple_choice item "%s"' \
				% self.name)

		# Determine whether a button is shown and determine the number of rows
		rows = len(option_list) + 2
		if self.var.advance_immediately == u'no' \
			or self.var.allow_multiple == u'yes':
			show_button = True
			click_accepts = False
			rows += 1
		else:
			show_button = False
			click_accepts = True

		# Determine the group for the checkboxes
		if self.var.allow_multiple == u'no':
			group = u'response_group'
		else:
			group = None

		# The variable in which the response is stored
		var = self.var.form_var

		# Build the form
		try:
			margins = [float(i) for i in str(self.var.margins).split(u';')]
		except:
			raise osexception(
				_(u'margins should be numeric values separated by a semi-colon'))
		if self.var.timeout == u'infinite':
			timeout = None
		else:
			timeout = self.var.timeout
		form = widgets.form(self.experiment, cols=1, rows=rows,
			spacing=self.var.spacing, margins=margins, theme=self.var._theme,
			item=self, timeout=timeout, clicks=self.var.form_clicks==u'yes')
		form.set_widget(widgets.label(form, self.var.form_title), (0,0))
		form.set_widget(widgets.label(form, self.var.question), (0,1))
		i = 2
		for option in option_list:
			form.set_widget(widgets.checkbox(form, option,
				group=group, click_accepts=click_accepts, var=var), (0,i))
			i += 1
		if show_button:
			form.set_widget(widgets.button(form, self.var.button_text), (0,i))

		# Go!
		form._exec()
Beispiel #2
0
    def run(self):
        """Run the item"""

        # Parse the option list
        option_list = self.get(u'options').split(u'\n')  # split by return
        option_list.pop(len(option_list) - 1)  # remove last (empty) option
        if len(option_list) == 0:
            raise osexception( \
             u'You must specify at least one response option in form_multiple_choice item "%s"' \
             % self.name)

        # Determine whether a button is shown and determine the number of rows
        rows = len(option_list) + 2
        if self.get(u'advance_immediately') == u'no' or \
         self.get(u'allow_multiple') == u'yes':
            show_button = True
            click_accepts = False
            rows += 1
        else:
            show_button = False
            click_accepts = True

        # Determine the group for the checkboxes
        if self.get(u'allow_multiple') == u'no':
            group = u'response_group'
        else:
            group = None

        # The variable in which the response is stored
        var = self.get(u'form_var')

        # Build the form
        try:
            margins = [float(i) for i in unicode(self.margins).split(u';')]
        except:
            raise osexception( \
             _(u'margins should be numeric values separated by a semi-colon'))
        form = widgets.form(self.experiment,
                            cols=1,
                            rows=rows,
                            spacing=self.get(u'spacing'),
                            margins=margins,
                            theme=self.get(u'theme'),
                            item=self)
        form.set_widget(widgets.label(form, self.get(u'form_title')), (0, 0))
        form.set_widget(widgets.label(form, self.get(u'question')), (0, 1))
        i = 2
        for option in option_list:
            form.set_widget(widgets.checkbox(form, option, group=group, \
             click_accepts=click_accepts, var=var), (0,i))
            i += 1
        if show_button:
            form.set_widget(widgets.button(form, self.get(u'button_text')), \
             (0,i))

        # Go!
        form._exec()
	def run(self):

		"""Run the item"""

		# Parse the option list
		option_list = self.get(u'options').split(u'\n') # split by return
		option_list.pop(len(option_list)-1) # remove last (empty) option
		if len(option_list) == 0:
			raise osexception( \
				u'You must specify at least one response option in form_multiple_choice item "%s"' \
				% self.name)

		# Determine whether a button is shown and determine the number of rows
		rows = len(option_list) + 2
		if self.get(u'advance_immediately') == u'no' or \
			self.get(u'allow_multiple') == u'yes':
			show_button = True
			click_accepts = False
			rows += 1
		else:
			show_button = False
			click_accepts = True

		# Determine the group for the checkboxes
		if self.get(u'allow_multiple') == u'no':
			group = u'response_group'
		else:
			group = None

		# The variable in which the response is stored
		var = self.get(u'form_var')

		# Build the form
		try:
			margins = [float(i) for i in unicode(self.margins).split(u';')]
		except:
			raise osexception( \
				_(u'margins should be numeric values separated by a semi-colon'))
		form = widgets.form(self.experiment, cols=1, rows=rows,
			spacing=self.get(u'spacing'), margins=margins,
			theme=self.get(u'_theme'), item=self)
		form.set_widget(widgets.label(form, self.get(u'form_title')), (0,0))
		form.set_widget(widgets.label(form, self.get(u'question')), (0,1))
		i = 2
		for option in option_list:
			form.set_widget(widgets.checkbox(form, option, group=group, \
				click_accepts=click_accepts, var=var), (0,i))
			i += 1
		if show_button:
			form.set_widget(widgets.button(form, self.get(u'button_text')), \
				(0,i))

		# Go!
		form._exec()
	def run(self):
		
		"""Run the item"""
		
		# Parse the option list
		option_list = unicode(self.get('options')).split('\n') # split by return
		option_list.pop(len(option_list)-1) # remove last (empty) option
		if len(option_list) == 0:
			raise exceptions.runtime_error( \
			'You must specify at least one response option in form_multiple_choice item "%s"' \
			% self.name)
			
		# Determine whether a button is shown and determine the number of rows
		rows = len(option_list) + 2
		if self.get('advance_immediately') == 'no' or \
			self.get('allow_multiple') == 'yes':
			show_button = True
			click_accepts = False
			rows += 1
		else:
			show_button = False
			click_accepts = True
			
		# Determine the group for the checkboxes
		if self.get('allow_multiple') == 'no':
			group = 'response_group'
		else:
			group = None			
			
		# The variable in which the response is stored
		var = self.get('form_var')
		
		# Build the form
		form = widgets.form(self.experiment, cols=1, rows=rows)		
		form.set_widget(widgets.label(form, self.get('form_title')), (0,0))
		form.set_widget(widgets.label(form, self.get('question')), (0,1))
		i = 2
		for option in option_list:
			form.set_widget(widgets.checkbox(form, option, group=group, \
				click_accepts=click_accepts, var=var), (0,i))
			i += 1
		if show_button:
			form.set_widget(widgets.button(form, self.get('button_text')), \
				(0,i))

		# Go!
		form._exec()
		return True
Beispiel #5
0
    def run(self):
        """Run the item"""

        # Parse the option list
        option_list = unicode(self.get('options')).split(
            '\n')  # split by return
        option_list.pop(len(option_list) - 1)  # remove last (empty) option
        if len(option_list) == 0:
            raise exceptions.runtime_error( \
            'You must specify at least one response option in form_multiple_choice item "%s"' \
            % self.name)

        # Determine whether a button is shown and determine the number of rows
        rows = len(option_list) + 2
        if self.get('advance_immediately') == 'no' or \
         self.get('allow_multiple') == 'yes':
            show_button = True
            click_accepts = False
            rows += 1
        else:
            show_button = False
            click_accepts = True

        # Determine the group for the checkboxes
        if self.get('allow_multiple') == 'no':
            group = 'response_group'
        else:
            group = None

        # The variable in which the response is stored
        var = self.get('form_var')

        # Build the form
        form = widgets.form(self.experiment, cols=1, rows=rows)
        form.set_widget(widgets.label(form, self.get('form_title')), (0, 0))
        form.set_widget(widgets.label(form, self.get('question')), (0, 1))
        i = 2
        for option in option_list:
            form.set_widget(widgets.checkbox(form, option, group=group, \
             click_accepts=click_accepts, var=var), (0,i))
            i += 1
        if show_button:
            form.set_widget(widgets.button(form, self.get('button_text')), \
             (0,i))

        # Go!
        form._exec()
        return True
    def run(self):
        """Run the item"""

        # Parse the option list
        option_list = self.var.options.split(u'\n')  # split by return
        # Filter out empty options
        option_list = list(filter(lambda option: option != u'', option_list))
        # option_list.pop(len(option_list)-1) # remove last (empty) option
        if len(option_list) == 0:
            raise osexception(
             u'You must specify at least one response option in form_multiple_choice item "%s"' \
             % self.name)

        # Determine whether a button is shown and determine the number of rows
        rows = len(option_list) + 2
        if self.var.advance_immediately == u'no' \
         or self.var.allow_multiple == u'yes':
            show_button = True
            click_accepts = False
            rows += 1
        else:
            show_button = False
            click_accepts = True

        # Determine the group for the checkboxes
        if self.var.allow_multiple == u'no':
            group = u'response_group'
        else:
            group = None

        # The variable in which the response is stored
        var = self.var.form_var

        # Build the form
        try:
            margins = [float(i) for i in str(self.var.margins).split(u';')]
        except:
            raise osexception(
                _(u'margins should be numeric values separated by a semi-colon'
                  ))
        if self.var.timeout == u'infinite':
            timeout = None
        else:
            timeout = self.var.timeout
        form = widgets.form(self.experiment,
                            cols=1,
                            rows=rows,
                            spacing=self.var.spacing,
                            margins=margins,
                            theme=self.var._theme,
                            item=self,
                            timeout=timeout,
                            clicks=self.var.form_clicks == u'yes')
        form.set_widget(widgets.label(form, self.var.form_title), (0, 0))
        form.set_widget(widgets.label(form, self.var.question), (0, 1))
        i = 2
        for option in option_list:
            form.set_widget(
                widgets.checkbox(form,
                                 option,
                                 group=group,
                                 click_accepts=click_accepts,
                                 var=var), (0, i))
            i += 1
        if show_button:
            form.set_widget(widgets.button(form, self.var.button_text), (0, i))

        # Go!
        form._exec()