senya 7 maanden geleden
bovenliggende
commit
7753b05274

+ 20 - 0
EntranseTesting/Models/partialClass/UserSession.cs

@@ -59,5 +59,25 @@ namespace EntranseTesting.Models
                 return "Потрачено " + CountHint + " очков";
             }
         }
+
+        [NotMapped]
+        public TextBlock AnswerRaiting
+        {
+            get
+            {
+                string value = "";
+                if (IdAppSettingsNavigation != null)
+                {
+                    value += "Оценка 5: с " + IdAppSettingsNavigation.Raiting5 + " б.\n";
+                    value += "Оценка 4: с " + IdAppSettingsNavigation.Raiting4 + "б. по " + (IdAppSettingsNavigation.Raiting5 - 1) + "б.\n";
+                    value += "Оценка 3: с " + IdAppSettingsNavigation.Raiting3 + "б. по " + (IdAppSettingsNavigation.Raiting4 - 1) + "б.\n";
+                }
+                else
+                    value = "Не определены параметры оценивания";
+                TextBlock tb = new TextBlock();
+                tb.Text = value;
+                return tb;
+            }
+        }
     }
 }

+ 2 - 0
EntranseTesting/ViewModels/EditorPageViewModel.cs

@@ -39,6 +39,7 @@ namespace EntranseTesting.ViewModels
             EnabledTaskMain = true;
             EnabledResults = true;
             EditingVisible = false;
+            if(Results != null)Results.Timer.Stop();
             SettingsApp = new TestSettingsViewModel();
             EditorUC = new TestSettings();
         }
@@ -50,6 +51,7 @@ namespace EntranseTesting.ViewModels
             EnabledSettings = true;
             EnabledResults = true;
             EditingVisible = true;
+            if (Results != null) Results.Timer.Stop();
             TaskMainPage = new TaskMainViewModel();
             EditorUC = new TaskMain();
         }

+ 10 - 1
EntranseTesting/ViewModels/EditorViewModel/ResultMainViewModel.cs

@@ -2,6 +2,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Linq;
+using Avalonia.Threading;
 using CommunityToolkit.Mvvm.ComponentModel;
 using EntranseTesting.Models;
 using Microsoft.EntityFrameworkCore;
@@ -18,7 +19,7 @@ namespace EntranseTesting.ViewModels
         [ObservableProperty]DateTime startDate = DateTime.Today;
         DateTime selectedEndDate = DateTime.Today;
         DateTime selectedStartDate = DateTime.Today;
-
+        [ObservableProperty] DispatcherTimer timer = new DispatcherTimer();
 
         public ResultMainViewModel()
         {
@@ -26,6 +27,14 @@ namespace EntranseTesting.ViewModels
             StartDate = connection.UserSessions.OrderBy(tb => tb.Date).ToList().First().Date;
             SelectedStartDate = StartDate;
             filter();
+            timer.Interval = new TimeSpan(0, 1, 30);
+            timer.Tick += restart;
+            timer.Start();
+        }
+
+        private void restart(object? sender, EventArgs e)
+        {
+            filter();
         }
 
         public ObservableCollection<UserSession> Answers { get => answers; set => answers = value; }

+ 3 - 0
EntranseTesting/ViewModels/MainWindowViewModel.cs

@@ -216,6 +216,7 @@ namespace EntranseTesting.ViewModels
             if (typeof(EditorPage) == UC.GetType())
             {
                 EditorPages.EditingVisible = false;
+                if (EditorPages.Results != null) EditorPages.Results.Timer.Stop();
             }
             if (typeof(TestPage) == UC.GetType())
             {
@@ -479,11 +480,13 @@ namespace EntranseTesting.ViewModels
             UserResultVisible = true;
             UserResult = new UserResultViewModel(idSession);
             UC = new UserResultPage();
+            EditorPages.Results.Timer.Stop();
         }
         public void ClickToAllResult()
         {
             UserResultVisible = false;
             UC = new EditorPage();
+            EditorPages.Results.Timer.Start();
         }
     }
 }

+ 15 - 2
EntranseTesting/Views/EditorViews/ResultMain.axaml

@@ -57,7 +57,10 @@
     <ScrollViewer HorizontalScrollBarVisibility="Auto"
                   VerticalScrollBarVisibility="Auto" Grid.Row="1">
       <DataGrid ItemsSource="{Binding EditorPages.Results.Answers}"             
-                IsReadOnly="True">
+                IsReadOnly="True"
+                CanUserResizeColumns="True"
+                CanUserReorderColumns="True"
+                CanUserSortColumns="True">
         <DataGrid.Columns>
           <DataGridTemplateColumn>
             <DataGridTemplateColumn.CellTemplate>
@@ -71,7 +74,17 @@
           </DataGridTemplateColumn>
           <DataGridTextColumn Header="Группа"  Binding="{Binding UserGroup}"/>
           <DataGridTextColumn Header="ФИО" Binding="{Binding UserName}"/>
-          <DataGridTextColumn Header="Оценка" Binding="{Binding Raiting}" />
+          <DataGridTemplateColumn Header="Оценка">
+            <DataGridTemplateColumn.CellTemplate>
+              <DataTemplate>
+                <TextBlock Text="{Binding Raiting}"
+                           HorizontalAlignment="Center"
+                           VerticalAlignment="Center"
+                           Cursor="Help"
+                           ToolTip.Tip="{Binding AnswerRaiting}"/>
+              </DataTemplate>
+            </DataGridTemplateColumn.CellTemplate>
+          </DataGridTemplateColumn>
           <DataGridTextColumn Header="Ответы" Binding="{Binding CountCorrectly}" />
           <DataGridTextColumn Header="Время" Binding="{Binding Time,StringFormat=hh\\:mm\\:ss}" />
           <DataGridTextColumn Header="Дата прохождения" Binding="{Binding Date, StringFormat={}{0:d MMMM yyyy&#x0a;HH\\:mm}}"/>

+ 1 - 0
EntranseTesting/Views/EditorViews/UserResultPage.axaml

@@ -29,6 +29,7 @@
                    Margin="10 0 0 0"/>
         <TextBlock Text="{Binding UserResult.Session.ProcentCorrectly, StringFormat=' или {0}%)'}"/>
       </WrapPanel>
+      <ContentControl Content="{Binding UserResult.Session.AnswerRaiting}"/>
     </StackPanel>