Esempio n. 1
0
 public bool EvaluateQuestionnaire(ICollection<Question> questions, Questionnaire masterQuestionnaire)
 {
     bool passed = true;
     foreach (Question quest in questions)
     {
         if (quest.Type != QuestionType.Essay)
         {
             Question evalQuestion =
                 masterQuestionnaire.Questions.First(x => x.QuestionID.Equals(quest.QuestionID));
             int totalCorrect = 0;
             foreach (Answer ans in quest.Answers)
             {
                 Answer evalAnswer = evalQuestion.Answers.First(x => x.AnswerID.Equals(ans.AnswerID));
                 if ((quest.Type == QuestionType.YesNo &&
                      evalAnswer.CorrectAnswer.Equals(ans.CorrectAnswer))
                     ||
                     (quest.Type == QuestionType.MultipleAnswer &&
                     evalAnswer.CorrectAnswer.Equals(true) &&
                     ans.CorrectAnswer.Equals(true))
                     )
                 {
                         totalCorrect++;
                 }
             }
             if (totalCorrect < evalQuestion.MinCorrect)
             {
                 passed = false;
             }
         }
     }
     return passed;
 }
Esempio n. 2
0
 public ActionResult Create(Questionnaire questionnaire)
 {
     if (ModelState.IsValid)
     {
         qs.CreateQuestionnaire(questionnaire);
         RedirectToAction("Index");
     }
     return View(questionnaire);
 }
Esempio n. 3
0
        public ActionResult Create()
        {
            var q = new Questionnaire();
            q.Questions = new List<Question> { new Question() };
            // dont want to create the questionnaire until the user has entered info need to display
            // the view to the user, get info, then add to db

            return View(q);
        }
Esempio n. 4
0
 // Here the system should attempt to store a questionnaire in the database. If it is
 // successful, return true. If it is not successful, return false.
 public void CreateQuestionnaire(Questionnaire q)
 {
     try
     {
         _questionnaireRepository.Add(q);
     }
     catch
     {
         throw;
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Position" /> class.
 /// </summary>
 /// <param name="_title">     The _title. </param>
 /// <param name="_minSal">    The _min sal. </param>
 /// <param name="_maxSal">    The _max sal. </param>
 /// <param name="_shortDesc"> The _short desc. </param>
 /// <param name="_longDesc">  The _long desc. </param>
 /// <param name="_exp">       The _exp. </param>
 /// <param name="_qaire">     The _qaire. </param>
 /// <param name="_phQuaire">  The _PH quaire. </param>
 public Position(string _title, float? _minSal, float? _maxSal, string _shortDesc, string _longDesc, int _exp,
     Questionnaire _qaire, PhoneQuestionnaire _phQuaire)
     : this()
 {
     Title = _title;
     MinSalary = _minSal;
     MaxSalary = _maxSal;
     ShortDescription = _shortDesc;
     LongDescription = _longDesc;
     MinExp = _exp;
     PositionQuestionnaire = _qaire;
     PhoneInterview = _phQuaire;
 }
Esempio n. 6
0
        public void TestAddQuestionnaire()
        {
            var newQuestionnaire = new Questionnaire
            {
                QuestionnaireID = questionnaires.Count() + 1,
                QuestionnaireTitle = "New Questionnaire",
                Questions = questions.ToList()
            };

            questionnaireService.CreateQuestionnaire(newQuestionnaire);
            Questionnaire q_returned = questionnaireService.GetQuestionnaire(newQuestionnaire.QuestionnaireID);
            Assert.AreEqual(newQuestionnaire.QuestionnaireID, q_returned.QuestionnaireID);
            Assert.AreEqual(newQuestionnaire.QuestionnaireTitle, q_returned.QuestionnaireTitle);
            Assert.AreEqual(newQuestionnaire.Questions, q_returned.Questions);
        }