コード例 #1
0
ファイル: Default.aspx.cs プロジェクト: stwehrli/SignalAward
        /// <summary>
        /// Adds an entry to the participant list. For every worker there will be 3 entries, one for each wave.
        /// </summary>
        protected void AddParticipant()
        {
            try
            {
                var participant2 = new Participant
                {
                    AccessCode = (string)Session["AccessCode"],
                    WorkerId = (string)Session["WorkerId"],
                    ArrivalTime = DateTime.Now,
                    Wave = (int)Session["Wave"]
                };

                using (SignalAwardContext db = new SignalAwardContext())
                {
                    string accessCode = (string)Session["AccessCode"];
                    HttpBrowserCapabilities browser = Request.Browser;

                    var participant = db.Participants.FirstOrDefault(p => p.AccessCode == accessCode);
                    if (participant == null)
                    {
                        participant = new Participant
                        {
                            AccessCode = (string)Session["AccessCode"],
                            WorkerId = (string)Session["WorkerId"],
                            Wave = (int)Session["Wave"],
                            F1 = (int)Session["F1"],
                            F2 = (int)Session["F2"],
                            ArrivalTime = DateTime.Now,
                            DepartureTime = DateTime.Now,
                            Browser = browser.Browser,
                            BrowserVersion = browser.Version,
                            Platform = browser.Platform,
                            Ip = Request.ServerVariables["REMOTE_ADDR"].ToString(),
                            ScreenResolution = "",
                            UserAgent = Request.ServerVariables["HTTP_USER_AGENT"].ToString(),

                        };
                        db.Participants.Add(participant);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                SaveExeption(ex.ToString(), "AddParticipant", Wizard.ActiveStepIndex);
            }
        }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: stwehrli/SignalAward
        protected void btnDownload_Click(object sender, EventArgs e)
        {
            string accessCode = Session["AccessCode"].ToString();

            var download = new Download
            {
                DId = 0,
                DownloadTime = DateTime.Now,
                Op = 1,
                AccessCode = accessCode,
                WorkerId = "",
                Ip = Session["Ip"].ToString()
            };

            using (SignalAwardContext db = new SignalAwardContext())
            {
                db.Downloads.Add(download);
                db.SaveChanges();
            }

            string fileName = accessCode + ".pdf";
            string filePath = "~/Cert/Certs/" + fileName;

            if (File.Exists(Server.MapPath(filePath)))
            {
                Response.ContentType = "Application/pdf";
                Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
                Response.TransmitFile(Server.MapPath(filePath));
                Response.End();
            }
            else
            {
                LabelDebug.Text = "Oh snap! Sorry, we cannot find your certificate. We will try to contact you by email.";
                LabelDebug.Visible = true;
                SaveExeption("File not found", "Download", 40);
            }
        }
コード例 #3
0
ファイル: Default.aspx.cs プロジェクト: stwehrli/SignalAward
        protected void SaveExeption(string message, string method, int page)
        {
            var error = new Error
            {
                ErrorDate = DateTime.Now,
                AccessCode = Session["AccessCode"].ToString(),
                WorkerId = Session["WorkerId"].ToString(),
                Message = message,
                Method = method,
                Page = page
            };

            using (SignalAwardContext db = new SignalAwardContext())
            {
                db.Errors.Add(error);
                db.SaveChanges();
            }
        }
コード例 #4
0
ファイル: Default.aspx.cs プロジェクト: stwehrli/SignalAward
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Brand.Text = "Attention Tasks";
                Session["AccessCode"] = "";
                Session["Ip"] = Request.ServerVariables["REMOTE_ADDR"];

                if (!string.IsNullOrEmpty(Request.QueryString["i"]))
                {
                    Session["AccessCode"] = Request.QueryString["i"];
                }

                string imageUrl = "~/controls/stimulus/award_silver.png";

                if (Session["AccessCode"].ToString().Length > 0)
                {
                    imageUrl = "~/controls/stimulus/award_" + AwardLevel(Session["AccessCode"].ToString()) + ".png";
                    //Image1.ImageUrl = imageUrl;
                }

                Image1.ImageUrl = imageUrl;

                var download = new Download
                {
                    DId = 0,
                    DownloadTime = DateTime.Now,
                    Op = 0,
                    AccessCode = Session["AccessCode"].ToString(),
                    WorkerId = "",
                    Ip = Session["Ip"].ToString()
                };

                using (SignalAwardContext db = new SignalAwardContext())
                {
                    db.Downloads.Add(download);
                    db.SaveChanges();
                }
            }
        }
コード例 #5
0
ファイル: Default.aspx.cs プロジェクト: stwehrli/SignalAward
        /// <summary>
        /// Save typewriting test results
        /// </summary>
        /// <param name="keyDown"></param>
        /// <param name="stage"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="keyLog"></param>
        protected void SaveTypewriting(string keyDown, string stage, string startTime, string endTime, string keyLog)
        {
            int test = 2;
            int typeLength = keyDown.Length;
            int typeDiff = -1;
            int typeDiffInsert = -1;
            int typeDiffDelete = -1;
            int typeDiffLength = -1;
            int typeDiffLower = -1;
            int typeDiffLowerLength = -1;

            //string wolf = @"Once upon a time, a Wolf decided to disguise himself as a Sheep in order to catch his prey more easily. He was hungry and knew that the shepherds of the area guarded their sheep well. Covering himself completely with an old sheepskin, he wandered into the pasture nearby. A flock of sheep was grazing there, blissful under the morning sun. ""When the shepherd turns his back I will slide in with them,"" said the Wolf, making his sly move into the flock eventually. Soon evening fell and the shepherd led his sheep away, back into the fold. He locked the gate securely and left. ""Aha! Now is my chance!"" said the Wolf, and was about to take off his disguise when the shepherd returned. He had come back to the fold to choose one of the animals for its meat, for the next day's meal. To the Wolf's bad luck, it was he, in sheep's disguise, who was chosen to be cut up! The Wolf found himself instantly under the sharp knife of the shepherd, and soon very much dead: the hunter becoming the hunted!";
            //string tiger = @"The tiger (Panthera tigris) is the largest cat species, reaching a total body length of up to 3.3 m (11 ft) and weighing up to 306 kg (670 lb). It is the third largest land carnivore (behind only the polar bear and the brown bear). Its most recognizable feature is a pattern of dark vertical stripes on reddish-orange fur with a lighter underside. It has exceptionally stout teeth, and the canines are the longest among living felids with a crown height of as much as 74.5 mm (2.93 in) or even 90 mm (3.5 in). In zoos, tigers have lived for 20 to 26 years, which also seems to be their longevity in the wild. They are territorial and generally solitary but social animals, often requiring large contiguous areas of habitat that support their prey requirements. This, coupled with the fact that they are indigenous to some of the more densely populated places on Earth, has caused significant conflicts with humans.";
            //string original;

            //if (stage == "1")
            //{
            //    original = wolf.Substring(0, keyDown.Length);
            //    //original = wolf;
            //}
            //else
            //{
            //    original = tiger.Substring(0, keyDown.Length);
            //    //original = tiger;
            //}

            //DiffResult dr1 = new DiffResult(original, keyDown);
            //DiffResult dr2 = new DiffResult(original.ToLower(), keyDown.ToLower());

            TypewritingResult tr = new TypewritingResult();
            tr.Wave = (int)Session["Wave"];
            tr.Stage = Convert.ToInt32(stage);
            tr.Input = keyDown;
            tr.GetResult();

            typeDiff = tr.Dr1.InsertCount + tr.Dr1.DeleteCount;
            typeDiffInsert = tr.Dr1.InsertCount;
            typeDiffDelete = tr.Dr1.DeleteCount;
            typeDiffLength = tr.Dr1.InsertLength + tr.Dr1.DeleteLength;
            typeDiffLower = tr.Dr2.InsertCount + tr.Dr2.DeleteCount;
            typeDiffLowerLength = tr.Dr2.InsertLength + tr.Dr2.DeleteLength;
            //LiteralDebug.Text = dr1.Html;

            try
            {
                var typeRes = new TextResult
                {
                    InsertDate = DateTime.Now,
                    AccessCode = (string)Session["AccessCode"],
                    WorkerId = (string)Session["WorkerId"],
                    Wave = (int)Session["Wave"],
                    Test = test,
                    Stage = Convert.ToInt32(stage),
                    StartTime = startTime,
                    EndTime = endTime,
                    TypeText = keyDown,
                    TypeLength = typeLength,
                    TypeDiff = typeDiff,
                    TypeDiffInsert = typeDiffInsert,
                    TypeDiffDelete = typeDiffDelete,
                    TypeDiffLength = typeDiffLength,
                    TypeDiffLower = typeDiffLower,
                    TypeDiffLowerLength = typeDiffLowerLength
                };

                List<KeyLog> keylist = KeyList(test, Convert.ToInt32(stage), startTime, endTime, keyLog);
                using (SignalAwardContext db = new SignalAwardContext())
                {
                    db.TextResults.Add(typeRes);
                    foreach (var key in keylist)
                    {
                        db.KeyLog.Add(key);
                    }
                    db.SaveChanges();
                }
            }
            catch(Exception ex)
            {
                LiteralDebug.Text += ex.ToString();
                SaveExeption(ex.ToString(), "SaveTypewriting", Wizard.ActiveStepIndex);
            }
        }
コード例 #6
0
ファイル: Default.aspx.cs プロジェクト: stwehrli/SignalAward
        /// <summary>
        /// Save proofreading test results
        /// </summary>
        /// <param name="keyDown"></param>
        /// <param name="stage"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="keyLog"></param>
        protected void SaveProofreading(string keyDown, string stage, string startTime, string endTime, string keyLog)
        {
            int test = 3;
            int typeLength = keyDown.Length;
            int typeDiff = -1;
            int typeDiffInsert = -1;
            int typeDiffDelete = -1;
            int typeDiffLength = -1;
            int typeDiffLower = -1;
            int typeDiffLowerLength = -1;

            //string ipad = @"iPads in school: a toy or a tool? Like many parents, my wife and I have tried to make sure our daughter reads real books and doesn’t get addicted to everything digital. And now her school district, which has laid off teachers and staff and eliminated programs because of budget problems, wants to spend several hundred million dollars on the latest electronic fad. And L.A. Unified School District is not the only district racing into the future while struggling to fix leaky roves and broken toilets. As Deasy argues, students are supposed to begin taking standardized tests on electronic devices in the 2014-15 school year as part of a new curriculum. And he said it would be irresponsible not to prepare students for an increasingly digital economy.";
            //string tornado = @"It’s as predictable as it is disheartening: A red state gets hit hard by a tornado outbreak -- in this case killing at least 24 people, many of them children attending school -- and the first batch of letters from readers (most of them from Southern California) use the tragedy to score political points. Sure, many of the letters express heartfelt condolences, but not without landing some political punches before signing of. It’s as if Americans who dwell in disaster-prone areas don't have a right to believe in low taxes and smaller government. It goes without saying that were shocked and saddend by what happened to the tornado victims and their families in Oklahoma. But with today's politically polarized climate that touches nearly every aspect of our lives, those condolences need to be swayed -- and without a side of barbed politics.";
            //string original;

            //if (stage == "1")
            //{
            //    original = ipad;
            //}
            //else
            //{
            //    original = tornado;
            //}

            //DiffResult dr1 = new DiffResult(original, keyDown);
            //DiffResult dr2 = new DiffResult(original.ToLower(), keyDown.ToLower());

            ProofreadingResult pr = new ProofreadingResult();
            pr.Wave = (int)Session["Wave"];
            pr.Stage = Convert.ToInt32(stage);
            pr.Input = keyDown;
            pr.GetResult();

            typeDiff = pr.Dr1.InsertCount + pr.Dr1.DeleteCount;
            typeDiffInsert = pr.Dr1.InsertCount;
            typeDiffDelete = pr.Dr1.DeleteCount;
            typeDiffLength = pr.Dr1.InsertLength + pr.Dr1.DeleteLength;
            typeDiffLower = pr.Dr2.InsertCount + pr.Dr2.DeleteCount;
            typeDiffLowerLength = pr.Dr2.InsertLength + pr.Dr2.DeleteLength;
            //LiteralDebug.Text = dr1.Html;

            try
            {
                var typeRes = new TextResult
                {
                    InsertDate = DateTime.Now,
                    AccessCode = (string)Session["AccessCode"],
                    WorkerId = (string)Session["WorkerId"],
                    Wave = (int)Session["Wave"],
                    Test = test,
                    Stage = Convert.ToInt32(stage),
                    StartTime = startTime,
                    EndTime = endTime,
                    TypeText = keyDown,
                    TypeLength = typeLength,
                    TypeDiff = typeDiff,
                    TypeDiffInsert = typeDiffInsert,
                    TypeDiffDelete = typeDiffDelete,
                    TypeDiffLength = typeDiffLength,
                    TypeDiffLower = typeDiffLower,
                    TypeDiffLowerLength = typeDiffLowerLength
                };

                List<KeyLog> keylist = KeyList(test, Convert.ToInt32(stage), startTime, endTime, keyLog);
                using (SignalAwardContext db = new SignalAwardContext())
                {
                    db.TextResults.Add(typeRes);
                    foreach (var key in keylist)
                    {
                        db.KeyLog.Add(key);
                    }
                    db.SaveChanges();
                }

            }
            catch (Exception ex)
            {
                LiteralDebug.Text += ex.ToString();
                SaveExeption(ex.ToString(), "SaveProofreading", Wizard.ActiveStepIndex);
            }
        }
コード例 #7
0
ファイル: Default.aspx.cs プロジェクト: stwehrli/SignalAward
        /// <summary>
        /// Saves time stamp of page requests
        /// </summary>
        protected void SavePageLog()
        {
            HttpBrowserCapabilities browser = Request.Browser;

            var pageLog = new PageLog
            {
                ClickDate = DateTime.Now,
                AccessCode = Session["AccessCode"].ToString(),
                WorkerId = Session["WorkerId"].ToString(),
                Wave = (int)Session["Wave"],
                Page = Wizard.ActiveStepIndex + 1,
                Ip = Request.ServerVariables["Remote_ADDR"].ToString(),
                Browser = browser.Browser + " " + browser.Version
            };

            using (SignalAwardContext db = new SignalAwardContext())
            {
                db.PageLog.Add(pageLog);
                db.SaveChanges();
            }
        }
コード例 #8
0
ファイル: Default.aspx.cs プロジェクト: stwehrli/SignalAward
        /// <summary>
        /// Save Math test result
        /// </summary>
        /// <param name="stage"></param>
        /// <param name="testId"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="KeyLog"></param>
        /// <param name="res1"></param>
        /// <param name="res2"></param>
        /// <param name="res3"></param>
        /// <param name="res4"></param>
        /// <param name="res5"></param>
        /// <param name="res6"></param>
        /// <param name="res7"></param>
        protected void SaveMath(string stage, string testSetId, string startTime, string endTime, string keyLog, string res1, string res2, string res3, string res4, string res5, string res6, string res7)
        {
            int test = 4;
            int testSet = -1;
            int _res1 = -1;
            int _res2 = -1;
            int _res3 = -1;
            int _res4 = -1;
            int _res5 = -1;
            int _res6 = -1;
            int _res7 = -1;
            int _resCount = 0;
            int _resError = 0;

            try
            {
                testSet = Convert.ToInt32(testSetId);

                if (Int32.TryParse(res1, out _res1)) _resCount++;
                if (Int32.TryParse(res2, out _res2)) _resCount++;
                if (Int32.TryParse(res3, out _res3)) _resCount++;
                if (Int32.TryParse(res4, out _res4)) _resCount++;
                if (Int32.TryParse(res5, out _res5)) _resCount++;
                if (Int32.TryParse(res6, out _res6)) _resCount++;
                if (Int32.TryParse(res7, out _res7)) _resCount++;

                SignalAward.Controls.Math ar = new SignalAward.Controls.Math();
                if (_res1 > 0 & _res1 != ar.GetResult(testSet, 1)) _resError++;
                if (_res2 > 0 & _res2 != ar.GetResult(testSet, 2)) _resError++;
                if (_res3 > 0 & _res3 != ar.GetResult(testSet, 3)) _resError++;
                if (_res4 > 0 & _res4 != ar.GetResult(testSet, 4)) _resError++;
                if (_res5 > 0 & _res5 != ar.GetResult(testSet, 5)) _resError++;
                if (_res6 > 0 & _res6 != ar.GetResult(testSet, 6)) _resError++;
                if (_res7 > 0 & _res7 != ar.GetResult(testSet, 7)) _resError++;

                var MathResult = new MathResult
                {
                    InsertDate = DateTime.Now,
                    AccessCode = Session["AccessCode"].ToString(),
                    WorkerId = Session["WorkerId"].ToString(),
                    Wave = (int)Session["Wave"],
                    Stage = Convert.ToInt32(stage),
                    TestSetId = Convert.ToInt32(testSetId),
                    StartTime = startTime,
                    EndTime = endTime,
                    ResCount = _resCount,
                    ResError = _resError,
                    Res1 = _res1,
                    Res2 = _res2,
                    Res3 = _res3,
                    Res4 = _res4,
                    Res5 = _res5,
                    Res6 = _res6,
                    Res7 = _res7
                };

                List<KeyLog> keylist = KeyList(test, Convert.ToInt32(stage), startTime, endTime, keyLog);
                using (SignalAwardContext db = new SignalAwardContext())
                {
                    db.MathResults.Add(MathResult);
                    foreach (var key in keylist)
                    {
                        db.KeyLog.Add(key);
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                LiteralDebug.Text += ex.ToString();
                SaveExeption(ex.ToString(), "SaveMath", Wizard.ActiveStepIndex);
            }
        }
コード例 #9
0
ファイル: Default.aspx.cs プロジェクト: stwehrli/SignalAward
        /// <summary>
        /// Save D2 test results
        /// </summary>
        /// <param name="stage"></param>
        /// <param name="sequence"></param>
        /// <param name="startTime"></param>
        /// <param name="clickLog"></param>
        /// <param name="result"></param>
        protected void SaveD2(string stage, string sequence, string startTime, string endTime, string keyLog, string result)
        {
            int test = 1;

            try
            {
                int gz = -1;
                int c = -1;
                int f1 = -1;
                int f2 = -1;
                string t;

                if (result.Length > 0)
                {
                    var resSplits = result.Split(',');
                    foreach (var r in resSplits)
                    {
                        if (r.StartsWith("gz"))
                        {
                            t = r.Replace("gz:", "").Trim();
                            gz = Convert.ToInt32(t);
                        }
                        if (r.StartsWith("c"))
                        {
                            t = r.Replace("c:", "").Trim();
                            c = Convert.ToInt32(t);
                        }
                        if (r.StartsWith("f1"))
                        {
                            t = r.Replace("f1:", "").Trim();
                            f1 = Convert.ToInt32(t);
                        }
                        if (r.StartsWith("f2"))
                        {
                            t = r.Replace("f2:", "").Trim();
                            f2 = Convert.ToInt32(t);
                        }
                    }
                }

                var d2res = new D2Result
                {
                    InsertDate = DateTime.Now,
                    AccessCode = (string)Session["AccessCode"],
                    WorkerId = (string)Session["WorkerId"],
                    Wave = (int)Session["Wave"],
                    Stage = Convert.ToInt32(stage),
                    StartTime = startTime,
                    EndTime = endTime,
                    Sequence = sequence,
                    GZ = gz,
                    C = c,
                    F1 = f1,
                    F2 = f2
                };

                List<KeyLog> keylist = KeyList(test, Convert.ToInt32(stage), startTime, endTime, keyLog);

                using (SignalAwardContext db = new SignalAwardContext())
                {
                    db.D2Results.Add(d2res);
                    foreach (var key in keylist)
                    {
                        db.KeyLog.Add(key);
                    }
                    db.SaveChanges();
                }

            }
            catch (Exception ex)
            {
                LiteralDebug.Text += ex.ToString();
                SaveExeption(ex.ToString(), "SaveD2", Wizard.ActiveStepIndex);
            }
        }
コード例 #10
0
ファイル: Default.aspx.cs プロジェクト: stwehrli/SignalAward
        /// <summary>
        /// Adds sociodemographic variables
        /// </summary>
        protected void UpdateParticipant(int page)
        {
            try
            {
                TextBox screenRes = (TextBox)Demography_0.FindControl("TbScreenRes");
                RadioButtonList satisfaction = (RadioButtonList)Demography_0.FindControl("Satisfaction");
                DropDownList state = (DropDownList)Demography_0.FindControl("State");
                TextBox county = (TextBox)Demography_0.FindControl("TbCounty");
                RadioButtonList areaType = (RadioButtonList)Demography_0.FindControl("AreaType");

                TextBox yearBorn = (TextBox)Demography_1.FindControl("TbAge");
                RadioButtonList gender = (RadioButtonList)Demography_1.FindControl("Gender");
                RadioButtonList education = (RadioButtonList)Demography_1.FindControl("Education");

                RadioButtonList employment = (RadioButtonList)Demography_2.FindControl("Employment");
                RadioButtonList language = (RadioButtonList)Demography_2.FindControl("Language");

                RadioButtonList happyness = (RadioButtonList)Demography_3.FindControl("Happyness");
                TextBox householdsize = (TextBox)Demography_3.FindControl("TbHoushold");
                TextBox income = (TextBox)Demography_3.FindControl("TbIncome");
                TextBox hits = (TextBox)Demography_3.FindControl("TbHits");

                using (SignalAwardContext db = new SignalAwardContext())
                {
                    string accessCode = (string)Session["AccessCode"];
                    var participant = db.Participants.FirstOrDefault(p => p.AccessCode == accessCode);
                    if (participant != null)
                    {
                        switch (page)
                        {
                            case 31:
                                participant.ScreenResolution = screenRes.Text;
                                participant.Satisfaction = (satisfaction.SelectedIndex + 1).ToString();
                                participant.State = state.SelectedValue;
                                participant.County = county.Text;
                                participant.AreaType = (areaType.SelectedIndex + 1).ToString();
                                break;
                            case 32:
                                participant.YearBorn = yearBorn.Text;
                                participant.Gender = (gender.SelectedIndex + 1).ToString();
                                participant.Education = (education.SelectedIndex + 1).ToString();
                                break;
                            case 33:
                                participant.Employment = (employment.SelectedIndex + 1).ToString();
                                participant.Language = (language.SelectedIndex + 1).ToString();
                                break;
                            case 34:
                                participant.Happyness = (happyness.SelectedIndex + 1).ToString();
                                participant.HouseholdSize = householdsize.Text;
                                participant.Income = income.Text;
                                participant.HitCount = hits.Text;
                                break;
                            case 35:
                                participant.Comments = TbComments.Text;
                                break;
                            case 36:
                                participant.DepartureTime = DateTime.Now;
                                break;
                        }
                        db.SaveChanges();
                    }
                }

            }
            catch (Exception ex)
            {
                SaveExeption(ex.ToString(), "UpdateParticipant", Wizard.ActiveStepIndex);
            }
        }
コード例 #11
0
ファイル: Access.cs プロジェクト: stwehrli/SignalAward
 /// <summary>
 /// Sets workerId in Design Table
 /// </summary>
 /// <param name="accessCode"></param>
 /// <param name="workerId"></param>
 public void SetWorkerIdInDesign(string accessCode, string workerId)
 {
     using (SignalAwardContext db = new SignalAwardContext())
     {
         var design = db.Designs.FirstOrDefault(d => d.AccessCode == accessCode);
         if (design != null)
         {
             design.WorkerId = workerId;
             db.SaveChanges();
         }
     }
 }