Пример #1
0
def surveyform():

    form = SurveyForm(csrf_enabled=False)

    if form.validate_on_submit():
        dropdown = form.dropdown.data
        multiple = form.multiple.data
        single = form.singletext.data
        # print(dropdown)

        # return redirect(url_for('testformresponse', dropdown = dropdown, single = single))

        return render_template(
            'testformresponse.html',
            dropdown=dropdown,
            single=single,
            multiple=multiple
        )  # singletext = singletext) #, multiple = multiple)

    return render_template('photo_form.html',
                           form=form,
                           price=request.args.get('price'),
                           address=request.args.get('address'),
                           goog_photo=request.args.get('goog_photo'),
                           filename=request.args.get('filename'))
Пример #2
0
def add_survey():
    form = SurveyForm()
    form.event.query_factory = event_query
    if form.validate_on_submit():
        value_average = (form.value_1.data + form.value_2.data + form.value_3.data + form.value_4.data + form.value_5.data) / 5
        speaker_average = (form.speaker_1.data + form.speaker_2.data + form.speaker_3.data) / 3
        content_average = (form.content_1.data + form.content_2.data) / 2
        facility_average = (form.facility_1.data + form.facility_2.data) / 2
        overall_average = (value_average + speaker_average + content_average + facility_average) / 4
        survey = Survey(value_1=form.value_1.data, value_2=form.value_2.data, value_3=form.value_3.data,
                        value_4=form.value_4.data, value_5=form.value_5.data, value_average=value_average,
                        speaker_1=form.speaker_1.data, speaker_2=form.speaker_2.data, speaker_3=form.speaker_3.data,
                        speaker_average=speaker_average, content_1=form.content_1.data, content_2=form.content_2.data,
                        content_average=content_average, facility_1=form.facility_1.data, facility_2=form.facility_2.data,
                        facility_average=facility_average, response_1=form.response_1.data, response_2=form.response_2.data,
                        response_3=form.response_3.data, response_4=form.response_4.data, name=form.name.data,
                        email=form.email.data, overall_average=overall_average
                        )

        db.session.add(survey)
        db.session.commit()
        survey.event = form.event.data
        db.session.commit()

        for speaker in survey.event.speakers:
            update_speaker(speaker)

        update_event(survey.event)

        flash("Survey Saved.")
        return redirect(url_for('index'))
    return render_template('add_survey.html', title='Add Survey', form=form)
Пример #3
0
def survey():
    form = SurveyForm()
    if form.validate_on_submit():
        current_user.robot_teaching = form.robot_teaching.data
        current_user.user_learning = form.user_learning.data
        current_user.age = form.age.data
        current_user.gender = form.gender.data
        current_user.ethnicity = form.ethnicity.data
        current_user.education = form.education.data
        current_user.robot = form.robot.data
        db.session.commit()
        redirect(url_for("index"))

    num_completed_trials = current_user.trials.count()
    num_completed_demos = current_user.demos.count()
    if current_user.robot_teaching:
        flash("You have completed the survey!")
        return redirect(url_for("index"))
    else:
        if current_user.consent and num_completed_demos == NUM_DEMOS and num_completed_trials == NUM_TRIALS and current_user.training:
            return render_template("survey.html",
                                   methods=["GET", "POST"],
                                   form=form)
        else:
            flash("You must complete the modules in order!")
            return redirect(url_for("index"))
Пример #4
0
def survey():
    """Allow students to view survey form"""
    form = SurveyForm()
    if request.method == 'GET':
        s_id = request.args.get('s')
        c_id = request.args.get('c')
        # pre-fill student ID and course only if valid (avoids accidental tampering)
        # avoids false presumption by user that prefilled data MUST be accurate
        if s_id and c_id and studentExists(s_id, c_id):
            form.student_id.data = s_id
            form.course_id.data = c_id
    if form.validate_on_submit():
        # numerical data has to be type-casted here - WTForms doesn't allow numerical choices (must be str type) but pandas sometimes doesn't properly calculate statistics if entered values are in str form
        response_data = (float(form.learning_1.data),
                         float(form.learning_2.data),
                         float(form.learning_3.data),
                         float(form.learning_4.data),
                         form.learning_5.data, form.learning_6.data,
                         float(form.lab_1.data), float(form.lab_2.data),
                         float(form.lab_3.data), float(form.lab_4.data),
                         float(form.lab_5.data), form.lab_6.data,
                         float(form.spaceequipment_1.data),
                         float(form.spaceequipment_2.data),
                         float(form.spaceequipment_3.data),
                         form.spaceequipment_4.data, float(form.time_1.data),
                         float(form.time_2.data), float(form.time_3.data),
                         form.lecture_1.data)
        addResult(form.student_id.data, form.course_id.data, response_data)
        flash('Survey submitted!')
        return redirect(url_for('main.survey'))
    return render_template('survey.html',
                           title='SET++',
                           form=form,
                           deadline=Deadline.query.first(),
                           time=datetime.utcnow())
Пример #5
0
def rate(workshop_id):
    workshop = Workshop.query.filter_by(id=workshop_id).first()
    timediff = datetime.utcnow() - workshop.workshop_start
    if workshop is None or timediff.days > 10:
        flash('Workshop survey is not available at the moment!')
        return redirect(url_for('index'))

    form = SurveyForm()
    form.workshop_id.data = workshop_id

    if form.validate_on_submit():
        response = Response(workshop_id=form.workshop_id.data,
                            difficulty=form.difficulty.data,
                            assistants_score=form.assistant.data,
                            knowledge=form.knowledgeable.data,
                            objectives=form.objective.data,
                            timeliness=form.time.data,
                            venue_score=form.venue.data,
                            satisfaction_score=form.satisfaction.data,
                            comments=form.comments.data)
        db.session.add(response)
        db.session.commit()
        return render_template('response.html')

    return render_template('survey.html',
                           form=form,
                           workshop_name=workshop.workshop_name,
                           workshop_category=workshop.workshop_category)
Пример #6
0
def surveyform():

    form = SurveyForm(csrf_enabled=False)

    if form.validate_on_submit():
        # data collection form
        notes = form.extranotes.data
        dropdown = form.dropdown.data
        multiple = form.multiple.data
        single = form.singletext.data
        outer = form.outer.data
        exterior = form.exterior.data
        interior = form.interior.data

        # add to csv
        #basepath = os.path.abspath('app/')
        #df = pd.read_csv(f'{basepath}/uploads/house_data.csv')
        #temp_df = pd.DataFrame([[filename, goog_photo, coords, address, price, dropdown, multiple, single, outer, exterior, interior, notes]], columns = df.columns)
        #df = df.append(temp_df)
        #df.to_csv(f'{basepath}/uploads/house_data.csv')

        # unnecessary to redirect, but should be able to
        # return redirect(url_for('testformresponse', dropdown = dropdown, single = single))

        # render template with variables from this form
        return render_template(
            'testformresponse.html',
            dropdown=dropdown,
            single=single,
            multiple=multiple,
            outer=outer,
            exterior=exterior,
            interior=interior,
            notes=request.args.get('notes'),
            price=request.args.get('price'),
            address=request.args.get('address'),
            goog_photo=request.args.get('goog_photo'),
            filename=request.args.get('filename'),
            coords=request.args.get(
                'coords'))  # singletext = singletext) #, multiple = multiple)

    # render template with passed variables from photo entry page
    return render_template('photo_form.html',
                           form=form,
                           price=request.args.get('price'),
                           address=request.args.get('address'),
                           goog_photo=request.args.get('goog_photo'),
                           filename=request.args.get('filename'),
                           coords=request.args.get('coords'))
Пример #7
0
def survey():
    g.user = current_user
    model_id = request.args.get('model_id', None)
    if model_id:
        session['model_id'] = model_id
    form = SurveyForm()
    if request.method == 'POST' and form.validate():
        survey = Survey()
        form.populate_obj(survey)
        survey.user = g.user
        survey.model = Model.query.get(session['model_id'])
        db.session.add(survey)
        db.session.commit()
        flash("Submission complete", "success")
        return redirect(url_for("index.index"))
    return render_template('survey.html', form=form)
Пример #8
0
def survey():
    """Presents a survey to be filled out by the user."""
    form = SurveyForm(request.form)
    if request.method == 'POST':
        flash('Thank you for taking our survey, your feedback is appreciated!')
        return redirect(url_for('home'))
    return render_template('survey.html', form=form)
Пример #9
0
def index():  ## this is run when the URLs are called ('view function')
    form = SurveyForm() ## instantiating our SurveyForm(), values taken from the users

    if form.validate_on_submit():  ## if form passed via submit in html

        address = Address(form.raw_address.data)  ## instantiating our Address class from address.py with the raw_address data passed from html (via SurveyForm)

        ## assigning the input values to our Assessment database in models.py
        assessment = Assessment(raw_address=form.raw_address.data,
                                lat = address.lat,
                                lng = address.lng,
                                street_number = address.street_number,
                                street_name = address.street_name,
                                city_name = address.city_name,
                                state_abr = address.state_abr,
                                postal_code = address.postal_code,
                                formatted_address = address.formatted_address,
                                agent_est = form.agent_est.data,
                                applicant_est = form.applicant_est.data,
                                google_place_id = address.google_place_id,
                                street_pic = address.street_pic,
                                zillow_estimate = address.zillow_estimate,
                                zillow_baths = address.zillow_baths,
                                zillow_bedrooms = address.zillow_bedrooms,
                                damage = form.damage.data,
                                other_damage = form.other_damage.data,
                                exterior = form.exterior.data,
                                interior = form.interior.data,
                                other_exterior = form.other_exterior.data,
                                other_interior = form.other_interior.data,
                                disaster_type = form.disaster_type.data,
                                disaster_name = form.disaster_name.data,
                                comments = form.comments.data,
                                author=current_user)
        db.session.add(assessment)  ## adding assessment to the db
        db.session.commit()  ## committing this addition
        flash('You have logged an assessment')  ## displaying success
        return redirect(url_for('index'))  ## redirecting to index URL

    ## conducting query from User db (in models.py) to access all assessments
    assessments = current_user.assessment_list().all()

    ## we return, to the html file in our template folder the forms and assessments
    return render_template('index.html', title='Home Page', form=form, assessments=assessments)
Пример #10
0
def newSurvey():
    """Route to the survey."""
    form = SurveyForm()
    ans = Answer(usedToken=current_user.id)
    db.session.add(ans)
    db.session.commit()
    if form.is_submitted():
        ans = Answer.query.filter_by(usedToken=current_user.id).first()
        for element in form:
            if element.id.startswith('q'):
                if type(element.data) is list:
                    setattr(ans, element.id, str(element.data))
                else:
                    setattr(ans, element.id, element.data)
        db.session.commit()
        if not current_user.is_Admin:
            current_user.invalidate_token()
        logout_user()
        return redirect('/fertig')
    return render_template('newSurvey.html', title='Umfrage', form=form)
Пример #11
0
def survey():
    form = SurveyForm()
    if form.validate_on_submit():

        review = Review(
            content=form.content.data,
            overall_rating=form.overall_rating.data,
            type_traveller=form.type_traveller.data,
            cabin_flown=form.cabin_flown.data,
            seat_comfort_rating=form.seat_comfort_rating.data,
            cabin_staff_rating=form.cabin_staff_rating.data,
            food_beverages_rating=form.food_beverages_rating.data,
            inflight_entertainment_rating=form.inflight_entertainment_rating.
            data,
            ground_service_rating=form.ground_service_rating.data,
            wifi_connectivity_rating=form.wifi_connectivity_rating.data,
            value_money_rating=form.value_money_rating.data)
        db.session.add(review)
        db.session.commit()

        return redirect(url_for('results'))
    return render_template('survey.html', title='Survey', form=form)
Пример #12
0
def survey():
    form = SurveyForm()
    if form.validate_on_submit():
        one = request.form['level_one']
        two = request.form['level_two']
        three = request.form['level_three']
        start = request.form['start_day_hour']
        end = request.form['end_day_hour']
        lunch = request.form['lunch_hour']
        dinner = request.form['dinner_hour']

        user_info = {'level_one' : one,
                    'level_two' : two,
                    'level_three' : three}
        user_preference = {'start_day_hour' : start,
                            'end_day_hour' : end,
                            'lunch_hour' : lunch,
                            'dinner_hour' : dinner}
        with open('user_info.json', 'w') as f:
            json.dump(user_info, f)
        with open('user_preference.json', 'w') as f:
            json.dump(user_preference, f)
        return redirect(url_for('calendar'))    
    return render_template('survey.html', title='Survey', form=form)
Пример #13
0
def poll(id):
    form = SurveyForm()
    current_poll = Poll.query.filter_by(id=id).first()
    if current_poll:
        if request.method == "POST":
            save_answer(form, id)
            flash('Poll Answer submitted')
            return redirect(url_for('home'))
        else:
            questions = Question.query.filter_by(parent=id).all()
            for question in questions:
                form.select_entries.append_entry()
                option_list = get_option_list(question)
                form.select_entries[-1].option.choices = option_list
                form.select_entries[-1].option.label = question.name
                form.select_entries[-1]['question'].data = question.id
            return render_template('survey.html', form=form, title=current_poll.name)
    else:
        print('no hay poll')