Ejemplo n.º 1
0
 private void button2_Click(object sender, EventArgs e)
 {
     timerKnowledge.Stop();
     timerPicture.Stop();
     this.Hide();
        Question Q = new Question();
       //  OnlineQuestionImagePattern Q = new OnlineQuestionImagePattern();
     Q.ShowDialog();
 }
 private void buttonQuit_Click(object sender, EventArgs e)
 {
     this.Hide();
     Question q = new Question();
     q.ShowDialog();
 }
        private void textFileDownloadComplete(object sender, AsyncCompletedEventArgs e)
        {
            if (e.Error != null)
              {
              MessageBox.Show("Problem while Downloading!\nOr no internet connection..");

              this.Hide();
              Question q = new Question();
              q.ShowDialog();

              }

              QuestionTextDownload();
        }
        public void OnetimeQuizChecker()
        {
            try
            {

                // step 1: Create a connection

                var result = Path.GetFullPath("InformationDatabase.mdf");
                string strConnection = "Data Source=.\\sqlexpress;AttachDbFilename=" + result + ";User Instance=true;Integrated Security=True;Pooling=False";
                SqlConnection objConnection = new SqlConnection(strConnection);
                objConnection.Open();

                // step 2: fire a command
                string username = UserInformation.getUserName();
                string quizno = onlineQuizSerialNo;
                string strCommand = "select QuizNo, userID from IndividualOnlineQuizTracker where QuizNo=@QN and userID=@UI";
                SqlCommand objCommand = new SqlCommand(strCommand, objConnection);

                objCommand.Parameters.Add(new SqlParameter("@QN", quizno));
                objCommand.Parameters.Add(new SqlParameter("@UI", username));

                // step 3: bind the result data with user interface

                SqlDataReader reader = objCommand.ExecuteReader();

                if (reader.Read())
                {
                    MessageBox.Show("You participated this quiz once! \n Please wait for the next round..");

                    this.Hide();
                    Question q = new Question();
                    q.ShowDialog();

                }
                else
                {

                }

                reader.Close();
                objConnection.Close();
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
        }
        public void selectQuestionNo()
        {
            try
            {

                // step 1: Create a connection

                var result = Path.GetFullPath("InformationDatabase.mdf");
                string strConnection = "Data Source=.\\sqlexpress;AttachDbFilename=" + result + ";User Instance=true;Integrated Security=True;Pooling=False;MultipleActiveResultSets=true";
                SqlConnection objConnection = new SqlConnection(strConnection);
                objConnection.Open();

                // step 2: fire a command
                string username = UserInformation.getUserName();
               // string quizno = onlineQuizSerialNo;

                AllorUnsolved = UserInformation.getAllorSolved();

                string strCommand = "";
                if (AllorUnsolved == "Unsolved")
                {

                    Unsolved = true;

                    strCommand = "SELECT QSN FROM Question EXCEPT SELECT QSN FROM Solve WHERE userID=@UN";

                }
                else if (AllorUnsolved == "All")
                {
                    All = true;
                    strCommand = "SELECT QSN FROM Question";
                }
                SqlCommand objCommand = new SqlCommand(strCommand, objConnection);

                objCommand.Parameters.Add(new SqlParameter("@UN", username));

                // step 3: bind the result data with user interface

                SqlDataReader reader = objCommand.ExecuteReader();

                while(reader.Read())
                {

                    for (int i = 0; i < reader.FieldCount; i++)
                    {

                       unsolvedQuestion.Add( reader[i].ToString());
                    }
                }

                    reader.Close();
                objConnection.Close();

                if (unsolvedQuestion.Count == 0 &&   Unsolved == true)
                {
                    MessageBox.Show("You have no unsolved Questions!");
                    Unsolved = false;

                    Question q = new Question();
                    q.ShowDialog();
                }
                else if (unsolvedQuestion.Count == 0 && All == true)
                {
                    MessageBox.Show("Please Update Questions!\nDatabase is empty.");
                    All = false;
                    Question q = new Question();
                    q.ShowDialog();
               }

               makeValue(unsolvedQuestion);

            }
            catch (Exception ex)
            {

                    MessageBox.Show(ex.Message);

                Question q = new Question();
                q.ShowDialog();

                //MessageBox.Show(ex.Message);
            }
        }
        public void removeForm()
        {
            ///total_score = total_score + point;

            myForm.RemoveAt(Form_track);

            myQuestionNo.RemoveAt(Form_track);

            if (myForm.Count == 0)
            {

                Question q = new Question();
                q.ShowDialog();
            }
            else if (Form_track >= myForm.Count)
            {
                Form_track = 0;
                callForm();
            }
            else
            {
                callForm();
            }
        }
        public void makeValue(List<string> QNo)
        {
            myQuestionNoTemp.Add(-5);
            try
            {

                for (int i = 0; i < QNo.Count; i++)
                {

                    myQuestion.Add(QNo[i]);

                }

                // step 1:
                var result = Path.GetFullPath("InformationDatabase.mdf");
                string strConnection = "Data Source=.\\sqlexpress;AttachDbFilename=" + result + ";User Instance=true;Integrated Security=True;Pooling=False";
                SqlConnection objConnection = new SqlConnection(strConnection);
                objConnection.Open();

                for (int i = 0; i < QNo.Count; i++)
                {

                    int j = int.Parse(QNo[i]);
                    string strCommand = "select QuestionType from Question where QSN=" + j + "";
                    SqlCommand objCommand = new SqlCommand(strCommand, objConnection);

                    SqlDataReader reader = objCommand.ExecuteReader();

                    // myFormTemp.Enqueue(reader[0].ToString());

                    reader.Read();

                    var nextItem = reader[0].ToString();

                    reader.Close();
                    // MessageBox.Show(nextItem.ToString());

                    if (nextItem == "Picture Question")
                    {
                        // PictureQuestion pq = new PictureQuestion();
                        // myForm.Add(pq);
                        myForm.Add(nextItem);
                        myQuestionNo.Add(j);

                    }
                    else if (nextItem == "Picture Question Objective Type")
                    {
                        // ObjectiveImageQuestion oiq = new ObjectiveImageQuestion();
                        // myForm.Add(oiq);
                        myForm.Add(nextItem);
                        myQuestionNo.Add(j);
                    }
                    else if (nextItem == "Normal Question")
                    {
                        // NormalQuestion nq = new NormalQuestion();
                        //myForm.Add(nq);
                        myForm.Add(nextItem);
                        myQuestionNo.Add(j);
                    }
                    else if (nextItem == "Normal Question Objective Type")
                    {
                        // NormalObjectiveQuestion noq = new NormalObjectiveQuestion();
                        // myForm.Add(noq);
                        myForm.Add(nextItem);
                        myQuestionNo.Add(j);
                    }
                    else if (nextItem == "Descriptive Question (No Image)")
                    {
                        //  MathNormalQuestion mnq = new MathNormalQuestion();
                        //myForm.Add(mnq);
                        myForm.Add(nextItem);
                        myQuestionNo.Add(j);
                    }
                    else if (nextItem == "Descriptive Question Objective Type (No Image)")
                    {
                        //  MathObjectiveQuestion moq = new MathObjectiveQuestion();
                        // myForm.Add(moq);
                        myForm.Add(nextItem);
                        myQuestionNo.Add(j);
                    }

                    else if (nextItem == "Flash Question")
                    {

                        // FlashImageQuestion fiq = new FlashImageQuestion();
                        //myForm.Add(fiq);
                        myForm.Add(nextItem);
                        myQuestionNo.Add(j);

                    }

                }
                objConnection.Close();

                /*  for (int i = 0; i < QNo.Length; i++)
                  {
                      Form newForm = myForm[i];
                      newForm.Show();

                  }*/

                Form_track = -1;
                total_score = 0;
                nextForm();

            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);

                Question q = new Question();
                q.ShowDialog();
            }
        }