def get_option_question(self,html_frag,question): logging.info("option question") field = typeformio.multiple_choice_field(question) option_data = collections.OrderedDict() for i,option in enumerate(html_frag.find_all(class_="answer-option-cell")): if option.find("input"): option_text='' id = option.find("input")['id'] if option.select("input.cb"): option_type = 'checkbox' elif option.find(class_="radio-button-input"): option_text = ' '.join(option.find(class_='radio-button-label-text').stripped_strings) field.add_option(option_text) option_type = 'radiobutton' else: option_type = 'unknown' option_data[id] = {'type':option_type,'text':option_text.replace('\n',''),'text_input':False} # if we have any open text options update the dict open_text_fields = html_frag.find_all(class_="other-answer-container") for open_text in open_text_fields: open_text_id = open_text['id'].split('_')[2] open_text_size = int(open_text['size']) option_data[open_text_id]['text_input']=open_text_size # convert back to list option_list = option_data.values() return field
def get_multiple_choice_question(self,html_frag,allow_multi_selection=False): logging.info("found multiple choice question") field = typeformio.multiple_choice_field() choices = [ l.text for l in html_frag.find_all(class_="ss-choice-label") if l.text != '' ] map(field.add_option,choices) field.set_tags((html_frag.select(".ss-choice-item input")[0]["name"]).replace(".",":")) # this should be coming soon #field.allow_multiple_selection(allow_multi_selection) return field
def get_multiple_choice_question(self, html_frag, allow_multi_selection=False): logging.info("found multiple choice question") field = typeformio.multiple_choice_field() choices = [ l.text for l in html_frag.find_all(class_="ss-choice-label") if l.text != '' ] map(field.add_option, choices) field.set_tags( (html_frag.select(".ss-choice-item input")[0]["name"]).replace( ".", ":")) # this should be coming soon #field.allow_multiple_selection(allow_multi_selection) return field
def get_option_question(self, html_frag, question): logging.info("option question") field = typeformio.multiple_choice_field(question) option_data = collections.OrderedDict() for i, option in enumerate( html_frag.find_all(class_="answer-option-cell")): if option.find("input"): option_text = '' id = option.find("input")['id'] if option.select("input.cb"): option_type = 'checkbox' elif option.find(class_="radio-button-input"): option_text = ' '.join( option.find( class_='radio-button-label-text').stripped_strings) field.add_option(option_text) option_type = 'radiobutton' else: option_type = 'unknown' option_data[id] = { 'type': option_type, 'text': option_text.replace('\n', ''), 'text_input': False } # if we have any open text options update the dict open_text_fields = html_frag.find_all(class_="other-answer-container") for open_text in open_text_fields: open_text_id = open_text['id'].split('_')[2] open_text_size = int(open_text['size']) option_data[open_text_id]['text_input'] = open_text_size # convert back to list option_list = option_data.values() return field