Пример #1
0
        private void radioButton1_Click_1(object sender, RoutedEventArgs e)
        {
            RadioButton radio = sender as RadioButton;

            //Boolean b = true;

            //if (radio.Tag.ToString().Equals(b.ToString()))
            //{
            //    IsAnswerCorrect = "true";
            //   // radio.IsChecked = true;
            //}
            //else
            //{
            //    IsAnswerCorrect = "false";
            //    //radio.IsChecked = false;
            //}

            string cn = radio.Content.ToString();

            string id = txtquesID.Text.ToString();
            long   qid;

            long.TryParse(id, out qid);
            var opp = (from Option opt in catAppDB.Options
                       where opt.Q_id == qid
                       select opt).Count();

            /*var testid = from Question que in catAppDB.Questions
             *           where que._id == qid
             *           select que;
             * var quelst = testid.ToList();*/



            var opp1 = from Option opt in catAppDB.Options
                       where opt.Q_id == qid
                       select opt;

            var opt1list = opp1.ToList();

            for (int i = 0; i < opp; i++)
            {
                var    opt2 = opt1list[i] as Option;
                string opt3 = opt2.Content.ToString();
                if (opt3 == cn)
                {
                    txtoptid.Text = opt2._id.ToString();
                }
            }

            long optid;

            long.TryParse(txtoptid.Text, out optid);

            using (catAppDB = new CatAppDataClasses(DBConnectionString))
            {
                Attempt_detail newAttempt_detail = new Attempt_detail
                {
                    Q_id = qid,
                    O_id = optid,

                    A_id = 2,


                    //Q_id=51,
                    //O_id=1842,
                    //_id=5002,
                    //A_id=1,

                    //            //  A_id=1,
                    //O_id=optid,

                    Mark_flag = true
                };



                catAppDB.Attempt_details.InsertOnSubmit(newAttempt_detail);

                catAppDB.SubmitChanges();

                //DialogClosed("OK");
            }
        }
Пример #2
0
        private void OK_Click(object sender, RoutedEventArgs e)
        {
            IDictionary <string, string> y = this.NavigationContext.QueryString;
            String b = Convert.ToString(y["TextData1"]);

            textBox2.Text = b.ToString();
            MessageBox.Show("b" + textBox2.Text);
            String timeonoff = b.ToString();
            long   tmonoff;

            long.TryParse(timeonoff, out tmonoff);
            bool tmd;

            if (tmonoff == 0)
            {
                tmd = false;
            }
            else
            {
                tmd = true;
            }
            string s = textBox1.Text;
            long   l;

            long.TryParse(s, out l);
            var timest = from Test t in catAppDB.Tests
                         where t._id == l
                         select t;

            Tests = new ObservableCollection <Test>(timest);
            var time = Tests.ToList();
            var t2   = time[0] as Test;

            var tt = t2.Allowed_time;

            txtAllowed.Text = tt.ToString();

            // txtAllowed.Text = Tests.ToString();



            // MessageBox.Show("Allowed Time" + txtAllowed.Text);
            //var tt = Tests.ToList();
            // int ts = tt[0].Allowed_time;
            //  txtAllowed.Text = Tests.ToString();
            string tmpstp = txtAllowed.Text;
            int    l1;
            long   uid = 0;

            int.TryParse(tmpstp, out l1);
            ll = l1;


            IList <User> UserList = this.GetUserList();

            foreach (User usr1 in UserList)
            {
                uid = usr1._id;
            }

            using (catAppDB = new CatAppDataClasses(DBConnectionString))
            {
                Attempt newAttempt = new Attempt
                {
                    T_id         = l,
                    Timpstamp    = l1,
                    Elapsed_time = l1 - ltotal,
                    U_id         = uid,

                    //T_id = 13,
                    //Timpstamp = 2100,

                    Complete = completed,
                    //Elapsed_time = 200,
                    Timed = tmd
                };


                catAppDB.Attempts.InsertOnSubmit(newAttempt);

                catAppDB.SubmitChanges();

                //DialogClosed("OK");
            }
        }