예제 #1
0
        public void finalizeExam()
        {
            ExamHistory exam = new ExamHistory();

            exam.ExamId    = examId;
            exam.UserId    = userId;
            exam.TakenDate = startDateTime;
            exam.Result    = this.getScorePercent() / 100;

            using (var context = new ExamsDBContext())
            {
                context.ExamHistory.Add(exam);
                context.SaveChanges();
            }
        }
예제 #2
0
        public void addAnswerToQuestion(string anwserText, bool isProper)
        {
            Answer answerHelper = new Answer();

            answerHelper.AnswerText = anwserText;
            answerHelper.IsProper   = isProper;
            answerHelper.QuestionId = questions[questions.Count - 1].QuestionId;

            using (var context = new ExamsDBContext())
            {
                context.Answer.Add(answerHelper);
                context.SaveChanges();
            };

            anwsers.Add(answerHelper);
        }
예제 #3
0
        public bool registerUser(string userLogin, string userPassword, string userEmail)
        {
            Users users = new Users();

            users.UserLogin    = userLogin;
            users.UserPassword = userPassword;
            users.Email        = userEmail;

            using (var context = new ExamsDBContext())
            {
                context.Users.Add(users);
                context.SaveChanges();
            };

            return(true);
        }
예제 #4
0
        public void deleteExam(Int64 examId)
        {
            //Exams exams = null;
            using (var context = new ExamsDBContext())
            {
                var examQ = from exams in context.Exams
                            where exams.ExamId == examId
                            select exams;

                var examToDelete = examQ.FirstOrDefault();

                context.Exams.Remove(examToDelete);
                context.SaveChanges();

                return;
            };
        }
예제 #5
0
        public Questions createQuestion(bool isMultiChoice, string questionTekst)
        {
            Questions questionsHelepr = new Questions();

            questionsHelepr.IsMultiChoice = isMultiChoice;
            questionsHelepr.QuestionText  = questionTekst;
            questionsHelepr.ExamId        = examHeader.ExamId;

            using (var context = new ExamsDBContext())
            {
                context.Questions.Add(questionsHelepr);
                context.SaveChanges();
            };

            questions.Add(questionsHelepr);

            return(questionsHelepr);
        }
예제 #6
0
        public Exams initializeExam(Int64 userId, string title, string description)
        {
            questions = new List <Questions>();
            anwsers   = new List <Answer>();

            examHeader            = new Exams();
            examHeader.UserId     = userId;
            examHeader.Title      = title;
            examHeader.Decription = description;

            headerCreated = true;

            using (var context = new ExamsDBContext())
            {
                context.Exams.Add(examHeader);
                context.SaveChanges();
            };

            return(examHeader);
        }