From 6ec84c76b90e79df1f89dff83e755851456e5f85 Mon Sep 17 00:00:00 2001 From: wangxiner55 <1468441589@qq.com> Date: Fri, 13 Sep 2024 19:11:38 +0800 Subject: [PATCH] Finish Detail Data Info --- StudentManager/Common/ErrorSet.cs | 52 ++++++- StudentManager/Common/HomeWorkManager.cs | 10 +- StudentManager/Common/HomeWorkSet.cs | 150 ++++++++++++++++++- StudentManager/Common/SQLHelper.cs | 2 + StudentManager/Data/CursonQuestionsData.cs | 1 + StudentManager/Data/QuestionLib.cs | 17 +++ StudentManager/Data/StudentData.cs | 2 +- StudentManager/Data/StudentInfo.cs | 24 +++- StudentManager/Editor/CheckView.xaml.cs | 6 +- StudentManager/Editor/DetailCheckView.xaml | 14 +- StudentManager/Editor/DetailView.xaml | 21 +-- StudentManager/Editor/DetailView.xaml.cs | 6 +- StudentManager/Editor/StudentsView.xaml | 9 +- StudentManager/Editor/StudentsView.xaml.cs | 6 + StudentManager/Model/Students.cs | 158 ++++++++++++--------- 15 files changed, 360 insertions(+), 118 deletions(-) diff --git a/StudentManager/Common/ErrorSet.cs b/StudentManager/Common/ErrorSet.cs index 9a3e09a..02e01c6 100644 --- a/StudentManager/Common/ErrorSet.cs +++ b/StudentManager/Common/ErrorSet.cs @@ -2,6 +2,7 @@ using StudentManager.Data; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -22,6 +23,25 @@ namespace StudentManager.Common public int CorrectCount { get; set; } = 0; } + public class DetailErrorInfo + { + public QuestionData QuestionData { get; set; } = new QuestionData(); + public int TotalUseCount { get; set; } = 1; + public int ErrorCount { get; set; } = 1; + public int CorrectCount { get; set; } = 0; + public bool Status { get; set; } = false; + } + + public class DetailErrorSetInfo + { + public int TotalCount { get; set; } = 0; + public int TotalErrorCount { get; set; } = 0; + public int CorrectCount { get; set; } = 0; + public int ErrorCount { get; set; } = 0; + public float ErrorRate { get; set; } = 0; + public float CorrectRate { get; set; } = 0; + } + public class ErrorSet { public int TotalCount { get; set; } = 0; @@ -40,6 +60,36 @@ namespace StudentManager.Common } } + public DetailErrorSetInfo GetDetailErrorSetInfo() + { + return new DetailErrorSetInfo + { + TotalCount = QuestionLib.GetQuestionCount(), + TotalErrorCount = Errores.Count(), + CorrectCount = CorrectArray.Count(), + ErrorCount = ErrorArray.Count(), + ErrorRate = ErrorArray.Count() / QuestionLib.GetQuestionCount(), + CorrectRate = CorrectArray.Count() / Errores.Count() + }; + } + + public ObservableCollection GetDetailErrorQuestionList() + { + ObservableCollection list = new ObservableCollection(); + foreach (var item in Errores) + { + list.Add(new DetailErrorInfo + { + QuestionData = QuestionLib.Get(item.Key), + CorrectCount = item.Value.CorrectCount, + ErrorCount = item.Value.ErrorCount, + Status = item.Value.QuestionBase.Status + }); + } + + return list; + } + public void AddQuestion(QuestionBase question) { if (question.Status) @@ -131,7 +181,7 @@ namespace StudentManager.Common SQLHelper.Query(Tables.UQTable, id).ForEach(x => { - AddQuestion(new QuestionBase { ID = x.PID, Status = x.Status}); + AddQuestion(new QuestionBase { ID = x.PID, Status = x.Status }); }); } } diff --git a/StudentManager/Common/HomeWorkManager.cs b/StudentManager/Common/HomeWorkManager.cs index 1ea0cb8..7b70bd7 100644 --- a/StudentManager/Common/HomeWorkManager.cs +++ b/StudentManager/Common/HomeWorkManager.cs @@ -13,7 +13,7 @@ namespace StudentManager.Common { public static HomeWork CommonHomeWork { get; set; } = new HomeWork(); - public static void Create(StudentInfo student,int lesson, int workNum = 10) + public static void Create(StudentInfo student,int lesson, bool appedCommonWork = false, int workNum = 10) { HomeWork work = new HomeWork { Lesson = lesson}; foreach(var item in student.ErrorSet.ErrorArray) @@ -21,21 +21,21 @@ namespace StudentManager.Common work.AddHomeWork(item); } - if (CommonHomeWork.Questions.Count > 0) + if (appedCommonWork && CommonHomeWork.Questions.Count > 0) { work.Append(CommonHomeWork); } - student.CurentHomeWork = work; + Public(work); } - public static void Public() + public static void Public(HomeWork homeWork) { foreach (var item in StudentLib.StudentDic) { - item.Value.PublicHomeWork(); + item.Value.PublicHomeWork(homeWork); } } } diff --git a/StudentManager/Common/HomeWorkSet.cs b/StudentManager/Common/HomeWorkSet.cs index 634b13f..f6de5c9 100644 --- a/StudentManager/Common/HomeWorkSet.cs +++ b/StudentManager/Common/HomeWorkSet.cs @@ -1,33 +1,98 @@ using DryIoc.ImTools; +using MySqlX.XDevAPI; using StudentManager.Data; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace StudentManager.Common { + public class DetailQuestionBase + { + public QuestionData QuestionData { get; set; } = new QuestionData(); + public bool Status { get; set; } = false; + } + + public class DetailHomeWorkInfo + { + public DetailQuestionBase QuestionData { get; set; } = new DetailQuestionBase(); + public DateTime DateTime { get; set; } = DateTime.Now; + public int Lesson { get; set; } = 0; + public bool Status { get; set; } = false; + + public int TotalCount { get; set; } = 0; + public int ErrorCount { get; set; } = 0; + public int CorrectCount { get; set; } = 0; + } + public class HomeWork { public int Lesson { get; set; } = 0; public bool Status { get; set; } = false; - public HashSet Questions { get; set; } = new HashSet(); + public DateTime DateTime { get; set; } = DateTime.Now; + public List Questions { get; set; } = new List(); + + + public int TotalCount { get; set; } = 0; + public int ErrorCount { get; set; } = 0; + public int CorrectCount { get; set; } = 0; + + public ObservableCollection GetDetailHomeWorkList() + { + ObservableCollection list = new ObservableCollection(); + foreach (var item in Questions) + { + list.Add(new DetailHomeWorkInfo + { + QuestionData = { + QuestionData = QuestionLib.Get(item.ID), + Status = item.Status }, + Status = Status, + Lesson = Lesson, + DateTime = DateTime, + TotalCount = TotalCount, + ErrorCount = ErrorCount, + CorrectCount = CorrectCount + }); + + } + return list; + } + + private void FreshData() + { + CorrectCount = 0; + ErrorCount = 0; + TotalCount = Questions.Count; + foreach (var item in Questions) + { + if (item.Status == true) CorrectCount++; + else ErrorCount++; + } + } + + public void AddHomeWork(QuestionBase workInfo) { Questions.Add(workInfo); + FreshData(); } public void AddHomeWork(int id) { Questions.Add(new QuestionBase { ID = id }); + FreshData(); } public void RemoveHomeWork(QuestionBase workInfo) { Questions.Remove(workInfo); + FreshData(); } public void Append(HomeWork homeWork) @@ -40,14 +105,74 @@ namespace StudentManager.Common } } + + + public class DetailHomeWorkSetInfo + { + public int TotalCount { get; set; } = 0; + public bool Status { get; set; } = false; + + public DateTime DateTime { get; set; } = DateTime.Now; + public int Lesson { get; set; } = 0; + + public int ErrorCount { get; set; } = 0; + public int CorrectCount { get; set; } = 0; + + } + public class HomeWorkSet { + [JsonInclude] private Dictionary HomeWorks { get; set; } = new Dictionary(); + public int TotalCount { get; set; } = 0; public void AddHomeWork(HomeWork homeWork) { HomeWorks.Add(homeWork.Lesson, homeWork); + TotalCount = HomeWorks.Count; + } + + public ObservableCollection GetDetailHomeWorkList(int lesson) + { + ObservableCollection list = new ObservableCollection(); + foreach (var item in HomeWorks[lesson].Questions) + { + list.Add(new DetailHomeWorkInfo + { + QuestionData = { + QuestionData = QuestionLib.Get(item.ID), + Status = item.Status }, + Status = HomeWorks[lesson].Status, + Lesson = HomeWorks[lesson].Lesson, + DateTime = HomeWorks[lesson].DateTime, + TotalCount = HomeWorks[lesson].TotalCount, + ErrorCount = HomeWorks[lesson].ErrorCount, + CorrectCount = HomeWorks[lesson].CorrectCount + }); + + } + return list; + } + + public ObservableCollection GetDetailHomeWorkSetList() + { + ObservableCollection list = new ObservableCollection(); + foreach (var item in HomeWorks) + { + list.Add(new DetailHomeWorkSetInfo + { + + Status = item.Value.Status, + Lesson = item.Value.Lesson, + DateTime = item.Value.DateTime, + TotalCount = item.Value.TotalCount, + ErrorCount = item.Value.ErrorCount, + CorrectCount = item.Value.CorrectCount + }); + + } + return list; } @@ -58,7 +183,13 @@ namespace StudentManager.Common public HomeWork Get(int cursonId) { - return HomeWorks[cursonId]; + if (HomeWorks.ContainsKey(cursonId)) return HomeWorks[cursonId]; + return null; + } + + public HomeWork GetLast() + { + return HomeWorks[TotalCount]; } public List GetAll() @@ -77,15 +208,24 @@ namespace StudentManager.Common return works; } - public void QueryCQSet(int id) + public void FreshAllHomeWork(int id) { HomeWorks.Clear(); SQLHelper.Query(Tables.CQTable, id).ForEach(x => { - HashSet Questions = new HashSet(); + List Questions = new List(); x.ProblemIDS.ForEach(y => Questions.Add(new QuestionBase { ID = y, Status = x.CorrectIDS.Contains(y) })); - HomeWorks.Add(x.Lesson, new HomeWork { Lesson = x.Lesson, Questions = Questions, Status = x.Status == 1 }); + HomeWorks.Add(x.Lesson, new HomeWork + { + Lesson = x.Lesson, + TotalCount = x.ProblemIDS.Length, + CorrectCount = x.CorrectCount, + ErrorCount = x.TotalCount - x.CorrectCount, + DateTime = x.DateTime, + Questions = Questions, + Status = x.Status == 1 + }); }); } } diff --git a/StudentManager/Common/SQLHelper.cs b/StudentManager/Common/SQLHelper.cs index 30333e3..ff743e0 100644 --- a/StudentManager/Common/SQLHelper.cs +++ b/StudentManager/Common/SQLHelper.cs @@ -40,6 +40,7 @@ namespace StudentManager.Common (data as StudentData).Grade = (byte)reader[5]; (data as StudentData).TotalsQuestions = (UInt16)reader[6]; (data as StudentData).CorrectionCount = (UInt16)reader[7]; + (data as StudentData).HomeWork = (UInt16)reader[8]; } else if (typeof(T) == typeof(QuestionData)) { @@ -65,6 +66,7 @@ namespace StudentManager.Common (data as CursonQuestionsData).CorrectIDS = string.IsNullOrEmpty(reader[2].ToString()) ? Array.Empty() : JsonConvert.DeserializeObject(reader[2].ToString()); (data as CursonQuestionsData).Lesson = (byte)reader[3]; (data as CursonQuestionsData).Status = (byte)reader[4]; + (data as CursonQuestionsData).DateTime = (DateTime)reader[5]; (data as CursonQuestionsData).TotalCount = (data as CursonQuestionsData).ProblemIDS.Length; (data as CursonQuestionsData).CorrectCount = (data as CursonQuestionsData).CorrectIDS.Length; } diff --git a/StudentManager/Data/CursonQuestionsData.cs b/StudentManager/Data/CursonQuestionsData.cs index 54e18d8..3b0f56e 100644 --- a/StudentManager/Data/CursonQuestionsData.cs +++ b/StudentManager/Data/CursonQuestionsData.cs @@ -11,6 +11,7 @@ namespace StudentManager.Data public int UID { get; set; } = 0; public int[] ProblemIDS { get; set; } = { }; public int[] CorrectIDS { get; set; } = { }; + public DateTime DateTime { get; set; } = DateTime.Now; public int Lesson { get; set; } = 0; public int TotalCount { get; set; } = 0; diff --git a/StudentManager/Data/QuestionLib.cs b/StudentManager/Data/QuestionLib.cs index fffdb91..af4d9eb 100644 --- a/StudentManager/Data/QuestionLib.cs +++ b/StudentManager/Data/QuestionLib.cs @@ -2,6 +2,7 @@ using StudentManager.Common; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; @@ -15,7 +16,13 @@ namespace StudentManager.Data { public static string FileName = "questionLib.dbqi"; public static Dictionary QuestionDic { get; set; } = new Dictionary(); + public static int TotalCount { get; set; } = 0; + public static int GetQuestionCount() + { + TotalCount = QuestionDic.Count; + return TotalCount; + } public static void Load() { QuestionDic.Clear(); @@ -34,6 +41,16 @@ namespace StudentManager.Data SQLHelper.Query(Tables.QuesTable).ForEach(x => QuestionDic.Add(x.Id, x)); } + public static ObservableCollection GetAllQuestion() + { + var list = new ObservableCollection(); + foreach (QuestionData data in QuestionDic.Values) + { + list.Add(data); + } + return list; + } + public static QuestionData Get(int id) { if (!QuestionDic.ContainsKey(id)) return null; diff --git a/StudentManager/Data/StudentData.cs b/StudentManager/Data/StudentData.cs index 883fdf8..39e2a94 100644 --- a/StudentManager/Data/StudentData.cs +++ b/StudentManager/Data/StudentData.cs @@ -16,7 +16,7 @@ namespace StudentManager.Data public int Grade { get; set; } = 1; public int TotalsQuestions { get; set; } = 0; public int CorrectionCount { get; set; } = 0; - + public int HomeWork { get; set; } = 0; public float ErrorRate { get; set; } = 0; public float CorrectRate { get; set; } = 0; diff --git a/StudentManager/Data/StudentInfo.cs b/StudentManager/Data/StudentInfo.cs index 0ed6b81..3fcf758 100644 --- a/StudentManager/Data/StudentInfo.cs +++ b/StudentManager/Data/StudentInfo.cs @@ -1,6 +1,7 @@ using StudentManager.Common; using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; @@ -50,6 +51,7 @@ namespace StudentManager.Data Address = x.Address, Contact = x.Contact, Grade = x.Grade, + CurrentHomeWorkIndex = x.HomeWork, })); foreach (var item in StudentDic) @@ -58,6 +60,16 @@ namespace StudentManager.Data } } + public static ObservableCollection GetAllStudents() + { + var list = new ObservableCollection(); + foreach (var item in StudentDic) + { + list.Add(item.Value); + } + return list; + } + public static StudentInfo QueryStudentDetailInfo(int uid) { return GetStudentDetailInfo(Get(uid)); @@ -82,14 +94,15 @@ namespace StudentManager.Data public static StudentInfo GetStudentDetailInfo(StudentInfo studentData) { studentData.ErrorSet.QueryErrorSet(studentData.UID); - studentData.HomeWorkSet.QueryCQSet(studentData.UID); + studentData.HomeWorkSet.FreshAllHomeWork(studentData.UID); + studentData.CurentHomeWork = studentData.HomeWorkSet.Get(studentData.CurrentHomeWorkIndex); return studentData; } public static void GetStudentDetailInfo(ref StudentInfo studentData) { studentData.ErrorSet.QueryErrorSet(studentData.UID); - studentData.HomeWorkSet.QueryCQSet(studentData.UID); + studentData.HomeWorkSet.FreshAllHomeWork(studentData.UID); } } @@ -101,15 +114,18 @@ namespace StudentManager.Data public string Contact { get; set; } = "Contact"; public string Address { get; set; } = "Address"; public int Grade { get; set; } = 1; + public int HomeWorkCount { get; set; } = 0; + public ErrorSet ErrorSet { get; set; } = new ErrorSet(); public HomeWorkSet HomeWorkSet { get; set; } = new HomeWorkSet(); + public int CurrentHomeWorkIndex = 0; public HomeWork CurentHomeWork { get; set; } = new HomeWork(); - public void PublicHomeWork() + public void PublicHomeWork(HomeWork homeWork) { - HomeWorkSet.AddHomeWork(CurentHomeWork); + HomeWorkSet.AddHomeWork(homeWork); } } } diff --git a/StudentManager/Editor/CheckView.xaml.cs b/StudentManager/Editor/CheckView.xaml.cs index 6154cab..0cd7750 100644 --- a/StudentManager/Editor/CheckView.xaml.cs +++ b/StudentManager/Editor/CheckView.xaml.cs @@ -28,11 +28,7 @@ namespace StudentManager.Editor private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { - var c = DataContext as Students; - if (c != null) - { - c.SelectedCQData = (Data.CursonQuestionsData)(sender as ListBox).SelectedItem; - } + } } } diff --git a/StudentManager/Editor/DetailCheckView.xaml b/StudentManager/Editor/DetailCheckView.xaml index ba4abec..227507c 100644 --- a/StudentManager/Editor/DetailCheckView.xaml +++ b/StudentManager/Editor/DetailCheckView.xaml @@ -10,12 +10,11 @@ - + + Command="{Binding DataContext.HomeWorkSelectedCommand ,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"/> @@ -25,13 +24,14 @@ - + - - - + + + + diff --git a/StudentManager/Editor/DetailView.xaml b/StudentManager/Editor/DetailView.xaml index 3bd105d..e5b23ba 100644 --- a/StudentManager/Editor/DetailView.xaml +++ b/StudentManager/Editor/DetailView.xaml @@ -27,6 +27,7 @@ @@ -65,12 +66,12 @@ - - - - - - + + + + + + @@ -87,14 +88,18 @@ - + + + + diff --git a/StudentManager/Editor/DetailView.xaml.cs b/StudentManager/Editor/DetailView.xaml.cs index 9e774a7..a62ce20 100644 --- a/StudentManager/Editor/DetailView.xaml.cs +++ b/StudentManager/Editor/DetailView.xaml.cs @@ -28,11 +28,7 @@ namespace StudentManager.Editor private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { - var c = DataContext as Students; - if (c != null) - { - c.SelectedCQData = (Data.CursonQuestionsData)(sender as ListBox).SelectedItem; - } + } } } diff --git a/StudentManager/Editor/StudentsView.xaml b/StudentManager/Editor/StudentsView.xaml index d7d2665..e1d9d96 100644 --- a/StudentManager/Editor/StudentsView.xaml +++ b/StudentManager/Editor/StudentsView.xaml @@ -18,11 +18,6 @@ SelectedItem="{Binding SelectedStudent}"> - - - + diff --git a/StudentManager/Editor/StudentsView.xaml.cs b/StudentManager/Editor/StudentsView.xaml.cs index cd1ebbc..47c8998 100644 --- a/StudentManager/Editor/StudentsView.xaml.cs +++ b/StudentManager/Editor/StudentsView.xaml.cs @@ -23,6 +23,12 @@ namespace StudentManager.Editor public StudentsView() { InitializeComponent(); + Initialized += StudentsView_Initialized; + } + + private void StudentsView_Initialized(object? sender, EventArgs e) + { + var data = DataContext; } } } diff --git a/StudentManager/Model/Students.cs b/StudentManager/Model/Students.cs index 4cfde50..7687e3d 100644 --- a/StudentManager/Model/Students.cs +++ b/StudentManager/Model/Students.cs @@ -47,21 +47,24 @@ namespace StudentManager.Model class Students : BindableBase { - private ObservableCollection studentDatas = new ObservableCollection(); - public ReadOnlyObservableCollection StudentDatas { get; private set; } + private ObservableCollection studentDatas = new ObservableCollection(); + public ReadOnlyObservableCollection StudentDatas { get; private set; } private ObservableCollection questionDatas = new ObservableCollection(); public ReadOnlyObservableCollection QuestionDatas { get; private set; } - private ObservableCollection studentQuestionDatas = new ObservableCollection(); - public ReadOnlyObservableCollection StudentQuestionDatas { get; private set; } + private ObservableCollection errorSetDatas = new ObservableCollection(); + public ReadOnlyObservableCollection ErrorSetDatas { get; private set; } private ObservableCollection cQDatas = new ObservableCollection(); public ReadOnlyObservableCollection CQDatas { get; private set; } - private ObservableCollection studentCQDatas = new ObservableCollection(); - public ReadOnlyObservableCollection StudentCQDatas { get; private set; } + private ObservableCollection homeWorkSet = new ObservableCollection(); + public ObservableCollection HomeWorkSet { get { return homeWorkSet; } private set { homeWorkSet = value; RaisePropertyChanged(); } } + + private ObservableCollection homeWork = new ObservableCollection(); + public ObservableCollection HomeWork { get { return homeWork; } private set { homeWork = value; RaisePropertyChanged(); } } private ObservableCollection menuBars = new ObservableCollection(); public ReadOnlyObservableCollection MenuBars { get; private set; } @@ -76,27 +79,53 @@ namespace StudentManager.Model } - private StudentData selectedStudent; - public StudentData SelectedStudent + private StudentInfo selectedStudent; + public StudentInfo SelectedStudent { get { return selectedStudent; } set { selectedStudent = value; RaisePropertyChanged(); } } - private CursonQuestionsData selectedCQData; - public CursonQuestionsData SelectedCQData + private DetailHomeWorkSetInfo selectedHomeWorkSet; + public DetailHomeWorkSetInfo SelectedHomeWorkSet { - get { return selectedCQData; } - set { selectedCQData = value; RaisePropertyChanged(); } + get { return selectedHomeWorkSet; } + set { selectedHomeWorkSet = value; RaisePropertyChanged(); } } + private DetailHomeWorkInfo selectedHomeWork; + public DetailHomeWorkInfo SelectedHomeWork + { + get { return selectedHomeWork; } + set { selectedHomeWork = value; RaisePropertyChanged(); } + } + + private StudentInfo studentInfo; + + public StudentInfo StudentInfo + { + get { return studentInfo; } + set { studentInfo = value; RaisePropertyChanged(); } + } + + private DetailErrorSetInfo errorSet; + + public DetailErrorSetInfo ErrorSet + { + get { return errorSet; } + set { errorSet = value; RaisePropertyChanged(); } + } + + + private readonly IRegionManager regionManager; public DelegateCommand RegionTo { get; set; } - public DelegateCommand SelectedCommand { get; set; } - public DelegateCommand CQSelectedCommand { get; set; } + public DelegateCommand SelectedCommand { get; set; } + public DelegateCommand HomeWorkSelectedCommand { get; set; } + public DelegateCommand HomeWorkSetSelectedCommand { get; set; } public DelegateCommand RegionToDetailCommand { get; set; } Students(IRegionManager regionManager) @@ -107,28 +136,44 @@ namespace StudentManager.Model regionManager.Regions[PrismManager.MainRegionName].RequestNavigate(x.ToString()); if(x == "DetailCheckView") { - RegionToDCV(); + RegionToDetailCheckView(); + } + if (x == "DetailView") + { + RegionToDetailView(); } RegionToStudents(); }); - SelectedCommand = new DelegateCommand(() => + SelectedCommand = new DelegateCommand((x) => { - cQDatas.Clear(); - SQLHelper.Query(Tables.CQTable, SelectedStudent.UID).ForEach(x => cQDatas.Add(x)); + if (x == null) return; + SelectedStudent = x; + RegionToDetailView(); }); - CQSelectedCommand = new DelegateCommand((e) => + HomeWorkSetSelectedCommand = new DelegateCommand((x) => { - selectedCQData = e; + if (x == null) return; + selectedHomeWorkSet = x; + HomeWork = SelectedStudent.HomeWorkSet.GetDetailHomeWorkList(SelectedHomeWorkSet.Lesson); }); - StudentDatas = new ReadOnlyObservableCollection(studentDatas); + HomeWorkSelectedCommand = new DelegateCommand((e) => + { + if(e == null) return; + //HomeWork = + }); + + + Load(); + + StudentDatas = new ReadOnlyObservableCollection(studentDatas); QuestionDatas = new ReadOnlyObservableCollection(questionDatas); - StudentQuestionDatas = new ReadOnlyObservableCollection(studentQuestionDatas); + ErrorSetDatas = new ReadOnlyObservableCollection(errorSetDatas); MenuBars = new ReadOnlyObservableCollection(menuBars); - CQDatas = new ReadOnlyObservableCollection(cQDatas); - StudentCQDatas = new ReadOnlyObservableCollection(studentCQDatas); + //CQDatas = new ReadOnlyObservableCollection(cQDatas); + HomeWorkSet = new ObservableCollection(homeWorkSet); @@ -136,22 +181,20 @@ namespace StudentManager.Model this.regionManager = regionManager; - - StudentInfo studentInfo = new StudentInfo(); - - //QueryAll(); - - StudentLib.FreshAllStudentInfo(); - StudentLib.Save(); - - QuestionLib.Load(); - QuestionLib.Save(); + SaveAll(); } - private void RegionToDCV() + private void RegionToDetailView() { - Debug.Assert(SelectedCQData != null); - GetQuestions(SelectedCQData.ProblemIDS); + if(selectedStudent == null) return; + ErrorSet = selectedStudent.ErrorSet.GetDetailErrorSetInfo(); + HomeWorkSet = selectedStudent.HomeWorkSet.GetDetailHomeWorkSetList(); + } + + private void RegionToDetailCheckView() + { + if (selectedHomeWorkSet == null) return; + HomeWork = SelectedStudent.HomeWorkSet.GetDetailHomeWorkList(SelectedHomeWorkSet.Lesson); } private void RegionToStudents() @@ -169,43 +212,18 @@ namespace StudentManager.Model menuBars.Add(new MenuBar() { Icon = "CodeGreaterThanOrEqual", Title = "出题", NameSpace = "DetailCheckView" }); } - - private void QueryAll() + private void Load() { - studentDatas.Clear(); - questionDatas.Clear(); - //cQDatas.Clear(); - //SQLHelper.Query(Tables.CQTable,1).ForEach(x => cQDatas.Add(x)); - SQLHelper.Query(Tables.UserTable).ForEach(x => studentDatas.Add(x)); - SQLHelper.Query(Tables.QuesTable).ForEach(x => questionDatas.Add(x)); - - - - ComputeData(); - //SQLHelper.UnionQuery().ForEach(x => questionDatas.Add(x)); + StudentLib.Load(); + QuestionLib.Load(); + studentDatas = StudentLib.GetAllStudents(); + questionDatas = QuestionLib.GetAllQuestion(); } - private void ComputeData() + private void SaveAll() { - TotalQuestions = questionDatas.Count(); - - foreach (var item in StudentDatas) - { - item.UnCorrectCount = item.TotalsQuestions - item.CorrectionCount; - item.ErrorRate = item.TotalsQuestions / TotalQuestions; - item.CorrectRate = item.CorrectionCount / item.TotalsQuestions; - } - } - - private void GetQuestions(int[] ids) - { - if (SelectedCQData == null) return; - studentCQDatas.Clear(); - foreach (var id in ids) - { - var q = QuestionDatas.FirstOrDefault((s) => s.Id == id); - studentCQDatas.Add(q); - } + StudentLib.Save(); + QuestionLib.Save(); } } }