Example #1
0
        public static void ReportSolution(int evaluation, Solution sol, BackgroundWorker worker)
        {
            var progress = new UserProgress
            {
                EvolutionStep = evaluation
            };


            var list = ObjectiveMapping.GetList(_model.ProblemType);

            var objindex = 0;

            if (list[0])
            {
                progress.FeatureP = sol.Objective[objindex];
                objindex++;
            }
            if (list[1])
            {
                progress.InteracP = sol.Objective[objindex];
                objindex++;
            }
            if (list[2])
            {
                progress.VariantP = sol.Objective[objindex];
            }

            worker.ReportProgress((int)100.0 * evaluation / _model.Setting.MaxEvaluations, progress);
        }
Example #2
0
        public async Task <IHttpActionResult> Post()
        {
            try
            {
                string UserName = User.Identity.Name;

                API_UserInfo UserInfo = new API_UserInfo();


                UserInfo DBUserInfo = await db.UserInfoes.FirstOrDefaultAsync(e => e.UserName == UserName);

                UserProgress UserProgress = await UserGet.Progress(UserName, DBUserInfo.LevelId, "ru");

                UserInfo.Name     = DBUserInfo.Fname;
                UserInfo.SureName = DBUserInfo.Lname;
                UserInfo.Image    = DBUserInfo.Image;
                UserInfo.OUK      = UserProgress.OUK;
                UserInfo.TBB      = UserProgress.TBB;

                return(Json(UserInfo));
            }
            catch (Exception ex) {
                return(BadRequest(ex.Message));
            }
        }
        public IActionResult ShowNextLesson(int lessonId)
        {
            String       userName = User.Identity.Name;
            UserProgress user     = upS.getUserProgressByUserId(uS.getUserId(userName));

            if (user == null)
            {
                upS.ChangProgress(uS.getUserId(userName), lessonId);
            }
            else
            {
                if (user.Id_Lesson_Learned < lessonId)
                {
                    upS.ChangProgress(uS.getUserId(userName), lessonId);
                }
            }

            int    nextLes = lessonId + 1;
            Lesson lesson  = qS.getLessonById(nextLes);

            if (lesson == null)
            {
                User User = uS.getUser(userName);

                return(View("Final", User));
            }
            else
            {
                return(RedirectToAction("ShowLesson", "Lessons", new { id = nextLes }));
            }
        }
Example #4
0
        public TestReportViewModel()
        {
            BackToHome = new Command(GoBackToHome);
            UserProgress progress = App.PritixDB.GetUserProgressForCurrentDictionary().Result;

            Score = string.Format("{0}/{1}", progress.UserMarks, progress.TotalMarks);
        }
Example #5
0
        public async Task UserProgressTest()
        {
            UserProgress entity;

            using (var dbContext = CreateContext())
            {
                var category  = dbContext.Categories.First();
                var flashcard = CreateTestFlashcard(category);
                var user      = CreateTestUser();
                dbContext.Flashcards.Add(flashcard);
                dbContext.Users.Add(user);
                entity = new UserProgress(user, flashcard);
                var repository = new Repository <UserProgress>(dbContext);

                await repository.Add(entity);

                dbContext.SaveChanges();
            }

            using (var dbContext = CreateContext())
            {
                var repository = new Repository <UserProgress>(dbContext);
                Assert.IsTrue(repository.GetAll().Any(e => e.UserId == entity.UserId && e.FlashcardId == entity.FlashcardId));
            }
        }
Example #6
0
 private void ReportProgress(Solution solution, FitnessValues values)
 {
     if (Model.Setting.ChiAndCmv || Model.Setting.EuclAndCmv)
     {
         Worker.ReportProgress(
             (int)(_counter * 100 / (double)Model.Setting.MaxEvaluations),
             new UserProgress
         {
             FeatureCmV    = solution.Objective[0],
             VariantCmV    = solution.Objective[1],
             InteracCmV    = solution.Objective[2],
             FeatureP      = solution.Objective[3],
             VariantP      = solution.Objective[4],
             EvolutionStep = _counter,
         });
     }
     else
     {
         var p = new UserProgress
         {
             FeatureP      = values.FeatureVal,
             EvolutionStep = _counter,
         };
         if (Model.Setting.NumberOfInteractions > 0)
         {
             p.InteracP = values.InteracVal;
         }
         if (!Model.Setting.NoVariantCalculation)
         {
             p.VariantP = values.VariantVal;
         }
         Worker.ReportProgress(
             (int)(_counter * 100 / (double)Model.Setting.MaxEvaluations), p);
     }
 }
Example #7
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            if (context.HttpContext.Session.TryGetValue(Constants.SessionKeyName, out var sessionId))
            {
                var debugGuid = Encoding.UTF8.GetString(sessionId).Replace("\"", "");
                var guidGood  = Guid.TryParse(debugGuid, out var cronosGuid);

                if (guidGood)
                {
                    if (_memoryCache.TryGetValue(cronosGuid, out UserProgress cronosState))
                    {
                        CronosState = cronosState;
                    }
                    else
                    {
                        //Alert user that session expired and they'll have to start over
                        TempData[Constants.ArtistErrorMessage] =
                            "Your session has been reset due to inactivity.  Please start again.";
                        CronosState = new UserProgress {
                            Id = cronosGuid
                        };
                        RedirectToAction("SelectArtist", "Home");
                    }
                }
            }
            else
            {
                CronosState = new UserProgress {
                    Id = Guid.NewGuid()
                };
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Date,Weight,WaistMeasurements,ArmMeasurements,LegMeasurements")] UserProgress userProgress)
        {
            if (id != userProgress.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userProgress);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserProgressExists(userProgress.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(userProgress));
        }
Example #9
0
        // GET: VIDEOS---------------------------------------------------------------------
        public async Task <ActionResult> Videos(string language)
        {
            try
            {
                string UserName = GetUserName();
                if (language == null)
                {
                    language = "ru";
                }


                UserInfo userinfo = await db.UserInfoes.FirstOrDefaultAsync(e => e.UserName == UserName);

                UserProgress UserProgress = await UserGet.Progress(UserName, userinfo.LevelId, language);


                ViewBag.OUK      = UserProgress.OUK;
                ViewBag.TBB      = UserProgress.TBB;
                ViewBag.language = language;

                List <Webinar_VideoL> VideoLessons = await db.Webinar_VideoL.Where(e => e.language == language).OrderByDescending(e => e.XId).ToListAsync();

                return(View(VideoLessons));
            }
            catch { }

            string ActionName = "Trainig-Videos";


            return(RedirectToAction("ErrorLogOff", "Account", new { language = language, ActionName = ActionName }));
        }
 public void UpgradeBlock(BlockData data)
 {
     UserProgress.DecreaseUpgradePoints();
     data.UpgradeCurrentMaxLevel();
     UserProgress.Save();
     upgradesBlocksArea.UpgradeBlock();
     UpdateUpgradePointsText();
 }
Example #11
0
    private void Start()
    {
        relatedProgress = GetComponent <UserProgress>();

        count.RelatedProgress       = relatedProgress.Count;
        spawnRate.RelatedProgress   = relatedProgress.SpawnRate;
        damage.RelatedProgress      = relatedProgress.Damage;
        attackSpeed.RelatedProgress = relatedProgress.AttackSpeed;
    }
        public async Task <IActionResult> Create([Bind("Id,Date,Weight,WaistMeasurements,ArmMeasurements,LegMeasurements")] UserProgress userProgress)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userProgress);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(userProgress));
        }
Example #13
0
        public UserProgress Progress()
        {
            var resp = new UserProgress();

            resp.UserId     = _selector.userId;
            resp.QuizId     = _selector.quizId;
            resp.Score      = _selector.score;
            resp.QuestionId = _selector.questionId;;

            return(resp);
        }
Example #14
0
        public void InsertUserProgress(UserProgressDTO userProgress)
        {
            UserProgress user = new UserProgress()
            {
                UserId   = userProgress.UserId,
                Module   = userProgress.Module,
                Progress = 0
            };

            _mongoRepository.InsertOne(user);
        }
	public static UserProgress GetUserProgress()
	{
		UserProgress _userProgress;
		_userProgress = Serializer.Deserialize<UserProgress>(UserConfigPath);

		if (_userProgress == null)
		{
			_userProgress = new UserProgress();
		}

		return _userProgress;
	}
        void SaveUserProgress()
        {
            UserProgress progressToSave = new UserProgress()
            {
                DictionaryId = App.PritixDB.CurrentDictionaryInUse.DictionaryId,
                UserMarks    = TestManager.GetInstance().GetUserTestMarks(),
                TotalMarks   = TestManager.GetInstance().GetTotalTestMarks(),
                UserId       = App.PritixDB.CurrentLoggedInUser.UserId,
                ScoreTime    = DateTime.Now
            };

            App.PritixDB.SaveUserProgress(progressToSave).Wait();
        }
    private void Start()
    {
        progress = GetComponent <UserProgress>();

        counts     = GetComponents <ICountSettable>();
        frequencys = GetComponents <IFrequencySettable>();
        damages    = GetComponents <IDamageSettable>();
        speeds     = GetComponents <ISpeedSettable>();

        Subscribe();

        Init();
    }
Example #18
0
        public async Task <IHttpActionResult> UpdateUserProgress(int courseId, int lessonId)
        {
            var progress = new UserProgress
            {
                CourseId = courseId,
                LessonId = lessonId,
                UserId   = User.Identity.GetUserId()
            };

            context.UserProgresses.Add(progress);

            await context.SaveChangesAsync();

            return(Ok(progress));
        }
        public void ChangProgress(string userId, int newLessonId)
        {
            UserProgress user = getUserProgressByUserId(userId);

            if (user == null)
            {
                UserProgress newUser = new UserProgress();
                newUser.Id_Lesson_Learned = newLessonId;
                newUser.User_ID           = userId;
                createUser(newUser);
            }
            else
            {
                user.Id_Lesson_Learned = newLessonId;
                updateUser(user);
            }
        }
        public void UpdateDictionaryDetails()
        {
            var mapping = App.PritixDB.GetUserDictMappingByDictId(App.PritixDB.CurrentDictionaryInUse.DictionaryId).Result;
            List <DictionaryDetail> dictDetails = App.PritixDB.GetDictionaryDetailsByMappingIndex(mapping.MappingIndex).Result;

            DictionaryDetails = new ObservableCollection <DictionaryDetail>(dictDetails);
            try
            {
                UserProgress progress = App.PritixDB.GetUserProgressForCurrentDictionary().Result;
                if (progress != null)
                {
                    ScoreVisibility = true;
                    Score           = string.Format("Your Latest Score is {0}/{1}", progress.UserMarks, progress.TotalMarks);
                }
            }
            catch (Exception e)
            {
            }
        }
        public async Task <IOutput> Handle(ResolvePracticeInput request, CancellationToken cancellationToken)
        {
            var practice = await _context.PracticeOrders
                           .Include(x => x.Author)
                           .Include(x => x.Lesson)
                           .FirstOrDefaultAsync(x => x.Id == request.PracticeId, cancellationToken: cancellationToken);

            if (practice is null)
            {
                return(ActionOutput.Error("Заявка на прохождение не нашлась"));
            }

            if (practice.IsDone)
            {
                return(ActionOutput.Error("Решение уже принято"));
            }

            if (practice.AuthorId == request.TeacherId)
            {
                return(ActionOutput.Error("Нельзя принять практику у себя"));
            }

            practice.IsDone     = true;
            practice.IsResolved = true;
            practice.TeacherId  = request.TeacherId;

            _context.PracticeOrders.Update(practice);

            await _context.SaveChangesAsync(cancellationToken);

            var progress = new UserProgress(practice.Author, practice.Lesson);
            await _context.Progresses.AddAsync(progress, cancellationToken);

            await _context.SaveChangesAsync(cancellationToken);

            _mailClient.SendMail(practice.Author.Mail, message =>
            {
                message.Subject = $"Практический урок {practice.Lesson.Name} пройден.";
                message.Body    = _templateCreator.GetResolveLetter(practice.Lesson.Name);
            });

            return(ActionOutput.Success);
        }
        public async Task <IOutput> Handle(AddProgressInput request, CancellationToken cancellationToken)
        {
            var user = await _context.Users
                       .FirstOrDefaultAsync(x => x.Id == request.UserId, cancellationToken : cancellationToken);

            if (user is null)
            {
                return(ActionOutput.Error("Пользователь не был найден"));
            }

            var lesson = await _context.Lessons.FindAsync(request.LessonId);

            if (lesson is null)
            {
                return(ActionOutput.Error("Урок не был найден"));
            }

            if (lesson.IsPractice)
            {
                return(ActionOutput.Error("Урок практический"));
            }

            var hasEqualProgress = await _context.Progresses
                                   .AnyAsync(x => x.UserId == user.Id && x.LessonId == lesson.Id,
                                             cancellationToken : cancellationToken);

            if (hasEqualProgress)
            {
                return(ActionOutput.Error("Данный урок уже засчитан"));
            }

            var progress = new UserProgress(user, lesson);

            await _context.Progresses.AddAsync(progress, cancellationToken);

            await _context.SaveChangesAsync(cancellationToken);

            var newUserProgresses =
                await _context.Progresses.Where(x => x.UserId == user.Id).ToListAsync(cancellationToken);

            return(ActionOutput.SuccessData(_mapper.Map <List <UserProgressView> >(newUserProgresses)));
        }
Example #23
0
            public static Result <UserProgress> Create(
                ObjectId moduleId, int level, decimal percentage, string name, int?validFor, bool videoViewed = false
                )
            {
                if (percentage < 0 || percentage > 1)
                {
                    return(Result.Fail <UserProgress>("Percentual deve ser maior que zero e menor ou igual a 1"));
                }

                var levels = Levels.Level.GetAllLevels().Data;

                if (!levels.Any(x => x.Id == level))
                {
                    return(Result.Fail <UserProgress>("Nivel de dificuldade não existe"));
                }

                var newObject = new UserProgress(moduleId, level, percentage, name, validFor, videoViewed);

                return(Result.Ok(newObject));
            }
Example #24
0
        // GET: VIDEOS---------------------------------------------------------------------
        public async Task <ActionResult> Videos(int Id, string language)
        {
            try
            {
                string UserName = GetUserName();
                if (language == null)
                {
                    language = "ru";
                }


                UserInfo userinfo = await db.UserInfoes.FirstOrDefaultAsync(e => e.UserName == UserName);

                UserProgress UserProgress = await UserGet.Progress(UserName, userinfo.LevelId, language);

                var Trainings = await db.Trainings.FindAsync(Id);

                if (Trainings == null || Trainings.Enable == false)
                {
                    return(RedirectToAction("Noaccess", "Error"));
                }

                Training_Property Training_Property = Trainings.Training_Property.FirstOrDefault(e => e.lang == language);

                ViewBag.OUK       = UserProgress.OUK;
                ViewBag.TBB       = UserProgress.TBB;
                ViewBag.ModulName = Training_Property.Titile;
                ViewBag.language  = language;

                List <Training_VideoXL> VideoXLessons = Trainings.Training_VideoXL.Where(e => e.Enable == true).OrderByDescending(e => e.XId).ToList();
                List <Training_VideoL>  VideoLessons  = VideoXLessons.Select(e => e.Training_VideoL.FirstOrDefault()).ToList();
                return(View(VideoLessons));
            }
            catch { }

            string ActionName = "Trainig-Videos";


            return(RedirectToAction("ErrorLogOff", "Account", new { language = language, ActionName = ActionName }));
        }
 void SignIn()
 {
     if (IsValidEmail)
     {
         if (string.IsNullOrEmpty(Password))
         {
             new DialogService().ShowError("Error !!", AppConstants.ERROR_MESSAGE_ALL_FIELDS_REQUIRED, "Ok", null);
         }
         else
         {
             var userInfo = App.PritixDB.GetUserByMailIdAndPassword(Email, Password).Result;
             if (userInfo != null)
             {
                 App.PritixDB.CurrentLoggedInUser = userInfo;
                 var          allprogress    = App.PritixDB.GetCurrentUserProgress().Result;
                 UserProgress latestProgress = App.PritixDB.GetUserLatestProgress().Result;
                 if (latestProgress != null)
                 {
                     Dictionary lastViewedDictionary = App.PritixDB.GetDictionaryById(latestProgress.DictionaryId).Result;
                     App.PritixDB.CurrentDictionaryInUse = lastViewedDictionary;
                     App.Current.MainPage = new NavigationPage(new DictionaryDetailsView());
                 }
                 else
                 {
                     App.Current.MainPage = new NavigationPage(new HomeView());
                 }
             }
             else
             {
                 new DialogService().ShowError("Error !!", AppConstants.ERROR_MESSAGE_USER_SIGN_IN_FAILED, "Ok", null);
             }
         }
     }
     else
     {
         new DialogService().ShowError("Error!", AppConstants.ERROR_MESSAGE_EMAIL_VALIDATION, "Ok", null);
     }
 }
Example #26
0
        // GET: MODULES--------------------------------------------------------------------
        public async Task <ActionResult> Modules(string language)
        {
            try
            {
                string UserName = GetUserName();
                if (language == null)
                {
                    language = "ru";
                }


                UserInfo userinfo = await db.UserInfoes.FirstOrDefaultAsync(e => e.UserName == UserName);

                UserProgress UserProgress = await UserGet.Progress(UserName, userinfo.LevelId, language);

                // Get User Modules
                var Trainings = await db.Trainings.Where(e => e.Enable == true).OrderBy(e => e.XId).ToListAsync();

                var trainings_properties = new List <Training_Property>();


                foreach (var training in Trainings)
                {
                    trainings_properties.Add(training.Training_Property.FirstOrDefault());
                }


                ViewBag.OUK      = UserProgress.OUK;
                ViewBag.TBB      = UserProgress.TBB;
                ViewBag.language = language;
                return(View(trainings_properties));
            }
            catch { }

            string ActionName = "Trainig-Modules";

            return(RedirectToAction("ErrorLogOff", "Account", new { language = language, ActionName = ActionName }));
        }
        public async Task ProceedFlashcard(int flashcardId, User user, FlashcardResult result)
        {
            var flashcard = await _unitOfWork.FlashcardRepository.GetById(flashcardId);

            EnsureUser(user);
            EnsureFlashcard(flashcard);

            var userProgress = await _unitOfWork.UserProgressRepository.GetById(user.Id, flashcardId);

            if (userProgress == null)
            {
                userProgress          = new UserProgress(user, flashcard);
                userProgress.Progress = CalculateNewProgress(userProgress.Progress, result);
                await _unitOfWork.UserProgressRepository.Add(userProgress);
            }
            else
            {
                userProgress.Progress = CalculateNewProgress(userProgress.Progress, result);
                _unitOfWork.UserProgressRepository.Update(userProgress);
            }

            await _unitOfWork.SaveChangesAsync();
        }
Example #28
0
        public async Task <ActionResult> certificates(string language)
        {
            try
            {
                string UserName = GetUserName();


                if (language == null)
                {
                    language = "ru";
                }
                ViewBag.language = language;


                UserInfo UserInfoOBJ = await db.UserInfoes.FirstOrDefaultAsync(e => e.UserName == UserName);

                UserProgress UserProgress = await UserGet.Progress(UserName, UserInfoOBJ.LevelId, language);

                var user_certificates = UserInfoOBJ.Users_Certificates.ToList();



                ViewBag.language = language;
                ViewBag.OUK      = UserProgress.OUK;
                ViewBag.TBB      = UserProgress.TBB;
                return(View(user_certificates));
            }
            catch
            {
            }


            string ActionName = "certificates";


            return(RedirectToAction("ErrorLogOff", "Account", new { language = language, ActionName = ActionName }));
        }
 private void UpdateUpgradePointsText()
 {
     upgradePoints.SetValue(UserProgress.GetUpgradePoints());
 }
 private void SetUpgradeButtonState()
 {
     upgradeButton.interactable = UserProgress.GetUpgradePoints() != 0;
 }
 public void updateUser(UserProgress user)
 {
     unitOfWork.UserProgress.Update(user);
     unitOfWork.Save();
 }
	public static void SaveUserProgress(UserProgress userProgress)
    {
        Serializer.Serialize(userProgress, UserConfigPath);
    }
 public void InitUserProgress()
 {
     userProgress = ConfigManager.GetUserProgress();
 }