private void ShowExamResult(KidsUser_BankStoryExam UserExam) { pnlDetails.Visible = true; pnlMain.Visible = false; lblCorrectCount.Text = UserExam.CorrectAnswer.ToString(); lblInCorectCount.Text = UserExam.InCorrectAnswer.ToString(); lblNoAnswerCount.Text = UserExam.NoAnswer.ToString(); lblScore.Text = UserExam.CalculatedScore.ToString(); }
private void SaveExamResult() { ExamTimer.Enabled = false; int CorrectAnswer = 0, InCorrectAnswer = 0, NoAnswer = 0; foreach (GridViewRow item in dgExamQuestion.Rows) { var QuestionId = (item.FindControl("QuestionId") as HiddenField).Value.ToInt32(); var A = (item.FindControl("rdoAnswerA") as RadioButton).Checked; var B = (item.FindControl("rdoAnswerB") as RadioButton).Checked; var C = (item.FindControl("rdoAnswerC") as RadioButton).Checked; var D = (item.FindControl("rdoAnswerD") as RadioButton).Checked; var UserAnswer = GetAnswer(A, B, C, D); var q = CurrentExam.BankStoryExam_Question.FirstOrDefault(o => o.QuestionId == QuestionId); if (UserAnswer == -1) NoAnswer++; else if (q.Answer == UserAnswer) CorrectAnswer++; else InCorrectAnswer++; } try { var user = OnlineKidsUser.Kids_UserInfo; var UserExam = new KidsUser_BankStoryExam { CorrectAnswer = CorrectAnswer, InCorrectAnswer = InCorrectAnswer, NoAnswer = NoAnswer, ExamId = CurrentExam.ExamId, CalculatedScore = CorrectAnswer / (CorrectAnswer + InCorrectAnswer + NoAnswer), CreateDateTime = DateTime.Now }; user.KidsUser_BankStoryExam.Add(UserExam); KidsUser_DataProvider.SaveKidsUser(user, this, RefreshOnlineKidsUserInfo); ShowExamResult(UserExam); } catch (Exception ex) { if (ex.Message.Contains("PK_KidsUser_BankStoryExam")) { RefreshOnlineKidsUserInfo(); ShowMessageBox("نتیجه آزمون شما قبلا ثبت شده است"); ShowExamResult(OnlineKidsUser.Kids_UserInfo.KidsUser_BankStoryExam.FirstOrDefault()); } } }