コード例 #1
0
        public IList <SurveyResults> GetSurveys()
        {
            List <SurveyResults> topFiveParks = new List <SurveyResults>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    string sql = "SELECT TOP 5 survey_result.parkCode , COUNT(*) as 'Favorites', park.parkName FROM survey_result Inner JOIN park ON park.parkCode = survey_result.parkCode GROUP BY survey_result.parkCode, parkName ORDER BY park.parkName ;";

                    SqlCommand cmd = new SqlCommand(sql, conn);

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        SurveyResults survey = new SurveyResults();
                        survey.ParkCode    = Convert.ToString(reader["parkCode"]);
                        survey.SurveyCount = Convert.ToInt32(reader["Favorites"]);
                        survey.ParkName    = Convert.ToString(reader["parkName"]);

                        topFiveParks.Add(survey);
                    }
                }
            }
            catch (SqlException)
            {
                throw;
            }
            return(topFiveParks);
        }
コード例 #2
0
ファイル: Survey.cs プロジェクト: lulzzz/DblDip
 public void When(SurveyResultAdded surveyResultAdded)
 {
     SurveyResults = SurveyResults.Concat(new[]
     {
         new SurveyResult(surveyResultAdded.SurveyResultId, surveyResultAdded.ClientEmail, surveyResultAdded.Answers)
     });
 }
コード例 #3
0
        public ActionResult ShowResults(int id)
        {
            Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
            Response.Cache.SetNoStore();
            SurveyResults surveyResults = new SurveyResults();
            var           optionOrder   = HttpContext.Request.QueryString["sortorder"];

            var viewModel = new SurveyViewModel()
            {
                Survey = _context.Surveys.SingleOrDefault(s => s.Id == id)
            };

            if (viewModel.Survey == null)
            {
                return(HttpNotFound());
            }
            else if (optionOrder != null)
            {
                surveyResults.OptionOrder = optionOrder;
                surveyResults.SurveyId    = id;
                surveyResults.UserId      = System.Web.HttpContext.Current.User.Identity.GetUserId();
                _context.SurveyResultsSet.Add(surveyResults);
                _context.SaveChanges();
            }

            test.runAlgorithm(id, _context);
            test.createjson(id, _context);

            return(View(viewModel));
        }
コード例 #4
0
        public bool SaveTestPage()
        {
            var sr = new SurveyResults();
            var p  = (Patron)Session["Patron"];
            int srid;

            if (SRID.Text != "0")
            {
                sr   = SurveyResults.FetchObject(int.Parse(SRID.Text));
                srid = sr.SRID;
            }
            else
            {
                sr.TenID        = p.TenID;
                sr.PID          = p.PID;
                sr.SID          = int.Parse(SID.Text);
                sr.StartDate    = DateTime.Now;
                sr.IsComplete   = false;
                sr.LastAnswered = 0;
                sr.Source       = Session["SSrc"] == null ? "" : Session["SSrc"].ToString();
                sr.SourceID     = Session["SSrcID"] == null ? 0 : int.Parse(Session["SSrcID"].ToString());

                sr.Insert();
                Session["SRID"] = sr.SRID;
                srid            = sr.SRID;
                SRID.Text       = sr.SRID.ToString();
            }

            // Save answers, in a loop;
            foreach (RepeaterItem i in SurveyQLst.Items)
            {
                var qp = i.FindControl("qp") as QuestionPreview;
                if (qp != null)
                {
                    qp.Save(srid);
                    sr.LastAnswered = int.Parse(qp.QNumber);
                    sr.Update();
                }
            }

            // Check in a loop if any of the answers generated a jump condition, and if so, set the start of the next page.))
            foreach (RepeaterItem i in SurveyQLst.Items)
            {
                var qp = i.FindControl("qp") as QuestionPreview;
                if (qp != null)
                {
                    var jq = qp.JumpLogicActivated();
                    if (jq > 0)
                    {
                        QNumber.Text    = (jq - 1).ToString();
                        sr.LastAnswered = int.Parse(QNumber.Text);   //If they quit, then they come back and start at the jump
                        sr.Update();
                        JumpActivated = true;
                        break;
                    }
                }
            }

            return(true);
        }
コード例 #5
0
        public async Task <SurveyResult> SurveyResults(int surveyId)
        {
            var response = await surveyResponseBoundedContext.GetSurveyResponse(surveyId);

            var survey = await surveyRootBoundedContext.ReadSurvey(surveyId);

            SurveyResult surveyResult = new SurveyResult();

            surveyResult.title = survey.title;

            IList <SurveyResults> results = new List <SurveyResults>();

            foreach (var data in response)
            {
                SurveyResults result = new SurveyResults();
                result.questionDesc     = survey.questions.Where(q => q.questionId == data.questionId).Select(q => q.questionDesc).FirstOrDefault();
                result.questionResponse = data.response;
                result.givenBy          = data.givenBy;

                results.Add(result);
            }

            surveyResult.surveyResults = results;

            return(surveyResult);
        }
コード例 #6
0
        protected void LoadData()
        {
            var patron = (Patron)Session["Curr_Patron"];

            if (Session["PSRID"] != null)
            {
                SRID.Text = Session["PSRID"].ToString();
            }
            if (Session["PSRID"] == null && SRID.Text == "")
            {
                Response.Redirect("PatronSurveys.aspx");
            }
            Session["PSRID"] = null;


            var sr = SurveyResults.FetchObject(int.Parse(SRID.Text));
            var s  = Survey.FetchObject(sr.SID);

            Name.Text = string.Format("{0} ({1})", s.Name, s.LongName);
            C.Text    = string.Format("{0}", sr.IsComplete.ToYesNo());
            S.Text    = string.Format("{0}", sr.IsComplete && sr.IsScorable ? sr.Score.ToString() : "");
            P.Text    = string.Format("{0}", sr.IsComplete && sr.IsScorable ? sr.ScorePct.ToString() : "");
            D.Text    = string.Format("{0}", sr.IsComplete && sr.IsScorable ? sr.EndDate.ToWidgetDisplayDate() : "");


            var ds = DAL.SurveyAnswers.GetAllExpanded(sr.SRID);

            rptr.DataSource = ds;
            rptr.DataBind();
        }
コード例 #7
0
        public ClaimsOfficeRoom Build()
        {
            var greeting = new[]
            {
                "Welcome to the claims office.",
                "You can type [help] for a list of the store commands.",
                "To leave the office type exit."
            };

            var listings = new ClaimListings();
            var claim1   = _gameState.MineClaims.Add(
                new MineClaim(
                    ChipDensity.Normal,
                    SiteHardness.Hard
                    ));

            var claim2 = _gameState.MineClaims.Add(
                new MineClaimFactory().BuildSite());

            listings.Add(new ClaimListing(claim2, 10, 15, SurveyResults.NoSurvey()));
            listings.Add(new ClaimListing(claim1, 10, 15, SurveyResults.GetFromClaim(claim1)));

            var claimsOffice = new ClaimsOfficeRoom(
                _gameState,
                greeting,
                _baseCommandsGroup.Join(new ClaimsOfficeCommandsGroupFactory(listings).Build()),
                listings
                );

            return(claimsOffice);
        }
コード例 #8
0
        public static Int32 Insert(SurveyResults bean)
        {
            int           ret;
            StringBuilder sql = new StringBuilder();

            sql.Append("INSERT INTO [SURVEYRESULTS] ");
            sql.Append("([UNIQ_ID], [USER_ID], [CREATED], [MODIFIED], [CORSO], [DATA], [DOCENTE], [ALLIEVO_NOME], [ALLIEVO_COGNOME], [ALLIEVO_EMAIL], [ALLIEVO_AZIENDA], [ALLIEVO_REPARTO], [Q1], [Q2], [Q3], [Q4], [Q5], [Q6], [Q7], [Q8], [Q9], [Q10], [Q11], [Q12])   ");
            sql.Append("VALUES(@UNIQ_ID, @USER_ID, @CREATED, @MODIFIED, @CORSO, @DATA, @DOCENTE, @ALLIEVO_NOME, @ALLIEVO_COGNOME, @ALLIEVO_EMAIL, @ALLIEVO_AZIENDA, @ALLIEVO_REPARTO, @Q1, @Q2, @Q3, @Q4, @Q5, @Q6, @Q7, @Q8, @Q9, @Q10, @Q11, @Q12); SELECT CAST(scope_identity() AS int)");
            try
            {
                using (SqlConnection cn = ResourceFactory.GetConnection())
                {
                    ret = cn.Query <Int32>(sql.ToString(), bean).FirstOrDefault();
                }
            }
            catch (Exception e)
            {
                ExceptionExtras eh = new ExceptionExtras("Errore durante la lettura dei SurveyResults");
                eh.AddParam("sql", sql);
                eh.AddParam("ID", bean);
                throw new CustomException(eh.ToString(), e);
            }

            return(ret);
        }
コード例 #9
0
        public void When_listing_is_purchased_lease_purchase_should_complete()
        {
            var command = new BuyClaimCommand();

            command.GameState = gameState;
            command.Listings  = new ClaimListings();
            var claim      = MineClaim.Default;
            var claimPrice = 1;

            command.Listings.Add(new ClaimListing(claim, claimPrice, 2, SurveyResults.NoSurvey()));
            command.ListingId = command.Listings.GetAll().First().Id;

            var handler = new BuyClaimCommandHandler();

            handler.Handle(command);

            command.Listings.GetAll().Count.ShouldBe(0);
            gameState.Miner.TaterTokens.ShouldBe(MINER_TOKENS - claimPrice);
            gameState.Miner.ClaimLeases.GetAll().Count.ShouldBe(1);
            gameState.Miner.ClaimLeases.GetAll().First().Claim.ShouldBe(claim);

            var output = ConsoleBufferHelper.GetText(proc.Output);

            output.ShouldStartWith($"{1} Purchase Complete!");
        }
コード例 #10
0
        public IList <SurveyResults> GetSurveys()
        {
            IList <SurveyResults> surveyResults = new List <SurveyResults>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    SqlCommand    cmd    = new SqlCommand("SELECT survey_result.parkCode, park.parkName, COUNT(*) AS count FROM survey_result INNER JOIN park ON survey_result.parkCode = park.parkCode GROUP BY survey_result.parkCode, park.parkName ORDER BY count DESC;", conn);
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        SurveyResults survey = new SurveyResults()
                        {
                            ParkName = Convert.ToString(reader["parkName"]),
                            ParkCode = Convert.ToString(reader["parkCode"]),
                            Count    = Convert.ToInt32(reader["count"]),
                        };

                        surveyResults.Add(survey);
                    }
                }
            }
            catch (SqlException ex)
            {
                throw;
            }

            return(surveyResults);
        }
コード例 #11
0
        public static bool Update(SurveyResults bean)
        {
            int           rowsAffected;
            StringBuilder sql = new StringBuilder();

            sql.Append("UPDATE [SURVEYRESULTS] ");
            sql.Append("SET [UNIQ_ID] =  @UNIQ_ID, [USER_ID] = @USER_ID, [CREATED] = @CREATED, [MODIFIED] = @MODIFIED, [CORSO] = @CORSO, [DATA] = @DATA, [DOCENTE] = @DOCENTE, [ALLIEVO_NOME] =  @ALLIEVO_NOME, [ALLIEVO_COGNOME] =  @ALLIEVO_COGNOME, [ALLIEVO_EMAIL] =  @ALLIEVO_EMAIL, [ALLIEVO_AZIENDA] =  @ALLIEVO_AZIENDA, [ALLIEVO_REPARTO] = @ALLIEVO_REPARTO,[Q1] = @Q1,[Q2] = @Q2,[Q3] = @Q3,[Q4] = @Q4,[Q5] = @Q5,[Q6] = @Q6,[Q7] = @Q7,[Q8] = @Q8,[Q9] = @Q9,[Q10] = @Q10,[Q11] = @Q11,[Q12] = @Q12 ");
            sql.Append("WHERE [ID] =  @ID");
            try
            {
                using (SqlConnection cn = ResourceFactory.GetConnection())
                {
                    rowsAffected = cn.Execute(sql.ToString(), bean);
                }
            }
            catch (Exception e)
            {
                ExceptionExtras eh = new ExceptionExtras("Errore durante la lettura dei SurveyResults");
                eh.AddParam("sql", sql);
                eh.AddParam("ID", bean);
                throw new CustomException(eh.ToString(), e);
            }

            if (rowsAffected > 0)
            {
                return(true);
            }
            return(false);
        }
コード例 #12
0
        public IList <SurveyResults> Results()
        {
            IList <SurveyResults> results = new List <SurveyResults>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("SELECT survey_result.parkCode, park.parkName, COUNT(survey_result.parkCode) AS favorite FROM survey_result JOIN park ON(park.parkCode = survey_result.parkCode) GROUP BY survey_result.parkCode, park.parkName ORDER by favorite DESC", conn);

                    SqlDataReader reader2 = cmd.ExecuteReader();
                    while (reader2.Read())
                    {
                        SurveyResults survey = ConvertReaderToSurveyResults(reader2);
                        results.Add(survey);
                    }
                }
            }
            catch (SqlException ex)
            {
                throw;
            }
            return(results);
        }
コード例 #13
0
        public SurveyResults Survey(float geographicDistance)
        {
            Validate_GeographicDistance(geographicDistance);

            // find the zone that the point is in & its local position within that zone
            var foundZone   = FindZone(geographicDistance);
            var pointInZone = FindPointInZone(geographicDistance, foundZone);

            // compute the point using the zone's equation
            var heightInZone = foundZone.Invoke(pointInZone);

            var geographicAltitude = ZoneHeightToGeographicAltitude(foundZone, heightInZone);
            var surveyResults      = new SurveyResults()
            {
                GeographicDistance = geographicDistance,
                LocalDistance01    = GeographicToLocalDistance(geographicDistance),
                Zone                      = foundZone,
                PointInZone               = pointInZone,
                HeightInZone              = heightInZone,
                GeographicAltitude        = geographicAltitude,
                HeightInBenthicProfile    = GeographicAltitudeToBenthicHeight(geographicAltitude),
                Space                     = Space.World,
                ClosestGeographicBoundary = pointInZone < 0.5f ? GetZoneGeographicDistanceBoundaries(foundZone).x : GetZoneGeographicDistanceBoundaries(foundZone).y
            };

            return(surveyResults);
        }
コード例 #14
0
        // Determines the order of highest voted surveys in the database using a COUNT
        // SQL function
        public List <SurveyResults> GetHighestVoteTotal()
        {
            List <SurveyResults> surveyResultsList = new List <SurveyResults>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand    cmd    = new SqlCommand(SQL_GetHighestVoteTotal, conn);
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        SurveyResults sr = new SurveyResults();

                        sr.ParkName  = Convert.ToString(reader["parkName"]);
                        sr.VoteTotal = Convert.ToInt32(reader["number_of_votes"]);

                        surveyResultsList.Add(sr);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(surveyResultsList);
        }
コード例 #15
0
ファイル: Statistics.aspx.cs プロジェクト: itproto/ilsrep
    public List<StatisticsItem> FormSurveyStatisticsList()
    {
        List<StatisticsItem> statisticsItems = new List<StatisticsItem>();
        List<String> users = PollDAL.GetUsers();
        int surveyID = Convert.ToInt32(Request["id"]);
        Survey survey = PollDAL.GetSurvey(surveyID);
        foreach (String user in users)
        {
            List<DateTime> datesOfAttempts = new List<DateTime>();
            datesOfAttempts = PollDAL.GetDatesOfAttempts(user, surveyID);

            if (datesOfAttempts.Count != 0)
            {
                StatisticsItem curStatisticsItem = new StatisticsItem();
                curStatisticsItem.name = user;
                curStatisticsItem.ID = user;
                curStatisticsItem.attemptsCount = datesOfAttempts.Count();

                // Calculate count of scores
                List<Double> scoresOfAttempts = new List<Double>();

                foreach (DateTime curDate in datesOfAttempts)
                {
                    SurveyResults resultsList = new SurveyResults();
                    resultsList = PollDAL.GetSurveyResults(surveyID, user, curDate);

                    int countOfCorrectAnswers = 0;

                    foreach (PollResult curResult in resultsList.results)
                    {
                        Poll currentPoll = survey.Polls.Find(delegate(Poll poll) { return poll.Id == curResult.questionId; });
                        if (currentPoll.CorrectChoiceID == curResult.answerId)
                            countOfCorrectAnswers++;
                    }

                    Double curScores = Convert.ToDouble(countOfCorrectAnswers) / Convert.ToDouble(resultsList.results.Count);
                    scoresOfAttempts.Add(curScores);
                }

                Double scores = 0;

                foreach (Double curScores in scoresOfAttempts)
                {
                    scores += curScores;
                }

                scores /= Convert.ToDouble(datesOfAttempts.Count) / 100;
                curStatisticsItem.scores = scores;
                statisticsItems.Add(curStatisticsItem);
            }
        }

        // Sort by scores
        statisticsItems.Sort();

        return statisticsItems;
    }
コード例 #16
0
        private SurveyResults ConvertReaderToSurveyResults(SqlDataReader reader2)
        {
            SurveyResults survey = new SurveyResults();

            survey.ParkCode  = Convert.ToString(reader2["parkCode"]);
            survey.ParkName  = Convert.ToString(reader2["parkName"]);
            survey.VoteCount = Convert.ToInt32(reader2["favorite"]);
            return(survey);
        }
コード例 #17
0
ファイル: CourseController.cs プロジェクト: Artikid/Test
        public IHttpActionResult Get(int id)
        {
            SurveyResults ret = SurveyResultsDAO.GetSingle(id);

            if (ret == null)
            {
                return(NotFound());
            }
            return(Ok(ret));
        }
コード例 #18
0
        public ActionResult Index()
        {
            var hospitalRatings = _surveyService.GetSurveySummary().ToArray();

            var surveyResults = new SurveyResults()
            {
                Ratings = hospitalRatings
            };

            return(View(surveyResults));
        }
コード例 #19
0
        public static bool PatronHasTakenTest(int PID, int SID, int TestType, int SrcID, out int SRID)
        {
            SRID = 0;
            var s = SurveyResults.FetchObject(PID, SID, Survey.Source(TestType), SrcID);

            if (s == null)
            {
                return(false);
            }
            SRID = s.SRID;
            return(true);
        }
コード例 #20
0
ファイル: Program.cs プロジェクト: Artikid/Test
 static void DisplaySurveyResults(SurveyResults s)
 {
     Console.WriteLine("==========================================");
     Console.WriteLine("  ID               = {0}", s.ID);
     Console.WriteLine("  DOCENTE          = {0}", s.DOCENTE);
     Console.WriteLine("  DATA             = {0}", s.DATA);
     Console.WriteLine("  CORSO            = {0}", s.CORSO);
     Console.WriteLine("  ALLIEVO_COGNOME  = {0}", s.ALLIEVO_COGNOME);
     Console.WriteLine("  ALLIEVO_NOME     = {0}", s.ALLIEVO_NOME);
     Console.WriteLine("  ALLIEVO_AZIENDA  = {0}", s.ALLIEVO_AZIENDA);
     Console.WriteLine("  ALLIEVO_EMAIL    = {0}", s.ALLIEVO_EMAIL);
     Console.WriteLine("  Note sul corso   = {0}", s.Q11);
     Console.WriteLine("==========================================");
 }
コード例 #21
0
        public SurveyResults ConvertSurveyResultsDTOToSurveyResults(SurveyResultsDTO surveyResultsDto)
        {
            SurveyResults surveyResults = new SurveyResults()
            {
                Age                = surveyResultsDto.Age,
                Gender             = surveyResultsDto.Gender,
                CarLicense         = surveyResultsDto.CarLicense,
                FirstCar           = surveyResultsDto.FirstCar,
                DriveTrain         = surveyResultsDto.DriveTrain,
                Drifting           = surveyResultsDto.Drifting,
                UsedBmwCount       = surveyResultsDto.UsedBmwCount,
                UsedBmwCarNameList = new List <string>()
            };

            if (surveyResultsDto.UsedBmw1Model != null)
            {
                surveyResults.UsedBmwCarNameList.Add(surveyResultsDto.UsedBmw1Model.ToString());
            }
            if (surveyResultsDto.UsedBmw2Model != null)
            {
                surveyResults.UsedBmwCarNameList.Add(surveyResultsDto.UsedBmw2Model.ToString());
            }
            if (surveyResultsDto.UsedBmw3Model != null)
            {
                surveyResults.UsedBmwCarNameList.Add(surveyResultsDto.UsedBmw3Model.ToString());
            }
            if (surveyResultsDto.UsedBmw4Model != null)
            {
                surveyResults.UsedBmwCarNameList.Add(surveyResultsDto.UsedBmw4Model.ToString());
            }
            if (surveyResultsDto.UsedBmw5Model != null)
            {
                surveyResults.UsedBmwCarNameList.Add(surveyResultsDto.UsedBmw5Model.ToString());
            }
            if (surveyResultsDto.UsedBmw6Model != null)
            {
                surveyResults.UsedBmwCarNameList.Add(surveyResultsDto.UsedBmw6Model.ToString());
            }
            if (surveyResultsDto.UsedBmw7Model != null)
            {
                surveyResults.UsedBmwCarNameList.Add(surveyResultsDto.UsedBmw7Model.ToString());
            }
            if (surveyResultsDto.UsedBmw8Model != null)
            {
                surveyResults.UsedBmwCarNameList.Add(surveyResultsDto.UsedBmw8Model.ToString());
            }
            return(surveyResults);
        }
コード例 #22
0
 public bool AddResultsToFile(SurveyResults surveyResults)
 {
     try
     {
         List <SurveyResults> allResults = JsonConvert.DeserializeObject <List <SurveyResults> >(File.ReadAllText(resultsFile));
         allResults.Add(surveyResults);
         string newJsonResult = JsonConvert.SerializeObject(allResults,
                                                            Formatting.Indented);
         File.WriteAllText(resultsFile, newJsonResult);
         return(true);
     }
     catch (JsonException e)
     {
         throw new JsonException();
     }
 }
コード例 #23
0
        public void SaveFreeForm()
        {
            int SRPK = int.Parse(SRID);
            var obj1 = SurveyResults.FetchObject(SRPK);
            var obj2 = new SurveyAnswers();

            obj2.SRID  = obj1.SRID;
            obj2.TenID = obj1.TenID;
            obj2.PID   = obj1.PID;
            obj2.SID   = obj1.SID;

            obj2.QID            = int.Parse(QID);
            obj2.DateAnswered   = DateTime.Now;
            obj2.QType          = 3;
            obj2.FreeFormAnswer = txtAnswer.Text;
            obj2.Insert();
        }
コード例 #24
0
        public void Report_error_message_if_listing_id_does_not_exist()
        {
            var command = new BuyClaimCommand();

            command.GameState = gameState;
            command.Listings  = new ClaimListings();
            command.Listings.Add(new ClaimListing(MineClaim.Default, 1, 2, SurveyResults.NoSurvey()));
            command.ListingId = 2;

            var handler = new BuyClaimCommandHandler();

            handler.Handle(command);

            var output = ConsoleBufferHelper.GetText(proc.Output);

            output.ShouldBe($"Listing Id 2 is unavailable.");
        }
コード例 #25
0
        // Return a list of all surveys completed
        public IList <SurveyResults> GetAllSurveys()
        {
            // Parameter to store what's returned
            IList <SurveyResults> surveys = new List <SurveyResults>();

            // Open a connection to database
            try
            {
                using (SqlConnection conn = new SqlConnection(this.connectionString))
                {
                    // Open the connection
                    conn.Open();

                    // Create query to pull back survey results ordered by number of votes then park name
                    string sql = "select p.parkName as parkname, p.parkCode as parkcode, count(*) as parkscount from survey_result sr " +
                                 "JOIN park p ON sr.parkCode = p.parkCode GROUP BY p.parkName, p.parkCode ORDER BY count(*) DESC, p.parkName ASC;";
                    SqlCommand    cmd    = new SqlCommand(sql, conn);
                    SqlDataReader reader = cmd.ExecuteReader();

                    // Read in the survey result rows and store them in a list
                    while (reader.Read())
                    {
                        // Loop through all of the survey results returned
                        SurveyResults results = new SurveyResults
                        {
                            ParksCount = Convert.ToInt32(reader["parkscount"]),
                            ParkName   = Convert.ToString(reader["parkname"]),
                            ParkCode   = Convert.ToString(reader["parkcode"])
                        };

                        // Save all surveys to a list of SurveyResults
                        surveys.Add(results);
                    }
                }

                // Return the list of all surveys
                return(surveys);
            }
            catch (SqlException)
            {
                throw;
            }
        }
コード例 #26
0
ファイル: SurveyController.cs プロジェクト: Artikid/Test
 public IHttpActionResult Put(SurveyResults bean, int id)
 {
     if (ModelState.IsValid)
     {
         try
         {
             bean.ID = id;
             bool ret = SurveyResultsDAO.Update(bean);
             return(Ok(ret));
         }
         catch (Exception e)
         {
             throw new Exception("", e);
         }
     }
     else
     {
         return(NotFound());
     }
 }
コード例 #27
0
        public static bool PatronNeedsPreTest()
        {
            var p  = (Patron)HttpContext.Current.Session["Patron"];
            var pg = Programs.FetchObject(p.ProgID);

            if (pg.PreTestID != 0)
            {
                var resID = 0;
                if (PatronHasCompletedTest(p.PID, pg.PreTestID, 1, pg.PID, out resID))
                {
                    return(false);
                }
                else
                {
                    if (pg.PreTestEndDate <= DateTime.Now)
                    {
                        return(false);
                    }

                    var QNum = 0;
                    if (resID > 0)
                    {
                        var sr = SurveyResults.FetchObject(resID);
                        QNum = sr.LastAnswered;
                        // has started ... needs to continue ...
                    }

                    HttpContext.Current.Session["PreTestMandatory"] = pg.PreTestMandatory;
                    HttpContext.Current.Session["SRID"]             = resID;  // which results to continue
                    HttpContext.Current.Session["SID"]    = pg.PreTestID;     // the test to restart
                    HttpContext.Current.Session["QNum"]   = QNum;             // question to restart from
                    HttpContext.Current.Session["SSrc"]   = Survey.Source(1); // pre - testing
                    HttpContext.Current.Session["SSrcID"] = pg.PID;           // program id

                    HttpContext.Current.Response.Redirect("AddlSurvey.aspx");
                }
            }
            return(false);
        }
コード例 #28
0
        public void SaveMatrix()
        {
            int SRPK = int.Parse(SRID);
            var ds   = SQChoices.GetAll(int.Parse(QID));

            foreach (RepeaterItem rLine in rptrMRows.Items)
            {
                var obj1 = SurveyResults.FetchObject(SRPK);
                var obj2 = new SurveyAnswers();

                obj2.SRID  = obj1.SRID;
                obj2.TenID = obj1.TenID;
                obj2.PID   = obj1.PID;
                obj2.SID   = obj1.SID;

                obj2.QID          = int.Parse(QID);
                obj2.DateAnswered = DateTime.Now;
                obj2.QType        = 4;

                var SQMLID = rLine.FindControl("SQMLID") as Label;
                obj2.SQMLID = int.Parse(SQMLID.Text);

                if (DisplayControl == "1")
                {
                    var rptrCheckCols = rLine.FindControl("rptrCheckCols") as Repeater;
                    foreach (RepeaterItem rChkI in rptrCheckCols.Items)
                    {
                        var SQCID       = rChkI.FindControl("SQCID") as Label;
                        var chkAns      = rChkI.FindControl("rbChoice") as CheckBox;
                        var ChoiceOrder = rChkI.FindControl("ChoiceOrder") as Label;
                        var AnsText     = ds.Tables[0].Rows[int.Parse(ChoiceOrder.Text) - 1]["ChoiceText"].ToString();
                        if (chkAns.Checked)
                        {
                            obj2.ChoiceAnswerIDs = string.Format("{0}{1}{2}",
                                                                 (obj2.ChoiceAnswerIDs.Length > 0 ? obj2.ChoiceAnswerIDs : ""),
                                                                 (obj2.ChoiceAnswerIDs.Length > 0 ? "," : ""), SQCID.Text);


                            obj2.ChoiceAnswerText = string.Format("{0}{1}{2}",
                                                                  (obj2.ChoiceAnswerText.Length > 0 ? obj2.ChoiceAnswerText : ""),
                                                                  (obj2.ChoiceAnswerText.Length > 0 ? "~|~" : ""), AnsText);
                        }
                    }
                }
                if (DisplayControl == "2")
                {
                    var rptrRadioCols = rLine.FindControl("rptrRadioCols") as Repeater;
                    foreach (RepeaterItem rRdoI in rptrRadioCols.Items)
                    {
                        var SQCID       = rRdoI.FindControl("SQCID") as Label;
                        var rbAns       = rRdoI.FindControl("rbChoice") as RadioButton;
                        var ChoiceOrder = rRdoI.FindControl("ChoiceOrder") as Label;
                        var AnsText     = ds.Tables[0].Rows[int.Parse(ChoiceOrder.Text) - 1]["ChoiceText"].ToString();


                        if (rbAns.Checked)
                        {
                            obj2.ChoiceAnswerIDs = string.Format("{0}{1}{2}",
                                                                 (obj2.ChoiceAnswerIDs.Length > 0 ? obj2.ChoiceAnswerIDs : ""),
                                                                 (obj2.ChoiceAnswerIDs.Length > 0 ? "," : ""), SQCID.Text);
                            obj2.ChoiceAnswerText = string.Format("{0}{1}{2}",
                                                                  (obj2.ChoiceAnswerText.Length > 0 ? obj2.ChoiceAnswerText : ""),
                                                                  (obj2.ChoiceAnswerText.Length > 0 ? "~|~" : ""), AnsText);
                        }
                    }
                }

                obj2.Insert();
            }
        }
コード例 #29
0
        public void SaveMultiChoice()
        {
            int SRPK = int.Parse(SRID);
            var obj1 = SurveyResults.FetchObject(SRPK);
            var obj2 = new SurveyAnswers();

            obj2.SRID  = obj1.SRID;
            obj2.TenID = obj1.TenID;
            obj2.PID   = obj1.PID;
            obj2.SID   = obj1.SID;

            obj2.QID          = int.Parse(QID);
            obj2.DateAnswered = DateTime.Now;
            obj2.QType        = 2;

            if (DisplayControl == "1")
            {
                foreach (RepeaterItem rChkI in rptrChk.Items)
                {
                    var SQCID   = rChkI.FindControl("SQCID") as Label;
                    var chkAns  = rChkI.FindControl("chkAns") as CheckBox;
                    var chkClar = rChkI.FindControl("txtChkClarification") as TextBox;

                    if (chkAns.Checked)
                    {
                        obj2.ChoiceAnswerIDs = string.Format("{0}{1}{2}",
                                                             (obj2.ChoiceAnswerIDs.Length > 0 ? obj2.ChoiceAnswerIDs : ""),
                                                             (obj2.ChoiceAnswerIDs.Length > 0 ? "," : ""), SQCID.Text);
                        obj2.ClarificationText = string.Format("{0}{1}{2}",
                                                               (obj2.ClarificationText.Length > 0 ? obj2.ClarificationText : ""),
                                                               (obj2.ClarificationText.Length > 0 ? "~|~" : ""), chkClar.Text);
                        obj2.ChoiceAnswerText = string.Format("{0}{1}{2}",
                                                              (obj2.ChoiceAnswerText.Length > 0 ? obj2.ChoiceAnswerText : ""),
                                                              (obj2.ChoiceAnswerText.Length > 0 ? "~|~" : ""), chkAns.Text);
                    }
                }
            }
            if (DisplayControl == "2")
            {
                foreach (RepeaterItem rRdoI in rptrRadio.Items)
                {
                    var SQCID  = rRdoI.FindControl("SQCID") as Label;
                    var rbAns  = rRdoI.FindControl("rbAns") as RadioButton;
                    var rbClar = rRdoI.FindControl("txtRBClarification") as TextBox;

                    if (rbAns.Checked)
                    {
                        obj2.ChoiceAnswerIDs = string.Format("{0}{1}{2}",
                                                             (obj2.ChoiceAnswerIDs.Length > 0 ? obj2.ChoiceAnswerIDs : ""),
                                                             (obj2.ChoiceAnswerIDs.Length > 0 ? "," : ""), SQCID.Text);
                        obj2.ClarificationText = string.Format("{0}{1}{2}",
                                                               (obj2.ClarificationText.Length > 0 ? obj2.ClarificationText : ""),
                                                               (obj2.ClarificationText.Length > 0 ? "~|~" : ""), rbClar.Text);
                        obj2.ChoiceAnswerText = string.Format("{0}{1}{2}",
                                                              (obj2.ChoiceAnswerText.Length > 0 ? obj2.ChoiceAnswerText : ""),
                                                              (obj2.ChoiceAnswerText.Length > 0 ? "~|~" : ""), rbAns.Text);
                    }
                }
            }
            if (DisplayControl == "3")
            {
                obj2.ChoiceAnswerIDs = ddMultipleChoice.SelectedValue;
                var ch  = SQChoices.FetchObject(int.Parse(ddMultipleChoice.SelectedValue));
                var ans = "N/A";
                if (ch != null)
                {
                    ans = ch.ChoiceText;
                }
                obj2.ChoiceAnswerText  = ans;
                obj2.ClarificationText = txtDDClarification.Text;
            }

            obj2.Insert();
        }
コード例 #30
0
        public string LoadQStats()
        {
            var q = DAL.SurveyQuestion.FetchObject(QID);

            var line1 = "<tr><td colspan=3>{0}</td></tr>";
            var line2 =
                "<tr><td style='padding-left: 10px;' valign=top align=left  width='33%'><b>Minimum Details: </b></td>" +
                "<td style='padding-right: 50px;' valign=top align=left  width='33%'><b>Medium Details</b> <a style='float:right;' class='ml{3}' href='javascript: showhide(\"ml{3}\", \"mt{3}\")'>show</a></td>" +
                "<td style='padding-right: 50px;' valign=top align=left  width='33%'><b>Full Details</b> <a style='float:right;' class='fl{3}' href='javascript: showhide(\"fl{3}\", \"ft{3}\")'>show</a></td></tr>" +
                "<tr><td style='padding-left: 10px;'valign=top align=left>{0}</td><td valign=top align=left>{1}</td><td>{2}</td></tr>";
            var line3 =
                "<tr><td style='padding-left: 10px;'valign=top align=left colspan=3>{0}</td></tr>";
            var line4 = "<tr><td colspan=3><hr></td></tr>";

            var line5 = "<tr><td style='padding-left: 10px;' valign=top align=left colspan=3>{0}</td></tr>";
            var ret   = "";

            if (QType == 2) // multiple choice
            {
                ret = string.Format(line1, q.QText);
                var ds          = SurveyResults.GetQStatsSimple(SID, QID, SQMLID, SourceType, SourceID);
                var header      = "<tr><td ><b>Answer</b></td><td width='100px' align=right><b>Count</td></tr>";
                var data        = "<tr><td>{0}</td><td align=right>{1}</td></tr>";
                var min         = "";
                var grDataTmplt = "['{0}', {1}],";
                var grData      = "";
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    min = string.Format("{0}{1}{2}", min, "\n", string.Format(data, row["ChoiceText"], row["Count"]));
                    if (Graphs)
                    {
                        grData = string.Format("{0}{1}{2}", grData, "\n", string.Format(grDataTmplt, row["ChoiceText"], row["Count"]));
                    }
                }
                if (grData.Length > 0)
                {
                    grData = grData.Substring(0, grData.Length - 1);
                    min    = min + getGraph("_s", QID, SQMLID, grData);
                }

                ds = SurveyResults.GetQStatsMedium(SID, QID, SQMLID, SourceType, SourceID);
                var med = "";
                grData = "";
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    med = string.Format("{0}{1}{2}", med, "\n", string.Format(data, row["ChoiceText"], row["Count"]));
                    if (Graphs)
                    {
                        grData = string.Format("{0}{1}{2}", grData, "\n", string.Format(grDataTmplt, row["ChoiceText"], row["Count"]));
                    }
                }
                if (grData.Length > 0)
                {
                    grData = grData.Substring(0, grData.Length - 1);
                    med    = med + getGraph("_m", QID, SQMLID, grData);
                }

                var header2 = "<tr><td><b>Answer AND Clarifications</b></td><td  width='100px' align=right><b>Count</td>";
                var data2   = "<tr><td valigh=top>{0}</td><td align=right valigh=top>{1}</td></tr>";
                var data3   = "<tr><td valigh=top colspan=2 style='padding-left:20px;'>{0}</td></tr>";
                var max     = "";
                grData = "";
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    var ds2 = SurveyResults.GetQClarifications(SID, QID, SQMLID, SourceType, SourceID, row["ChoiceTextORIGINAL"].ToString());

                    var clText = "";
                    foreach (DataRow cl in ds2.Tables[0].Rows)
                    {
                        clText = clText + (clText.Length == 0 ? "" : "<br>") + cl["ClarificationText"].ToString();
                    }

                    max = string.Format("{0}{1}{2}", max, "\n", string.Format(data2, row["ChoiceText"], row["Count"]));
                    if (clText != "")
                    {
                        max = string.Format("{0}{1}{2}", max, "\n", string.Format(data3, clText));
                    }

                    if (Graphs)
                    {
                        grData = string.Format("{0}{1}{2}", grData, "\n", string.Format(grDataTmplt, row["ChoiceText"], row["Count"]));
                    }
                }
                if (grData.Length > 0)
                {
                    grData = grData.Substring(0, grData.Length - 1);
                    max    = max + getGraph("_f", QID, SQMLID, grData);
                }

                line2 = string.Format(line2, "<table>" + header + min + "</table>",
                                      "<table id='mt" + QID + "' style='display:none;'>" + header + med + "</table>",
                                      "<table id='ft" + QID + "' style='display:none;'>" + header + max + "</table>", QID);
                ret = ret + line2;
            }
            if (QType == 3) //free form
            {
                ret = string.Format(line1, q.QText);

                var ds2 = SurveyResults.GetQFreeForm(SID, QID, SQMLID, SourceType, SourceID);

                var clText = "";
                foreach (DataRow cl in ds2.Tables[0].Rows)
                {
                    clText = clText + (clText.Length == 0 ? "" : "<br>") + cl["FreeFormAnswer"].ToString();
                }
                line3 = string.Format(line2, clText);
                ret   = ret + line3;
            }

            var line6 =
                "<tr><td style='padding-left: 20px;' valign=top align=left  width='33%'><b>Minimum Details: </b></td>" +
                "<td style='padding-right: 50px;' valign=top align=left  width='33%'><b>Medium Details</b> <a style='float:right;' class='ml{3}_{4}' href='javascript: showhide(\"ml{3}_{4}\", \"mt{3}_{4}\")'>show</a></td>" +
                "<td style='padding-right: 50px;' valign=top align=left  width='33%'><b>Full Details</b> <a style='float:right;' class='fl{3}_{4}' href='javascript: showhide(\"fl{3}_{4}\", \"ft{3}_{4}\")'>show</a></td></tr>" +
                "<tr><td style='padding-left: 20px;'valign=top align=left>{0}</td><td valign=top align=left>{1}</td><td>{2}</td></tr>";

            if (QType == 4) //matrix
            {
                if (ShowQText == 1)
                {
                    ret = string.Format(line1, q.QText);
                }

                var ln = SQMatrixLines.FetchObject(SQMLID);
                ret = ret + string.Format(line5, ln.LineText);
                var grDataTmplt = "['{0}', {1}],";
                var grData      = "";

                var ds     = SurveyResults.GetQStatsSimple(SID, QID, SQMLID, SourceType, SourceID);
                var header = "<tr><td ><b>Answer</b></td><td width='100px' align=right><b>Count</td></tr>";
                var data   = "<tr><td>{0}</td><td align=right>{1}</td></tr>";
                var min    = "";
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    min = string.Format("{0}{1}{2}", min, "\n", string.Format(data, row["ChoiceText"], row["Count"]));
                    if (Graphs)
                    {
                        grData = string.Format("{0}{1}{2}", grData, "\n", string.Format(grDataTmplt, row["ChoiceText"], row["Count"]));
                    }
                }
                if (grData.Length > 0)
                {
                    grData = grData.Substring(0, grData.Length - 1);
                    min    = min + getGraph("_s", QID, SQMLID, grData);
                }

                ds = SurveyResults.GetQStatsMedium(SID, QID, SQMLID, SourceType, SourceID);
                var med = "";
                grData = "";
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    med = string.Format("{0}{1}{2}", med, "\n", string.Format(data, row["ChoiceText"], row["Count"]));
                    if (Graphs)
                    {
                        grData = string.Format("{0}{1}{2}", grData, "\n", string.Format(grDataTmplt, row["ChoiceText"], row["Count"]));
                    }
                }
                if (grData.Length > 0)
                {
                    grData = grData.Substring(0, grData.Length - 1);
                    med    = med + getGraph("_m", QID, SQMLID, grData);
                }

                var header2 = "<tr><td><b>Answer AND Clarifications</b></td><td  width='100px' align=right><b>Count</td>";
                var data2   = "<tr><td valigh=top>{0}</td><td align=right valigh=top>{1}</td></tr>";
                var data3   = "<tr><td valigh=top colspan=2 style='padding-left:20px;'>{0}</td></tr>";
                var max     = "";
                grData = "";
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    var ds2 = SurveyResults.GetQClarifications(SID, QID, SQMLID, SourceType, SourceID, row["ChoiceTextORIGINAL"].ToString());

                    var clText = "";
                    foreach (DataRow cl in ds2.Tables[0].Rows)
                    {
                        clText = clText + (clText.Length == 0 ? "" : "<br>") + cl["ClarificationText"].ToString();
                    }

                    max = string.Format("{0}{1}{2}", max, "\n", string.Format(data2, row["ChoiceText"], row["Count"]));
                    if (clText != "")
                    {
                        max = string.Format("{0}{1}{2}", max, "\n", string.Format(data3, clText));
                    }
                    if (Graphs)
                    {
                        grData = string.Format("{0}{1}{2}", grData, "\n", string.Format(grDataTmplt, row["ChoiceText"], row["Count"]));
                    }
                }
                if (grData.Length > 0)
                {
                    grData = grData.Substring(0, grData.Length - 1);
                    max    = max + getGraph("_f", QID, SQMLID, grData);
                }

                line6 = string.Format(line6, "<table>" + header + min + "</table>",
                                      "<table id='mt" + QID + "_" + SQMLID + "' style='display:none;'>" + header + med + "</table>",
                                      "<table id='ft" + QID + "_" + SQMLID + "' style='display:none;'>" + header + max + "</table>", QID, SQMLID);
                ret = ret + line6;



                //ret = ret + string.Format(line5, "<hr>");
            }
            return(ret + line4);
        }
コード例 #31
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con1 = new SqlConnection(SqlDataSource3.ConnectionString);
        SqlConnection con2 = new SqlConnection(SqlDataSource1.ConnectionString);
        SqlConnection con3 = new SqlConnection(SqlDataSource2.ConnectionString);
        SurveyResults SR = new SurveyResults();

        con2.Open();

        string str2SQL = "SELECT * FROM [koalasurvey].[Surveys]";
        SqlCommand cmd2 = new SqlCommand(str2SQL, con2);
        SqlDataReader reader2 = cmd2.ExecuteReader();
        reader2.Read();

        while (reader2["SurveyID"].ToString() != Request["SurveyID"])
        {
            reader2.Read();
        }
        SR.SurveyTitle = reader2["SurveyName"].ToString();

        con2.Close();
        con3.Open();

        string str3SQL = "SELECT * FROM [koalasurvey].[Question]";
        SqlCommand cmd3 = new SqlCommand(str3SQL, con3);
        SqlDataReader reader3 = cmd3.ExecuteReader();

        reader3.Read();

        while (reader3["SurveyID"].ToString() != Request["SurveyID"])
        {
            reader3.Read();
        }

        SR.question1 = reader3["QuestionText"].ToString();
        reader3.Read();
        SR.question2 = reader3["QuestionText"].ToString();
        reader3.Read();
        SR.question3 = reader3["QuestionText"].ToString();

        con3.Close();
        con1.Open();

        string str1SQL = "SELECT * FROM [koalasurvey].[Answers]";
        SqlCommand cmd = new SqlCommand(str1SQL, con1);
        SqlDataReader reader1 = cmd.ExecuteReader();

        if(reader1.Read())
        {
            SR.SurveyID = Convert.ToInt32(Request["SurveyID"]);

            while (reader1["SurveyID"].ToString() != Request["SurveyID"])
            {
                reader1.Read();
            }

            SR.choice11 = Convert.ToInt32(reader1["AnswerCount"]);
            SR.choiceText11 = Convert.ToString(reader1["AnswerText"]);
            reader1.Read();
            SR.choice12 = Convert.ToInt32(reader1["AnswerCount"]);
            SR.choiceText12 = Convert.ToString(reader1["AnswerText"]);
            reader1.Read();
            SR.choice13 = Convert.ToInt32(reader1["AnswerCount"]);
            SR.choiceText13 = Convert.ToString(reader1["AnswerText"]);
            reader1.Read();
            SR.choice14 = Convert.ToInt32(reader1["AnswerCount"]);
            SR.choiceText14 = Convert.ToString(reader1["AnswerText"]);
            reader1.Read();
            SR.choice21 = Convert.ToInt32(reader1["AnswerCount"]);
            SR.choiceText21 = Convert.ToString(reader1["AnswerText"]);
            reader1.Read();
            SR.choice22 = Convert.ToInt32(reader1["AnswerCount"]);
            SR.choiceText22 = Convert.ToString(reader1["AnswerText"]);
            reader1.Read();
            SR.choice23 = Convert.ToInt32(reader1["AnswerCount"]);
            SR.choiceText23 = Convert.ToString(reader1["AnswerText"]);
            reader1.Read();
            SR.choice24 = Convert.ToInt32(reader1["AnswerCount"]);
            SR.choiceText24 = Convert.ToString(reader1["AnswerText"]);
            reader1.Read();
            SR.choice31 = Convert.ToInt32(reader1["AnswerCount"]);
            SR.choiceText31 = Convert.ToString(reader1["AnswerText"]);
            reader1.Read();
            SR.choice32 = Convert.ToInt32(reader1["AnswerCount"]);
            SR.choiceText32 = Convert.ToString(reader1["AnswerText"]);
            reader1.Read();
            SR.choice33 = Convert.ToInt32(reader1["AnswerCount"]);
            SR.choiceText33 = Convert.ToString(reader1["AnswerText"]);
            reader1.Read();
            SR.choice34 = Convert.ToInt32(reader1["AnswerCount"]);
            SR.choiceText34 = Convert.ToString(reader1["AnswerText"]);

            /*while(reader1["SurveyID"].ToString() == Request["SurveyID"])
            {
                SR.choices.Add(Convert.ToInt32(reader1["AnswerCount"]));
                SR.choiceText.Add(reader1["AnswerText"].ToString());
                reader1.Read();
            }*/
        }

        con1.Close();

        JavaScriptSerializer serializer = new JavaScriptSerializer();
        string strJson = serializer.Serialize(SR);

        Response.Clear();
        Response.ContentType = "application/json; charset=utf-8";
        Response.Write(strJson);
        Response.End();
    }
コード例 #32
0
ファイル: SurveyService.cs プロジェクト: Ludaxord/Survey-app
        public SurveyResults GetSurveyResult(int survey_id, int user_id)
        {
            var survey = _context.Surveys.Find(survey_id);

            if (survey != null)
            {
                var results = survey.Survey_Finished_Users;

                var questions = survey.Survey_Options;

                dynamic finish_user_json = JsonConvert.DeserializeObject(results);

                dynamic option_json = JsonConvert.DeserializeObject(questions);

                JArray             answers       = new JArray();
                List <JSONAnswers> jAnsList      = new List <JSONAnswers>();
                SurveyResults      surveyResults = new SurveyResults();
                foreach (var result in finish_user_json)
                {
                    var resultUserId     = result["user_id"];
                    var resultSurveyName = result["user_id"];
                    var resultSurveyId   = (int)result["survey_id"];
                    if (resultUserId == user_id)
                    {
                        if (survey_id == resultSurveyId)
                        {
                            surveyResults.SurveyId   = resultSurveyId;
                            surveyResults.UserId     = resultUserId;
                            surveyResults.SurveyText = survey.Survey_Name;
                            answers = result["answers"];


                            foreach (var s in option_json)
                            {
                                JSONAnswers   jSONAnswers    = new JSONAnswers();
                                List <string> answersString  = new List <string>();
                                List <string> answersOptions = new List <string>();
                                foreach (var a in answers)
                                {
                                    if (a["question_number"] == s["question_number"])
                                    {
                                        jSONAnswers.QuestionNumber = (int)s["question_number"];
                                        jSONAnswers.QuestionName   = (string)s["question_text"];
                                        if (s["question_type_id"] == 6)
                                        {
                                            foreach (var iterateOption in s["question_answers"])
                                            {
                                                foreach (var i in iterateOption.Properties())
                                                {
                                                    var aq = a["question_answer"];
                                                    if (i.Name == Convert.ToString(aq))
                                                    {
                                                        answersString.Add((Convert.ToString(i.Value)));
                                                    }
                                                }
                                            }
                                            answersOptions.Add((Convert.ToString(a["question_answer"])));
                                        }
                                        else if (s["question_type_id"] == 5)
                                        {
                                            foreach (var iterateOption in s["question_answers"])
                                            {
                                                foreach (var i in iterateOption.Properties())
                                                {
                                                    var aq = a["question_answer"];
                                                    foreach (var x in aq.OfType <JProperty>())
                                                    {
                                                        if (i.Name == Convert.ToString(x.Name))
                                                        {
                                                            answersString.Add((Convert.ToString(i.Value)));
                                                        }
                                                    }
                                                }
                                            }
                                            foreach (var opt in a["question_answer"].OfType <JProperty>())
                                            {
                                                answersOptions.Add((Convert.ToString(opt.Name)));
                                            }
                                        }
                                        else
                                        {
                                            answersString.Add((Convert.ToString(a["question_answer"])));
                                        }
                                    }
                                }
                                jSONAnswers.QuestionAnswers     = answersOptions;
                                jSONAnswers.QuestionAnswersText = answersString;
                                jAnsList.Add(jSONAnswers);
                            }
                        }
                    }
                    else
                    {
                        SurveyResults s = null;
                        return(s);
                    }
                }

                surveyResults.Answers = jAnsList;

                return(surveyResults);
            }
            else
            {
                SurveyResults surveyResults = null;
                return(surveyResults);
            }
        }