void openPage(object selectedObject)
        {
            try
            {
                if (selectedObject == null || selectedObject.GetType() != typeof(StudentsPageModel))
                {
                    return;
                }

                var student = selectedObject as StudentsPageModel;

                if (_title == CrossLocalization.Translate("practice_mark"))
                {
                    _services.Navigation.OpenAddSingleMark(_title, student.Name, practiceVisitingList, _takedLabs, selSubGroup);
                }
                else if (_title == CrossLocalization.Translate("stats_page_labs_rating"))
                {
                    _services.Navigation.OpenAddSingleMark(_title, student.Name, labsVisitingList, _takedLabs, selSubGroup);
                }
            }
            catch (Exception ex)
            {
                AppLogs.Log(ex);
            }
        }
 SettingsPageModel createItem(string icon, string localizedKey)
 {
     return(new SettingsPageModel {
         Icon = icon,
         Title = CrossLocalization.Translate(localizedKey)
     });
 }
Ejemplo n.º 3
0
        protected StatsPageEnum getPageToOpen(string pageString)
        {
            var labsRatingString       = CrossLocalization.Translate("stats_page_labs_rating");
            var labsVisitingString     = CrossLocalization.Translate("stats_page_labs_visiting");
            var practiseVisitingString = CrossLocalization.Translate("practiсe_visiting");
            var practiseRatingString   = CrossLocalization.Translate("practice_mark");

            if (pageString.Equals(labsRatingString))
            {
                return(StatsPageEnum.LabsRating);
            }
            else if (pageString.Equals(labsVisitingString))
            {
                return(StatsPageEnum.LabsVisiting);
            }
            else if (pageString.Equals(practiseVisitingString))
            {
                return(StatsPageEnum.PractiseVisiting);
            }
            else if (pageString.Equals(practiseRatingString))
            {
                return(StatsPageEnum.PractiseMarks);
            }
            else
            {
                return(StatsPageEnum.LecturesVisiting);
            }
        }
Ejemplo n.º 4
0
        async Task selectServer(object selectedObject)
        {
            try {
                if (selectedObject == null || !(selectedObject is ServerPageModel))
                {
                    return;
                }

                var server = (ServerPageModel)selectedObject;

                if (!_services.Preferences.IsLoggedIn)
                {
                    changeServer(server);
                    return;
                }

                var result = await _services.Dialogs.ShowConfirmationMessage(
                    CrossLocalization.Translate("base_warning"),
                    CrossLocalization.Translate("settings_server_change_message"));

                if (!result)
                {
                    SelectedItem = null;
                    return;
                }

                changeServer(server);
                _services.Device.MainThread(() => _services.Navigation.OpenLogin());
            } catch (Exception ex) {
                AppLogs.Log(ex);
            }
        }
Ejemplo n.º 5
0
        protected async Task openParental()
        {
            if (string.IsNullOrEmpty(GroupNumber))
            {
                _service.Dialogs.ShowError(CrossLocalization.Translate("parental_error_empty_group_number"));
                return;
            }
            try
            {
                IsLoading = true;
                var result = await DataAccess.GetGroupInfo(GroupNumber);

                if (result.Code.Equals("200"))
                {
                    _service.Preferences.GroupId       = result.GroupId;
                    _service.Preferences.GroupName     = GroupNumber;
                    _service.Preferences.ChosenGroupId = result.GroupId;
                    (_service.Navigation as AppPages).OpenParentalStat(_service, result);
                }
                else
                {
                    _service.Dialogs.ShowError(CrossLocalization.Translate("parental_group_not_found"));
                }
                IsLoading = false;
            }
            catch
            {
                _service.Dialogs.ShowError(CrossLocalization.Translate("parental_connection_error"));
            }
        }
        void setTitle(TimeSpan timeLeft)
        {
            var questionDetails   = $"{_questionNumber}/{_questionCount}";
            var timeLeftFormatted = timeLeft.ToString(@"hh\:mm\:ss");

            Title = $"{CrossLocalization.Translate("question_title")} {questionDetails} ({timeLeftFormatted})";
        }
        protected async Task closePage()
        {
            try {
                var result = await _services.Dialogs.ShowConfirmationMessage(
                    CrossLocalization.Translate("base_warning"),
                    CrossLocalization.Translate("test_passing_cancel_message"));

                if (!result)
                {
                    return;
                }

                _timerCancellation = true;

                if (_isBusySpeech)
                {
                    _isBusySpeech = false;
                    _services.Device.CancelSpeech();
                }

                await _services.Navigation.ClosePage(true, false);
            } catch (Exception ex) {
                AppLogs.Log(ex);
            }
        }
        async Task setSystemOrDefaultLanguage(bool isToggled)
        {
            try {
                if (!_isSystemToggleActive || isToggled == (
                        _services.Preferences.LanguageCode == Languages.SYSTEM.LangCode))
                {
                    _isSystemToggleActive = true;
                    return;
                }

                if (!await changeLanguageConfirmation())
                {
                    IsSystemLanguage = !isToggled;
                    return;
                }

                if (isToggled)
                {
                    CrossLocalization.SetLanguage(Languages.SYSTEM.LangCode);
                    toggleLanguages(Languages.SYSTEM.LangCode);
                }
                else
                {
                    CrossLocalization.SetLanguage(Languages.EN.LangCode);
                    toggleLanguages(Languages.EN.LangCode);
                }
            } catch (Exception ex) {
                AppLogs.Log(ex);
            }
        }
        Frame createSummary()
        {
            var summaryLabel = new Label {
                Style     = AppStyles.GetLabelStyle(NamedSize.Large),
                TextColor = Color.FromHex(Theme.Current.StatisticsDetailsTitleColor),
                Text      = _statsPageEnum == StatsPageEnum.LabsRating || _statsPageEnum == StatsPageEnum.PractiseMarks ?
                            CrossLocalization.Translate("stats_summary_rating") :
                            CrossLocalization.Translate("stats_summary_visiting")
            };

            var summaryDetailsLabel = new Label {
                HorizontalOptions = LayoutOptions.EndAndExpand,
                Style             = AppStyles.GetLabelStyle(NamedSize.Large),
                TextColor         = Color.FromHex(Theme.Current.StatisticsDetailsResultsColor)
            };

            summaryDetailsLabel.SetBinding(Label.TextProperty, "Summary");

            return(new Frame {
                HasShadow = false,
                Margin = _studentNameMargin,
                BackgroundColor = Color.FromHex(Theme.Current.BaseBlockColor),
                Content = new StackLayout {
                    Orientation = StackOrientation.Horizontal,
                    Children = { summaryLabel, summaryDetailsLabel }
                }
            });
        }
Ejemplo n.º 10
0
        StackLayout createExpandableView(bool isExpand = true)
        {
            var expandTextString = isExpand ?
                                   CrossLocalization.Translate("stats_expand_chart_text") :
                                   CrossLocalization.Translate("stats_collapse_chart_text");

            var expandIconString = isExpand ?
                                   Theme.Current.StatisticsExpandIcon :
                                   Theme.Current.StatisticsCollapseIcon;

            var expandLabel = createExpandLabel(expandTextString);
            var expandIcon  = createExpandIcon(expandIconString);

            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, "ExpandCommand");

            return(new StackLayout {
                Padding = _expandableViewPadding,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                GestureRecognizers =
                {
                    tapGestureRecognizer
                },
                Children =
                {
                    expandLabel,
                    expandIcon
                }
            });
        }
        Grid createButtonLayout()
        {
            var acceptButton = createButton(
                CrossLocalization.Translate("test_passing_answer"),
                "AnswerCommand");

            var skipButton = createButton(
                CrossLocalization.Translate("test_passing_skip"),
                "SkipCommand");

            var buttonGridLayout = new Grid {
                HeightRequest     = _buttonGridHeight,
                VerticalOptions   = LayoutOptions.EndAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = _buttonGridPadding,
                BackgroundColor   = Color.FromHex(Theme.Current.BaseBlockColor),
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            buttonGridLayout.Children.Add(skipButton, 0, 0);
            buttonGridLayout.Children.Add(acceptButton, 1, 0);
            return(buttonGridLayout);
        }
Ejemplo n.º 12
0
        public SavePracticeAndLabsPageView(string title, int subjectId, int groupId)
        {
            _title = title;
            var httpContent = new StringContent("", Encoding.UTF8, "application/json");

            BackgroundColor = Color.FromHex(Theme.Current.AppBackgroundColor);
            Padding         = _padding;
            NavigationPage.SetHasNavigationBar(this, false);
            if (_title == CrossLocalization.Translate("practice_mark"))
            {
                string link       = Links.GetParticialsMarks;
                var    groupItems = new GroupAndSubjModel();
                groupItems.GroupId   = groupId;
                groupItems.SubjectId = subjectId;
                var body = JsonConvert.SerializeObject(groupItems);
                httpContent = new StringContent(body, Encoding.UTF8, "application/json");
                var obj = requestDataAsync(link, httpContent);
                practicMarksList = JsonConvert.DeserializeObject <LabsVisitingList>(obj.Result.ToString());
                BindingContext   = new SavePracticeAndLabsPageViewModel(new PlatformServices(), subjectId, practicMarksList, groupId, title);
                createViews();
            }
            else if (_title == CrossLocalization.Translate("stats_page_labs_rating"))
            {
                string link = Links.GetLabsCalendarData + "subjectId=" + subjectId + "&groupId=" + groupId;
                var    obj  = requestDataAsync(link, httpContent);
                labMarksList   = JsonConvert.DeserializeObject <LabsVisitingList>(obj.Result.ToString());
                BindingContext = new SavePracticeAndLabsPageViewModel(new PlatformServices(), subjectId, labMarksList, groupId, title);
                createLabsMarks();
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Open page by ID.
        /// </summary>
        /// <param name="id">Card ID.</param>
        void openPageById(int id)
        {
            switch (id)
            {
            case 0:
                _services.Navigation.OpenTesting(
                    CrossLocalization.Translate("learning_card_tests"));
                break;

            case 1:
                _services.Navigation.OpenEemc(
                    CrossLocalization.Translate("learning_card_eemc"));
                break;

            case 2:
                _services.Navigation.OpenFiles(
                    CrossLocalization.Translate("learning_card_files"));
                break;

            case 3:
                _services.Navigation.OpenRecommendations(
                    CrossLocalization.Translate("learning_card_adaptive"));
                break;
            }
        }
Ejemplo n.º 14
0
        StackLayout createBodyLayout()
        {
            var releaseNotesButton = createButton(
                CrossLocalization.Translate("settings_about_release_notes"),
                "ReleaseNotesCommand");

            var sendLogsButton = createButton(
                CrossLocalization.Translate("settings_about_send_logs"),
                "SendLogsCommand");

            var openGithubButton = createButton(
                CrossLocalization.Translate("settings_about_open_source"),
                "OpenSourceCommand");

            var openWebPageButton = createButton(
                CrossLocalization.Translate("settings_about_open_web_version"),
                "OpenWebSiteCommand");

            return(new StackLayout {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children =
                {
                    releaseNotesButton,
                    sendLogsButton,
                    openGithubButton,
                    openWebPageButton,
                    createContributorsBlock()
                }
            });
        }
        async Task answerQuestion(TestAnswerPostModel answerModel, bool isAuto = false)
        {
            try {
                if (answerModel == null || answerModel.Answers == null || answerModel.Answers.Count == 0)
                {
                    _services.Dialogs.ShowError(CrossLocalization.Translate("answer_question_not_selected_error"));
                    return;
                }

                await DataAccess.AnswerQuestionAndGetNext(answerModel);

                if (DataAccess.IsError)
                {
                    _services.Dialogs.ShowError(DataAccess.ErrorMessage);
                    return;
                }

                if (!isAuto)
                {
                    _questionsLeft--;
                }

                await getAndSetQuestion(getNextQuestion());
            } catch (Exception ex) {
                AppLogs.Log(ex);
            }
        }
        async Task selectTheme(object selectedObject)
        {
            try {
                SelectedItem = null;

                if (selectedObject == null || !(selectedObject is ThemePageModel))
                {
                    return;
                }

                var theme = selectedObject as ThemePageModel;

                var result = await _services.Dialogs.ShowConfirmationMessage(
                    CrossLocalization.Translate("base_warning"),
                    CrossLocalization.Translate("settings_theme_change_message"));

                if (!result)
                {
                    return;
                }

                changeTheme(theme);
                switchPage();
            } catch (Exception ex) {
                AppLogs.Log(ex);
            }
        }
 ThemePageModel getThemeDetails(string theme)
 {
     return(new ThemePageModel {
         Theme = theme,
         Title = CrossLocalization.Translate(theme?.ToLower()),
         IsChecked = _services.Preferences.Theme == theme
     });
 }
 string getTitle(StatsPageEnum pageType)
 {
     return(pageType switch
     {
         StatsPageEnum.LabsRating => CrossLocalization.Translate("stats_page_labs_rating"),
         StatsPageEnum.LabsVisiting => CrossLocalization.Translate("stats_page_labs_visiting"),
         _ => CrossLocalization.Translate("stats_page_lectures_visiting"),
     });
Ejemplo n.º 19
0
 Label createContributorLabel(string localizedKey, bool bold = false)
 {
     return(new Label {
         Style = AppStyles.GetLabelStyle(bold: bold),
         HorizontalTextAlignment = TextAlignment.Center,
         Text = CrossLocalization.Translate(localizedKey),
         TextColor = Color.FromHex(Theme.Current.AboutTextColor)
     });
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Set downloading.
 /// </summary>
 void setDownloading()
 {
     PlatformServices.Device.MainThread(() => {
         _progressDialog = PlatformServices.Dialogs.ShowProgress(
             CrossLocalization.Translate("files_downloading"),
             CrossLocalization.Translate("base_cancel"),
             () => abortDownload());
     });
 }
Ejemplo n.º 21
0
 ServerPageModel getServerDetails(string serverAddress, string descriptionLocalizedKey)
 {
     return(new ServerPageModel {
         Address = serverAddress,
         Title = Servers.GetServerType(serverAddress),
         Description = CrossLocalization.Translate(descriptionLocalizedKey),
         IsChecked = _services.Preferences.Server == serverAddress
     });
 }
 protected async Task openSettings()
 {
     try {
         await _services.Navigation.OpenSettings(
             CrossLocalization.Translate("main_settings"));
     } catch (Exception ex) {
         AppLogs.Log(ex);
     }
 }
        void setInitData()
        {
            Username   = _services.Preferences.UserLogin;
            IsLoggedIn = _services.Preferences.IsLoggedIn;
            Avatar     = _services.Preferences.Avatar;
            var isProfessor = string.IsNullOrEmpty(_services.Preferences.GroupName);

            Group = isProfessor ? null : _services.Preferences.GroupName;
            Role  = CrossLocalization.Translate(isProfessor ? "role_professor" : "role_student");
        }
 Label createTimePassedLabel()
 {
     return(new Label {
         HorizontalTextAlignment = TextAlignment.Center,
         HorizontalOptions = LayoutOptions.CenterAndExpand,
         Style = AppStyles.GetLabelStyle(NamedSize.Medium),
         TextColor = Color.FromHex(Theme.Current.TestResultsRatingColor),
         Text = $"{CrossLocalization.Translate("test_results_time")} {_timePassed}"
     });
 }
 Label createRatingTitleLabel()
 {
     return(new Label {
         TextColor = Color.FromHex(Theme.Current.BaseSectionTextColor),
         HorizontalTextAlignment = TextAlignment.Center,
         HorizontalOptions = LayoutOptions.CenterAndExpand,
         Text = CrossLocalization.Translate("test_results_label"),
         Style = AppStyles.GetLabelStyle()
     });
 }
 public TestingResultsPageView(int testId, bool fromComplexLearning, string timePassed = null)
 {
     _timePassed     = timePassed;
     BackgroundColor = Color.FromHex(Theme.Current.AppBackgroundColor);
     Title           = CrossLocalization.Translate("test_results_title");
     BindingContext  = new TestingResultsPageViewModel(
         testId, fromComplexLearning, new PlatformServices());
     createToolbar();
     createViews();
 }
        public NewsDetailsPageView(string title, string body)
        {
            Title = CrossLocalization.Translate("news_details_title");
            var dynSize = FontSizeController.GetDynamicSize(_bodyFontSize);

            _services      = new PlatformServices();
            BindingContext = new NewsDetailsPageViewModel(dynSize, title, body, _services);
            setToolbar();
            createViews();
        }
Ejemplo n.º 28
0
 Label createChooseLabel()
 {
     return(new Label {
         Margin = _chooseLabelMargin,
         FontAttributes = FontAttributes.Bold,
         TextColor = Color.FromHex(Theme.Current.BaseSectionTextColor),
         Text = CrossLocalization.Translate("settings_theme_choose"),
         Style = AppStyles.GetLabelStyle(NamedSize.Large, true)
     });
 }
Ejemplo n.º 29
0
 public SaveMarksPageViewModel(IPlatformServices services, int _subjectId, object stat, int groupId, string title)
 {
     _titleOfPage = title;
     _services    = services;
     if (title == CrossLocalization.Translate("stats_page_lectures_visiting"))
     {
         groupData = stat as VisitingLecturesList;
         createLecturesVisitingPage(groupData);
     }
     else if (title == CrossLocalization.Translate("stats_page_labs_visiting"))
     {
         labsVisitingList = stat as LabsVisitingList;
         _takedLabs       = new TakedLabs();
         WebRequest request = WebRequest.Create(Links.GetLabsTest + "subjectId=" + _subjectId + "&groupId=" + groupId);
         request.Headers.Add("Authorization", _services.Preferences.AccessToken);
         WebResponse response = request.GetResponse();
         string      json     = "";
         using (Stream stream = response.GetResponseStream())
         {
             using (StreamReader reader = new StreamReader(stream))
             {
                 string line = "";
                 while ((line = reader.ReadLine()) != null)
                 {
                     json += line;
                 }
             }
         };
         _takedLabs = JsonConvert.DeserializeObject <TakedLabs>(json);
         createLabsVisitingPage(labsVisitingList);
     }
     else if (title == CrossLocalization.Translate("practiсe_visiting"))
     {
         subjectId            = _subjectId;
         practiceVisitingList = stat as LabsVisitingList;
         _takedLabs           = new TakedLabs();
         WebRequest request = WebRequest.Create(Links.GetPracticialsTest + "subjectId=" + _subjectId + "&groupId=" + groupId);
         request.Headers.Add("Authorization", _services.Preferences.AccessToken);
         WebResponse response = request.GetResponse();
         string      json     = "";
         using (Stream stream = response.GetResponseStream())
         {
             using (StreamReader reader = new StreamReader(stream))
             {
                 string line = "";
                 while ((line = reader.ReadLine()) != null)
                 {
                     json += line;
                 }
             }
         };
         _takedLabs = JsonConvert.DeserializeObject <TakedLabs>(json);
         createPracticialsVisitingPage(practiceVisitingList);
     }
 }
Ejemplo n.º 30
0
 Label createSubjectsLabel()
 {
     return(new Label {
         BackgroundColor = Color.FromHex(Theme.Current.AppBackgroundColor),
         Padding = _subjectsLabelMargin,
         FontAttributes = FontAttributes.Bold,
         TextColor = Color.FromHex(Theme.Current.BaseSectionTextColor),
         Text = CrossLocalization.Translate("today_subjects"),
         Style = AppStyles.GetLabelStyle(NamedSize.Large, true)
     });
 }