Exemplo n.º 1
0
 protected void GetPrevQuestion()
 {
     navigator.GetPreviousQuestion(questionAnswerSet);
     question = questionAnswerSet.Questions[0];
     //navigator.SetActiveQuestion(question.Id);
     answersRow = question.GetAnswersRows();
 }
Exemplo n.º 2
0
        private void GetRandomQuestion(QuestionAnswerSet questionAnswers)
        {
            QuestionAnswerSet.QuestionsDataTable qt   = questionsAnswers[activeSetIndex, activeZoneIndex].Questions;
            QuestionAnswerSet.QuestionsRow[]     rows =
                (QuestionAnswerSet.QuestionsRow[])qt.Select("DifficultyLevelId = " + activeDifficultyLevel.ToString());
            if (rows.Length == 0)
            {
                throw new Exception(
                          String.Format(
                              "The content of the test is incorrent. There is not enough questions of difficulty {0} in zone {1} of question set {2}",
                              activeDifficultyLevel, activeZoneIndex + 1, activeSetIndex + 1));
            }

            questionAnswers.Clear();
            activeQuestion.Clear();

            QuestionAnswerSet.QuestionsRow q = rows[random.Next(rows.Length)];
            DataRow[] dr = new DataRow[] { q };
            QuestionAnswerSet.AnswersRow[] ar = q.GetAnswersRows();
            activeQuestion.Merge(dr);
            activeQuestion.Merge(ar);
            questionAnswers.Merge(dr);
            questionAnswers.Merge(ar);

            qt.RemoveQuestionsRow(q);
        }
Exemplo n.º 3
0
 public override void DoGetActiveQuestion(QuestionAnswerSet questionAnswerSet)
 {
     questionAnswerSet.Clear();
     QuestionAnswerSet.QuestionsRow qr =
         questionsAnswers[activeSetIndex].Questions[activeQuestionIndexes[activeSetIndex]];
     questionAnswerSet.Merge(new DataRow[] { qr });
     questionAnswerSet.Merge(qr.GetAnswersRows());
 }
Exemplo n.º 4
0
 protected void GetNextQuestion()
 {
     if (!navigator.HasNextQuestion)
     {
         throw new ApplicationException("No next question");
     }
     navigator.GetNextQuestion(questionAnswerSet);
     question   = questionAnswerSet.Questions[0];
     answersRow = question.GetAnswersRows();
 }
Exemplo n.º 5
0
        private void CheckNavigator(INavigator navigator)
        {
            QuestionSetSet.QuestionSetsRow qs;
            QuestionAnswerSet qd = new QuestionAnswerSet();

            while (navigator.HasNextSet)
            {
                if (navigator.HasPreviousSet && random.Next(3) == 1)
                {
                    qs = navigator.GetPreviousSet();
                }
                else
                {
                    qs = navigator.GetNextSet();
                }

                while (navigator.HasNextQuestion)
                {
                    if (navigator.HasPreviousQuestion && random.Next(3) == 1)
                    {
                        navigator.GetPreviousQuestion(qd);
                    }
                    else
                    {
                        navigator.GetNextQuestion(qd);
                    }

                    QuestionAnswerSet.QuestionsRow q = qd.Questions[0];

                    if (q.SubtypeId == (byte)Question.Subtype.ReadingComprehensionPassage)
                    {
                        Assert.Fail("Set cannot directly contain question of type ReadingComprehensionPassage");
                    }

                    if (q.SubtypeId == (byte)Question.Subtype.ReadingComprehensionQuestionToPassage)
                    {
                        navigator.GetPasssageToQuestion(q.Id);
                    }

                    QuestionAnswerSet.AnswersRow[] a = q.GetAnswersRows();

                    navigator.SetUserAnswer(a[random.Next(a.Length)].Id);
                }
            }

            navigator.CommitResult();
        }
Exemplo n.º 6
0
        public ImageSet Render(QuestionAnswerSet.QuestionsRow question)
        {
            ImageSet s = new ImageSet();

            InitBuffer(question.SubtypeId != (int)BuisinessObjects.Subtype.ReadingComprehensionQuestionToPassage
                           ? largeBuffer
                           : smallBuffer);

            //Render question's picture
            Image picture = question.IsPictureNull() ? null : Image.FromStream(new MemoryStream(question.Picture));

            if (picture != null)
            {
                activeGraphics.DrawImageUnscaled(picture, (activeBuffer.Width - picture.Width) / 2, 0);
                cursor.Y = picture.Height + 12;
            }

            RenderText(question.Text);

            cursor.Y += 10;
            activeGraphics.DrawLine(pen, 0, cursor.Y, activeBuffer.Width, cursor.Y);
            ++cursor.Y;

            s.question = CreateImageFromActiveBuffer();

            QuestionAnswerSet.AnswersRow[] ar = question.GetAnswersRows();
            s.answers = new Bitmap[ar.Length];
            int i = 0;

            foreach (QuestionAnswerSet.AnswersRow row in ar)
            {
                InitBuffer(question.SubtypeId != (int)BuisinessObjects.Subtype.ReadingComprehensionQuestionToPassage
                               ? largeBufferA
                               : smallBufferA);
                RenderText(row.Text);
                s.answers[i] = CreateImageFromActiveBuffer();
                ++i;
            }

            return(s);
        }
Exemplo n.º 7
0
        public void Render()
        {
            string fileName = "c:\\test.gif";

            File.Exists(fileName);
            File.Delete(fileName);

            QuestionAnswerSet q = new QuestionAnswerSet();

            Bitmap bitmap = new Bitmap(50, 50, PixelFormat.Format16bppRgb555);

            for (int i = 0; i < 50; ++i)
            {
                bitmap.SetPixel(i, i, Color.Red);
            }

            MemoryStream stream = new MemoryStream();

            bitmap.Save(stream, ImageFormat.Gif);

            byte[] picture = stream.GetBuffer();

            QuestionAnswerSet.QuestionsRow row =
                q.Questions.AddQuestionsRow((byte)Question.Type.Quantitative, (byte)Question.Subtype.DataSufficiency,
                                            0, text, picture);

            ImageSet set = renderer.Render(row);

            //set.Question.Save(fileName, ImageFormat.Gif);

            int j = 0;

            foreach (Image image in set.Answers)
            {
                image.Save(fileName + j.ToString(), ImageFormat.Gif);
                ++j;
            }
        }
Exemplo n.º 8
0
 private void GetNextQuestion()
 {
     navigator.GetNextQuestion(questionAnswerSet);
     question   = questionAnswerSet.Questions[0];
     answersRow = question.GetAnswersRows();
 }
Exemplo n.º 9
0
 public void GetActivQuestion()
 {
     navigator.GetActiveQuestion(questionAnswerSet);
     question   = questionAnswerSet.Questions[0];
     answersRow = question.GetAnswersRows();
 }
Exemplo n.º 10
0
        private void _setUserAnswer(int answerId)
        {
            CheckTime();
            QuestionAnswerSet.QuestionsRow          q   = ActiveQuestion;
            ResultResultDetailSet.ResultsDetailsRow row =
                result.ResultsDetails.FindByResultIdQuestionId(result.Results[0].Id, q.Id);

            bool isCorrect = false;

            foreach (QuestionAnswerSet.AnswersRow r in q.GetAnswersRows())
            {
                if (r.Id == answerId)
                {
                    isCorrect = r.IsCorrect;
                    break;
                }
            }

            double scoreForCorrect = CalculateScoreOfActiveQuestion(true);
            double score           = CalculateScoreOfActiveQuestion(isCorrect);

            ResultResultDetailSet.ResultsDetailsOfSetsRow setRow =
                result.ResultsDetailsOfSets.FindByResultIdQuestionSetId(resultRow.Id,
                                                                        sets.QuestionSets[activeSetIndex].Id);

            if (row != null)
            {
                row.AnswerId = answerId;
                QuestionIdentity qi = new QuestionIdentity(setRow.QuestionSetId, q.Id);
                if (isCorrect)
                {
                    if (((Question.Status)questionStatus[q.Id]).status != BuisinessObjects.StatusType.ANSWER_IS_CORRECT)
                    {
                        setRow.Score += score;
                    }

                    QuestionInfoForReview.incorrect.Remove(qi);
                }
                else
                {
                    if (((Question.Status)questionStatus[q.Id]).status == BuisinessObjects.StatusType.ANSWER_IS_CORRECT)
                    {
                        setRow.Score -= scoreForCorrect;
                    }

                    if (!QuestionInfoForReview.incorrect.Contains(qi))
                    {
                        QuestionInfoForReview.incorrect.Add(qi);
                    }
                }
            }
            else
            {
                result.ResultsDetails.AddResultsDetailsRow(
                    resultRow,
                    q.Id,
                    answerId,
                    (byte)(ActiveQuestionIndex + 1),
                    questionStartTime,
                    DateTime.Now);

                questionStartTime = DateTime.Now;
                setRow.Score     += score;
            }

            ((Question.Status)questionStatus[q.Id]).status = isCorrect
                                                                  ? BuisinessObjects.StatusType.ANSWER_IS_CORRECT
                                                                  : BuisinessObjects.StatusType.ANSWER_IS_INCORRECT;
            ((Question.Status)questionStatus[q.Id]).answeredId = answerId;
            ((Question.Status)questionStatus[q.Id]).score      = score;
        }