protected void btnAddAnnwer_Click(object sender, EventArgs e) { AnswerDAL aDAL = new AnswerDAL(); aDAL.AddAnswer(txtbxAnswer.Text, ddlQuestion.SelectedValue, chbxIsRightAnswer.Checked); GetViewOfAnswers(); }
public List <QuestionDTO> GetUserAnsweredQuestion(long Userid, int PageNo, int PageSize) { AnswerDal = new AnswerDAL(); return(AnswerDal.GetUserAnsweredQuestion(Userid, PageNo, PageSize)); }
public int DownvoteAnswer(int AnswerId) { AnswerDal = new AnswerDAL(); return(AnswerDal.DownvoteAnswer(AnswerId)); }
public int UpvoteAnswer(int AnswerId) { AnswerDal = new AnswerDAL(); return(AnswerDal.UpvoteAnswer(AnswerId)); }
public List <AnswerDTO> GetAnswer(int answerid) { AnswerDal = new AnswerDAL(); return(AnswerDal.getAnswer(answerid)); }
public long AddAnswer(AnswerDTO Answer) { AnswerDal = new AnswerDAL(); return(AnswerDal.AddAnswer(Answer)); }
protected void SaveAnswersState(List <AnswerABC> answerList, string question) { AnswerDAL aDAL = new AnswerDAL(); aDAL.UpToDateAnswerRightState(answerList, question); }
protected void GetViewOfAnswers() { AnswerDAL aDAL = new AnswerDAL(); int k = 0, i = 0; //счетчик для айдишников эелемента Label lblAnswer = new Label(); Label lblAnswerNumber = new Label(); CheckBox chbxIsRight = new CheckBox(); Label lblBr = new Label(); TableRow tRow = new TableRow(); TableCell tCell = new TableCell(); // use for wherever you need indexes foreach (AnswerABC answ in aDAL.GetAllAnswersByQuestion(ddlQuestion.SelectedValue)) { lblAnswer = new Label(); lblAnswerNumber = new Label(); lblAnswer.ID = string.Format("lblAnswer{0}", k); lblAnswerNumber.Text = string.Format("{0}) ", k + 1); lblAnswer.Text = string.Format("{0}", answ.AnswerCurrent); chbxIsRight = new CheckBox(); chbxIsRight.ID = string.Format("chbxIsRight{0}", k); chbxIsRight.AutoPostBack = true; lblBr = new Label(); lblBr.Text = "<br/>"; if (!answ.IsRight) { chbxIsRight.Checked = false; } else { chbxIsRight.Checked = true; } // don't copy -paste - use nested "for" cycle tCell.Controls.Add(lblAnswerNumber); tCell.ID = string.Format("answCell{0}{1}", k, i); i++; tRow.Cells.Add(tCell); tCell = new TableCell(); tCell.Controls.Add(lblAnswer); tCell.ID = string.Format("answCell{0}{1}", k, i); i++; tRow.Cells.Add(tCell); tCell = new TableCell(); tCell.Controls.Add(chbxIsRight); tCell.ID = string.Format("answCell{0}{1}", k, i); i++; tRow.Cells.Add(tCell); tCell = new TableCell(); tRow.ID = string.Format("answRow{0}", k); tblAnswers.Rows.Add(tRow); tRow = new TableRow(); k++; i = 0; } }
protected void btnComplete_Click(object sender, EventArgs e) { //Достаем все радиобаттоны из таблицы List <RadioButton> rbtnList = new List <RadioButton>(); rbtnList = GetAllRbtnFromTable(tblTest); //Получаем из списка всех радиобаттонов только нажатые List <string> idOfSelectedRBTN = new List <string>(); idOfSelectedRBTN = GetAllSelectedRBTNID(rbtnList); //Получаем цифры из полного ИД List <string> tmpSelectedRbtn = new List <string>(); foreach (string rbtnID in idOfSelectedRBTN) { string rbtn = rbtnID; rbtn = GetNumbersFromString(rbtnID); tmpSelectedRbtn.Add(rbtn); } idOfSelectedRBTN = tmpSelectedRbtn; //Конвертируем айдишник лэйбла List <string> listOfLblID = new List <string>(); foreach (string id in idOfSelectedRBTN) { listOfLblID.Add(ConvertIDToMask(id, "lblAnswer", false)); } //Получаем список из лэйблов(те, что напротив нажатого баттона) List <Label> listLbl = new List <Label>(); foreach (string lblId in listOfLblID) { listLbl.Add((Label)GetControlInTable(tblTest, lblId)); } AnswerDAL aDAL = new AnswerDAL(); //проверяем правильные ли ответы и возвращаем результат int rightAnswers = 0; Color clrRight = new Color(); Color clrWrong = new Color(); clrRight = Color.Green; clrWrong = Color.Red; foreach (Label lbl in listLbl) { if (aDAL.IsRightAnswer(lbl.Text)) { ChangeRowColorTo(tblTest, string.Format("tRow{0}", GetNumbersFromString(lbl.ID)), clrRight); rightAnswers++; } else { ChangeRowColorTo(tblTest, string.Format("tRow{0}", GetNumbersFromString(lbl.ID)), clrWrong); } } TestABC tABC = new TestABC(Session["choosedSubTheme"].ToString()); lblResult.Text = GetResultInString(tABC.QuestionCount, rightAnswers, "Your result is: ") + "%"; double underScoredRes = tABC.QuestionCount / 100.00; double res = rightAnswers / underScoredRes; SubThemeDAL stDAL = new SubThemeDAL(); int idSubTheme = stDAL.GetSubThemeIdBySubThemeNameViaStoredProc(Session["choosedSubTheme"].ToString()); BaseDAL dalABC = new BaseDAL(); MembershipABC memABC = new MembershipABC(); Guid idUser = memABC.GetUserIdByUserName(Membership.GetUser().UserName); tABC.InsertResult(res, idSubTheme, idUser, DateTime.Now); //btnComplete.Visible = false; }
public void CreateTableOfQuests(Table tbl, TestABC tABC, bool isShuffle) { QuestionDAL qDAL = new QuestionDAL(); AnswerDAL aDAL = new AnswerDAL(); Label lblQestion = new Label(); Label lblAnswer = new Label(); Label lblNumerator = new Label(); RadioButton rbtnAnswer = new RadioButton(); TableCell tCell = new TableCell(); TableRow tRow = new TableRow(); int i = 0; int j = 0; int q = 0; tbl.CssClass = "AbcTest"; foreach (QuestionABC qt in tABC.QuestionList) { lblNumerator.Text = string.Format("{0}.", q + 1); tCell.Controls.Add(lblNumerator); tCell.HorizontalAlign = HorizontalAlign.Center; tCell.VerticalAlign = VerticalAlign.Middle; tCell.ID = string.Format("tCell{0}{1}", i, j); j++; tRow.Cells.Add(tCell); lblNumerator = new Label(); tCell = new TableCell(); lblQestion.Text = qt.QuestionCurrent; tCell.Controls.Add(lblQestion); tCell.HorizontalAlign = HorizontalAlign.Center; tCell.VerticalAlign = VerticalAlign.Middle; tCell.ID = string.Format("tCell{0}{1}", i, j); tRow.Cells.Add(tCell); j = 0; tRow.ID = string.Format("tRow{0}", i); i++; tbl.Rows.Add(tRow); tCell = new TableCell(); tRow = new TableRow(); lblQestion = new Label(); if (isShuffle) { Shuffle(qt.ListAnswers); } foreach (AnswerABC answer in qt.ListAnswers) { rbtnAnswer.ID = string.Format("rbtn{0}", i); rbtnAnswer.GroupName = string.Format("rbtnGrP{0}", q); tCell.Controls.Add(rbtnAnswer); tCell.HorizontalAlign = HorizontalAlign.Center; tCell.VerticalAlign = VerticalAlign.Middle; tCell.ID = string.Format("tCell{0}{1}", i, j); j++; tRow.Cells.Add(tCell); tCell = new TableCell(); lblAnswer.ID = string.Format("lblAnswer{0}", i); lblAnswer.Text = answer.AnswerCurrent; tCell.Controls.Add(lblAnswer); tCell.HorizontalAlign = HorizontalAlign.Center; tCell.ID = string.Format("tCell{0}{1}", i, j); tCell.HorizontalAlign = HorizontalAlign.Left; j++; tRow.Cells.Add(tCell); tCell = new TableCell(); j = 0; tRow.ID = string.Format("tRow{0}", i); i++; tbl.Rows.Add(tRow); tRow = new TableRow(); rbtnAnswer = new RadioButton(); lblAnswer = new Label(); } q++; } }