Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     TbStage.Text = Stage;
     int wave = (int)Session["Wave"];
     int stage = Convert.ToInt32(Stage);
     ProofreadingResult pr = new ProofreadingResult();
     TbKeyDown.Text = pr.GetStimulus(wave, stage);
 }
Exemplo n.º 2
0
        /// <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);
            }
        }