Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool isShuffle;

            if (IsPostBack)
            {
                isShuffle = false;
                CreateTableOfQuests(tblTest, (TestABC)Session["choosetTest"], isShuffle);

                lblTester.Text = "Postback";

                foreach (Control ctrl in tblTest.Controls)
                {
                    lblTester.Text += ctrl.GetType().ToString() + " " + ctrl.ID + "<br/>";
                }
            }
            if (!IsPostBack)
            {
                isShuffle = true;
                TestABC tABC = new TestABC(Session["choosedSubTheme"].ToString());
                Session.Add("choosetTest", tABC);
                CreateTableOfQuests(tblTest, tABC, isShuffle);

                lblTester.Text = "!Postback";

                foreach (Control ctrl in tblTest.Controls)
                {
                    lblTester.Text += ctrl.GetType().ToString() + " " + ctrl.ID + "<br/>";
                }
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            TestABC       tABC = new TestABC();
            MembershipABC user = new MembershipABC();

            Guid userId = new Guid();

            userId = user.GetUserIdByUserName(Membership.GetUser().UserName);


            tABC.CreateViewOfStatistic(userId, tblStatistic);
        }
Пример #3
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;
        }
Пример #4
0
        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++;
            }
        }