/// <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); } }
/// <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); } }