public QuizzesController(QuizContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Esempio n. 2
0
 public GradesController(QuizContext context)
 {
     _context = context;
 }
 public CategoriesController(QuizContext context)
 {
     _context = context;
 }
Esempio n. 4
0
 public QuizDetailController(QuizContext context)
 {
     _context = context;
 }
Esempio n. 5
0
 public QuestionsController(QuizContext context)
 {
     this.context = context;
 }
Esempio n. 6
0
 public EfUnitOfWork()
 {
     _db = new QuizContext();
 }
Esempio n. 7
0
 public HomeController(/*Microsoft.AspNetCore.Identity.UserManager<IdentityUser> userManager,*/ QuizContext db)
 {
     this.db = db;
 }
Esempio n. 8
0
 public ScoresController(QuizContext context, UserManager <User> _userManager)
 {
     _context    = context;
     userManager = _userManager;
 }
        // ReSharper disable once UnusedMember.Global
        public void Configure(
            IApplicationBuilder app,
            IHostingEnvironment env,
            ILoggerFactory loggerFactory,
            QuizContext context)
        {
            context.Database.Migrate();

            loggerFactory.AddConsole(LogLevel.Information);


            //if (env.IsDevelopment())
            //{
            app.UseDeveloperExceptionPage();
            //}

            app.UseStaticFiles();
            if (env.IsDevelopment() == false)
            {
                //Enforce HTTPS
                //Enable App Insights
                //Enable custom error pages
            }

            //app.UseCookieAuthentication();

            //app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
            //{
            //    ClientId = Configuration["AzureAd:ClientId"],
            //    Authority = Configuration["AzureAd:Authority"],
            //    CallbackPath = Configuration["AzureAd:CallbackPath"],
            //    TokenValidationParameters = new TokenValidationParameters()
            //    {
            //        ValidateIssuer = false
            //    }
            //});
            app.UseJwtBearerAuthentication(new JwtBearerOptions
            {
                AutomaticAuthenticate = true,
                AutomaticChallenge    = true,
                Authority             = Configuration["AzureAd:Authority"],
                Audience = Configuration["AzureAd:Audience"],
                TokenValidationParameters = new TokenValidationParameters()
                {
                    ValidateIssuer = false
                }
            });

            app.UseSession();
            app.UseSignalR();

            app.UseMvc(routes =>
            {
                routes.MapRoute("default", "{*url}", new
                {
                    controller = "Home",
                    action     = "Index"
                });
            });

            //app.UseWebSockets();
        }
Esempio n. 10
0
 public QuizUsersController(QuizContext context)
 {
     _context = context;
 }
Esempio n. 11
0
 public ContestantsApiKeyAuthAttribute(QuizContext context)
 {
     this.quizContext = context;
 }
Esempio n. 12
0
 public QuestionController(QuizContext context)
 {
     _context = context;
 }
Esempio n. 13
0
 public TakeQuizModel(QuizContext context, ISessionHelper sessionHelper)
 {
     db = context;
     this.sessionHelper = sessionHelper;
 }
Esempio n. 14
0
 public SessionsController(QuizContext context)
 {
     _context = context;
 }
Esempio n. 15
0
 public TestService(QuizContext context)
 {
     _context = context;
 }
Esempio n. 16
0
 public QuizRepository(QuizContext quizContext)
 {
     this.quizContext = quizContext;
 }
Esempio n. 17
0
        public AttemptFilterView Filter(QuizContext cx, ApplicationUser user)
        {
            CurrentUser = user;

            var users = new HashSet <ApplicationUser>();

            foreach (var group in cx.Groups.Where(x => x.Creator.Id == user.Id).ToList())
            {
                foreach (var applicationUser in group.ApplicationUsers)
                {
                    users.Add(applicationUser);
                }
            }

            var userIds = users.Select(x => x.Id).ToList();

            var filteringData = cx.QuizAttempts.
                                Where(x => x.User.Id == user.Id ||
                                      userIds.Contains(user.Id) ||
                                      x.Quiz.User.Id == user.Id).ToList();

            filteringData = filteringData.
                            Where(x => _Filter(x)).
                            ToList();

            int pagesCount = 0;

            int lastPagePushSize = filteringData.Count % PageSize;

            //last has all size OR Count == 0
            if (lastPagePushSize == 0)
            {
                pagesCount = filteringData.Count / PageSize;
                //Count == 0
                if (pagesCount == 0)
                {
                    pagesCount = 1;
                }
                else
                {
                    lastPagePushSize = PageSize;
                }
            }
            else
            {
                pagesCount = filteringData.Count / PageSize + 1;
            }

            if (Page > pagesCount)
            {
                //bag
                Page = 1;
            }

            var data = filteringData.GetRange((Page - 1) * PageSize,
                                              Page == pagesCount ? lastPagePushSize : PageSize);

            //quizzes - my + which i passed
            var attempts = cx.QuizAttempts.Where(x => x.User.Id == CurrentUser.Id).ToList();
            var quizIds  = attempts.Select(x => x.Quiz.Id).ToList();

            //groups - my + opened!!!!!!!!!!!!!!!!!!!!!!!!!!!
            var openedIds = user.Groups.Select(x => x.Id).ToList();

            var result = new AttemptFilterView()
            {
                Filters = this,
                Data    = data,
                Quizzes = cx.Quizzes.Where(x => x.User.Id == user.Id ||
                                           quizIds.Contains(x.Id)).ToList(),
                Groups = cx.Groups.Where(x => x.Creator.Id == user.Id ||
                                         openedIds.Contains(x.Id)),
                Users      = users,
                PagesCount = pagesCount
            };

            return(result);
        }
Esempio n. 18
0
 public TopicsRepository(QuizContext quizContext)
 {
     _context = quizContext
                ?? throw new ArgumentNullException(nameof(quizContext));
 }
Esempio n. 19
0
 protected DataService(QuizContext context)
 {
     _context = context;
 }
Esempio n. 20
0
 public UserRepository()
 {
     db = new QuizContext();
 }
Esempio n. 21
0
 public HomeController(QuizContext context)
 {
     db = context;
 }
Esempio n. 22
0
        public static ExamViewModal CalculateResultData(ExamViewModal examViewModal)
        {
            int correctAnswercount = 0;
            int WrongAnswerCount   = 0;
            int NoAnswerCount      = 0;

            foreach (QuestionViewModel qvmodel in examViewModal.QuestionSheet)
            {
                var question = QuizAPI.Repository.QuestionRepository.GetQuestion(qvmodel.QuestionId);

                qvmodel.CorrectAnswer = question.CorrectAnswerIndex;

                int knowledgeareaid = question.KnowledgeAreaId;



                if (qvmodel.UserAnswer.Trim() == "")
                {
                    qvmodel.isCorrect = "S";
                    NoAnswerCount++;
                }
                else
                {
                    if (qvmodel.UserAnswer.Trim() == qvmodel.CorrectAnswer.Trim())
                    {
                        qvmodel.isCorrect = "Y";
                        correctAnswercount++;
                    }
                    else
                    {
                        qvmodel.isCorrect = "N";
                        WrongAnswerCount++;
                    }
                }


                var asd = from cnt in examViewModal.ExamKnowledgeViewModals
                          where cnt.KnowledgeAreaID == knowledgeareaid
                          select cnt;
                foreach (var element in asd)
                {
                    if (qvmodel.isCorrect == "Y")
                    {
                        element.CorrectAnswerCount = element.CorrectAnswerCount + 1;
                    }
                    else if (qvmodel.isCorrect == "S")
                    {
                        element.NoAnswerCount = element.NoAnswerCount + 1;
                    }
                    else if (qvmodel.isCorrect == "N")
                    {
                        element.WrongAnswersCount = element.WrongAnswersCount + 1;
                    }
                }
            }



            examViewModal.correctAnswercount = correctAnswercount;
            examViewModal.WrongAnswerCount   = WrongAnswerCount;
            examViewModal.NoAnswerCount      = NoAnswerCount;

            examViewModal.TotalMark    = correctAnswercount * examViewModal.MarkPerQstn;
            examViewModal.Negativemark = WrongAnswerCount * examViewModal.NegativemarkPerQstn;

            examViewModal.FinalMark = examViewModal.TotalMark - examViewModal.Negativemark;



            using (QuizContext cntxt = new QuizContext())
            {
                CandidateResult canreslt = new CandidateResult();
                canreslt.CandidateId        = examViewModal.Candidateviewmodal.CandidateId;
                canreslt.ExamTableMainId    = examViewModal.ExamTableMainId;
                canreslt.correctAnswercount = examViewModal.correctAnswercount;
                canreslt.WrongAnswerCount   = examViewModal.WrongAnswerCount;
                canreslt.NoAnswerCount      = examViewModal.NoAnswerCount;
                canreslt.UsedMinutes        = examViewModal.UsedMinutes;
                canreslt.TotalQuestion      = examViewModal.TotalQuestion;
                canreslt.TotalMark          = examViewModal.TotalMark;
                canreslt.Negativemark       = examViewModal.Negativemark;
                canreslt.FinalMark          = examViewModal.FinalMark;
                canreslt.ExamDate           = DateTime.Now;
                cntxt.CandidateResults.Add(canreslt);
                cntxt.SaveChanges();

                foreach (ExamKnowledgeViewModal knwmdl in examViewModal.ExamKnowledgeViewModals)
                {
                    CandidateResultDetail canresltdet = new CandidateResultDetail();
                    canresltdet.CandidateResultId  = canreslt.CandidateResultId;
                    canresltdet.KnowledgeAreaID    = knwmdl.KnowledgeAreaID;
                    canresltdet.TotalQstn          = knwmdl.TotalQstn;
                    canresltdet.WrongAnswersCount  = knwmdl.WrongAnswersCount;
                    canresltdet.NoAnswerCount      = knwmdl.NoAnswerCount;
                    canresltdet.CorrectAnswerCount = knwmdl.CorrectAnswerCount;
                    cntxt.CandidateResultDetails.Add(canresltdet);
                    cntxt.SaveChanges();
                }
            }



            return(examViewModal);
        }
Esempio n. 23
0
 public QuizzesController(QuizContext context)
 {
     _context = context;
 }
Esempio n. 24
0
        private async void cntnBtn_Clicked(object sender, EventArgs e)
        {
            if (!rightOption.IsChecked && !wrongOption1.IsChecked && !wrongOption2.IsChecked && !wrongOption3.IsChecked)
            {
                uint timeout = 50;

                await cntnBtn.TranslateTo(-15, 0, timeout);

                await cntnBtn.TranslateTo(15, 0, timeout);

                await cntnBtn.TranslateTo(-10, 0, timeout);

                await cntnBtn.TranslateTo(10, 0, timeout);

                await cntnBtn.TranslateTo(-5, 0, timeout);

                await cntnBtn.TranslateTo(5, 0, timeout);

                cntnBtn.TranslationX = 0;
            }

            else if (rightOption.IsChecked)
            {
                cntnBtn.IsEnabled = false;

                Color color = Color.FromHex("#5DFC0A");
                cntnBtn.Text            = "Correct!";
                cntnBtn.BackgroundColor = color;

                AudioService audio = new AudioService();
                audio.PlayAudioFile("correct.mp3");

                App.counter++;

                using (QuizContext context = new QuizContext())
                {
                    var button = context.Buttons.First(a => a.Id == 2);
                    button.Passed     = true;
                    button.DoneBefore = true;

                    context.SaveChanges();
                }

                await Task.Delay(1300);

                await Navigation.PushModalAsync(new State.IntroPassed());
            }
            else
            {
                using (QuizContext context = new QuizContext())
                {
                    var button = context.Buttons.First(a => a.Id == 2);

                    button.Passed = false;
                    context.SaveChanges();
                }

                cntnBtn.IsEnabled = false;

                Color color = Color.FromHex("#FF0000");
                cntnBtn.Text            = "Wrong!";
                cntnBtn.BackgroundColor = color;

                AudioService audio = new AudioService();
                audio.PlayAudioFile("wrong.mp3");

                await Task.Delay(1300);

                await Navigation.PushModalAsync(new State.IntroFailed());
            }
        }
Esempio n. 25
0
 public Handler(QuizContext context)
 {
     this.context = context;
 }
Esempio n. 26
0
 /// <summary>
 /// Class constructor
 /// </summary>
 /// <param name="context"></param>
 public QuestionsController(QuizContext context)
 {
     //Sets the context
     this.context = context;
 }
Esempio n. 27
0
 public TestRepository(QuizContext context)
 {
     _db = context;
 }
 public QuizService(QuizContext context)
 {
     this._quizContext = context;
 }
Esempio n. 29
0
 public QuestionsController(QuizContext quizContext, ILogger <QuestionsController> logger)
 {
     _logger      = logger;
     _quizContext = quizContext;
 }
Esempio n. 30
0
 public QuestionController(QuizContext context, UserManager <User> user)
 {
     quizContext = context;
     userManager = user;
 }