コード例 #1
0
ファイル: QuizWindow.xaml.cs プロジェクト: mominul/SAT
        private void getques()
        {
            
            if (TotalQues==0)
            {
                score = 100 * nof_correct / (nof_correct+nof_unanswered+nof_wrong);
                System.Windows.MessageBox.Show("Correct: " + Convert.ToString(nof_correct) + " ,wrong: " + Convert.ToString(nof_wrong) + " ,Unanswered: " + Convert.ToString(nof_unanswered)+" : So, you scored : "+Convert.ToString(score)+"% in this session");
                DBProgressConnect DBProgressConnect_inst = new DBProgressConnect();
                //globaldata gb = new globaldata();
                DBProgressConnect_inst.Insert(globaldata.current_user, Convert.ToString(DateTime.Now), Convert.ToString(score));

                ActivitySelection Actv_Instnc = new ActivitySelection();
                this.Hide();
                Actv_Instnc.Show();
            }
            else
            {
                rdbtn1.IsChecked = false;
                rdbtn2.IsChecked = false;
                rdbtn3.IsChecked = false;
                rdbtn4.IsChecked = false;
                DBVocaConnect DBConnect_inst = new DBVocaConnect();
                int data_count = DBConnect_inst.Count();
                DataTable QuesLoadTable = new DataTable();
                QuesLoadTable = DBConnect_inst.Read();

                Random Rand_Gen = new Random();
                int[] x = new int[4];
                for (int j = 0; j < 4; j++)
                {
                    x[j] = Rand_Gen.Next(data_count + 1);
                }
                string ques;
                ques = QuesLoadTable.Rows[x[0]][1].ToString();
                ques = ques.Trim();
                txtblck1.Text = "Question: " + ques;
                CorrectAns = QuesLoadTable.Rows[x[0]][2].ToString();
                CorrectAns = CorrectAns.Trim();
                //label6.Content = "Database Entry: " + (x[0] + 1).ToString() + "\nCorrect Answer: " + CorrectAns;

                string[] AllAns = new string[4];
                for (int i = 0; i < 4; i++)
                {
                    AllAns[i] = QuesLoadTable.Rows[x[i]][2].ToString();
                }

                new Random().Shuffle(AllAns);

                rdbtn1.Content = AllAns[0].Trim();
                rdbtn2.Content = AllAns[1].Trim();
                rdbtn3.Content = AllAns[2].Trim();
                rdbtn4.Content = AllAns[3].Trim();

                TotalQues--;
            }
        }
コード例 #2
0
ファイル: LearningWindow.xaml.cs プロジェクト: mominul/SAT
 public LearningWindow()
 {
     InitializeComponent();
     DBVocaConnect DBVCnnct_inst = new DBVocaConnect();
     QuesLoadTable = DBVCnnct_inst.Read();
     data_count = DBVCnnct_inst.Count();
     x = new int[data_count+1];
     for (int i = 1; i <= data_count; i++ )
     {
         x[i] = Rand_Gen.Next(1, data_count + 1);
     }
         
     getques();
 }