示例#1
0
        /// <summary>
        /// Get the point results for Unique questions in a quizEntry
        /// </summary>
        /// <param name="quizId">The quiz Id</param>
        /// <param name="quizEntryID">Teh Quiz Entry ID</param>
        /// <returns>Points Result for unique questions in a quizEntry</returns>
        private int GetResultsForUniqueQuestions(int quizId, int quizEntryID)
        {
            int result = 0;

            try
            {
                //AnswerQuestionChoices
                List <AnswerQuestionChoice> answerquestionList = AnswerQuestionChoiceManager.GetAll();

                //answer
                List <Answer> answerList = AnswerManager.GetAnswersByQuizEntryId(quizEntryID);

                //Questionchoices for unique answer
                List <QuestionChoice> questionschoicesUniqueList = QuestionChoiceManager.GetCorrectQuestionForUnique();

                //Question
                List <Question> questionlist = QuestionManager.GetQuestionsByQuizId(quizId);

                //Get the Results for UNIQUE CHOICE QUESTION
                result =
                    (from Aq in answerquestionList
                     join a in answerList on Aq.AnswerId equals a.Id
                     join qc in questionschoicesUniqueList on Aq.QuestionChoiceId equals qc.Id
                     join q in questionlist on a.Question_Id equals q.Id
                     select qc).Sum(x => x.PointsValue);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing);
            }
            return(result);
        }
示例#2
0
        /// <summary>
        /// Get the point results for Multiple questions in a quizEntry
        /// </summary>
        /// <param name="quizId">The quiz Id</param>
        /// <param name="quizEntryID">Teh Quiz Entry ID</param>
        /// <returns>Points Result for Multiple questions in a quizEntry</returns>
        private int GetResultsForMultipleQuestions(int quizId, int quizEntryID)
        {
            int result = 0;

            try
            {
                //Get the ids of the multiple answer
                List <int> QuestionIdsMultiple = QuestionChoiceManager.GetQuestionsMultiples(quizId);

                //AnswerQuestionChoices
                List <AnswerQuestionChoice> answerquestionList = AnswerQuestionChoiceManager.GetAll();

                //answer
                List <Answer> answerList = AnswerManager.GetAnswersByQuizEntryId(quizEntryID);


                //Question
                List <Question> questionlist = QuestionManager.GetQuestionsByQuizId(quizId);

                //Questionchoices
                List <QuestionChoice> questionschoicesList = QuestionChoiceManager.GetAll();

                //Questionchoices for multiple answer
                List <QuestionChoice> questionschoicesMultipleList = QuestionChoiceManager.GetCorrectQuestionForMultiple();

                int multipleresult = 0;

                //Get the Results for MULTIPLE CHOICE QUESTION
                foreach (var item in QuestionIdsMultiple)
                {
                    //Get the answer for the student for each multiple question
                    List <string> studentchoices =
                        (from Aq in answerquestionList
                         join a in answerList on Aq.AnswerId equals a.Id
                         join qc in questionschoicesList on Aq.QuestionChoiceId equals qc.Id
                         join q in questionlist on a.Question_Id equals q.Id
                         where qc.Question_Id == item
                         select qc.Id.ToString()).ToList();

                    //Get the correct Answer

                    List <string> correctanswer =
                        (from qc in questionschoicesMultipleList
                         where qc.Question_Id == item
                         select qc.Id.ToString()).ToList();

                    if (Extensions.AreEqual(studentchoices, correctanswer)) //Correct Answer
                    {
                        multipleresult += (from qc in questionschoicesMultipleList
                                           where qc.Question_Id == item
                                           select qc).Sum(x => x.PointsValue);
                    }

                    result = multipleresult;
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing);
            }
            return(result);
        }