Example #1
0
    protected void StopTimerButton(object sender, EventArgs e)
    {
        long elapsedTime = ((Int32)DateTime.Now.Subtract(DateTime.Parse(Session["StartTime"].ToString())).TotalSeconds);

        Timer1.Enabled = false;
        //StartTimer.Enabled = true;
        StopTimer.Enabled = false;
        //register users time in DB
        TimesManager timesManager = new TimesManager();

        timesManager.registerTheoryTime(User.Identity.Name, elapsedTime);
    }
Example #2
0
    public void SubmitAnswer(object sender, EventArgs e)
    {
        //check answer
        if (((AnswerA.Checked == true) && PossibleAnswer1.Text == getCorrectAnswerById(Int32.Parse(QuestionID.Text))) ||
            ((AnswerB.Checked == true) && PossibleAnswer2.Text == getCorrectAnswerById(Int32.Parse(QuestionID.Text))) ||
            ((AnswerC.Checked == true) && PossibleAnswer3.Text == getCorrectAnswerById(Int32.Parse(QuestionID.Text))) ||
            ((AnswerD.Checked == true) && PossibleAnswer4.Text == getCorrectAnswerById(Int32.Parse(QuestionID.Text))))     //check for correct answer
        {
            correctAnswers++;
            ViewState.Add("correctAnswers", correctAnswers);
            string message = "Correct Answer";
            string script  = "window.onload = function(){ alert('" + message + "')};";
            ClientScript.RegisterStartupScript(this.GetType(), "Correct", script, true);
        }
        else
        {
            string message = "Wrong Answer";
            string script  = "window.onload = function(){ alert('" + message + "')};";
            ClientScript.RegisterStartupScript(this.GetType(), "Wrong", script, true);
        }

        if (UsedQuestionList.Count == 10)                                                                                       // Question limit for end of test
        {
            int testElapsedTime = ((Int32)DateTime.Now.Subtract(DateTime.Parse(Session["StartTime"].ToString())).TotalSeconds); //test time
            Timer1.Enabled = false;

            //start of evaluation
            //get pastknowledge
            UserPreferences userPreferences = new UserPreferences();
            string          pastKnowledge   = userPreferences.getUsersPastKnowledge(User.Identity.Name);
            //get VAK type
            string usersVakType = userPreferences.getUsersVakType(User.Identity.Name);
            //get theory time
            TimesManager timesManager = new TimesManager();
            Int64        theoryTime   = timesManager.getTheoryTime(User.Identity.Name); //mporei na epistrepsei arnhtikh timh
            timesManager.registerTestTime(User.Identity.Name, (Int64)testElapsedTime);  //also record the test time

            registerScore(User.Identity.Name, correctAnswers);                          // katagrafh swstwn apanthsewn sth bash



            int boredomPoints = 0;

            boredomPoints = boredomPoints + correctAnswers; //Each correct answer contributes 1 point

            if (pastKnowledge == "Low")                     // Low=3 , Medium=2 , High=1
            {
                boredomPoints = boredomPoints + 3;
            }
            else if (pastKnowledge == "Medium")
            {
                boredomPoints = boredomPoints + 2;
            }
            else if (pastKnowledge == "High")
            {
                boredomPoints = boredomPoints + 1;
            }

            if (testElapsedTime < 120) // Low=3 , Medium=2 , High=1    Time is in seconds
            {
                boredomPoints = boredomPoints + 3;
            }
            else if (testElapsedTime < 180)
            {
                boredomPoints = boredomPoints + 2;
            }
            else if (testElapsedTime >= 180)
            {
                boredomPoints = boredomPoints + 1;
            }

            //Check theory time. Theory time evaluation is not the same for each category
            if (usersVakType == "Visual")
            {
                if (theoryTime < 2400) // Low=3 , Medium=2 , High=1    Time is in seconds
                {
                    boredomPoints = boredomPoints + 3;
                }
                else if (theoryTime < 4000)
                {
                    boredomPoints = boredomPoints + 2;
                }
                else if (theoryTime >= 4000)
                {
                    boredomPoints = boredomPoints + 1;
                }
            }
            else if (usersVakType == "Auditory")
            {
                if (theoryTime < 2000) // Low=3 , Medium=2 , High=1    Time is in seconds
                {
                    boredomPoints = boredomPoints + 3;
                }
                else if (theoryTime < 3600)
                {
                    boredomPoints = boredomPoints + 2;
                }
                else if (theoryTime >= 3600)
                {
                    boredomPoints = boredomPoints + 1;
                }
            }
            else if (usersVakType == "Kinesthetic")
            {
                if (theoryTime < 1200) // Low=3 , Medium=2 , High=1    Time is in seconds
                {
                    boredomPoints = boredomPoints + 3;
                }
                else if (theoryTime < 2000)
                {
                    boredomPoints = boredomPoints + 2;
                }
                else if (theoryTime >= 2000)
                {
                    boredomPoints = boredomPoints + 1;
                }
            }

            Boolean boredom;
            if (boredomPoints <= 10) // Less than 10 points means user could be bored.
            {
                boredom = true;
            }
            else
            {
                boredom = false;
            }

            if (boredom == true) //elegxos gia boredom
            {
                string message = "END of test. It took you " + testElapsedTime.ToString() + " seconds. But it looks like you might be bored! Play this Tic-Tac-Toe game for a bit and then come back.";
                string script  = "window.onload = function(){ alert('" + message + "');location.href='Triliza.aspx'};";
                ClientScript.RegisterStartupScript(this.GetType(), "End of Test", script, true);
                //Response.Redirect("~/Triliza.aspx");
            }
            else
            {
                string message = "END of test. It took you " + testElapsedTime.ToString() + " seconds";
                string script  = "window.onload = function(){ alert('" + message + "')};";
                ClientScript.RegisterStartupScript(this.GetType(), "End of Test", script, true);
            }
        }
        else
        {
            setNextQuestion();
        }
    }