Пример #1
0
        public async Task AddQuestionToSample(SampleQuestion question, Guid quizId)
        {
            SampleQuiz quiz = await _context.SampleQuizes.FirstAsync(s => s.Id.Equals(quizId));

            quiz.Questions.Add(question);
            await _context.SaveChangesAsync();
        }
Пример #2
0
        public async Task RemoveSampleQuiz(Guid quizId)
        {
            SampleQuiz quiz = await _context.SampleQuizes.FirstAsync(s => s.Id.Equals(quizId));

            _context.SampleQuizes.Remove(quiz);
            await _context.SaveChangesAsync();
        }
Пример #3
0
        /*public async Task AddSolvingQuiz(SolvingQuiz quiz, string UserId)
         * {
         *  User user = await _context.Users.FirstAsync(s => s.Id.Equals(UserId));
         *  user.SolvedQuizes.Add(quiz);
         *  user.IsUpdated = true;
         *  await _context.SaveChangesAsync();
         * }*/

        public async Task AddQuizesToUser(SolvingQuiz quiz, SampleQuiz sample, string UserId)
        {
            User user = await _context.Users.FirstAsync(s => s.Id.Equals(UserId));

            user.SolvedQuizes.Add(quiz);
            user.SampleQuizes.Add(sample);
            user.IsUpdated = true;
            await _context.SaveChangesAsync();
        }
Пример #4
0
 public SolvingQuiz(SampleQuiz quiz)
 {
     Id                = Guid.NewGuid();
     QuizName          = quiz.QuizName;
     Questions         = new List <SolvedQuestion>();
     DateSolved        = DateTime.Now;
     NumberOfQuestions = quiz.Questions.Count;                           //mozda bi trebao na 0 stavit pa dodavat za jedno naknadno hmm
     CorrectQuestions  = 0;
     QuizGenre         = quiz.QuizGenre;
 }
Пример #5
0
        public static SolvingQuiz CreateFromSample(SampleQuiz sample)
        {
            SolvingQuiz quiz = new SolvingQuiz(sample);
            Random      rand = new Random();

            foreach (SampleQuestion questionSample in sample.Questions)
            {
                SolvedQuestion question = new SolvedQuestion(questionSample.QuestionText, questionSample.CorrectAnswer);
                quiz.Questions.Add(question);
                if (rand.Next() % 2 == 1)
                {
                    quiz.Questions.Reverse();
                }
            }
            return(quiz);
        }
Пример #6
0
 public async Task AddSampleQuiz(SampleQuiz quiz)
 {
     _context.SampleQuizes.Add(quiz);
     await _context.SaveChangesAsync();
 }