private void helpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Dictionary fr2 = new Dictionary();
            fr2.MdiParent = ((Form1)this.f.FindForm()).g();

            fr2.Show();
        }
 /// <summary>
 /// The Constructor that displays result details
 /// </summary>
 /// <param name="candidateName">The name of the candidate</param>
 /// <param name="time">the total allocatable time</param>
 /// <param name="elapsedTime">the time used</param>
 /// <param name="examCode">the exam code, gotten from the exam file</param>
 /// <param name="score">the candidates score</param>
 /// <param name="requiredScore">the score required to pass</param>
 /// <param name="sectionQuestionNumbers">the number of questions per section</param>
 /// <param name="rightSectionQuestionNumbers">the number of correct questions per section</param>
 public Score_Sheet(string candidateName, int time, int elapsedTime, string examCode, int score, int requiredScore, Dictionary<string, int> sectionQuestionNumbers, Dictionary<string, int> rightSectionQuestionNumbers)
 {
     InitializeComponent();
     lbl_date.Text = DateTime.Now.Date.ToShortDateString();
     if (score >= requiredScore)
     {
         lbl_status.Text = "Passed";
         lbl_status.Font = new Font("Microsoft Sans Serif", 8.25F);
         lbl_status.ForeColor = Color.Green;
     }
     else
     {
         lbl_status.Text = "Failed";
         lbl_status.Font = new Font("Microsoft Sans Serif", 8.25F);
         lbl_status.ForeColor = Color.Red;
     }
     lbl_candidate_name.Text = candidateName;
     lbl_elapsed_time.Text = elapsedTime.ToString();
     lbl_exam_number.Text = examCode;
     lbl_time.Text = time.ToString();
     dgv_show_breakdown.Rows.Clear();
     //
     for (int i = 0; i < sectionQuestionNumbers.Count; i++)
     {
         dgv_show_breakdown.Rows.Add(sectionQuestionNumbers.ElementAt(i).Key, sectionQuestionNumbers.ElementAt(i).Value, rightSectionQuestionNumbers.ElementAt(i).Value);
     }
     //
     chr_display_score.Series["Required Score"].Points.AddXY(1, requiredScore);
     chr_display_score.Series["Score"].Points.AddXY(0, score);
     //
     required = requiredScore;
     got = score;
 }
Example #3
0
 /// <summary>
 /// The default constructor to the question class
 /// </summary>
 public Question()
 {
     SectionTitle = "";
     QuestionNumber = 0;
     QuestionText = "";
     QuestionImagePath = null;
     QuestionOptions = new Dictionary<char, string>();
     QuestionAnswer = 'A';
     AnswerExplanation = null;
 }
Example #4
0
 private void btn_end_Click(object sender, EventArgs e)
 {
     for (int j = pan_display.Controls.OfType<RadioButton>().Count() - 1; j >= 0; --j)
     {
         var ctrls = pan_display.Controls.OfType<RadioButton>();
         var ctrl = ctrls.ElementAt(j);
         if (((RadioButton)ctrl).Checked)
         {
             givenAnswers[questionIndex] = Convert.ToChar(ctrl.Name.Replace("rdb_", ""));
         }
         pan_display.Controls.Remove(ctrl);
         ctrl.Dispose();
     }
     timer.Stop();
     //determine how many answers are correct and get section details
     int numOfCorrect = 0;
     int total;
     Dictionary<string, int> totalQuestionsPerSection = new Dictionary<string, int>();
     Dictionary<string, int> rightQuestionsPerSection = new Dictionary<string, int>();
     for (int i = 0; i < questions.Count; i++)
     {
         if (totalQuestionsPerSection.ContainsKey(questions.ElementAt(i).SectionTitle))
         {
             totalQuestionsPerSection[questions.ElementAt(i).SectionTitle] += 1;
         }
         else
         {
             totalQuestionsPerSection.Add(questions.ElementAt(i).SectionTitle, 1);
         }
         if (rightQuestionsPerSection.ContainsKey(questions.ElementAt(i).SectionTitle))
         {
             if (questions.ElementAt(i).QuestionAnswer == givenAnswers[i])
             {
                 rightQuestionsPerSection[questions.ElementAt(i).SectionTitle] += 1;
                 numOfCorrect += 1;
             }
         }
         else
         {
             rightQuestionsPerSection.Add(questions.ElementAt(i).SectionTitle, 0);
             if (questions.ElementAt(i).QuestionAnswer == givenAnswers[i])
             {
                 rightQuestionsPerSection[questions.ElementAt(i).SectionTitle] += 1;
                 numOfCorrect += 1;
             }
         }
     }
     total = questions.Count;
     Score_Sheet scs = new Score_Sheet(Properties.Settings.Default.CandidatesName, Properties.Settings.Default.TimerValue, totalSeconds / 60, examCode, ((numOfCorrect * 1000)/ total), passingScore, totalQuestionsPerSection, rightQuestionsPerSection);
     this.Hide();
     scs.ShowDialog();
     this.Close();
 }
        private void DrawMeshShadow(Matrix transform, ModelMesh mesh, float alpha)
        {
            // Store original effects for mesh parts, before substituting them for shadow rendering
            var originalEffects = new Dictionary<ModelMeshPart, Effect>();
            foreach (ModelMeshPart part in mesh.MeshParts)
            {
                originalEffects[part] = part.Effect;
                part.Effect = _basicEffect;
            }

            foreach (BasicEffect effect in mesh.Effects)
            {
                effect.AmbientLightColor = Vector3.Zero;
                effect.Alpha = alpha;
                effect.DirectionalLight0.Enabled = false;
                effect.DirectionalLight1.Enabled = false;
                effect.DirectionalLight2.Enabled = false;
//                effect.View = _basicEffect.View;
//                effect.Projection = _basicEffect.Projection;
                effect.World = transform*_shadowTransform;
            }
            mesh.Draw();

            // Restore former effects for mesh parts
            foreach (ModelMeshPart part in mesh.MeshParts)
            {
                part.Effect = originalEffects[part];
            }
        }
Example #6
0
        private void UI_Load(object sender, EventArgs e)
        {
            if (Properties.Settings.Default.FirstRun)
            {
                string OESFolderPath = Path.GetDirectoryName(Application.StartupPath);
                string OESExamplesFolderPath = Path.Combine(OESFolderPath, "Examples");
                if (Directory.Exists(OESExamplesFolderPath))
                {
                    string[] oesFilePaths = Directory.GetFiles(OESExamplesFolderPath, "*.oef", SearchOption.TopDirectoryOnly);
                    List<string> paths = new List<string>();
                    foreach (string oesFile in oesFilePaths)
                    {
                        for (int i = 0; i < dgv_exams.Rows.Count; i++)
                        {
                            paths.Add(dgv_exams.Rows[i].Cells[1].Value.ToString());
                        }
                        if (!(paths.Exists(p => p == oesFile)))
                        {
                            dgv_exams.Rows.Add(Path.GetFileNameWithoutExtension(oesFile), oesFile);
                        }
                    }
                    Properties.Settings.Default.FirstRun = false;
                    Properties.Settings.Default.Save();
                }
                else
                {
                    Properties.Settings.Default.FirstRun = false;
                    Properties.Settings.Default.Save();
                }
            }
            Dictionary<string, string> exams = new Dictionary<string, string>();
            if (Properties.Settings.Default.ExamPaths != null)
            {
                for (int i = 0; i < Properties.Settings.Default.ExamPaths.Count; i++)
                {
                    exams.Add(Properties.Settings.Default.ExamPaths[i], Properties.Settings.Default.ExamTitles[i]);
                }
            }
            dgv_exams.Rows.Clear();
            foreach (var exam in exams)
            {
                dgv_exams.Rows.Add(exam.Value, exam.Key);
            }

            //Select opened file
            if (!string.IsNullOrWhiteSpace(openedFilePath))
            {
                foreach(DataGridViewRow row in dgv_exams.Rows)
                {
                    if (row.Cells[1].Value.ToString() == openedFilePath)
                    {
                        row.Selected = true;
                    }
                }
            }
        }
        /// <summary>
        ///   Allows the game to perform any initialization it needs to before starting to run.
        ///   This is where it can query for any required services and load any non-graphic
        ///   related content.  Calling base.Initialize will enumerate through any components
        ///   and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            _basicEffect = CreateBasicEffect(this);

            #region Load scenario / test scenarios

            _testMaxHVelocityIter = _testConfiguration.MaxHVelocities.GetEnumerator();
            if (!_testMaxHVelocityIter.MoveNext())
                throw new Exception("No maxHVelocities defined in _testConfiguration.");

            _testScenarioIter = _testConfiguration.TestScenarios.GetEnumerator();

            if (IsTestMode)
                NextTestScenario();
            else
            {
                _testScenarioIter.MoveNext();
                _scenario = _testScenarioIter.Current;
            }

            if (_scenario == null)
                throw new Exception("Could not load scenario from XML.");

            #endregion

            #region Cameras

            // We must create a dummy camera target until the helicopter instance is created, to avoid exceptions
            var cameraOffset = new Vector3(0.0f, 0.5f, -0.5f);
            var startPos = _scenario.HelicopterScenarios[0].StartPosition + cameraOffset;
            _cockpitMesh = new SimpleModel("Models/apache-cockpit", this, this);
            InitCamera(MyCameraType, startPos + new Vector3(0, 0.5f, 4), new WorldDummy(Vector3.Zero));

            #endregion

            #region Sunlight, skydome, terrain and trees

            // Initialize skydome and sunlight parameters
            _skydome = new SkydomeComponent(this, this);
            _terrain = new TerrainComponent(this, this, _skydome.Parameters);

            UpdateTerrain(_scenario);
            

            // Initialize trees
            // TODO Forest component does not support dynamic loading/unloading of components yet
            if (_scenario.SceneElements.Contains("Forest"))
                _forest = new Forest(this, this, _terrain.Mesh, _skydome.Parameters);

            #endregion

            #region Misc components

            _fpsUtil = new FPS(this);
            _barrels = GetBarrels();
            _texturedGround = new FlatTexturedGround(this, this);

            _currentWaypoint = new WaypointMesh(this, this);
            _currentWaypoint.Position = new Vector3(0, 1, 0);


            #endregion

            #region Physics

            _terrainCollision = new TerrainCollision(this, this);

            // We implemented our own crash detection for whenever Jitter is disabled
            _terrainCollision.SetHeightValues(_heightmap.HeightValues);

            #endregion

            #region Helicopters

            
            // Initialize helicopter(s)
            InitHelicopters(_skydome.Parameters, _heightmap);
            Camera.LookAtTarget = _helicopter;
            _terrainCollision.Helicopter = _helicopter; // TODO Clean this up, non-intuitive usage
            _helicopter.Crashed += HelicopterCrashEventHandler;

            #endregion

            #region Test scenario results

            if (IsTestMode)
            {
                _testResults = new Dictionary<string, List<ScenarioTestResult>>();
            }

            #endregion


            // Add game components to the game loop
            AddGameComponents();

            Reset();

            base.Initialize();
        }
        private void ExportTestResultsToFile(string filename, Dictionary<string, List<ScenarioTestResult>> testResults)
        {
#if XBOX
            return;
#endif

            string testResultsDirectory = _relativeOutputPath;
            try
            {

                if (!Directory.Exists(testResultsDirectory))
                {
                    Directory.CreateDirectory(testResultsDirectory);
                    Console.WriteLine(@"Created folder.");
                }
                else
                {
                    string[] filesToDelete = Directory.GetFiles(testResultsDirectory);
                    foreach (var filenameToDelete in filesToDelete)
                    {
                        try
                        {
                            File.Delete(filenameToDelete);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }
                }

                string filepath = Path.Combine(testResultsDirectory, filename);

                using (var file = new StreamWriter(filepath))
                {
                    foreach (List<ScenarioTestResult> scenarioResults in testResults.Values)
                    {
                        foreach (ScenarioTestResult r in scenarioResults)
                        {
                            // TODO Multiple helicopters
                            string flightlogPath = Path.Combine(testResultsDirectory, GetFlightLogFilename(r));
                            FlightLogXMLFile.Write(flightlogPath, r.FlightLog, r.Scenario.HelicopterScenarios[0].Task.AllWaypoints);

                            file.WriteLine("Scenario: " + r.Scenario.Name);
                            file.WriteLine("Scenario ended by: " + r.EndTrigger);
                            file.WriteLine("Duration: {0} s", Math.Round(r.Duration.TotalSeconds, 1));
                            file.WriteLine("Sensors: \r\n" + r.Sensors);
                            file.WriteLine(r.Autopilot.ToString());
                            file.WriteLine();
                            file.WriteLine("MaxEstimatedPositionError: {0} m", Math.Round(r.MaxEstimatedPositionError, 2));
                            file.WriteLine("AvgEstimatedPositionError: {0} m", Math.Round(r.AvgEstimatedPositionError, 2));
                            file.WriteLine("MinEstimatedPositionError: {0} m", Math.Round(r.MinEstimatedPositionError, 2));

                            file.WriteLine("MaxHeightAboveGround: {0} m", Math.Round(r.MaxHeightAboveGround, 2));
                            file.WriteLine("AvgHeightAboveGround: {0} m", Math.Round(r.AvgHeightAboveGround, 2));
                            file.WriteLine("MinHeightAboveGround: {0} m", Math.Round(r.MinHeightAboveGround, 2));

                            file.WriteLine("MaxVelocity: {0} km/h", Math.Round(r.MaxVelocity * 3.6, 1));
                            file.WriteLine("AvgVelocity: {0} km/h", Math.Round(r.AvgVelocity * 3.6, 1));

                            file.WriteLine();
                            file.WriteLine();
                            file.WriteLine();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
 public KeyboardEvents(Game game)
     : base(game)
 {
     _prevPressedKeys = new Dictionary<Keys, bool>();
 }
Example #10
0
 public static List<Question> GetQuestions(string ExamFilesFolderPath)
 {
     List<Question> result = new List<Question>();
     string fileName = ExamFilesFolderPath.Replace(Path.GetDirectoryName(ExamFilesFolderPath), "");
     string[] sections = Question.GetSections(Properties.Settings.Default.SelectedSections);
     string xmlFilePath = GlobalPathVariables.GetXmlFilePath(ExamFilesFolderPath);
     XPathDocument doc = new XPathDocument(xmlFilePath);
     XPathNavigator nav = doc.CreateNavigator();
     XmlNamespaceManager nm = new XmlNamespaceManager(nav.NameTable);
     // Compile a standard XPath expression
     XPathExpression expr;
     XPathNodeIterator iterator;
     string version = "";
     expr = nav.Compile("//FileVersion");
     iterator = nav.Select(expr);
     while(iterator.MoveNext())
     {
         version = iterator.Current.Value;
     }
     for (int i = 0; i < sections.Length; i++)
     {
         expr = nav.Compile("//Section[@Title='" + sections[i] + "']/Question");
         iterator = nav.Select(expr);
         // Iterate on the node set
         while (iterator.MoveNext())
         {
             Question ques = new Question();
             ques.SectionTitle = sections[i];
             ques.QuestionNumber = Convert.ToInt32(iterator.Current.GetAttribute("No", nm.DefaultNamespace));
             Dictionary<char, string> options = new Dictionary<char, string>();
             XPathNodeIterator iter = iterator.Current.SelectChildren(XPathNodeType.Element);
             while (iter.MoveNext())
             {
                 if (iter.Current.LocalName == "Text")
                 {
                     ques.QuestionText = iter.Current.Value;
                 }
                 else if (iter.Current.LocalName == "Image")
                 {
                     ques.QuestionImagePath = iter.Current.Value;
                 }
                 else if (iter.Current.LocalName == "Answer")
                 {
                     ques.QuestionAnswer = Convert.ToChar(iter.Current.Value);
                 }
                 if (iter.Current.LocalName == "Options")
                 {
                     XPathNodeIterator ite = iter.Current.SelectChildren(XPathNodeType.Element);
                     while (ite.MoveNext())
                     {
                         char option;
                         string optionText;
                         string tempp = ite.Current.GetAttribute("Title", nm.DefaultNamespace);
                         option = Convert.ToChar(tempp);
                         optionText = ite.Current.Value;
                         options.Add(option, optionText);
                     }
                     ques.QuestionOptions = options;
                 }
                 if (version == "1.0")
                 {
                     ques.AnswerExplanation = "Version 1.0 files do not support explanations";
                 }
                 else
                 {
                     if (iterator.Current.LocalName == "AnswerExplanation")
                         ques.AnswerExplanation = iterator.Current.Value;
                 }
             }
             result.Add(ques);
         }
     }
     return result;
 }
Example #11
0
 private void helpToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Dictionary fr2 = new Dictionary();
     fr2.MdiParent = this;
     fr2.Show();
 }
        public void DisplayQuestion (NavigationOption option)
        {
            lbl_question_number.Visible = true;
            lbl_answer_explanation.Visible = false;
            lbl_section_title.Visible = true;
            label2.Visible = true;
            label3.Visible = true;
            txt_question.Visible = true;
            pic_image.Visible = true;
            
            if (option == NavigationOption.Begin)
            {
                currentQuestionIndex = 0;
                Question question = questions.ElementAt(currentQuestionIndex);
                lbl_question_number.Text = question.QuestionNumber.ToString();
                lbl_section_title.Text = question.SectionTitle;
                txt_question.Text = question.QuestionText;
                lbl_answer_explanation.Text = question.AnswerExplanation;
                if (!(string.IsNullOrWhiteSpace(question.QuestionImagePath)))
                {
                    string imagePath = Path.Combine(GlobalPathVariables.GetExamFilesFolder(filename), question.QuestionImagePath);
                    pic_image.ImageLocation = imagePath;
                }
                for (int i = 0; i < question.QuestionOptions.Count; i++)
                {
                    RadioButton rdb = new RadioButton();
                    rdb.AutoSize = true;
                    rdb.Text = question.QuestionOptions.ElementAt(i).Key + ". - " + question.QuestionOptions.ElementAt(i).Value;
                    rdb.Name = "rdb_" + question.QuestionOptions.ElementAt(i).Key;
                    rdb.Location = new Point(51, 464 + (i * 22));
                    pan_display.Controls.Add(rdb);
                }
                if ((Exam_Settings.ExamType.SelectedSections.ToString() == Properties.Settings.Default.ExamType && questions.Count == 1) || (Exam_Settings.ExamType.SelectedNumber.ToString() == Properties.Settings.Default.ExamType && Properties.Settings.Default.NumOfQuestions == 1))
                    btn_next.Enabled = false;
                this.Invalidate();
            }

            if (option == NavigationOption.Previous)
            {
                //determine the selected answer for this question and save it before moving to the previous question
                for (int j = pan_display.Controls.OfType<RadioButton>().Count() - 1; j >= 0; --j)
                {
                    var ctrls = pan_display.Controls.OfType<RadioButton>();
                    var ctrl = ctrls.ElementAt(j);
                    if (((RadioButton)ctrl).Checked)
                    {
                        givenAnswers[currentQuestionIndex] = Convert.ToChar(ctrl.Name.Replace("rdb_", ""));
                    }
                    pan_display.Controls.Remove(ctrl);
                    ctrl.Dispose();
                }
                if (currentQuestionIndex > 0)
                {
                    currentQuestionIndex -= 1;
                    Question question = questions.ElementAt(currentQuestionIndex);
                    lbl_question_number.Text = question.QuestionNumber.ToString();
                    lbl_section_title.Text = question.SectionTitle;
                    txt_question.Text = question.QuestionText;
                    lbl_answer_explanation.Text = question.AnswerExplanation;
                    if (string.IsNullOrWhiteSpace(question.QuestionImagePath))
                    {
                        pic_image.ImageLocation = "";
                    }
                    else
                    {
                        pic_image.ImageLocation = Path.Combine(GlobalPathVariables.GetExamFilesFolder(filename), question.QuestionImagePath);
                    }
                    for (int i = 0; i < question.QuestionOptions.Count; i++)
                    {
                        RadioButton rdb = new RadioButton();
                        rdb.AutoSize = true;
                        rdb.Text = question.QuestionOptions.ElementAt(i).Key + ". - " + question.QuestionOptions.ElementAt(i).Value;
                        rdb.Name = "rdb_" + question.QuestionOptions.ElementAt(i).Key;
                        rdb.Location = new Point(51, 464 + (i * 22));
                        if (question.QuestionOptions.ElementAt(i).Key == givenAnswers[currentQuestionIndex])
                            rdb.Checked = true;
                        pan_display.Controls.Add(rdb);
                    }
                    if (currentQuestionIndex == 0)
                    {
                        btn_previous.Enabled = false;
                    }
                }
            }

            if (option == NavigationOption.Next)
            {
                //determine the selected answer for this question and save it before moving to the next question
                for (int j = pan_display.Controls.OfType<RadioButton>().Count() - 1; j >= 0; --j)
                {
                    var ctrls = pan_display.Controls.OfType<RadioButton>();
                    var ctrl = ctrls.ElementAt(j);
                    if (((RadioButton)ctrl).Checked)
                    { 
                        givenAnswers[currentQuestionIndex] = Convert.ToChar(ctrl.Name.Replace("rdb_", ""));
                    }
                    pan_display.Controls.Remove(ctrl);
                    ctrl.Dispose();
                }
                currentQuestionIndex += 1;
                Question question = questions.ElementAt(currentQuestionIndex);
                lbl_question_number.Text = question.QuestionNumber.ToString();
                lbl_section_title.Text = question.SectionTitle;
                txt_question.Text = question.QuestionText;
                lbl_answer_explanation.Text = question.AnswerExplanation;
                if (string.IsNullOrWhiteSpace(question.QuestionImagePath))
                {
                    pic_image.ImageLocation = "";
                }
                else
                {
                    pic_image.ImageLocation = Path.Combine(GlobalPathVariables.GetExamFilesFolder(filename), question.QuestionImagePath);
                }
                for (int i = 0; i < question.QuestionOptions.Count; i++)
                {
                    RadioButton rdb = new RadioButton();
                    rdb.AutoSize = true;
                    rdb.Text = question.QuestionOptions.ElementAt(i).Key + ". - " + question.QuestionOptions.ElementAt(i).Value;
                    rdb.Name = "rdb_" + question.QuestionOptions.ElementAt(i).Key;
                    rdb.Location = new Point(51, 464 + (i * 22));
                    if (question.QuestionOptions.ElementAt(i).Key == givenAnswers[currentQuestionIndex])
                        rdb.Checked = true;
                    pan_display.Controls.Add(rdb);
                }
                btn_previous.Enabled = true;
                if ((Exam_Settings.ExamType.SelectedSections.ToString() == Properties.Settings.Default.ExamType && currentQuestionIndex == questions.Count - 1) || (Exam_Settings.ExamType.SelectedNumber.ToString() == Properties.Settings.Default.ExamType && currentQuestionIndex == Properties.Settings.Default.NumOfQuestions))
                    btn_next.Enabled = false;
                this.Invalidate();
            }           
 
            if (option == NavigationOption.End)
            {
                //determine the selected answer for this question and save it before ending the exam
                for (int j = pan_display.Controls.OfType<RadioButton>().Count() - 1; j >= 0; --j)
                {
                    var ctrls = pan_display.Controls.OfType<RadioButton>();
                    var ctrl = ctrls.ElementAt(j);
                    if (((RadioButton)ctrl).Checked)
                    {
                        givenAnswers[currentQuestionIndex] = Convert.ToChar(ctrl.Name.Replace("rdb_", ""));
                    }
                    pan_display.Controls.Remove(ctrl);
                    ctrl.Dispose();
                }
                //Stop the countdown timer
                timer.Stop();
                //determine how many answers are correct and get section details
                int numOfCorrect = 0;
                int total;
                Dictionary<string, int> totalQuestionsPerSection = new Dictionary<string, int>();
                Dictionary<string, int> rightQuestionsPerSection = new Dictionary<string, int>();
                for (int i = 0; i < questions.Count; i++)
                {
                    if (totalQuestionsPerSection.ContainsKey(questions.ElementAt(i).SectionTitle))
                    {
                        totalQuestionsPerSection[questions.ElementAt(i).SectionTitle] += 1;
                    }
                    else
                    {
                        totalQuestionsPerSection.Add(questions.ElementAt(i).SectionTitle, 1);
                    }
                    if (rightQuestionsPerSection.ContainsKey(questions.ElementAt(i).SectionTitle))
                    {
                        if (questions.ElementAt(i).QuestionAnswer == givenAnswers[i])
                        {
                            rightQuestionsPerSection[questions.ElementAt(i).SectionTitle] += 1;
                            numOfCorrect += 1;
                        }
                    }
                    else
                    {
                        rightQuestionsPerSection.Add(questions.ElementAt(i).SectionTitle, 0);
                        if (questions.ElementAt(i).QuestionAnswer == givenAnswers[i])
                        {
                            rightQuestionsPerSection[questions.ElementAt(i).SectionTitle] += 1;
                            numOfCorrect += 1;
                        }
                    }
                }
                total = questions.Count;
                Score_Sheet scs;
                if (Properties.Settings.Default.ExamType == Exam_Settings.ExamType.SelectedNumber.ToString())
                {
                    scs = new Score_Sheet(totalSeconds / 60.0, examCode, ((numOfCorrect * 1000) / Properties.Settings.Default.NumOfQuestions), totalQuestionsPerSection, rightQuestionsPerSection);
                }
                else
                {
                    scs = new Score_Sheet(totalSeconds / 60.0, examCode, ((numOfCorrect * 1000) / total), totalQuestionsPerSection, rightQuestionsPerSection);
                }
                this.Hide();
                scs.ShowDialog();
                this.Close();
            }
        }
Example #13
0
 /// <summary>
 /// Returns the index of the given key in the dictionary
 /// </summary>
 /// <param name="key">The string key for the dictionary</param>
 /// <param name="dictionary">The dictionary to check</param>
 /// <returns></returns>
 public int GetIndex(Dictionary<string, int> dictionary, string key)
 {
     int index = 0;
     for (int i = 0; i < dictionary.Count; i++)
     {
         if (dictionary.ElementAt(i).Key == key)
         {
             index = 1;
         }
     }
     return index;
 }