protected void Timer1_Tick(object sender, EventArgs e) { //var x = Request.QueryString["st"].ToString(); //int y = int.Parse(x); //Response.Redirect("StudentChoseExam.aspx?id=" + y); var chap = Request.QueryString["id"].ToString(); int ch = int.Parse(chap); Tbl_ExamStructure rr = db.Tbl_ExamStructure.First(u => u.Chapter_ID == ch); int MCQA = rr.Num_Ques_Mcq_A; int MCQB = rr.Num_Ques_Mcq_B; int MCQC = rr.Num_Ques_Mcq_C; int TFA = rr.Num_Ques_TF_A; int TFB = rr.Num_Ques_TF_B; int TFC = rr.Num_Ques_TF_C; int ques = MCQA + MCQB + MCQC + TFA + TFB + TFC; var x = Request.QueryString["st"].ToString(); int y = int.Parse(x); Tbl_chapter rr1 = db.Tbl_chapter.First(u => u.Chapter_ID == ch); int sub = rr1.Subject_ID; var re = new Tbl_Result { Student_ID = y, Chapter_ID = ch, Result = int.Parse(Label8.Text), Subject_ID = sub, }; db.Tbl_Result.Add(re); db.SaveChanges(); Label1.Text = "your result " + Label8.Text + " from " + ques.ToString(); Label9.Text = "الدرجة" + Label8.Text + " من" + ques.ToString(); RadioButtonList1.Visible = false; RadioButtonList2.Visible = false; Button1.Visible = false; Button2.Visible = true; }
protected void Button1_Click(object sender, EventArgs e) { int mark = int.Parse(RadioButtonList1.SelectedValue.ToString()); int final_mark = int.Parse(Label8.Text); final_mark += mark; Label8.Text = final_mark.ToString(); var chap = Request.QueryString["id"].ToString(); int ch = int.Parse(chap); Tbl_ExamStructure rr = db.Tbl_ExamStructure.First(u => u.Chapter_ID == ch); int MCQA = rr.Num_Ques_Mcq_A; int MCQB = rr.Num_Ques_Mcq_B; int MCQC = rr.Num_Ques_Mcq_C; int TFA = rr.Num_Ques_TF_A; int TFB = rr.Num_Ques_TF_B; int TFC = rr.Num_Ques_TF_C; int ques = MCQA + MCQB + MCQC + TFA + TFB + TFC; int y1 = int.Parse(Label2.Text); int y2 = int.Parse(Label3.Text); int y3 = int.Parse(Label4.Text); int y4 = int.Parse(Label5.Text); int y5 = int.Parse(Label6.Text); int y6 = int.Parse(Label7.Text); int num = y1 + y2 + y3 + y4 + y5 + y6; if (y1 < MCQA) { var rrA = db.Tbl_Question.Where(u => u.Chapter_ID == ch && u.Question_Level == "A" && u.Type == "MCQ").OrderBy(u => u.Question_ID).Skip(y1); foreach (var item in rrA) { Label1.Text = item.Question_En.ToString(); y1 += 1; Label2.Text = y1.ToString(); int qA = item.Question_ID; var stateidA = from Tbl_Answer in db.Tbl_Answer where Tbl_Answer.Question_ID == qA select new { Tbl_Answer.Answer_En, Tbl_Answer.Correct_Answer }; var statenameA = stateidA.ToList(); if (statenameA.Count > 0) { RadioButtonList1.DataSource = statenameA.ToList(); RadioButtonList1.DataTextField = "Answer_En"; RadioButtonList1.DataValueField = "Correct_Answer"; RadioButtonList1.DataBind(); } break; } } else if (y2 < MCQB) { var rrA = db.Tbl_Question.Where(u => u.Chapter_ID == ch && u.Question_Level == "B" && u.Type == "MCQ").OrderBy(u => u.Question_ID).Skip(y2); foreach (var item in rrA) { Label1.Text = item.Question_En.ToString(); y2 += 1; Label3.Text = y2.ToString(); int qA = item.Question_ID; var stateidA = from Tbl_Answer in db.Tbl_Answer where Tbl_Answer.Question_ID == qA select new { Tbl_Answer.Answer_En, Tbl_Answer.Correct_Answer }; var statenameA = stateidA.ToList(); if (statenameA.Count > 0) { RadioButtonList1.DataSource = statenameA.ToList(); RadioButtonList1.DataTextField = "Answer_En"; RadioButtonList1.DataValueField = "Correct_Answer"; RadioButtonList1.DataBind(); } break; } } else if (y3 < MCQC) { var rrA = db.Tbl_Question.Where(u => u.Chapter_ID == ch && u.Question_Level == "C" && u.Type == "MCQ").OrderBy(u => u.Question_ID).Skip(y3); foreach (var item in rrA) { Label1.Text = item.Question_En.ToString(); y3 += 1; Label4.Text = y3.ToString(); int qA = item.Question_ID; var stateidA = from Tbl_Answer in db.Tbl_Answer where Tbl_Answer.Question_ID == qA select new { Tbl_Answer.Answer_En, Tbl_Answer.Correct_Answer }; var statenameA = stateidA.ToList(); if (statenameA.Count > 0) { RadioButtonList1.DataSource = statenameA.ToList(); RadioButtonList1.DataTextField = "Answer_En"; RadioButtonList1.DataValueField = "Correct_Answer"; RadioButtonList1.DataBind(); } break; } } else if (y4 < TFA) { var rrA = db.Tbl_Question.Where(u => u.Chapter_ID == ch && u.Question_Level == "A" && u.Type == "T/F").OrderBy(u => u.Question_ID).Skip(y4); foreach (var item in rrA) { Label1.Text = item.Question_En.ToString(); y4 += 1; Label5.Text = y4.ToString(); int qA = item.Question_ID; var stateidA = from Tbl_Answer in db.Tbl_Answer where Tbl_Answer.Question_ID == qA select new { Tbl_Answer.Answer_En, Tbl_Answer.Correct_Answer }; var statenameA = stateidA.ToList(); if (statenameA.Count > 0) { RadioButtonList1.DataSource = statenameA.ToList(); RadioButtonList1.DataTextField = "Answer_En"; RadioButtonList1.DataValueField = "Correct_Answer"; RadioButtonList1.DataBind(); } break; } } else if (y5 < TFB) { var rrA = db.Tbl_Question.Where(u => u.Chapter_ID == ch && u.Question_Level == "B" && u.Type == "T/F").OrderBy(u => u.Question_ID).Skip(y5); foreach (var item in rrA) { Label1.Text = item.Question_En.ToString(); y5 += 1; Label6.Text = y5.ToString(); int qA = item.Question_ID; var stateidA = from Tbl_Answer in db.Tbl_Answer where Tbl_Answer.Question_ID == qA select new { Tbl_Answer.Answer_En, Tbl_Answer.Correct_Answer }; var statenameA = stateidA.ToList(); if (statenameA.Count > 0) { RadioButtonList1.DataSource = statenameA.ToList(); RadioButtonList1.DataTextField = "Answer_En"; RadioButtonList1.DataValueField = "Correct_Answer"; RadioButtonList1.DataBind(); } break; } } else if (y6 < TFC) { var rrA = db.Tbl_Question.Where(u => u.Chapter_ID == ch && u.Question_Level == "C" && u.Type == "T/F").OrderBy(u => u.Question_ID).Skip(y6); foreach (var item in rrA) { Label1.Text = item.Question_En.ToString(); y6 += 1; Label7.Text = y6.ToString(); int qA = item.Question_ID; var stateidA = from Tbl_Answer in db.Tbl_Answer where Tbl_Answer.Question_ID == qA select new { Tbl_Answer.Answer_En, Tbl_Answer.Correct_Answer }; var statenameA = stateidA.ToList(); if (statenameA.Count > 0) { RadioButtonList1.DataSource = statenameA.ToList(); RadioButtonList1.DataTextField = "Answer_En"; RadioButtonList1.DataValueField = "Correct_Answer"; RadioButtonList1.DataBind(); } break; } } else if (num == ques) { var x = Request.QueryString["st"].ToString(); int y = int.Parse(x); Tbl_chapter rr1 = db.Tbl_chapter.First(u => u.Chapter_ID == ch); int sub = rr1.Subject_ID; var re = new Tbl_Result { Student_ID = y, Chapter_ID = ch, Result = int.Parse(Label8.Text), Subject_ID = sub, }; db.Tbl_Result.Add(re); db.SaveChanges(); Label1.Text = "your result " + Label8.Text + " from " + ques.ToString(); RadioButtonList1.Visible = false; Button1.Visible = false; Button2.Visible = true; } }