Exemplo n.º 1
0
        /// <summary>
        /// Get the Maximun points possible for a quiz
        /// </summary>
        /// <param name="quizId">The quiz Id</param>
        /// <param name="quizEntryID">Teh Quiz Entry ID</param>
        /// <returns>int: Max points in a quiz</returns>
        private int GetMaxPointOfQuiz(int quizId)
        {
            int result = 0;

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

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

                //Get the MaxPoint of the quizz
                result =
                    (from qc in questionschoicesList
                     join q in questionlist on qc.Question_Id equals q.Id
                     select qc).Sum(x => x.PointsValue);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing);
            }
            return(result);
        }
Exemplo n.º 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);
        }