Beispiel #1
0
		public QuizInfoModel(QuizModel model, SlideBlock currentBlock, int index, QuizState quizState)
		{
			QuizModel = model;
			CurrentBlock = currentBlock;
			BlockIndex = index;
			QuizState = quizState;
		}
Beispiel #2
0
 public QuizBlockData(QuizModel model, int index, QuizState quizState, DefaultDictionary <string, int> questionAnswersFrequency = null, bool isInstructor = false, bool debugView = false, bool isCourseAdmin = false)
 {
     QuizModel  = model;
     BlockIndex = index;
     QuizState  = quizState;
     QuestionAnswersFrequency = questionAnswersFrequency ?? new DefaultDictionary <string, int>();
     IsCourseAdmin            = isCourseAdmin;
     IsInstructor             = isInstructor;
     DebugView = debugView;
 }
Beispiel #3
0
		public ActionResult Quiz(QuizSlide slide, string courseId, string userId)
		{
			var slideId = slide.Id;
			var maxDropCount = GetMaxDropCount(slide);
			var state = GetQuizState(courseId, userId, slideId, maxDropCount);
			var resultsForQuizes = GetResultForQuizes(courseId, userId, slideId, state.Item1);
			var model = new QuizModel
			{
				CourseId = courseId,
				Slide = slide,
				QuizState = state.Item1,
				TryNumber = state.Item2,
				MaxDropCount = maxDropCount,
				ResultsForQuizes = resultsForQuizes,
				AnswersToQuizes =
					userQuizzesRepo.GetAnswersForShowOnSlide(courseId, slide,
						userId)
			};

			if (model.QuizState != QuizState.NotPassed && model.RightAnswers == model.QuestionsCount)
				model.QuizState = QuizState.Total;

			return PartialView(model);
		}
Beispiel #4
0
		public ActionResult Quiz(QuizSlide slide, string courseId, string userId, bool isGuest, bool isLti = false, ManualQuizChecking manualQuizCheckQueueItem = null, int? groupId = null)
		{
			if (isGuest)
				return PartialView(GuestQuiz(slide, courseId));
			var slideId = slide.Id;
			var maxDropCount = GetMaxDropCount(slide);
			var state = GetQuizState(courseId, userId, slideId, maxDropCount);
			var quizState = state.Item1;
			var tryNumber = state.Item2;
			var resultsForQuizes = GetResultForQuizes(courseId, userId, slideId, state.Item1);

			log.Info($"Создаю тест для пользователя {userId} в слайде {courseId}:{slide.Id}, isLti = {isLti}");

			var quizVersion = quizzesRepo.GetLastQuizVersion(courseId, slideId);
			if (quizState != QuizState.NotPassed)
				quizVersion = userQuizzesRepo.FindQuizVersionFromUsersAnswer(courseId, slideId, userId);

			/* If we haven't quiz version in database, create it */
			if (quizVersion == null)
				quizVersion = quizzesRepo.AddQuizVersionIfNeeded(courseId, slide);

			/* Restore quiz slide from version stored in the database */
			var quiz = quizVersion.RestoredQuiz;
			slide = new QuizSlide(slide.Info, quiz);

			var userAnswers = userQuizzesRepo.GetAnswersForShowOnSlide(courseId, slide, userId);
			var canUserFillQuiz = CanUserFillQuiz(quizState);

			var model = new QuizModel
			{
				CourseId = courseId,
				Slide = slide,
				QuizState = quizState,
				TryNumber = tryNumber,
				MaxDropCount = maxDropCount,
				ResultsForQuizes = resultsForQuizes,
				AnswersToQuizes = userAnswers,
				IsLti = isLti,
				ManualQuizCheckQueueItem = manualQuizCheckQueueItem,
				CanUserFillQuiz = canUserFillQuiz,
				GroupId = groupId,
			};

			if (model.QuizState != QuizState.NotPassed && model.Score == quiz.MaxScore)
				model.QuizState = QuizState.Total;

			return PartialView(model);
		}