Example #1
0
        private void OnTimeExpired(NewAccountModel model)
        {
            while (!this.IsHandleCreated);
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                    OnTimeExpired, model);
                return;
            }

            timeLeft.Text = "00:00";
            timer1.Enabled = false;
            MessageBox.Show("Time expired.", "REACH");
            controller.FinishQuizSet();
        }
Example #2
0
        private void OnTestChanged(NewAccountModel model)
        {
            while (!this.IsHandleCreated);
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                    OnTestChanged, model);
                return;
            }

            // stop the timer
            timer1.Enabled = false;
            timeLeft.Text = ConvertToTime(60 * NewAccountModel.MINUTES_PER_QUIZ);
            MessageBox.Show("Start the test for: " + model.CurrentQuiz.Domain, "REACH");

            // set the domain
            domain.Text = model.CurrentQuiz.Domain;

            // reset the timer
            timer1.Enabled = true;
        }
Example #3
0
        private void OnTick(NewAccountModel model)
        {
            while (!this.IsHandleCreated) ;
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                    OnTick, model);
                return;
            }

            timeLeft.Text = ConvertToTime(model.RemainingTime);
            if (model.RemainingTime > 10)
                timeLeft.ForeColor = Color.Black;
            else
                timeLeft.ForeColor = Color.Red;
        }
Example #4
0
        private void OnAllTestsFinished(NewAccountModel model)
        {
            while (!this.IsHandleCreated);
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                    OnAllTestsFinished, model);
                return;
            }

            timer1.Enabled = false;

            if (type == TAKE_NEW_CERT)
            {
                int score = model.GetScoreForTest(0);

                if (score >= NewAccountModel.MIN_PASSING_SCORE)
                {
                    MessageBox.Show(
                        "You obtained " + score + " points and received the certification for the domain!",
                        "REACH");
                    controller.TakeNewCert(model.CertifiedDomains[0], score);
                }
                else
                    MessageBox.Show(
                        "You didn't pass the test and did not received the certification. You may try again.",
                        "REACH");

                parentForm.Close();
                this.Close();
                return;
            }

            testContainer.Visible = false;
            resultsContainer.Visible = true;
            int passed = 0;
            for (int i = 0; i < model.CertifiedDomains.Count; ++i)
            {
                // rating control
                RatingControl r = new RatingControl();
                r.Location = new Point(89, 99 + i * (r.Height+1));
                r.Rating = model.GetScoreForTest(i);
                r.Fixed = true;
                if (r.Rating >= NewAccountModel.MIN_PASSING_SCORE)
                    ++passed;
                r.Visible = true;
                resultsContainer.Controls.Add(r);

                // the label with the domain
                Label domainTitle = new Label();
                domainTitle.Location = new Point(12, 106 + i * (r.Height + 1));
                domainTitle.Font = new Font(
                    "Microsoft Sans Serif",
                    9.75F,
                    FontStyle.Regular,
                    GraphicsUnit.Point,
                    ((byte)(0)));
                domainTitle.Text = model.CertifiedDomains[i].Name + ":";
                domainTitle.Visible = true;
                resultsContainer.Controls.Add(domainTitle);

                // the label with the result
                Label domainStatus = new Label();
                domainStatus.Location = new Point(211, 106 + i * (r.Height+1));
                domainStatus.Font = new Font(
                    "Microsoft Sans Serif",
                    9.75F,
                    FontStyle.Bold,
                    GraphicsUnit.Point,
                    ((byte)(0)));
                if (r.Rating >= NewAccountModel.MIN_PASSING_SCORE)
                {
                    domainStatus.ForeColor = Color.Green;
                    domainStatus.Text = "Passed";
                }
                else
                {
                    domainStatus.ForeColor = Color.Red;
                    domainStatus.Text = "Failed";
                }
                domainStatus.Visible = true;
                resultsContainer.Controls.Add(domainStatus);
            }
            if (passed > 0)
            {
                resultTitle.Text =
                    "Your account was created. You will receive a certificate for each domain that you passed successfully.";
                controller.CreateAccount();
            }
            else
                resultTitle.Text =
                    "You didn't pass any test. Your account was not created. You may try again.";
        }
Example #5
0
        private void OnQuestionChanged(NewAccountModel model)
        {
            while (!this.IsHandleCreated);
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                    OnQuestionChanged, model);
                return;
            }

            title.Text = model.CurrentQuestion.Title;
            varA.Checked = varB.Checked = varC.Checked = varD.Checked = false;
            varA.Text = model.CurrentQuestion.VarA;
            varB.Text = model.CurrentQuestion.VarB;
            varC.Text = model.CurrentQuestion.VarC;
            varD.Text = model.CurrentQuestion.VarD;
            switch (model.CurrentQuestion.Answer)
            {
                case 0: varA.Checked = true; break;
                case 1: varB.Checked = true; break;
                case 2: varC.Checked = true; break;
                case 3: varD.Checked = true; break;
                default: break;
            }

            NextQuestionButton.Enabled = !model.IsLastQuestionInSet();
            PreviousQuestionButton.Enabled = !model.IsFirstQuestionInSet();

            q1.BackColor = q2.BackColor = q3.BackColor =
                q4.BackColor = q5.BackColor = Color.White;
            switch (model.CurrentQuestionIndex)
            {
                case 0: q1.BackColor = Color.Lime; break;
                case 1: q2.BackColor = Color.Lime; break;
                case 2: q3.BackColor = Color.Lime; break;
                case 3: q4.BackColor = Color.Lime; break;
                case 4: q5.BackColor = Color.Lime; break;
                default: break;
            }
        }
Example #6
0
        private void OnUsernameTaken(NewAccountModel model)
        {
            while (!this.IsHandleCreated);
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                    OnUsernameTaken, model);
                return;
            }

            errors = new Dictionary<string, string>();
            errors["username"] = "******";
            errorMessage.Text = errors["username"];
            mark(username, "username");
            this.Enabled = true;
        }
Example #7
0
 private void OnQuizReceivedFromServer(NewAccountModel model)
 {
     while (!this.IsHandleCreated);
     if (this.InvokeRequired)
     {
         this.Invoke((MyAccountController.ExternalEventHandler)
             OnQuizReceivedFromServer, model);
         return;
     }
     new NewAccountTestView(NewAccountTestView.TAKE_NEW_CERT, this);
 }
Example #8
0
        private void OnStartTest(NewAccountModel model)
        {
            while (!this.IsHandleCreated);
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                    OnStartTest, model);
                return;
            }

            this.Enabled = false;
            errorMessage.Text = "Test is in progress...";
            new NewAccountTestView(NewAccountTestView.CREATE_NEW_ACCOUNT, null);
        }
Example #9
0
        private void OnTimeOut(NewAccountModel model)
        {
            while (!this.IsHandleCreated);
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                    OnTimeOut, model);
                return;
            }

            errors = new Dictionary<string, string>();
            errors["general"] = "The server is not responding. Try again.";
            errorMessage.Text = errors["general"];
            this.Enabled = true;
        }
Example #10
0
        private void OnLocalVerificationComplete(NewAccountModel model)
        {
            while (!this.IsHandleCreated);
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                    OnLocalVerificationComplete, model);
                return;
            }

            this.Enabled = false;
            username.BackColor = NORMAL_COLOR;
            password.BackColor = NORMAL_COLOR;
            confirm.BackColor = NORMAL_COLOR;
            email.BackColor = NORMAL_COLOR;
            domains.BackColor = NORMAL_COLOR;
            errorMessage.Text = "Talking to server...";
        }
Example #11
0
        private void OnDomainsTimeOut(NewAccountModel model)
        {
            while (!this.IsHandleCreated) ;
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                    OnDomainsTimeOut, model);
                return;
            }

            status.Text = "The server is not reachable.";
            tryagain.Visible = true;
        }
Example #12
0
        private void OnDomainsReceived(NewAccountModel model)
        {
            while (!this.IsHandleCreated);
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                    OnDomainsReceived, model);
                return;
            }

            domains.Items.Clear();
            domains.Items.AddRange(model.AllDomains.ToArray());
            status.Visible = false;
            tryagain.Visible = false;
            CreateNewAccountBtn.Enabled = true;
        }
Example #13
0
 private void OnCreateAccountInit(NewAccountModel model)
 {
     while (!this.IsHandleCreated);
     if (this.InvokeRequired)
     {
         this.Invoke((NewAccountController.ExternalEventHandler)
             OnCreateAccountInit, model);
         return;
     }
     this.Enabled = true;
     errorMessage.Text = "Talking to server...";
 }
Example #14
0
        private void OnCreateAccountDeny(NewAccountModel model)
        {
            while (!this.IsHandleCreated);
            if (this.InvokeRequired)
            {
                this.Invoke((NewAccountController.ExternalEventHandler)
                    OnCreateAccountDeny, model);
                return;
            }

            errors = model.Errors;
            mark(username, "username");
            mark(password, "password");
            mark(confirm, "confirm");
            mark(email, "email");
            mark(domains, "domains");
            NewAccountView_MouseMove(null, null);
        }