浏览代码

complite 3/4 methods for attendance

Alexandra Schekaleva 5 月之前
父节点
当前提交
b456d26ecb
共有 23 个文件被更改,包括 54 次插入16 次删除
  1. 二进制
      EducationDepartment/.vs/EducationDepartment/DesignTimeBuild/.dtbcache.v2
  2. 二进制
      EducationDepartment/.vs/EducationDepartment/FileContentIndex/35ad3a1b-631e-4c91-8ca3-b482260eee68.vsidx
  3. 二进制
      EducationDepartment/.vs/EducationDepartment/FileContentIndex/c0446c71-b3c0-4204-96f9-928e1f6e9b2d.vsidx
  4. 二进制
      EducationDepartment/.vs/EducationDepartment/FileContentIndex/c1a144a7-37e5-44e2-a0ab-f6883ff9a444.vsidx
  5. 二进制
      EducationDepartment/.vs/EducationDepartment/FileContentIndex/c336f4f7-63dc-444d-9b4c-f0856899c0ce.vsidx
  6. 二进制
      EducationDepartment/.vs/EducationDepartment/v17/.futdcache.v2
  7. 二进制
      EducationDepartment/.vs/EducationDepartment/v17/.suo
  8. 二进制
      EducationDepartment/.vs/ProjectEvaluation/educationdepartment.metadata.v7.bin
  9. 二进制
      EducationDepartment/.vs/ProjectEvaluation/educationdepartment.projects.v7.bin
  10. 5 0
      EducationDepartment/EducationDepartment/Models/AttendanceInfo.cs
  11. 45 10
      EducationDepartment/EducationDepartment/ViewModels/AttendanceViewModel.cs
  12. 3 5
      EducationDepartment/EducationDepartment/Views/Attendance.axaml
  13. 二进制
      EducationDepartment/EducationDepartment/bin/Debug/net7.0/EducationDepartment.dll
  14. 二进制
      EducationDepartment/EducationDepartment/bin/Debug/net7.0/EducationDepartment.pdb
  15. 二进制
      EducationDepartment/EducationDepartment/obj/Debug/net7.0/Avalonia/original.dll
  16. 二进制
      EducationDepartment/EducationDepartment/obj/Debug/net7.0/Avalonia/original.pdb
  17. 二进制
      EducationDepartment/EducationDepartment/obj/Debug/net7.0/Avalonia/original.ref.dll
  18. 二进制
      EducationDepartment/EducationDepartment/obj/Debug/net7.0/Avalonia/resources
  19. 1 1
      EducationDepartment/EducationDepartment/obj/Debug/net7.0/EducationDepartment.csproj.CoreCompileInputs.cache
  20. 二进制
      EducationDepartment/EducationDepartment/obj/Debug/net7.0/EducationDepartment.dll
  21. 二进制
      EducationDepartment/EducationDepartment/obj/Debug/net7.0/EducationDepartment.pdb
  22. 二进制
      EducationDepartment/EducationDepartment/obj/Debug/net7.0/ref/EducationDepartment.dll
  23. 二进制
      EducationDepartment/EducationDepartment/obj/Debug/net7.0/refint/EducationDepartment.dll

二进制
EducationDepartment/.vs/EducationDepartment/DesignTimeBuild/.dtbcache.v2


二进制
EducationDepartment/.vs/EducationDepartment/FileContentIndex/35ad3a1b-631e-4c91-8ca3-b482260eee68.vsidx


二进制
EducationDepartment/.vs/EducationDepartment/FileContentIndex/c0446c71-b3c0-4204-96f9-928e1f6e9b2d.vsidx


二进制
EducationDepartment/.vs/EducationDepartment/FileContentIndex/c1a144a7-37e5-44e2-a0ab-f6883ff9a444.vsidx


二进制
EducationDepartment/.vs/EducationDepartment/FileContentIndex/c336f4f7-63dc-444d-9b4c-f0856899c0ce.vsidx


二进制
EducationDepartment/.vs/EducationDepartment/v17/.futdcache.v2


二进制
EducationDepartment/.vs/EducationDepartment/v17/.suo


二进制
EducationDepartment/.vs/ProjectEvaluation/educationdepartment.metadata.v7.bin


二进制
EducationDepartment/.vs/ProjectEvaluation/educationdepartment.projects.v7.bin


+ 5 - 0
EducationDepartment/EducationDepartment/Models/AttendanceInfo.cs

@@ -8,6 +8,11 @@ namespace EducationDepartment.Models
 {
     internal class AttendanceInfo
     {
+        public AttendanceInfo(string value, double percentage)
+        {
+            Value = value;
+            Percentage = percentage;
+        }
         //discipline, group, student
         public string Value { get; set; }
         //attendance %

+ 45 - 10
EducationDepartment/EducationDepartment/ViewModels/AttendanceViewModel.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Linq;
+using EducationDepartament.Views;
 using EducationDepartment.Models;
 using Microsoft.EntityFrameworkCore;
 
@@ -59,30 +60,64 @@ namespace EducationDepartment.ViewModels
 			{
 				if (OptionValue == "Вся группа") 
 				{
-					ParameterName = "Студент";
+					ParameterName = $"Студенты группы {secondSelectedOption}";
 					//извлечь студента группы + расчет посещаемости по всем дисц
+					foreach(var student in connect.Students.Include(x=>x.User).Include(x=>x.Group)
+						.Where(x=>x.Group.Name == secondSelectedOption).Select(x => x.User).ToList())
+					{
+						var data = connect.Attendances.Include(x => x.Student).Where(x => x.Student.User == student);
+						if(data.Count()==0) AttendanceTable.Add(new AttendanceInfo(student.ToString(),1));
+                        else AttendanceTable.Add(new AttendanceInfo(student.ToString(),
+							(double)(data.Count(x=>x.Attended))/data.Count()));
+					}
 				} 
 				else
                 {
-                    ParameterName = "Дисциплина";
+                    ParameterName = $"Дисциплины студента {optionValue}";
 					//извлечь дисцилину студента + расчет посещаемости
+					foreach (var studentDiscipline in connect.Groupdisciplines.Include(x => x.TeacherDiscipline.Discipline)
+						.Include(x => x.Group).Where(x => x.Group.Name == secondSelectedOption).Select(x => x.TeacherDiscipline.Discipline).ToList())
+					{
+						var data = connect.Attendances.Include(x => x.Student).Include(x => x.Timetable.GroupDiscipline.TeacherDiscipline.Discipline)
+							.Where(x => x.Student.User.ToString() == optionValue && x.Timetable.GroupDiscipline.TeacherDiscipline.Discipline == studentDiscipline).ToList();
+						if(data.Count==0) AttendanceTable.Add(new AttendanceInfo(studentDiscipline.Name, 1));
+                        else AttendanceTable.Add(new AttendanceInfo(studentDiscipline.Name,
+							(double)(data.Count(x => x.Attended)) / data.Count()
+							));
+					}
                 }
             }
             else if (selectedOption == "Дисциплина")
 			{
 				if (OptionValue == "Все группы")
-                {
-                    ParameterName = "Группа";
+				{
+					ParameterName = $"Группы на дисциплине {secondSelectedOption}";
 					//извлечь группу посещающую дисциплину + расчет
-                }
-                else
-                {
-                    ParameterName = "Студент";
+					foreach (var group in connect.Groupdisciplines.Include(x => x.Group).Include(x => x.TeacherDiscipline.Discipline)
+						.Where(x => x.TeacherDiscipline.Discipline.Name == secondSelectedOption).Select(x => x.Group))
+					{
+						var data = connect.Attendances.Include(x => x.Timetable.GroupDiscipline.Group)
+							.Include(x => x.Timetable.GroupDiscipline.TeacherDiscipline.Discipline)
+							.Where(x => x.Timetable.GroupDiscipline.Group == group &&
+							x.Timetable.GroupDiscipline.TeacherDiscipline.Discipline.Name == secondSelectedOption);
+						if (data.Count() == 0) AttendanceTable.Add(new AttendanceInfo(group.Name, 1));
+						else
+							AttendanceTable.Add(new AttendanceInfo(group.Name,
+								(double)(data.Count(x => x.Attended)) / data.Count()));
+					}
+				}
+				else
+				{
+					ParameterName = $"Студенты группы {optionValue}";
 					//извлечь студентов группы + их посещаемость предмета
+					foreach (var studentOnDiscipline in connect.Attendances.Include(x => x.Student).Include(x => x.Timetable.GroupDiscipline.TeacherDiscipline.Discipline)
+						.Include(x => x.Timetable.GroupDiscipline.Group)
+						.Where(x => x.Timetable.GroupDiscipline.Group.Name == secondSelectedOption && x.Timetable.GroupDiscipline.TeacherDiscipline.Discipline.Name == optionValue))
+					{
+						//??
+					}
                 }
             }
-            //struct with: value - %
-            //binding
         }
 		List<AttendanceInfo> attendanceTable;
         List<AttendanceInfo> AttendanceTable { get => attendanceTable; set { attendanceTable = value; OnPropertyChanged(nameof(AttendanceTable)); } }

+ 3 - 5
EducationDepartment/EducationDepartment/Views/Attendance.axaml

@@ -39,7 +39,7 @@
 				<ComboBox ItemsSource="{Binding AttendanceVM.Values}" SelectedItem="{Binding AttendanceVM.OptionValue}"  Width="250" Height="5" Margin="0,0,0,0"  HorizontalAlignment="Center"  HorizontalContentAlignment="Center" VerticalContentAlignment="Center"  Foreground="White" Background="#09102A" BorderBrush="#4158AE" BorderThickness="2">
 				</ComboBox>
 				<Button Content="Показать" Command="{Binding AttendanceVM.GetNewAttendance}" Width="100" Height="35" Margin="0,5,0,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Center" Foreground="White" Background="#4158AE"/>
-				<TextBlock Text="Дисциплина/Группа" Margin="150,0,0,10" HorizontalAlignment="Left" FontSize="14" Foreground="White"/>
+				<TextBlock Text="{Binding AttendanceVM.ParameterName}" Margin="150,0,0,10" HorizontalAlignment="Left" FontSize="14" Foreground="White"/>
 				<TextBlock Text="% посещаемости" Margin="0,-28,150,10" HorizontalAlignment="Right"  FontSize="14" Foreground="White"/>
 
 				<ScrollViewer VerticalScrollBarVisibility="Visible" Height="200" Width="650">
@@ -51,11 +51,9 @@
 									BorderBrush="White" BorderThickness="1"
 									Padding="5">
 									<StackPanel Orientation="Horizontal">
-										<TextBlock Foreground="White" Text="{Binding GroupDiscipline.Group.Name}"/>
+										<TextBlock Foreground="White" Text="{Binding Value}"/>
 										<TextBlock Margin="5 0" FontWeight="Bold"
-												Foreground="White"	Text="{Binding GroupDiscipline.TeacherDiscipline.Discipline.Name}"/>
-										<TextBlock Margin="5 0" FontWeight="Bold"
-										Foreground="White"	Text="{Binding GroupDiscipline.TeacherDiscipline.Teacher.User}"/>
+												Foreground="White"	Text="{Binding Percentage}"/>
 									</StackPanel>
 								</Border>
 							</DataTemplate>

二进制
EducationDepartment/EducationDepartment/bin/Debug/net7.0/EducationDepartment.dll


二进制
EducationDepartment/EducationDepartment/bin/Debug/net7.0/EducationDepartment.pdb


二进制
EducationDepartment/EducationDepartment/obj/Debug/net7.0/Avalonia/original.dll


二进制
EducationDepartment/EducationDepartment/obj/Debug/net7.0/Avalonia/original.pdb


二进制
EducationDepartment/EducationDepartment/obj/Debug/net7.0/Avalonia/original.ref.dll


二进制
EducationDepartment/EducationDepartment/obj/Debug/net7.0/Avalonia/resources


+ 1 - 1
EducationDepartment/EducationDepartment/obj/Debug/net7.0/EducationDepartment.csproj.CoreCompileInputs.cache

@@ -1 +1 @@
-4066aa302521b10d20205a4e14d351fd1680b426
+e1e8763e36da9081e8c83a48d2570dbdb1e4d468

二进制
EducationDepartment/EducationDepartment/obj/Debug/net7.0/EducationDepartment.dll


二进制
EducationDepartment/EducationDepartment/obj/Debug/net7.0/EducationDepartment.pdb


二进制
EducationDepartment/EducationDepartment/obj/Debug/net7.0/ref/EducationDepartment.dll


二进制
EducationDepartment/EducationDepartment/obj/Debug/net7.0/refint/EducationDepartment.dll