public void getQuestion(int no) { string str = "select * from Personality_Question where Question_id=" + no + ""; SqlDataAdapter da2 = new SqlDataAdapter(str, sqlconn); DataSet ds2 = new DataSet(); da2.Fill(ds2, "Personality_Question"); if (ds2.Tables[0].Rows.Count > 0) { DataRow dtr; int i = 0; while (i < ds2.Tables[0].Rows.Count) { dtr = ds2.Tables[0].Rows[i]; lblQuestion.Text = "Q." + Session["counter"].ToString() + " " + dtr["Question"].ToString(); RblOption.ClearSelection(); RblOption.Items.Clear(); RblOption.Items.Add(dtr["Disagree_Strongly"].ToString()); RblOption.Items.Add(dtr["Disagree_Litle"].ToString()); RblOption.Items.Add(dtr["Neither_agree_nor_disagree"].ToString()); RblOption.Items.Add(dtr["Agree_Litle"].ToString()); RblOption.Items.Add(dtr["Agree_Strongly"].ToString()); i++; } } }
public void getQuestion(int no) { sid = Session["exam"].ToString(); string str = "select * from Question where slNo=" + no + ""; SqlDataAdapter da2 = new SqlDataAdapter("select * from Question_Table where Eid='" + sid + "' and Quesno= " + no + "", sqlconn); DataSet ds2 = new DataSet(); da2.Fill(ds2, "Question"); if (ds2.Tables[0].Rows.Count > 0) { DataRow dtr; int i = 0; while (i < ds2.Tables[0].Rows.Count) { dtr = ds2.Tables[0].Rows[i]; Session["Answer"] = Convert.ToString(Convert.ToInt32(dtr["Answer"].ToString()) - 1); lblQuestion.Text = "Q." + Session["counter"].ToString() + " " + dtr["Quesname"].ToString(); RblOption.ClearSelection(); RblOption.Items.Clear(); RblOption.Items.Add(dtr["Optionone"].ToString()); RblOption.Items.Add(dtr["Optiontwo"].ToString()); RblOption.Items.Add(dtr["Optionthree"].ToString()); RblOption.Items.Add(dtr["Optionfour"].ToString()); i++; } } }
public void getQuestion(int no) { string str = "select * from ref_questions where slNo=" + no + ""; SqlDataAdapter da2 = new SqlDataAdapter(str, sqlconn); DataSet ds2 = new DataSet(); da2.Fill(ds2, "Question"); if (ds2.Tables[0].Rows.Count > 0) { DataRow dtr; int i = 0; while (i < ds2.Tables[0].Rows.Count) { dtr = ds2.Tables[0].Rows[i]; Session["Answer"] = Convert.ToString(Convert.ToInt32(dtr["Answer"].ToString()) - 1); lblQuestion.Text = "Q." + Session["counter"].ToString() + " " + dtr["Question"].ToString(); RblOption.ClearSelection(); RblOption.Items.Clear(); RblOption.Items.Add(dtr["Option1"].ToString()); RblOption.Items.Add(dtr["Option2"].ToString()); RblOption.Items.Add(dtr["Option3"].ToString()); RblOption.Items.Add(dtr["Option4"].ToString()); i++; } } }
//Display Options public void DisplayOptions(int no) { // string strCmdA = "select * from Evaluations.ObjTestPaper where QuestionID=" + no + ""; string strCmdA = string.Format(@"SELECT * from Evaluations.OnlineTestTransaction where QuestionID={0} AND TestID={1} AND CandidateID={2}", no, Convert.ToInt32(lblTestID.Text), Convert.ToInt32(lblCandidateID.Text)); SqlDataAdapter ObjDAa = new SqlDataAdapter(strCmdA, BD.ObjCn); DataSet ObjDS = new DataSet(); ObjDAa.Fill(ObjDS, "Answers"); if (ObjDS.Tables[0].Rows.Count > 0) { DataRow dtrA; int i = 0; while (i < ObjDS.Tables[0].Rows.Count) { dtrA = ObjDS.Tables[0].Rows[i]; RblOption.ClearSelection(); RblOption.Items.Clear(); RblOption.Items.Add(dtrA["OptionA"].ToString()); RblOption.Items.Add(dtrA["OptionB"].ToString()); RblOption.Items.Add(dtrA["OptionC"].ToString()); RblOption.Items.Add(dtrA["OptionD"].ToString()); i++; } } }//End Function getOptions()
//Display question and options, Save correct answer in session variable public void getQuestion(int no) { //string strCmdQ = "SELECT * from Evaluations.ObjTestPaper where QuestionID=" + no + ""; string strCmdQ = string.Format(@"SELECT * from Evaluations.OnlineTestTransaction where QuestionID={0} AND TestID={1} AND CandidateID={2}", no, Convert.ToInt32(lblTestID.Text), Convert.ToInt32(lblCandidateID.Text)); //string strCmdQ = string.Format("select * from Evaluations.ObjQuestions where QuestionID={0} OR CourseID='{1}'", no, strCourseID) ; SqlDataAdapter ObjDAq = new SqlDataAdapter(strCmdQ, BD.ObjCn); DataSet ObjDS = new DataSet(); ObjDAq.Fill(ObjDS, "Question"); //Display Test ID DataRow dr = ObjDS.Tables[0].Rows[0]; lblTestID.Text = dr["TestID"].ToString(); //lblTestTitle.Text = dr["CourseTitle"].ToString(); if (ObjDS.Tables[0].Rows.Count > 0) { DataRow dtrQ; int i = 0; while (i < ObjDS.Tables[0].Rows.Count) { dtrQ = ObjDS.Tables[0].Rows[i]; Session["TransactionID"] = dtrQ["TransactionID"].ToString();//TransactionID from Users Answer Sheet Session["Answer"] = dtrQ["CorrectAnswer"].ToString(); //Display Question lblQuestion.Text = "Q" + Session["counter"].ToString() + "." + " " + dtrQ["Question"].ToString(); //Display options RblOption.ClearSelection(); RblOption.Items.Clear(); RblOption.Items.Add(dtrQ["OptionA"].ToString()); RblOption.Items.Add(dtrQ["OptionB"].ToString()); RblOption.Items.Add(dtrQ["OptionC"].ToString()); RblOption.Items.Add(dtrQ["OptionD"].ToString()); i++; } } //Commented following as there is no need to make trip again-Shivmani 06/06/2019 //DisplayOptions(no); }
//Display Options public void DisplayOptions(int no) { string strCmdA = "select * from Evaluations.ObjTestPaper where QuestionID=" + no + ""; SqlDataAdapter ObjDAa = new SqlDataAdapter(strCmdA, BD.ObjCn); DataSet ObjDS = new DataSet(); ObjDAa.Fill(ObjDS, "Answers"); if (ObjDS.Tables[0].Rows.Count > 0) { DataRow dtrA; int i = 0; while (i < ObjDS.Tables[0].Rows.Count) { dtrA = ObjDS.Tables[0].Rows[i]; RblOption.ClearSelection(); RblOption.Items.Clear(); RblOption.Items.Add(dtrA["OptionA"].ToString()); RblOption.Items.Add(dtrA["OptionB"].ToString()); RblOption.Items.Add(dtrA["OptionC"].ToString()); RblOption.Items.Add(dtrA["OptionD"].ToString()); i++; } } }//End Function getOptions()