コード例 #1
0
        /// <summary>
        /// Function to get Question that will be used in the quiz module
        /// </summary>
        /// <param name="Cnic">User cnic number</param>
        /// <returns></returns>
        public List <ServerInterfaces.Question> getAllQuestionsForQuiz(long Cnic)
        {
            List <ServerInterfaces.Question> questionList = new List <ServerInterfaces.Question>();

            using (AdmissionTestingSystemEntities db = new AdmissionTestingSystemEntities())
            {
                var result = from question in db.Questions
                             join student in db.StudentInformations on question.PaperId equals student.ExamPaperId
                             join paper in db.ExamPapers on question.PaperId equals paper.Id
                             where student.StudentCnic == Cnic
                             select question;

                foreach (Question q in result)
                {
                    ServerInterfaces.Question questions = new ServerInterfaces.Question();
                    questions.Id         = q.Id;
                    questions.OptionA    = q.OptionA;
                    questions.OptionB    = q.OptionB;
                    questions.OptionC    = q.OptionC;
                    questions.OptionD    = q.OptionD;
                    questions.PaperId    = q.PaperId;
                    questions.Question1  = q.Question1;
                    questions.CorrectAns = q.CorrectAns;

                    questionList.Add(questions);
                }
            }

            return(questionList);
        }
コード例 #2
0
        /// <summary>
        /// Function to get the List of All the questions used in paper pool module
        /// </summary>
        /// <returns></returns>
        public List <ServerInterfaces.Question> getAllQuestions(string paperId)
        {
            List <ServerInterfaces.Question> questionList = new List <ServerInterfaces.Question>();

            using (AdmissionTestingSystemEntities db = new AdmissionTestingSystemEntities())
            {
                var ques = (from questions in db.Questions where questions.PaperId == paperId select questions);

                foreach (Question q in ques)
                {
                    ServerInterfaces.Question questions = new ServerInterfaces.Question();
                    questions.Id         = q.Id;
                    questions.OptionA    = q.OptionA;
                    questions.OptionB    = q.OptionB;
                    questions.OptionC    = q.OptionC;
                    questions.OptionD    = q.OptionD;
                    questions.PaperId    = q.PaperId;
                    questions.Question1  = q.Question1;
                    questions.CorrectAns = q.CorrectAns;

                    questionList.Add(questions);
                }
            }

            return(questionList);
        }