Exemplo n.º 1
0
 public ActionResult Comments(FormCollection form)
 {
     try
     {
         ViewBag.questiontext = "Do you have any other comments?";
         var c = new ResearchDB();
         var answer = form["input"];
         int surveyNum = 2;
         int questionNum = 10;
         var UserID = Request.Cookies["UserID"].Value;
         var question = c.Surveys.First(s => s.SurveyID == surveyNum).SurveyQuestions.First(q => q.QuestionID == questionNum);
         c.SurveyAnswers.Add(new SurveyAnswer
         {
             QuestionID = 10,
             SurveyID = 2,
             UserID = int.Parse(UserID),
             Value = answer
         });
         c.SaveChanges();
         SaveEndTime();
         ViewBag.questiontext = question.QuestionText;
         return View("Survey2Complete");
     }
     catch (NullReferenceException e)
     {
         System.IO.File.WriteAllText("C:\\Log.txt", e.Message);
         return View("Error");
     }
 }
Exemplo n.º 2
0
 public ActionResult SaveEndTime()
 {
     try
     {
         var c = new ResearchDB();
         var UserID = Request.Cookies["UserID"].Value;
         var UserIDint = int.Parse(UserID);
         var user = c.Users.Find(UserIDint);
         user.EndTime = DateTime.Now;
         c.SaveChanges();
         return null;
     }
     catch (NullReferenceException e)
     {
         System.IO.File.WriteAllText("C:\\Log.txt", e.Message);
         return View("Error");
     }
 }
Exemplo n.º 3
0
        public ActionResult Survey2(FormCollection form)
        {
            try
            {
                var survNum = form["survNum"];
                var questNum = form["questNum"];
                var answer = form["input"];
                var c = new ResearchDB();
                var UserID = Request.Cookies["UserID"].Value;
                var surveyNum = int.Parse(survNum);
                var questionNum = int.Parse(questNum);
                var currentQuestion = c.Surveys.First(s => s.SurveyID == surveyNum).SurveyQuestions.First(q => q.QuestionID == questionNum);
                c.SurveyAnswers.Add(new SurveyAnswer
                {
                    QuestionID = currentQuestion.QuestionID,
                    SurveyID = surveyNum,
                    UserID = int.Parse(UserID),
                    Value = answer
                });

                c.SaveChanges();
                if (questionNum < 10)
                {
                    if (questionNum == 3 || questionNum == 4)
                    {
                        questionNum = 6;
                    }
                    else if (questionNum == 9)
                    {
                        ViewBag.questiontext = "Do you have any other comments?";
                        return View("Comments");
                    }
                    else
                    {
                        questionNum++;
                    }
                    var question = c.Surveys.First(s => s.SurveyID == surveyNum).SurveyQuestions.First(q => q.QuestionID == questionNum);
                    ViewBag.questiontext = question.QuestionText;
                    ViewBag.questNum = questionNum;
                    ViewBag.survNum = surveyNum;
                    return View();
                }
                else
                {
                    return View("Survey2Complete");
                }
            }
            catch (NullReferenceException e)
            {
                System.IO.File.WriteAllText("C:\\Log.txt", e.Message);
                return View("Error");
            }
        }
Exemplo n.º 4
0
        public ActionResult StartResearch()
        {
            //User has agreed to participate: create new record for them in db.
            var c = new ResearchDB();
            var u = new User
            {
                StartTime = DateTime.Now,
                EndTime = DateTime.Now,
                OptimisedUI = Count()
            };

            c.Users.Add(u);
            c.SaveChanges();
            var ID = u.UserID;
            var UI = u.OptimisedUI;
            Response.Cookies.Add(new HttpCookie("UserID", ID.ToString())); //track User throughout journey by ID
            Response.Cookies.Add(new HttpCookie("OptimisedUI", UI.ToString())); //assign User to correct tutorial
            return View();
        }