예제 #1
0
        /// <summary>
        /// Creates a new survey using a json object containing necessary survey fields.
        /// </summary>
        /// <param name="cs"> The consumer survey service used to send the HTTP requests.</param>
        /// <param name="owners"> The list of owners that will be in the newly created survey.</param>
        /// <returns>
        /// A Survey object containing information about the survey.
        /// </returns>

        private static Survey CreateSurvey(ConsumersurveysService cs, List <String> owners)
        {
            SurveyAudience audience = new SurveyAudience()
            {
                Country = "US"
            };
            List <SurveyQuestion> questions = new List <SurveyQuestion>();
            SurveyQuestion        question  = new SurveyQuestion()
            {
                UnitsPosition          = "before",
                Type                   = "openNumericQuestion",
                Question               = "How much did you pay for your last phone?",
                LowValueLabel          = "1",
                UnitOfMeasurementLabel = "$",
                SingleLineResponse     = true,
                OpenTextPlaceholder    = "enter amount here",
            };

            questions.Add(question);

            Survey survey = new Survey()
            {
                Owners              = owners,
                Description         = "What phones do people buy and how much do they pay?",
                Title               = "Phone purchase survey",
                WantedResponseCount = 110,
                Audience            = audience,
                Questions           = questions,
            };
            Survey createdSurvey = cs.Surveys.Insert(survey).Execute();

            return(createdSurvey);
        }
예제 #2
0
        /// <summary>
        /// Creates a new survey using a json object containing necessary survey fields.
        /// </summary>
        /// <param name="surveysService"> The survey service used to send the HTTP requests.</param>
        /// <param name="owners"> The list of owners that will be in the newly created survey.</param>
        /// <returns>
        /// A Survey object containing information about the survey.
        /// </returns>

        private static Survey CreateSurvey(SurveysService surveysService, List <String> owners)
        {
            // [START google_surveys_create]
            List <string> langs = new List <string>();

            langs.Add("en-US");

            SurveyAudience audience = new SurveyAudience()
            {
                Country   = "US",
                Languages = langs
            };
            List <SurveyQuestion> questions = new List <SurveyQuestion>();
            SurveyQuestion        question  = new SurveyQuestion()
            {
                Type     = "numericOpenEnded",
                Question = "How much did you pay for your last phone?",
                UnitOfMeasurementLabel = "$",
                SingleLineResponse     = true,
                OpenTextPlaceholder    = "enter amount here",
            };

            questions.Add(question);

            Survey newSurvey = new Survey()
            {
                Owners              = owners,
                Description         = "What phones do people buy and how much do they pay?",
                Title               = "Phone purchase survey",
                WantedResponseCount = 110,
                Audience            = audience,
                Questions           = questions,
            };
            Survey survey = surveysService.Surveys.Insert(newSurvey).Execute();

            // [END google_surveys_create]

            return(survey);
        }
예제 #3
0
        /// <summary>
        /// Creates a new survey using a json object containing necessary survey fields.
        /// </summary>
        /// <param name="cs"> The consumer survey service used to send the HTTP requests.</param>
        /// <param name="owners"> The list of owners that will be in the newly created survey.</param>
        /// <returns>
        /// A Survey object containing information about the survey.
        /// </returns>

        private static Survey CreateSurvey(ConsumersurveysService cs, List<String> owners)
        {
            SurveyAudience audience = new SurveyAudience()
            {
                Country = "US"
            };
            List<SurveyQuestion> questions = new List<SurveyQuestion>();
            SurveyQuestion question = new SurveyQuestion()
            {
                UnitsPosition = "before",
                Type = "openNumericQuestion",
                Question = "How much did you pay for your last phone?",
                LowValueLabel = "1",
                UnitOfMeasurementLabel = "$",
                SingleLineResponse = true,
                OpenTextPlaceholder = "enter amount here",
            };
            questions.Add(question);

            Survey survey = new Survey()
            {
                Owners = owners,
                Description = "What phones do people buy and how much do they pay?",
                Title = "Phone purchase survey",
                WantedResponseCount = 110,
                Audience = audience,
                Questions = questions,
            };
            Survey createdSurvey = cs.Surveys.Insert(survey).Execute();
            return createdSurvey;
        }