Esempio n. 1
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);
        }
Esempio n. 2
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());
 }
Esempio n. 3
0
 public void GetActiveQuestion(QuestionAnswerSet questionAnswerSet)
 {
     if (!IsActiveQuestionValid)
     {
         throw new InvalidOperationException("Current question is invalid");
     }
     CheckTime();
     DoGetActiveQuestion(questionAnswerSet);
 }
Esempio n. 4
0
        public void GetQuestionsAnswersByQuestionSetId(int questionSetId, QuestionAnswerSet questionsAnswers)
        {
            IDataParameter[] p = AdapterQuestionsByQuestionSetId.GetFillParameters();
            p[0].Value = questionSetId;
            AdapterQuestionsByQuestionSetId.Fill(questionsAnswers.Questions);

            p          = AdapterAnswersByQuestionSetId.GetFillParameters();
            p[0].Value = questionSetId;
            AdapterAnswersByQuestionSetId.Fill(questionsAnswers.Answers);
        }
Esempio n. 5
0
 public void GetNextQuestion(QuestionAnswerSet questionAnswerSet)
 {
     if (!HasNextQuestion)
     {
         throw new InvalidOperationException("No next question");
     }
     CheckTime();
     DoGetNextQuestion(questionAnswerSet);
     if (!questionStatus.Contains(questionAnswerSet.Questions[0].Id))
     {
         questionStatus[questionAnswerSet.Questions[0].Id] = new Question.Status();
     }
 }
Esempio n. 6
0
    public void NextQuestion()
    {
        currentQAIndex++;
        //If there is no next question, go back to the first question (customize to the behaviour you'd like)
        if (questionAnswerList.Count <= currentQAIndex)
        {
            currentQAIndex = 0;
        }
        currentQA = questionAnswerList[currentQAIndex];

        //Display question somehow
        string question = currentQA.question;
    }
Esempio n. 7
0
 protected override void DoGetNextQuestion(QuestionAnswerSet questionAnswerSet)
 {
     if (_reviwState == ReviewState.none)
     {
         activeQuestionIndexes[activeSetIndex] = activeQuestionIndexes[activeSetIndex] + 1;
         GetActiveQuestion(questionAnswerSet);
     }
     if (_reviwState == ReviewState.ReviewFlagged || _reviwState == ReviewState.ReviewIncorrect)
     {
         SetActiveQuestion(GetNextReviewQuestion().QuestionId);
         GetActiveQuestion(questionAnswerSet);
     }
 }
Esempio n. 8
0
        public void GetQuestionsAnswersByQuestionSetIdAndZone(int questionSetId, byte questionZone,
                                                              QuestionAnswerSet questionsAnswers)
        {
            IDataParameter[] p = AdapterQuestionsByQuestionSetIdAndZone.GetFillParameters();
            p[0].Value = questionSetId;
            p[1].Value = questionZone;
            AdapterQuestionsByQuestionSetIdAndZone.Fill(questionsAnswers.Questions);

            p          = AdapterAnswersByQuestionSetIdAndZone.GetFillParameters();
            p[0].Value = questionSetId;
            p[1].Value = questionZone;
            AdapterAnswersByQuestionSetIdAndZone.Fill(questionsAnswers.Answers);
        }
Esempio n. 9
0
    public QuestionAnswerSet currentQA;                 //The current question-to-answer set.

    private void Start()
    {
        //Initialize current question to the first in the list
        if (questionAnswerList.Count > 0)
        {
            currentQA = questionAnswerList[0];
        }

        correctAnswerresulttext.text = "";
        wrongAnswerresulttext.text   = "";
        currentQuestion.text         = "";
        startButton.SetActive(true);
        blurStart.SetActive(true);
        green.SetActive(false);
        red.SetActive(false);
    }
    public void InitializePuzzle(int Variant, int Question)
    {
        Debug.Log("Client init puzzle");

        //Same for all players:
        SelectedVariant = PuzzleVariants[Variant];
        //Different question for all players:
        MySelectedQuestion = SelectedVariant.SeqeunceQuestions[Question];

        QuestionText.text     = MySelectedQuestion.Question;
        ClueQuestiontext.text = MySelectedQuestion.Question;
        ClueText.text         = MySelectedQuestion.Clue;

        //Start sequence
        StartCoroutine(RunSequence());
    }
Esempio n. 11
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();
        }
Esempio n. 12
0
        protected override void DoGetNextQuestion(QuestionAnswerSet questionAnswers)
        {
            ++activeQuestionInZone;
            if (activeQuestionInZone >= questionsInZones[activeZoneIndex])
            {
                if (activeZoneIndex >= 2)
                {
                    throw new Exception("No next question");
                }

                ++activeZoneIndex;
                activeQuestionInZone  = 0;
                activeDifficultyLevel = 1;
                consecutiveTrue       = 0;
                consecutiveFalse      = 0;
            }

            if (activeQuestionInZone != 0)
            {
                if (lastIsCorrect)
                {
                    consecutiveFalse = 0;
                    ++consecutiveTrue;
                    if (consecutiveTrue >= CONSECUTIVE_LEN_TO_ADAPT[activeZoneIndex] && activeDifficultyLevel < 3)
                    {
                        ++activeDifficultyLevel;
                        consecutiveTrue = 0;
                    }
                }
                else
                {
                    consecutiveTrue = 0;
                    ++consecutiveFalse;
                    if (consecutiveFalse >= CONSECUTIVE_LEN_TO_ADAPT[activeZoneIndex] && activeDifficultyLevel > 1)
                    {
                        --activeDifficultyLevel;
                        consecutiveFalse = 0;
                    }
                }
            }

            GetRandomQuestion(questionAnswers);
            ++activeQuestionIndex;
        }
Esempio n. 13
0
        public TestNavigator(TestSet.TestsRow test, Manager manager) : base(test, manager)
        {
            questionsAnswers = new QuestionAnswerSet[sets.QuestionSets.Count, 3];

            int i = 0, timeMin = 0;

            foreach (QuestionSetSet.QuestionSetsRow set in sets.QuestionSets)
            {
                for (byte zoneIndex = 0; zoneIndex <= 2; ++zoneIndex)
                {
                    QuestionAnswerSet qa = new QuestionAnswerSet();
                    manager.DataProvider.GetQuestionsAnswersByQuestionSetIdAndZone(set.Id, (byte)(zoneIndex + 1), qa);
                    questionsAnswers[i, zoneIndex] = qa;
                }
                ++i;
                totalQuestions += set.NumberOfQuestionsInZone1 + set.NumberOfQuestionsInZone2 +
                                  set.NumberOfQuestionsInZone3;
                questionsInZones[0] = set.NumberOfQuestionsInZone1;
                questionsInZones[1] = set.NumberOfQuestionsInZone2;
                questionsInZones[2] = set.NumberOfQuestionsInZone3;
                if (timeMin >= 0)
                {
                    if (set.IsTimeLimitNull())
                    {
                        timeMin = -1;
                    }
                    else
                    {
                        timeMin += set.TimeLimit;
                    }
                }
            }

            base.NextSet += new SimpleMethod(TestNavigator_NextSet);

            if (timeMin >= 0)
            {
                totalTime = new TimeSpan(0, timeMin, 0);
            }
            else
            {
                totalTime = TimeSpan.MaxValue;
            }
        }
Esempio n. 14
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;
            }
        }
Esempio n. 15
0
 public void SetQuestion(int index)
 {
     currentQAIndex = index;
     currentQA      = questionAnswerList[currentQAIndex];
 }
Esempio n. 16
0
 public abstract void DoGetActiveQuestion(QuestionAnswerSet questionAnswerSet);
Esempio n. 17
0
        public PracticeNavigator(TestSet.TestsRow test, Manager manager) : base(test, manager)
        {
            questionsAnswers      = new QuestionAnswerSet[sets.QuestionSets.Count];
            activeQuestionIndexes = new int[sets.QuestionSets.Count];

            int i       = 0;
            int timeMin = 0;

            totalQuestions = 0;
            Random r = new Random();

            foreach (QuestionSetSet.QuestionSetsRow set in sets.QuestionSets)
            {
                totalQuestions += set.NumberOfQuestionsToPick;
                if (timeMin >= 0)
                {
                    if (set.IsTimeLimitNull())
                    {
                        timeMin = -1;
                    }
                    else
                    {
                        timeMin += set.TimeLimit;
                    }
                }

                activeQuestionIndexes[i] = -1;
                questionsAnswers[i]      = new QuestionAnswerSet();
                manager.DataProvider.GetQuestionsAnswersByQuestionSetId(set.Id, questionsAnswers[i]);

                _explanationsDataTable = manager.DataProvider.GetExplanations(test.Id);

                if (questionsAnswers[i].Questions.Count < set.NumberOfQuestionsToPick)
                {
                    throw new Exception(
                              "Test is not valid: NumberOfQuestionsToPick is greater then total number of questions assigned to the test");
                }

                //Take random questions from the set so we have only NumberOfQuestionsToPick questions.
                int count = questionsAnswers[i].Questions.Count;
                if (set.NumberOfQuestionsToPick - questionsAnswers[i].Questions.Count < set.NumberOfQuestionsToPick / 2)
                {
                    while (count != set.NumberOfQuestionsToPick)
                    {
                        int j;
                        do
                        {
                            j = r.Next(questionsAnswers[i].Questions.Count);
                        } while (questionsAnswers[i].Questions[j].RowState == DataRowState.Deleted);
                        questionsAnswers[i].Questions[j].Delete();
                        --count;
                    }
                }
                else
                {
                    foreach (QuestionAnswerSet.QuestionsRow row in questionsAnswers[i].Questions)
                    {
                        row.Delete();
                    }

                    count = 0;
                    while (count != set.NumberOfQuestionsToPick)
                    {
                        int j;
                        do
                        {
                            j = r.Next(questionsAnswers[i].Questions.Count);
                        } while (questionsAnswers[i].Questions[j].RowState != DataRowState.Deleted);
                        questionsAnswers[i].Questions[j].RejectChanges();
                        ++count;
                    }
                }

                questionsAnswers[i].Questions.AcceptChanges();

                ++i;
            }

            if (timeMin >= 0)
            {
                totalTime = new TimeSpan(0, timeMin, 0);
            }
            else
            {
                totalTime = TimeSpan.MaxValue;
            }

            SetActiveSet(sets.QuestionSets[0].Id);
            SetActiveQuestion(questionsAnswers[0].Questions[0].Id);
        }
Esempio n. 18
0
 protected override void DoGetPreviousQuestion(QuestionAnswerSet questionAnswerSet)
 {
     throw new InvalidOperationException("DoGetPreviousQuestion is not supported");
 }
Esempio n. 19
0
 public override void DoGetActiveQuestion(QuestionAnswerSet questionAnswerSet)
 {
     questionAnswerSet.Clear();
     questionAnswerSet.Merge(new DataRow[] { activeQuestion.Questions[0] });
     questionAnswerSet.Merge(activeQuestion.Questions[0].GetAnswersRows());
 }
Esempio n. 20
0
 protected abstract void DoGetPreviousQuestion(QuestionAnswerSet questionAnswerSet);
Esempio n. 21
0
    public void Init(ReviewWebForm form)
    {
        _reviewWebForm = form;
        if (!((_webTestController.navigator.HasNextSet) || (_webTestController.navigator.HasNextQuestion)))
        {
            form.ImageButton.ImageUrl = @"images/exitTestButton.gif";
        }
        else
        {
            form.ImageButton.ImageUrl = @"images/returnButton.gif";
        }

        //form.ImageButton.Click += new ImageClickEventHandler(imageButton_Click);

        int questionCount;

        Question.Status status;
        TableRow        tr = new TableRow();
        TableCell       tc = new TableCell();

        tc.BorderStyle = BorderStyle.Groove;
        int rows = 0;

        form.SetsTable.Rows.Add(tr);
        form.SetsTable.Rows[rows].Cells.Add(tc);
        form.SetsTable.Rows[rows].Cells[0].Text            = "#";
        form.SetsTable.Rows[rows].Cells[0].Font.Size       = FontUnit.Medium;
        form.SetsTable.Rows[rows].Cells[0].ForeColor       = Color.White;
        form.SetsTable.Rows[rows].Cells[0].HorizontalAlign = HorizontalAlign.Center;
        form.SetsTable.Rows[rows].Cells[0].BackColor       = Color.FromArgb(8433377);
        tc             = new TableCell();
        tc.BorderStyle = BorderStyle.Groove;
        form.SetsTable.Rows[rows].Cells.Add(tc);
        form.SetsTable.Rows[rows].Cells[1].Text            = "Section name";
        form.SetsTable.Rows[rows].Cells[1].Font.Size       = FontUnit.Medium;
        form.SetsTable.Rows[rows].Cells[1].ForeColor       = Color.White;
        form.SetsTable.Rows[rows].Cells[1].HorizontalAlign = HorizontalAlign.Center;
        form.SetsTable.Rows[rows].Cells[1].BackColor       = Color.FromArgb(8433377);
        tc             = new TableCell();
        tc.BorderStyle = BorderStyle.Groove;
        form.SetsTable.Rows[rows].Cells.Add(tc);
        form.SetsTable.Rows[rows].Cells[2].Text            = "Score";
        form.SetsTable.Rows[rows].Cells[2].Font.Size       = FontUnit.Medium;
        form.SetsTable.Rows[rows].Cells[2].ForeColor       = Color.White;
        form.SetsTable.Rows[rows].Cells[2].HorizontalAlign = HorizontalAlign.Center;
        form.SetsTable.Rows[rows].Cells[2].BackColor       = Color.FromArgb(8433377);
        ++rows;
        for (int i = 0; i < _webTestController.navigator.QuestionsAnswers.Length; i++)
        {
            int cells = 0;
            tr = new TableRow();

            form.SetsTable.Rows.Add(tr);
            form.SetsTable.Rows[rows].Cells.Add(tc);
            tc             = new TableCell();
            tc.BorderStyle = BorderStyle.Groove;
            form.SetsTable.Rows[rows].Cells.Add(tc);
            form.SetsTable.Rows[rows].Cells[cells].Text = (i + 1).ToString();
            //form.SetsTable.Rows[rows].Cells[cells].Font.Size = FontUnit.XSmall;
            form.SetsTable.Rows[rows].Cells[cells].ForeColor = Color.White;
            ++cells;
            tc             = new TableCell();
            tc.BorderStyle = BorderStyle.Groove;
            tc             = new TableCell();
            tc.BorderStyle = BorderStyle.Groove;
            form.SetsTable.Rows[rows].Cells.Add(tc);
            LinkButton setLinkButton = new LinkButton();
            setLinkButton.Text      = _webTestController.navigator.Sets.QuestionSets[i].Name;
            setLinkButton.ForeColor = Color.White;
            setLinkButton.ID        = i.ToString();
            setLinkButton.Click    += new EventHandler(setLinkButton_Click);
            form.SetsTable.Rows[rows].Cells[cells].Controls.Add(setLinkButton);
            ++cells;
            _qas          = _webTestController.navigator.QuestionsAnswers[i];
            questionCount = _webTestController.navigator.QuestionsAnswers[i].Questions.Count;
            double setScore = 0;
            for (int j = 0; j < questionCount; ++j)
            {
                status    = _webTestController.navigator.GetQuestionStatus(_qas.Questions[j].Id);
                setScore += status.score;
            }
            tc             = new TableCell();
            tc.BorderStyle = BorderStyle.Groove;
            tc             = new TableCell();
            tc.BorderStyle = BorderStyle.Groove;
            form.SetsTable.Rows[rows].Cells[cells].Text      = setScore.ToString();
            form.SetsTable.Rows[rows].Cells[cells].ForeColor = Color.White;
            ++rows;
        }

        _qas          = _webTestController.navigator.QuestionsAnswers[_webTestController.activSetNumber];
        questionCount = _webTestController.navigator.QuestionsAnswers[_webTestController.activSetNumber].Questions.Count;


        tr = new TableRow();
        tc = new TableCell();

        tc.BorderStyle = BorderStyle.Groove;

        rows = 0;

        tc             = new TableCell();
        tc.BorderStyle = BorderStyle.Groove;
        form.QuestionTable.Rows.Add(tr);
        form.QuestionTable.Rows[rows].Cells.Add(tc);
        form.QuestionTable.Rows[rows].Cells[0].Text            = "#";
        form.QuestionTable.Rows[rows].Cells[0].ForeColor       = Color.White;
        form.QuestionTable.Rows[rows].Cells[0].Font.Size       = FontUnit.Medium;
        form.QuestionTable.Rows[rows].Cells[0].HorizontalAlign = HorizontalAlign.Center;
        form.QuestionTable.Rows[rows].Cells[0].BackColor       = Color.FromArgb(8433377);
        tc             = new TableCell();
        tc.BorderStyle = BorderStyle.Groove;
        form.QuestionTable.Rows[rows].Cells.Add(tc);
        form.QuestionTable.Rows[rows].Cells[1].Text            = "Question";
        form.QuestionTable.Rows[rows].Cells[1].ForeColor       = Color.White;
        form.QuestionTable.Rows[rows].Cells[1].Font.Size       = FontUnit.Medium;
        form.QuestionTable.Rows[rows].Cells[1].HorizontalAlign = HorizontalAlign.Center;
        form.QuestionTable.Rows[rows].Cells[1].BackColor       = Color.FromArgb(8433377);
        tc             = new TableCell();
        tc.BorderStyle = BorderStyle.Groove;
        form.QuestionTable.Rows[rows].Cells.Add(tc);
        form.QuestionTable.Rows[rows].Cells[2].Text            = "Status";
        form.QuestionTable.Rows[rows].Cells[2].ForeColor       = Color.White;
        form.QuestionTable.Rows[rows].Cells[2].Font.Size       = FontUnit.Medium;
        form.QuestionTable.Rows[rows].Cells[2].HorizontalAlign = HorizontalAlign.Center;
        form.QuestionTable.Rows[rows].Cells[2].BackColor       = Color.FromArgb(8433377);
        ++rows;


        for (int i = 0; i < questionCount; ++i)
        {
            int cells = 0;
            tr = new TableRow();
            form.QuestionTable.Rows.Add(tr);

            status         = _webTestController.navigator.GetQuestionStatus(_qas.Questions[i].Id);
            tc             = new TableCell();
            tc.BorderStyle = BorderStyle.Groove;
            form.QuestionTable.Rows[rows].Cells.Add(tc);
            form.QuestionTable.Rows[rows].Cells[cells].Text     += (i + 1).ToString();
            form.QuestionTable.Rows[rows].Cells[cells].ForeColor = Color.White;
            ++cells;

            tc             = new TableCell();
            tc.BorderStyle = BorderStyle.Groove;
            form.QuestionTable.Rows[rows].Cells.Add(tc);
            LinkButton questoinLinkButton = new LinkButton();
            questoinLinkButton.ForeColor = Color.White;
            //form.questionTable.Rows[rows].Cells[cells].Text = "<input type=\"image\" src=/" + "images/status/" + Question.Status.StatusType.GetName(typeof(Question.Status.StatusType), (int)status.status).ToString() + ".bmp"+">";
            questoinLinkButton.Text = "<input type=\"image\" src=" + "images/status/" +
                                      BuisinessObjects.StatusType.GetName(typeof(BuisinessObjects.StatusType),
                                                                          (int)status.status).ToString() + ".gif" +
                                      ">";
            questoinLinkButton.Text     += _webTestController.renderer.RenderToString(_qas.Questions[i].Text);
            questoinLinkButton.ID        = i.ToString();
            questoinLinkButton.Click    += new EventHandler(questoinLinkButton_Click);
            questoinLinkButton.ID        = "questoinLinkButton" + i.ToString();
            questoinLinkButton.Font.Size = FontUnit.Small;
            form.QuestionTable.Rows[rows].Cells[cells].Controls.Add(questoinLinkButton);
            ++cells;

            tc             = new TableCell();
            tc.BorderStyle = BorderStyle.Groove;
            form.QuestionTable.Rows[rows].Cells.Add(tc);
            switch ((int)status.status)
            {
            case 0:
                form.QuestionTable.Rows[rows].Cells[cells].Text = "Not seen";
                break;

            case 1:
                form.QuestionTable.Rows[rows].Cells[cells].Text = "Not answered";
                break;

            case 2:
                form.QuestionTable.Rows[rows].Cells[cells].Text = "Correct";
                break;

            case 3:
                form.QuestionTable.Rows[rows].Cells[cells].Text = "Incorrect";
                break;
            }
            form.QuestionTable.Rows[rows].Cells[cells].ForeColor = Color.White;
            ++rows;
        }
    }
Esempio n. 22
0
 protected abstract void DoGetNextQuestion(QuestionAnswerSet questionAnswerSet);