public ProblemQuestionRelationship(Problem problem, Question question, int possibleAnswersCount, int negativeAnswersCount)
     : base(DataBaseContext.Session)
 {
     _problem = problem;
     _question = question;
     PossibleAnswersCount = possibleAnswersCount;
     NegativeAnswersCount = negativeAnswersCount;
 }
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     var newQuestion = new Question(newQuestionText.Text);
     DataBaseContext.CreateQuestion(newQuestion);
     var relation1 = new ProblemQuestionRelationship(_problem1, newQuestion, Int32.Parse(prob1Yes.Text),
         Int32.Parse(prob1No.Text));
     var relation2 = new ProblemQuestionRelationship(_problem2, newQuestion, Int32.Parse(prob2Yes.Text),
         Int32.Parse(prob2No.Text));
     DataBaseContext.CreateRelationship(relation1);
     DataBaseContext.CreateRelationship(relation2);
     this.Close();
 }
Esempio n. 3
0
 private void OnAnswerGiven(object sender, AnswerEventArgs answerEventArgs)
 {
     try
     {
         ProblemDetector.AnswerCalculation(_currentQuestion, answerEventArgs.Result);
         problemsListBox.DataSource = ProblemDetector.ProblemRatios;
         problemsListBox.DisplayMember = "Problem.ShortName";
         problemsListBox.Refresh();
         _currentQuestion = ProblemDetector.GetNextQuestion();
         questionTextLabel.Text = _currentQuestion.QuestionText;
     }
     catch (NullReferenceException exception)
     {
         new AddNewQuestion(ProblemDetector.ProblemRatios[0].Problem, ProblemDetector.ProblemRatios[1].Problem)
             .ShowDialog();
         detectedProblemLabel.Text = ProblemDetector.ProblemRatios[0].Problem.ShortName;
         xtraTabControl1.SelectedTabPageIndex = 2;
     }
 }
 public static void AnswerCalculation(Question question, bool? answer)
 {
     _askedQuestionsNoStat.Add(question);
     if (!answer.HasValue)
     {
         return;
     }
     _askedQuestions.Add(new Tuple<Question, bool?>(question, answer));
     Debug.Print("Answer calculation started: Q: {0}. A: {1}", question.Oid, answer);
     foreach (ProblemQuestionRelationship relationship in question.Relationships)
     {
         double coef = answer.Value
             ? relationship.PossibleAnswersCount/
               (relationship.PossibleAnswersCount + relationship.NegativeAnswersCount)
             : relationship.NegativeAnswersCount/
               (relationship.PossibleAnswersCount + relationship.NegativeAnswersCount);
         ProblemRatio problem = ProblemRatios.FirstOrDefault(p => p.Problem == relationship.Problem);
         if (problem == null)
         {
             continue;
         }
         double currentProblemDetectCount = problem.Problem.DetectedCount == 0.0
             ? 1.0
             : problem.Problem.DetectedCount;
         double globalProblemDetectCount = DataBaseContext.General == 0.0
             ? 1.0
             : DataBaseContext.General;
         double problemFrequency = currentProblemDetectCount/globalProblemDetectCount;
         problem.Ratio += coef*problemFrequency;
         Debug.Print("Answer calculated! Problem {0} {1}+{2}", problem.Problem.Oid, problem.Ratio, coef);
     }
     ProblemRatios = new ObservableCollection<ProblemRatio>(ProblemRatios.OrderByDescending(o => o.Ratio));
     if (_askedQuestions.Count == 1)
     {
         NextQuestionOrSuggestion(true);
     }
     else
     {
         NextQuestionOrSuggestion();
     }
 }
 public ProblemQuestionRelationship(Problem problem, Question question)
     : this(problem, question, 0, 0)
 {
 }
 public QuestionFoundEventArgs(Question question)
 {
     Question = question;
 }
Esempio n. 7
0
 private void presetButton4_Click(object sender, EventArgs e)
 {
     PresetFacade.Presets[0].MakePreset();
     _currentQuestion = ProblemDetector.GetNextQuestion();
     questionTextLabel.Text = _currentQuestion.QuestionText;
 }
Esempio n. 8
0
 private void unsolvedButton_Click(object sender, EventArgs e)
 {
     ProblemDetector.WrongProblem(ProblemDetector.ProblemRatios[0]);
     _currentQuestion = ProblemDetector.GetNextQuestion();
     questionTextLabel.Text = _currentQuestion.QuestionText;
 }
 public static void CreateQuestion(Question question)
 {
     _questions.Add(question);
     _session.Save(_questions);
     Debug.Print("Question {0} saved", question.QuestionText);
 }