public List <Questionmaster> startexam(int Qzmid) { DALCommon dal = new DALCommon(ConStr); List <Questionmaster> Queslst = new List <Questionmaster>(); DataTable _dtquestion = new DataTable(); _dtquestion = dal.GetQuizequestionList(Qzmid); DataTable _dtquestionoption = new DataTable(); for (int i = 0; i < _dtquestion.Rows.Count; i++) { Questionmaster _singlequest = new Questionmaster(); _singlequest.Qmid = Convert.ToInt32(_dtquestion.Rows[i]["Qmid"]); _singlequest.Question = Convert.ToString(_dtquestion.Rows[i]["Question"]); _dtquestionoption = dal.GetQuestionoptionList(_singlequest.Qmid); List <Questionoptions> _optionlst = new List <Questionoptions>(); for (int k = 0; k < _dtquestionoption.Rows.Count; k++) { Questionoptions _optionsingle = new Questionoptions(); _optionsingle.Opmid = Convert.ToInt32(_dtquestionoption.Rows[k]["Opmid"]); _optionsingle.Optiontext = Convert.ToString(_dtquestionoption.Rows[k]["Optiontext"]); _optionlst.Add(_optionsingle); } _singlequest.Optionlist = _optionlst; Queslst.Add(_singlequest); } return(Queslst); }
public List <Questionmaster> Genratenoofquestion(int quenumber) { List <Questionmaster> Queslst = new List <Questionmaster>(); for (int i = 0; i < quenumber; i++) { Questionmaster _singlequest = new Questionmaster() { Qmid = i + 1, Question = "", Optionlist = new List <Questionoptions>() { new Questionoptions { Opmid = 1, Optiontext = "Option 1" }, new Questionoptions { Opmid = 2, Optiontext = "Option 2" }, new Questionoptions { Opmid = 3, Optiontext = "Option 3" }, new Questionoptions { Opmid = 4, Optiontext = "Option 4" } } }; Queslst.Add(_singlequest); } return(Queslst); }