コード例 #1
0
        /// <summary>
        /// Turn a detail survey response into a survey id with a list of associated questions and answers.
        /// </summary>
        /// <param name="surveyDetailResponse">Has all data regarding the survey</param>
        public void LoadSurvey(GetSurveyDetailsResponse surveyDetailResponse)
        {
            int questionNumber = 0;
            List<QuestionInfo> qList = new List<QuestionInfo>();
            List<QuestionAnswerFlat> qafList = new List<QuestionAnswerFlat>();

            SurveyID = surveyDetailResponse.SurveyDetailsResult.SurveyID;
            foreach(PageInfo surveyPage in surveyDetailResponse.SurveyDetailsResult.PageList)
            {
                foreach(QuestionInfo pageQuestion in surveyPage.QuestionList.OrderBy(e => e.Position))
                {
                    string row = "0";
                    string col = "0";
                    qList.Add(pageQuestion);
                    questionNumber++;
                    foreach (AnswerInfo questionAnswer in pageQuestion.QuestionAnswerList.OrderBy(e => e.Position))
                    {
                        if (questionAnswer.AnswerType == AnswerTypeEnum.Row)
                        {
                            row = questionAnswer.AnswerID;
                        }
                        if (questionAnswer.AnswerType == AnswerTypeEnum.Column)
                        {
                            col = questionAnswer.Column;
                        }
                        QuestionAnswerFlat qaf = new QuestionAnswerFlat();
                        qaf.AnswerID = questionAnswer.AnswerID;
                        qaf.AnswerNumber = questionAnswer.Position;
                        qaf.AnswerText = questionAnswer.Text;
                        qaf.AnswerType = questionAnswer.AnswerType;
                        qaf.AnswerVisible = questionAnswer.Visible;
                        qaf.QuestionID = pageQuestion.QuestionID;
                        qaf.QuestionNumber = questionNumber;
                        qaf.QuestionSubtype = pageQuestion.QuestionType.Subtype;
                        qaf.QuestionText = pageQuestion.Heading;
                        qaf.QuestionType = pageQuestion.QuestionType.Family;
                        qaf.Column = col;
                        qaf.Row = row;
                        qaf.Weight = questionAnswer.Weight;
                        qafList.Add(qaf);
                    }
                }
            }

            QuestionList = qList;
            SurveyWithAnswers = qafList;
        }
コード例 #2
0
 private void DBSurveyResponseUpdate(GetSurveyDetailsResponse surveyDetails, List<QuestionAnswerFlat> surveyWithAnswers)
 {
     string SurveyID = surveyDetails.SurveyDetailsResult.SurveyID;
     foreach(PageInfo pInfo in surveyDetails.SurveyDetailsResult.PageList)
     {
         string PageID = pInfo.PageID;
         string PageHeading = pInfo.Heading;
         int questionsPerPage = 0;
         double pageRankSum = 0;
         foreach(QuestionInfo qInfo in pInfo.QuestionList)
         {
             int partsPerQuestion = 0;
             double questionRankSum = 0;
             if(qInfo.QuestionType.Subtype == QuestionSubtypeEnum.Rating || qInfo.QuestionType.Subtype == QuestionSubtypeEnum.Ranking)
             {
                 List<QuestionAnswerFlat> qRatingsList = surveyWithAnswers.Where(e => e.QuestionID == qInfo.QuestionID).ToList<QuestionAnswerFlat>();
                 foreach(QuestionAnswerFlat qaf in qRatingsList)
                 {
                     if(qaf.AnswerType == AnswerTypeEnum.Row)
                     {
                         questionRankSum += qaf.RankAvg;
                         partsPerQuestion++;
                     }
                 }
             }
             double questionRankAvg = questionRankSum / partsPerQuestion;
             // Write survey results to database.
             //Survey.SurveyResponseUpdate(SurveyID, qInfo.QuestionID, PageHeading, PageID, questionRankAvg, connString);
             questionsPerPage += partsPerQuestion;
             pageRankSum += questionRankSum;
         }
         double pageRankAvg = pageRankSum / questionsPerPage;
         // Write survey page summary to database.
         //Survey.SurveyResponseUpdate(SurveyID, "", PageHeading, PageID, pageRankAvg, connString);
     }
 }