Exemplo n.º 1
0
        private void LoadQuestion(int Qnumber)
        {
            if (GraphicDisplayForm != null)
            {
                GraphicDisplayForm.Close();
            }
            //---- send question info class with data
            clsQuestionInfo oTQ  = new clsQuestionInfo();
            DataRow         oRow = QuestionListRandomized[Qnumber];

            oTQ.AnswerA        = oRow.Field <string>("AnswerA");
            oTQ.AnswerB        = oRow.Field <string>("AnswerB");
            oTQ.AnswerC        = oRow.Field <string>("AnswerC");
            oTQ.AnswerD        = oRow.Field <string>("AnswerD");
            oTQ.QuestionNumber = oRow.Field <string>("QuestionNumber");
            oTQ.QuestionText   = oRow.Field <string>("TestQuestion") + " - " + oTQ.QuestionNumber;
            sCurrentTQnumber   = oTQ.QuestionNumber;
            if (!CorrectAnswersDic.ContainsKey(sCurrentTQnumber))
            {
                string[] oTemp = new string[] { oRow.Field <string>("CorrectAnswer"), "" };
                CorrectAnswersDic.Add(sCurrentTQnumber, oTemp);
                oTQ.CorrectAnswerLetter = oTemp;
            }
            else
            {
                oTQ.CorrectAnswerLetter = CorrectAnswersDic[sCurrentTQnumber];
            }
            TQholder.SetQuestion(oTQ);
            FreezeBoxes();
            if (oRow.Field <string>(8) != "")             //  graphic name
            {
                string sFileName = oRow.Field <string>(8);
                if (sFileName.Contains("."))
                {
                    sFileName = sFileName.Substring(0, sFileName.IndexOf("."));
                }
                sFileName = sFileName.Replace(" ", "_");
                //sFileName = sFileName.Replace("-", "_");
                if (oTQ.QuestionNumber[0] == 'E')
                {
                    sFileName = "Extra_Pool_graphic" + sFileName.Substring(sFileName.LastIndexOf("_"));
                }
                if (oTQ.QuestionNumber[0] == 'G')
                {
                    sFileName = "General_Pool_graphic" + sFileName.Substring(sFileName.LastIndexOf("_"));
                }
                if (oTQ.QuestionNumber[0] == 'T')
                {
                    sFileName = "Tech_Pool_graphic" + sFileName.Substring(sFileName.LastIndexOf("_"));
                }
                GraphicDisplayForm = new frmGraphicDisplayForm();
                //GraphicDisplayForm.GraphicToShow = (Image)Properties.Resources.ResourceManager.GetObject(sFileName);
                GraphicDisplayForm.GraphicToShow = Image.FromFile(Application.StartupPath + "\\QuestionGraphics\\" + sFileName + ".jpg");
                GraphicDisplayForm.Show();
            }
        }
        public void SetQuestion(clsQuestionInfo QuestionInfo)
        {
            bIsLocked = false;
            ClearChoices();
            bIsLoading = false;

            //---- set values
            CorrectAnswerChoice  = QuestionInfo.CorrectAnswerLetter[0];
            txtTestQuestion.Text = QuestionInfo.QuestionText;
            txtAnswerA.Text      = QuestionInfo.AnswerA;
            txtAnswerB.Text      = QuestionInfo.AnswerB;
            txtAnswerC.Text      = QuestionInfo.AnswerC;
            txtAnswerD.Text      = QuestionInfo.AnswerD;
            QuestionNumber       = QuestionInfo.QuestionNumber;
            string sPreviousChoice = QuestionInfo.CorrectAnswerLetter[1];

            if (sPreviousChoice == "")
            {
                return;                 // no previous choice made
            }
            bIsLoading = true;
            switch (sPreviousChoice)
            {
            case "A":
                lblAnswerA_Click(null, EventArgs.Empty);
                break;

            case "B":
                lblAnswerB_Click(null, EventArgs.Empty);
                break;

            case "C":
                lblAnswerC_Click(null, EventArgs.Empty);
                break;

            case "D":
                lblAnswerD_Click(null, EventArgs.Empty);
                break;
            }
        }