com.google.api.services.consumersurveys.model.SurveyQuestion

Here are the examples of the java api class com.google.api.services.consumersurveys.model.SurveyQuestion taken from open source projects.

1. App#createSurvey()

Project: consumer-surveys
File: App.java
/**
   * Creates a new survey using a json object containing necessary survey fields.
   * @param cs The Consumer Surveys Service used to send the HTTP requests.
   * @param owners The list of owners that will be in the newly created survey.
   * return A survey object for the survey we created.
   */
private static Survey createSurvey(Consumersurveys cs, List<String> owners) throws Exception {
    // Setting survey properties.
    Survey survey = new Survey();
    survey.setOwners(owners);
    survey.setDescription("What phones do people buy and how much do they pay?");
    survey.setTitle("Phone purchase survey");
    survey.setWantedResponseCount(110);
    // Creating the audience.
    SurveyAudience audience = new SurveyAudience();
    audience.setCountry("US");
    survey.setAudience(audience);
    // Creating a question for the survey.
    List<SurveyQuestion> questions = new ArrayList<SurveyQuestion>();
    SurveyQuestion question = new SurveyQuestion();
    question.setUnitsPosition("before");
    question.setType("openNumericQuestion");
    question.setQuestion("How much did you pay for your last phone?");
    question.setLowValueLabel("1");
    question.setUnitOfMeasurementLabel("$");
    question.setSingleLineResponse(true);
    question.setOpenTextPlaceholder("enter amount here");
    questions.add(question);
    survey.setQuestions(questions);
    Survey createdSurvey = cs.surveys().insert(survey).execute();
    System.out.println("Created survey with id: " + createdSurvey.getSurveyUrlId());
    return createdSurvey;
}