async Task getLabs(bool isVisiting)
        {
            var dataLabs     = new LabsModel();
            var dataTestLabs = new TakedLabs();

            if (Servers.Current == Servers.EduCatsAddress)
            {
                dataTestLabs = await DataAccess.GetLabsTest(_currentSubjectId, _currentGroupId);
            }
            else
            {
                dataLabs = await DataAccess.GetLabs(_currentSubjectId, _currentGroupId);
            }

            if (dataTestLabs == null)
            {
                return;
            }

            if (dataLabs == null)
            {
                return;
            }

            if (isVisiting)
            {
                setVisitingLabsStatistics(dataLabs, dataTestLabs);
            }
            else
            {
                setRatingLabsStatistics(dataLabs, dataTestLabs);
            }
        }
        void setVisitingLabsStatistics(LabsModel dataLabs, TakedLabs takedLabs)
        {
            var labsTetsVisitingStatus = takedLabs.ScheduleProtectionLabs?.Select(
                labs => new StatsPageLabsVisitingModel(
                    labs.ScheduleProtectionLabId, labs.Date));

            var labsVisitingStatus = dataLabs.ProtectionLabs?.Select(
                labs => new StatsPageLabsVisitingModel(
                    labs.ProtectionLabId, labs.Date));

            var practVisitingStatus = takedLabs.ScheduleProtectionPracticals?.Select(
                pract => new StatsPageLabsVisitingModel(
                    pract.ScheduleProtectionPracticalId, pract.Date));


            if (_statisticsPage == StatsPageEnum.LabsVisiting)
            {
                if (Servers.Current == Servers.EduCatsAddress)
                {
                    _currentLabsVisitingList = new List <StatsPageLabsVisitingModel>(labsTetsVisitingStatus);
                }
                else
                {
                    _currentLabsVisitingList = new List <StatsPageLabsVisitingModel>(labsVisitingStatus);
                }
            }
            else
            {
                _currentPractVisitingList = new List <StatsPageLabsVisitingModel>(practVisitingStatus);
            }
        }
        void setVisitingPractStatistics(TakedLabs dataTestPract)
        {
            var practVisitingStatus = dataTestPract.ScheduleProtectionPracticals?.Select(
                pract => new StatsPageLabsVisitingModel(
                    pract.ScheduleProtectionPracticalId, pract.Date));

            _currentPractVisitingList = new List <StatsPageLabsVisitingModel>(practVisitingStatus);
        }
        void setRatingPractStatistics(TakedLabs dataTestPract)
        {
            var marksTestPractList = dataTestPract.Practicals?.Select(
                pract => new StatsPageLabsRatingModel(
                    pract.PracticalId, pract.ShortName, pract.Theme));

            _currentPractMarksList = new List <StatsPageLabsRatingModel>(marksTestPractList);
        }
示例#5
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);
     }
 }
        void setRatingLabsStatistics(LabsModel dataLabs, TakedLabs takedLabs)
        {
            var marksTestLabsList = takedLabs.Labs?.Select(
                labs => new StatsPageLabsRatingModel(
                    labs.LabId, labs.ShortName, labs.Theme));
            var marksLabsList = dataLabs.Labs?.Select(
                labs => new StatsPageLabsRatingModel(
                    labs.LabId, labs.ShortName, labs.Theme));

            if (Servers.Current == Servers.EduCatsAddress)
            {
                _currentLabsMarksList = new List <StatsPageLabsRatingModel>(marksTestLabsList);
            }
            else
            {
                _currentLabsMarksList = new List <StatsPageLabsRatingModel>(marksLabsList);
            }
        }
示例#7
0
 public SaveSingleStudentMarkPageViewModel(IPlatformServices services,
                                           string nameofLabOrPr, LabsVisitingList marks, TakedLabs prOrLabStat, string title, string _studName, int subGruop)
 {
     _subGruop   = subGruop;
     studentName = _studName;
     _title      = title;
     if (title == CrossLocalization.Translate("practice_mark"))
     {
         fullPractice = marks;
     }
     else if (title == CrossLocalization.Translate("stats_page_labs_rating"))
     {
         fullMarksLabs = marks;
     }
     _services         = services;
     _takedLabs        = prOrLabStat;
     SelectedShortName = nameofLabOrPr;
 }
        public SaveSingleStudentMarkPageView(string title, string name, LabsVisitingList marks, TakedLabs prOrLabStat, int subGruop)
        {
            _title = title;

            if (title == CrossLocalization.Translate("practice_mark"))
            {
                foreach (var pract in prOrLabStat.Practicals)
                {
                    NameOfLabOrPractice.Add(pract.ShortName);
                }
                BindingContext = new SaveSingleStudentMarkPageViewModel(new PlatformServices(),
                                                                        NameOfLabOrPractice.FirstOrDefault(), marks, prOrLabStat, title, name, subGruop);
            }
            else if (title == CrossLocalization.Translate("stats_page_labs_rating"))
            {
                foreach (var lab in prOrLabStat.Labs)
                {
                    if (lab.SubGroup == subGruop)
                    {
                        NameOfLabOrPractice.Add(lab.ShortName);
                    }
                }
                BindingContext = new SaveSingleStudentMarkPageViewModel(new PlatformServices(),
                                                                        NameOfLabOrPractice.FirstOrDefault(), marks, prOrLabStat, title, name, subGruop);
            }
            BackgroundColor = Color.FromHex(Theme.Current.AppBackgroundColor);
            Padding         = _padding;
            NavigationPage.SetHasNavigationBar(this, false);
            var entryStyle = getEntryStyle();
            var inicials   = new Label
            {
                VerticalOptions = LayoutOptions.CenterAndExpand,
                TextColor       = Color.FromHex(Theme.Current.StatisticsDetailsTitleColor),
                Style           = AppStyles.GetLabelStyle(),
                Text            = name,
            };

            var nameOfPrOrLb = new Picker
            {
                BackgroundColor         = Color.White,
                HeightRequest           = 50,
                ItemsSource             = NameOfLabOrPractice,
                HorizontalTextAlignment = TextAlignment.Center,
            };

            nameOfPrOrLb.SetBinding(Picker.SelectedItemProperty, "SelectedShortName");

            var markLabel = new Label
            {
                VerticalOptions = LayoutOptions.CenterAndExpand,
                TextColor       = Color.FromHex(Theme.Current.StatisticsDetailsTitleColor),
                Style           = AppStyles.GetLabelStyle(),
                Text            = CrossLocalization.Translate("mark"),
            };

            var dateLabel = new Label
            {
                VerticalOptions = LayoutOptions.CenterAndExpand,
                TextColor       = Color.FromHex(Theme.Current.StatisticsDetailsTitleColor),
                Style           = AppStyles.GetLabelStyle(),
                Text            = CrossLocalization.Translate("date"),
            };

            var commentLabel = new Label
            {
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                TextColor         = Color.FromHex(Theme.Current.StatisticsDetailsTitleColor),
                Style             = AppStyles.GetLabelStyle(),
                Text = CrossLocalization.Translate("comment"),
            };

            var showCommentLabel = new Label
            {
                VerticalOptions = LayoutOptions.CenterAndExpand,
                TextColor       = Color.FromHex(Theme.Current.StatisticsDetailsTitleColor),
                Style           = AppStyles.GetLabelStyle(),
                HeightRequest   = 60,
                Text            = CrossLocalization.Translate("show_for_student"),
            };

            var showComment = new Switch
            {
                IsToggled = false,
            };

            showComment.SetBinding(Switch.IsToggledProperty, "ShowForStud");

            var markPicker = new Picker
            {
                BackgroundColor         = Color.White,
                HeightRequest           = 50,
                ItemsSource             = Marks,
                HorizontalTextAlignment = TextAlignment.Center,
            };

            markPicker.SetBinding(Picker.SelectedItemProperty, "Mark");

            var datePicker = new Entry
            {
                Style      = entryStyle,
                ReturnType = ReturnType.Done,
                Text       = DateTime.Today.ToString("dd.MM.yyyy"),
                TextColor  = Color.Black,
                IsReadOnly = true,
            };

            var commentEntry = new Entry
            {
                Style      = entryStyle,
                ReturnType = ReturnType.Done,
            };

            commentEntry.SetBinding(Entry.TextProperty, "Comment");

            var gridLayout = new Grid
            {
                BackgroundColor = Color.FromHex(Theme.Current.BaseBlockColor),
                Padding         = _gridPadding,
                VerticalOptions = LayoutOptions.Start,
            };

            var saveBut = new Button
            {
                FontAttributes  = FontAttributes.Bold,
                Text            = CrossLocalization.Translate("save_marks"),
                TextColor       = Color.FromHex(Theme.Current.LoginButtonTextColor),
                BackgroundColor = Color.FromHex(Theme.Current.LoginButtonBackgroundColor),
                HeightRequest   = _controlHeight,
                Style           = AppStyles.GetButtonStyle(bold: true)
            };

            saveBut.SetBinding(Button.CommandProperty, "SaveMarksButton");

            gridLayout.Children.Add(inicials, 0, 0);
            gridLayout.Children.Add(nameOfPrOrLb, 0, 1);
            gridLayout.Children.Add(markLabel, 0, 2);
            gridLayout.Children.Add(markPicker, 2, 2);
            gridLayout.Children.Add(dateLabel, 0, 3);
            gridLayout.Children.Add(datePicker, 2, 3);
            gridLayout.Children.Add(commentLabel, 0, 4);
            gridLayout.Children.Add(commentEntry, 2, 4);
            gridLayout.Children.Add(showCommentLabel, 0, 5);
            gridLayout.Children.Add(showComment, 2, 5);
            gridLayout.Children.Add(saveBut, 0, 6);
            Grid.SetColumnSpan(inicials, 3);
            Grid.SetColumnSpan(showCommentLabel, 2);
            Grid.SetColumnSpan(commentLabel, 2);
            Grid.SetColumnSpan(markLabel, 2);
            Grid.SetColumnSpan(saveBut, 3);
            Grid.SetColumnSpan(nameOfPrOrLb, 3);
            Content = gridLayout;
        }