Esempio n. 1
0
        //Enter Feedback
        public bool createFeedbackAnswer(FeedbackAnswer feedModel)
        {
            bool  result = false;
            float fValue = 0;

            using (myProjectEntities context = new myProjectEntities())
            {
                Mapper.CreateMap <FeedbackAnswer, tblFeedbackResult>();

                tblFeedbackResult newFeed = Mapper.Map <FeedbackAnswer, tblFeedbackResult>(feedModel);

                context.tblFeedbackResults.Add(newFeed);

                context.SaveChanges();

                var   valueFeed = context.tblFeedbackResults.Where(q => q.FK_Feedback_id == feedModel.FK_Feedback_id).Select(q => q.feedback_answer).AsEnumerable();
                float d         = float.Parse(valueFeed.Aggregate((a, b) => a + b).ToString());
                int   count     = valueFeed.Count();
                fValue = d / count;

                tblFeedback f = context.tblFeedbacks.Where(q => q.PK_Feedback_id == feedModel.FK_Feedback_id).FirstOrDefault();
                f.feedback_value       = fValue;
                context.Entry(f).State = EntityState.Modified;
                context.SaveChanges();
            }


            return(result);
        }
        public string CreateProfessor(Professor_Profile prfsrProfile)
        {
            string   result;
            Service1 s       = new Service1();                      // use some student Registration code
            bool     exEmail = s.ExistingEmail(prfsrProfile.email); //check whether the email is existing or not

            if (exEmail)
            {
                using (myProjectEntities context = new myProjectEntities())
                {
                    string vCode = Guid.NewGuid().ToString(); // create verification code
                    prfsrProfile.verification_code = vCode;
                    prfsrProfile.profile_pic       = "~/Images/profile.png";
                    prfsrProfile.status            = 0;

                    Mapper.CreateMap <Professor_Profile, tblProfessor>();
                    tblProfessor newProf = Mapper.Map <Professor_Profile, tblProfessor>(prfsrProfile);

                    context.tblProfessors.Add(newProf);
                    int qq = context.SaveChanges();
                    result = qq.ToString();

                    bool sendMail = s.SendEmail(prfsrProfile.firstname + " " + prfsrProfile.middlename + " " + prfsrProfile.lastname, prfsrProfile.email, "Account Verification", prfsrProfile.verification_code);
                }
            }
            else
            {
                result = "Existing Email";
            }

            return(result);
        }
Esempio n. 3
0
        //To save complete quiz in one go
        public bool quizAnswer(List <QuizResultModel> quizRData)
        {
            bool      result = false;
            Stopwatch st     = new Stopwatch();

            using (myProjectEntities context = new myProjectEntities())
            {
                for (int i = 0; i < quizRData.Count; i++)
                {
                    Mapper.CreateMap <QuizResultModel, tblQuizResult>();

                    tblQuizResult newQuizR = Mapper.Map <QuizResultModel, tblQuizResult>(quizRData[i]);

                    context.tblQuizResults.Add(newQuizR);
                }
                int q = context.SaveChanges();


                //Mapper.CreateMap<QuizResultModel, tblQuizResult>();
                //List<tblQuizResult> newQuizR = Mapper.Map<List<QuizResultModel>, List<tblQuizResult>>(quizRData);
                //st.Restart();
                //context.tblQuizResults.AddRange(newQuizR);
                //st.Stop();
                //st.Restart();
                //context.SaveChanges();
                //st.Stop();
            }


            return(result);
        }
Esempio n. 4
0
        //Create Questions for quiz. This is awesome
        public int CreateQuestion(questionModel quesData)
        {
            int result = 0;

            using (myProjectEntities context = new myProjectEntities())
            {
                Mapper.CreateMap <questionModel, tblQuizQuestion>();
                tblQuizQuestion newQues = Mapper.Map <questionModel, tblQuizQuestion>(quesData);

                List <tblQuizOption> newOpt = new List <tblQuizOption>();

                Mapper.CreateMap <optionModel, tblQuizOption>();
                foreach (optionModel opt in quesData.optionModel)
                {
                    tblQuizOption o = Mapper.Map <optionModel, tblQuizOption>(opt);

                    newOpt.Add(o);
                }

                newQues.tblQuizOptions = newOpt.ToList();
                context.tblQuizQuestions.Add(newQues); //Execute the add function
                int q = context.SaveChanges();
                if (q > 0)
                {
                    result = newQues.PK_Question_id;        //set return to true
                }
            }
            return(result);
        }
Esempio n. 5
0
        //Delete Question with all Options
        public bool DeleteQuestion(int quesData)
        {
            bool result = false;

            using (myProjectEntities context = new myProjectEntities())
            {
                tblQuizQuestion quesDetail = context.tblQuizQuestions.Where(w => w.PK_Question_id == quesData).FirstOrDefault();
                float           m1         = (float)quesDetail.marks;

                tblQuizDetail quizDetail = context.tblQuizDetails.Where(a => a.PK_Quiz_id == quesDetail.FK_Quiz_id).FirstOrDefault();
                float         m2         = (float)quizDetail.quiz_weightage - m1;

                quizDetail.quiz_weightage       = m2;
                context.Entry(quizDetail).State = EntityState.Modified;
                context.SaveChanges();

                int q = context.spDeleteQuestionWithOption(quesData);

                if (q != 0)
                {
                    result = true;         //set return to true
                }
            }
            return(result);
        }
        // Create Lectures
        public int createLecture(lectureModel lectureData, bool feed, DateTime endDate)
        {
            int result = 0;

            using (myProjectEntities context = new myProjectEntities())
            {
                lectureData.lecture_status = 1;

                Mapper.CreateMap <lectureModel, tblLecture>();
                tblLecture newLec = Mapper.Map <lectureModel, tblLecture>(lectureData);

                context.tblLectures.Add(newLec);
                int qq = context.SaveChanges();
                result = qq;

                if (feed)
                {
                    feedbackModel feedModel = new feedbackModel();
                    feedModel.FK_Lecture_id = newLec.PK_Lecture_id;
                    feedModel.end_date      = endDate;
                    qq = createFeedback(feedModel);
                }
                return(result);
            }
        }
Esempio n. 7
0
        //Update existing Questions
        public bool UpdateQuestion(questionModel quesData)
        {
            bool result = false;

            using (myProjectEntities context = new myProjectEntities())  //update weightage
            {
                tblQuizQuestion quesDetail = context.tblQuizQuestions.Where(w => w.PK_Question_id == quesData.PK_Question_id).FirstOrDefault();
                float           m1         = (float)quesDetail.marks;

                tblQuizDetail quizDetail = context.tblQuizDetails.Where(a => a.PK_Quiz_id == quesData.FK_Quiz_id).FirstOrDefault();
                float         m2         = (float)quizDetail.quiz_weightage - m1;

                quizDetail.quiz_weightage       = m2 + (float)quesData.marks;
                context.Entry(quizDetail).State = EntityState.Modified;
                context.SaveChanges();
            }
            using (myProjectEntities context = new myProjectEntities())
            {
                Mapper.CreateMap <questionModel, tblQuizQuestion>();
                tblQuizQuestion newQues = Mapper.Map <questionModel, tblQuizQuestion>(quesData);
                context.Entry(newQues).State = EntityState.Modified;
                context.SaveChanges();
            }
            if (quesData.question_type == "Optional" || quesData.question_type == "Multiple Choice")
            {
                using (myProjectEntities context = new myProjectEntities())
                {
                    List <tblQuizOption> newOpt = context.tblQuizOptions.Where(s => s.FK_Question_id == quesData.PK_Question_id).ToList();

                    foreach (optionModel item in quesData.optionModel)
                    {
                        foreach (tblQuizOption item1 in newOpt)
                        {
                            if (item.PK_Option_id == item1.PK_Option_id)
                            {
                                item1.isAnswer = item.isAnswer;
                            }
                        }
                    }

                    context.SaveChanges();
                }
            }

            result = true;
            return(result);


            //This is to update just the Question i.e. without option model
            //Mapper.CreateMap<questionModel, tblQuizQuestion>();
            //tblQuizQuestion s = Mapper.Map<questionModel, tblQuizQuestion>(quesData);
            //context.Entry(s).State = EntityState.Modified;
            //int q = context.SaveChanges();
            //if (q == 1)
            //    result = true;
            //return result;
        }
Esempio n. 8
0
        public bool createFeedAnswer(int studentId, int lectureId, float answer)
        {
            bool  result = false;
            float fValue = 0;

            using (myProjectEntities context = new myProjectEntities())
            {
                int            q3        = 0;
                var            feedId    = context.tblFeedbacks.Where(q => q.FK_Lecture_id == lectureId).FirstOrDefault();
                FeedbackAnswer feedModel = new FeedbackAnswer();
                feedModel.feedback_answer = answer;
                feedModel.feedback_date   = System.DateTime.Now;
                feedModel.FK_Feedback_id  = Convert.ToInt32(feedId.PK_Feedback_id);
                feedModel.FK_Student_id   = studentId;


                Mapper.CreateMap <FeedbackAnswer, tblFeedbackResult>();

                tblFeedbackResult newFeed = Mapper.Map <FeedbackAnswer, tblFeedbackResult>(feedModel);

                context.tblFeedbackResults.Add(newFeed);

                q3 = context.SaveChanges();
                //Now update feedback value in tblFeedback
                //This is because after every submission there is change in the overall feedback value
                if (q3 != 0)
                {
                    var   valueFeed = context.tblFeedbackResults.Where(q => q.FK_Feedback_id == feedModel.FK_Feedback_id).Select(q => q.feedback_answer).AsEnumerable();
                    float d         = float.Parse(valueFeed.Aggregate((a, b) => a + b).ToString());
                    int   count     = valueFeed.Count();
                    fValue = d / count;

                    tblFeedback f = context.tblFeedbacks.Where(q => q.PK_Feedback_id == feedModel.FK_Feedback_id).FirstOrDefault();
                    f.feedback_value       = fValue;
                    context.Entry(f).State = EntityState.Modified;
                    q3 = context.SaveChanges();
                    if (q3 != 0)
                    {
                        result = true;
                    }
                }
            }
            return(result);
        }
Esempio n. 9
0
        //Updated
        public int Question_Create(questionModel quesData)
        {
            int result = 0;

            using (myProjectEntities context = new myProjectEntities())
            {
                Mapper.CreateMap <questionModel, tblQuizQuestion>();
                tblQuizQuestion newQues = Mapper.Map <questionModel, tblQuizQuestion>(quesData);

                if (quesData.question_type == "Optional" || quesData.question_type == "Multiple Choice")//Check is not options
                {
                    List <tblQuizOption> newOpt = new List <tblQuizOption>();

                    Mapper.CreateMap <optionModel, tblQuizOption>();


                    foreach (optionModel opt in quesData.optionModel)
                    {
                        tblQuizOption o = Mapper.Map <optionModel, tblQuizOption>(opt);

                        newOpt.Add(o);
                    }

                    newQues.tblQuizOptions = newOpt.ToList();
                }
                context.tblQuizQuestions.Add(newQues); //Execute the add function
                int q = context.SaveChanges();
                if (q > 0)
                {
                    result = newQues.PK_Question_id;        //set return to true
                }
                tblQuizDetail quizDetail = context.tblQuizDetails.Where(a => a.PK_Quiz_id == newQues.FK_Quiz_id).FirstOrDefault();
                quizDetail.quiz_weightage       = quizDetail.quiz_weightage + (float)newQues.marks;
                context.Entry(quizDetail).State = EntityState.Modified;
                context.SaveChanges();
            }
            return(result);
        }
Esempio n. 10
0
        //try enter
        public bool quizAnswerSave(QuizResultModel quizRData)
        {
            bool      result = false;
            Stopwatch st     = new Stopwatch();

            using (myProjectEntities context = new myProjectEntities())
            {
                Mapper.CreateMap <QuizResultModel, tblQuizResult>();

                tblQuizResult newQuizR = Mapper.Map <QuizResultModel, tblQuizResult>(quizRData);

                context.tblQuizResults.Add(newQuizR);
                int q = context.SaveChanges();
            }
            return(result);
        }
Esempio n. 11
0
        //Update existing Quiz + Change the status to delete the quiz
        public bool UpdateQuiz(quizModel quizData)
        {
            bool result = false;

            using (myProjectEntities context = new myProjectEntities())
            {
                Mapper.CreateMap <quizModel, tblQuizDetail>();
                tblQuizDetail s = Mapper.Map <quizModel, tblQuizDetail>(quizData);
                context.Entry(s).State = EntityState.Modified;
                int q = context.SaveChanges();
                if (q == 1)
                {
                    result = true;
                }
                return(result);
            }
        }
        //Update Lecture data
        public bool updateLecture(lectureModel lectureData)
        {
            bool result = false;

            using (myProjectEntities context = new myProjectEntities())
            {
                Mapper.CreateMap <lectureModel, tblLecture>();
                tblLecture s = Mapper.Map <lectureModel, tblLecture>(lectureData);
                context.Entry(s).State = EntityState.Modified;
                int q = context.SaveChanges();
                if (q == 1)
                {
                    result = true;
                }
                return(result);
            }
        }
Esempio n. 13
0
        //Create Options
        public bool CreateOption(optionModel optionData)
        {
            bool result = false;

            using (myProjectEntities context = new myProjectEntities())
            {
                Mapper.CreateMap <optionModel, tblQuizOption>();
                tblQuizOption newOpt = Mapper.Map <optionModel, tblQuizOption>(optionData);
                context.tblQuizOptions.Add(newOpt); //Execute the add function
                int q = context.SaveChanges();
                if (q == 1)
                {
                    result = true;         //set return to true
                }
            }
            return(result);
        }
Esempio n. 14
0
        //Update Options
        public bool UpdateOption(optionModel optionData)
        {
            bool result = false;

            using (myProjectEntities context = new myProjectEntities())
            {
                Mapper.CreateMap <optionModel, tblQuizOption>();
                tblQuizOption s = Mapper.Map <optionModel, tblQuizOption>(optionData);
                context.Entry(s).State = EntityState.Modified;
                int q = context.SaveChanges();
                if (q == 1)
                {
                    result = true;
                }
                return(result);
            }
        }
        //Create new Feedback
        public int createFeedback(feedbackModel feedData)
        {
            int result = 0;

            using (myProjectEntities context = new myProjectEntities())
            {
                Mapper.CreateMap <feedbackModel, tblFeedback>();

                tblFeedback newFeed = Mapper.Map <feedbackModel, tblFeedback>(feedData);

                context.tblFeedbacks.Add(newFeed);
                int q = context.SaveChanges();
                if (q > 0)
                {
                    result = newFeed.PK_Feedback_id;
                }
                return(result);
            }
        }
Esempio n. 16
0
        //Save individual question of the quiz
        public bool startQuiz(QuizResultModel quizRData)
        {
            bool result = false;

            using (myProjectEntities context = new myProjectEntities())
            {
                Mapper.CreateMap <QuizResultModel, tblQuizResult>();

                tblQuizResult newQuizR = Mapper.Map <QuizResultModel, tblQuizResult>(quizRData);

                context.tblQuizResults.Add(newQuizR);
                //context.Entry(newQuizR).State = EntityState.Modified;
                int q = context.SaveChanges();
                if (q > 0)
                {
                    result = true;
                }
            }
            return(result);
        }
Esempio n. 17
0
        //Create Quiz
        public int CreateQuiz(quizModel quizData)
        {
            int result = 0;

            using (myProjectEntities context = new myProjectEntities())
            {
                quizData.quiz_update = System.DateTime.Now; // Last Update or Created Date Time
                quizData.quiz_status = 1;                   // Live coming Quiz

                Mapper.CreateMap <quizModel, tblQuizDetail>();
                tblQuizDetail newQuiz = Mapper.Map <quizModel, tblQuizDetail>(quizData);


                context.tblQuizDetails.Add(newQuiz); //Execute the add function
                int q = context.SaveChanges();
                if (q == 1)
                {
                    result = newQuiz.PK_Quiz_id;     //set return to true
                }
            }
            return(result);
        }