def seed_personal_questions(): # survey_old = Survey.query.filter_by(name='personal_questions').first() # db.session.delete(survey_old) # db.session.commit() survey = Survey(name="demographic_questions") questions = [] # 1 question_1 = Question(text='What is your gender?', type='radio', name='gender') question_1.simple_choices = [ SimpleChoice(text='Female'), SimpleChoice(text='Male'), SimpleChoice(text='Other/Prefer not to say') ] questions.append(question_1) # 2 question_2 = Question(text='What is your age?', type='text_field', name='age') questions.append(question_2) # 3 question_3 = Question( text='What is the highest level of education you have completed?', type='radio', name='education') question_3.simple_choices = [ SimpleChoice(text='8th grade'), SimpleChoice(text='Some high school'), SimpleChoice(text='High school graduate'), SimpleChoice(text='Vocational or technical school'), SimpleChoice(text='Some college'), SimpleChoice(text='Associate degree'), SimpleChoice(text='Bachelor’s degree'), SimpleChoice(text='Graduate work'), SimpleChoice(text='I prefer not to say') ] questions.append(question_3) # 4 question_4 = Question( text='What is the level of your English proficiency?', type='radio', name='native_english_speaker') question_4.simple_choices = [ SimpleChoice(text='Native speaker'), SimpleChoice(text='Near-native speaker'), SimpleChoice(text='Non-native speaker'), ] questions.append(question_4) survey.questions = questions db.session.add(survey) db.session.commit()
def seed_annotation_questions(): # survey_old = Survey.query.filter_by(name='annotation_questions').first() # db.session.delete(survey_old) # db.session.commit() survey = Survey(name="annotation_questions") questions = [] # 1 question_1 = Question( text= 'Please highlight words or phrases that you think introduce bias or convey strong opinions/emotions in the sentence displayed above.', type='highlight', name='sentence_bias_annotation') questions.append(question_1) # 2 question_2 = Question( text='Do you find the above sentence as biased or non-biased?', type='radio', name='sentence_bias_label') question_2.simple_choices = [ SimpleChoice(text='Biased'), SimpleChoice(text='Non-biased') ] questions.append(question_2) # 3 question_3 = Question( text= 'Would you say that the sentence is entirely factual or expresses the writer’s opinion?', type='radio', name='sentence_opinion_fact') question_3.simple_choices = [ SimpleChoice(text='Entirely factual'), SimpleChoice(text='Expresses writer’s opinion'), SimpleChoice(text='Somewhat factual but also opinionated') ] questions.append(question_3) survey.questions = questions db.session.add(survey) db.session.commit()
def create_survey(current_user): data = request.get_json() survey = Survey(name=data['name']) questions = [] for q in data['questions']: question = Question(text=q['question']) question.choices = [Choice(text=c) for c in q['choices']] questions.append(question) survey.questions = questions survey.creator = current_user db.session.add(survey) db.session.commit() return jsonify(survey.to_dict()), 201
def surveys(): if request.method == 'GET': surveys = Survey.query.all() return jsonify({'surveys': [s.to_dict() for s in surveys]}) elif request.method == 'POST': data = request.get_json() survey = Survey(name=data['name']) questions = [] for q in data['questions']: question = Question(text=q['question']) question.choices = [Choice(text=c) for c in q['choices']] questions.append(question) survey.questions = questions db.session.add(survey) db.session.commit() return jsonify(survey.to_dict()), 201
def seed_iqc_questions(): survey = Survey(name="info_quality_control") questions = [] # 1 question_1 = Question(text='How is bias connected to the sentiment?', type='radio', name='bias_sentiment') question_1.simple_choices = [ SimpleChoice(text='Bias is the same as negative sentiment'), SimpleChoice(text='Bias is the same as positive sentiment'), SimpleChoice( text= 'Bias can be both positive, negative or even not have particular sentiment' ), SimpleChoice(text='Bias is not connected to sentiment at all') ] questions.append(question_1) survey.questions = questions db.session.add(survey) db.session.commit()
def seed_idealogy_questions(): # survey_old = Survey.query.filter_by(name='idealogy_questions').first() # db.session.delete(survey_old) # db.session.commit() survey = Survey(name="idealogy_questions") idealogy_questions = [] # 1 question_1 = Question( text= 'Do you consider yourself to be liberal, conservative or somewhere in between?', type='range_slider', name='political_ideology') question_1.range_slider_choices = [ RangeSliderChoice(min_range=-10, max_range=10, label_left_side='Very liberal', label_right_side='Very conservative') ] idealogy_questions.append(question_1) # 2 question_2 = Question( text='How often on an average do you check the news?', type='radio', name='news_check_frequency') question_2.simple_choices = [ SimpleChoice(text='Never'), SimpleChoice(text='Very rarely'), SimpleChoice(text='Several times per month'), SimpleChoice(text='Several times per week'), SimpleChoice(text='Every day'), SimpleChoice(text='Several times per day') ] idealogy_questions.append(question_2) # 3 question_3 = Question( text='Please select AT LEAST one news outlets that you follow.', type='checkbox', name='followed_news_outlets') question_3.simple_choices = [ SimpleChoice(text='Fox News'), SimpleChoice(text='Fox News'), SimpleChoice(text='New York Times'), SimpleChoice(text='CNN'), SimpleChoice(text='MSNBC'), SimpleChoice(text='Reuters'), SimpleChoice(text='Breitbart'), SimpleChoice(text='The Federalist'), SimpleChoice(text='Huffington Post'), SimpleChoice(text='New York Post'), SimpleChoice(text='Alternet'), SimpleChoice(text='USA Today'), SimpleChoice(text='ABC News'), SimpleChoice(text='CBS News'), SimpleChoice(text='Univision'), SimpleChoice(text='The Washington Post'), SimpleChoice(text='The Wall Street Journal'), SimpleChoice(text='The Guardian'), SimpleChoice(text='BuzzFeed'), SimpleChoice(text='Vice'), SimpleChoice(text='Time magazine'), SimpleChoice(text='Business Insider') ] idealogy_questions.append(question_3) survey.questions = idealogy_questions db.session.add(survey) db.session.commit()