private void LoadTask(Task task = null)
        {
            IsRightResult = false;
            UserQuery     = "";
            ResultList    = null;

            if (task != null)
            {
                _sheme = TrainSQL_Commands.GetDbSheme(task.dbID);

                TaskInfo = $"#{task.TaskID} " + task.TaskText;
                if (_sheme != null)
                {
                    DBImage = Helper.BytesToBitmapImage(_sheme.ShemeImg);
                    DBInfo  = _sheme.Info;
                }
            }
            else
            {
                if (tasks.Count() > 1)
                {
                    TrainSQL_Commands.AddUserProgress(CurrentUser.Login, _rightAnswersCount, tasks.Count());

                    MessageBox.Show($"Ваш результат: {_rightAnswersCount}/{tasks.Count()}");
                }
                Mediator.Inform("LoadUserMainPage", CurrentUser.Login);
            }
        }
        private object[] ExecuteQuery(string query)
        {
            Task currTask = tasks[_index];

            object res = TrainSQL_Commands.IsCorrectQuery(query, currTask);

            if (res is object[] values &&
                values.Length == 2)
            {
                return(values);
            }

            return(null);
        }
        private void GetTheme(int themeIndex = 0)
        {
            _currentTheme = TrainSQL_Commands.ShowTheme(themeIndex);
            if (_currentTheme != null)
            {
                UpdateContent(_currentTheme.ThemeID, _currentTheme.ThemeName, _currentTheme.Theory);

                if (_themeIndex > themeIndex)
                {
                    _themeIndex--;
                }
                else if (_themeIndex < themeIndex)
                {
                    _themeIndex++;
                }
            }
        }
 public TheoryPageViewModel(int themeID = 0)
 {
     _themeIndex = TrainSQL_Commands.GetThemeIndex(themeID);
     GetTheme(_themeIndex);
 }
 public TaskDecisionPageViewModel(int count = 5)
 {
     tasks = TrainSQL_Commands.GetTestList(count);
     LoadTask(tasks[_index]);
 }
示例#6
0
        public UserMainPageViewModel(string login = "")
        {
            if (login != "")
            {
                // поиск пользователя в БД
                _user = TrainSQL_Commands.FindUser(login);

                // получение данных пользователя
                UserPhoto = Helper.BytesToBitmapImage(_user.Photo);
                UserLogin = _user.Login;
                UserEmail = _user.UserEmail;
                UserRole  = TrainSQL_Commands.GetUserRole(_user);

                // прогресс пользователя
                List <Progress> progress = TrainSQL_Commands.GetUserProgress(UserLogin);

                // проверка, прошёл ли пользователь хотя бы 1 тест
                if (progress != null && progress.Count() > 1)
                {
                    Items = new ObservableCollection <BaseCoordinate>();

                    // построение графика прогресса пользователя
                    for (int i = 0; i < progress.Count - 1; i++)
                    {
                        // создание новой линии
                        LineVM line = new LineVM()
                        {
                            X1 = i * 70,
                            Y1 = 210 - progress[i].RightAnswersQuantity * 32,
                            X2 = (i + 1) * 70,
                            Y2 = 210 - progress[i + 1].RightAnswersQuantity * 32
                        };

                        // выбор цвета линии на графике
                        if (line.Y1 > line.Y2)
                        {
                            line.StrokeColor = Brushes.Lime; // зелёный - результаты улучшились
                        }
                        else if (line.Y1 < line.Y2)
                        {
                            line.StrokeColor = Brushes.Red; // красный - результаты ухудшились
                        }
                        else
                        {
                            line.StrokeColor = Brushes.Gold; // жёлтый - - результаты не изменились
                        }
                        // добавление линии в коллекцию
                        Items.Add(line);

                        // добавление даты прохождения теста
                        Items.Add(new TextBlockVM()
                        {
                            Left    = 70 * i + 40,
                            Top     = 210,
                            TextOut = progress[i + 1].TestDate.ToString()
                        });
                    }

                    CanWidth = 75 * progress.Count();
                }
            }
        }