Exemple #1
0
        /// <summary>
        /// Returns a list of questions that have comments.
        /// </summary>
        /// <returns></returns>
        public List <QuestionsWithComments> GetQuestionsWithComments()
        {
            using (var db = new CSET_Context())
            {
                var results = new List <QuestionsWithComments>();

                // get any "marked for review" or commented answers that currently apply
                var relevantAnswers = RelevantAnswers.GetAnswersForAssessment(_assessmentId)
                                      .Where(ans => !string.IsNullOrEmpty(ans.Comment))
                                      .ToList();

                if (relevantAnswers.Count == 0)
                {
                    return(results);
                }

                bool requirementMode = relevantAnswers[0].Is_Requirement;

                // include Question or Requirement contextual information
                if (requirementMode)
                {
                    var query = from ans in relevantAnswers
                                join req in db.NEW_REQUIREMENT on ans.Question_Or_Requirement_ID equals req.Requirement_Id
                                select new QuestionsWithComments()
                    {
                        Answer            = ans.Answer_Text,
                        CategoryAndNumber = req.Standard_Category + " - " + req.Requirement_Title,
                        Question          = req.Requirement_Text,
                        Comment           = ans.Comment
                    };

                    return(query.ToList());
                }
                else
                {
                    var query = from ans in relevantAnswers
                                join q in db.NEW_QUESTION on ans.Question_Or_Requirement_ID equals q.Question_Id
                                join h in db.vQUESTION_HEADINGS on q.Heading_Pair_Id equals h.Heading_Pair_Id
                                orderby h.Question_Group_Heading
                                select new QuestionsWithComments()
                    {
                        Answer            = ans.Answer_Text,
                        CategoryAndNumber = h.Question_Group_Heading + " #" + ans.Question_Number,
                        Question          = q.Simple_Question,
                        Comment           = ans.Comment
                    };

                    return(query.ToList());
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Returns a list of questions that have been marked for review or have comments.
        /// </summary>
        /// <returns></returns>
        public List <QuestionsWithComments> getQuestionsWithCommentsOrMarkedForReview()
        {
            using (var db = new CSET_Context())
            {
                var results = new List <QuestionsWithComments>();

                // get any "marked for review" or commented answers that currently apply
                var relevantAnswers = RelevantAnswers.GetAnswersForAssessment(_assessmentId)
                                      .Where(ans => ans.Mark_For_Review == true || ans.Comment != null)
                                      .ToList();

                if (relevantAnswers.Count == 0)
                {
                    return(results);
                }

                bool requirementMode = relevantAnswers[0].Is_Requirement;

                // include Question or Requirement contextual information
                if (requirementMode)
                {
                    var query = from ans in relevantAnswers
                                join req in db.NEW_REQUIREMENT on ans.Question_Or_Requirement_ID equals req.Requirement_Id
                                select new QuestionsWithComments()
                    {
                        Answer            = ans.Answer_Text,
                        CategoryAndNumber = req.Standard_Category + " - " + req.Requirement_Title,
                        MarkedForReview   = ans.Mark_For_Review.ToString(),
                        Question          = req.Requirement_Text,
                        Comment           = ans.Comment
                    };

                    return(query.ToList());
                }
                else
                {
                    var query = from ans in relevantAnswers
                                join q in db.NEW_QUESTION on ans.Question_Or_Requirement_ID equals q.Question_Id
                                join h in db.vQUESTION_HEADINGS on q.Heading_Pair_Id equals h.Heading_Pair_Id
                                orderby h.Question_Group_Heading
                                select new QuestionsWithComments()
                    {
                        Answer            = ans.Answer_Text,
                        CategoryAndNumber = h.Question_Group_Heading + " #" + ans.Question_Number,
                        MarkedForReview   = ans.Mark_For_Review.ToString(),
                        Question          = q.Simple_Question,
                        Comment           = ans.Comment
                    };

                    return(query.ToList());
                }



                var dblist = from a in db.AVAILABLE_STANDARDS
                             join b in db.NEW_QUESTION_SETS on a.Set_Name equals b.Set_Name
                             join c in db.Answer_Questions on b.Question_Id equals c.Question_Or_Requirement_Id
                             join q in db.NEW_QUESTION on c.Question_Or_Requirement_Id equals q.Question_Id
                             join h in db.vQUESTION_HEADINGS on q.Heading_Pair_Id equals h.Heading_Pair_Id
                             where a.Selected == true && a.Assessment_Id == _assessmentId &&
                             c.Assessment_Id == _assessmentId &&
                             (c.Mark_For_Review == true || c.Comment != null)
                             orderby h.Question_Group_Heading
                             select new QuestionsWithComments()
                {
                    Answer            = c.Answer_Text,
                    CategoryAndNumber = h.Question_Group_Heading + " #" + c.Question_Number,
                    MarkedForReview   = c.Mark_For_Review.ToString(),
                    Question          = q.Simple_Question,
                    Comment           = c.Comment
                };

                return(dblist.ToList <QuestionsWithComments>());
            }
        }