/// <summary>
        /// Delete by object
        /// </summary>
        /// <param name="objUI"></param>
        public Message Delete(LOT_ExamQuestion_Section objGUI)
        {
            Message msg = null;
            try
            {
                // Get current group in dbContext
                LOT_ExamQuestion_Section item = GetByExQuestionIDAndSectionID(objGUI.ExamQuestionID, objGUI.SectionID);
                dbContext.LOT_ExamQuestion_Sections.DeleteOnSubmit(item);
                dbContext.SubmitChanges();

                msg = new Message(MessageConstants.I0001, MessageType.Info, "Exam Question-Section ", "deleted");
            }
            catch (Exception)
            {
                // Show system error
                msg = new Message(MessageConstants.E0036, MessageType.Error);
            }
            return msg;
        }
Beispiel #2
0
        public string CalculateMarkSection(LOT_Exam exam, LOT_ExamQuestion_Section section, sp_GetCandidateListByExamResult candidate,
            ref double totalMark, ref double totalMaxMark, ref bool isNan)
        {
            List<sp_GetCandidateAnswerListResult> listAnswer = candidateAnswerDAO.GetCandidateAnswer(candidate.ID, section.ID);
            List<sp_GetCandidateAnswerListResult> correctAnswers = listAnswer.Where(c => c.IsCorrect == true).ToList<sp_GetCandidateAnswerListResult>();
            double mark = (((double)section.MaxMark) / listAnswer.Count) * correctAnswers.Count;

            string result=string.Empty;
            if (!double.IsNaN(mark))
            {
                result = Math.Round(mark) + "/" + section.MaxMark;
                totalMaxMark += (double)section.MaxMark;
                totalMark += mark;
            }
            else
            {
                totalMaxMark += 0;
                totalMark += 0;
                isNan = false;
            }
            return result;
        }
        /// <summary>
        /// Update to db
        /// </summary>
        /// <param name="objUI"></param>
        /// <returns></returns>
        public Message Update(LOT_ExamQuestion_Section objUI)
        {
            Message msg = null;
            try
            {
                if (objUI != null)
                {
                    LOT_ExamQuestion_Section objDB = GetByExQuestionIDAndSectionID(objUI.ExamQuestionID, objUI.SectionID);
                    if (objDB != null)
                    {
                        objDB.MaxMark = objUI.MaxMark;
                        objDB.NumberOfQuestions = objUI.NumberOfQuestions;
                        objDB.IsRandom = objUI.IsRandom;
                        dbContext.SubmitChanges();
                    }
                    else
                    {
                        msg = new Message(MessageConstants.E0005, MessageType.Error, "Section name '" + objUI.LOT_Section.SectionName + "'", "database");
                    }
                    // Show success message
                    msg = new Message(MessageConstants.I0001, MessageType.Info, "Exam Question-Section ", "updated");

                }
            }
            catch (Exception)
            {
                // Show system error
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }
            return msg;
        }
        /// <summary>
        /// Insert to db
        /// </summary>
        /// <param name="objUI"></param>
        /// <returns></returns>
        public Message Insert(LOT_ExamQuestion_Section objUI)
        {
            Message msg = null;
            try
            {
                if (objUI != null)
                {
                    // Set more info

                    dbContext.LOT_ExamQuestion_Sections.InsertOnSubmit(objUI);
                    dbContext.SubmitChanges();

                    // Show success message
                    msg = new Message(MessageConstants.I0001, MessageType.Info, "Exam Question-Section ", "added");

                }
            }
            catch (Exception)
            {
                // Show system error
                msg = new Message(MessageConstants.E0007, MessageType.Error);
            }
            return msg;
        }