diff --git a/StudentManager/Common/ErrorSet.cs b/StudentManager/Common/ErrorSet.cs new file mode 100644 index 0000000..be26481 --- /dev/null +++ b/StudentManager/Common/ErrorSet.cs @@ -0,0 +1,86 @@ +using StudentManager.Data; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StudentManager.Common +{ + public class ErrorInfo + { + public int ID { get; set; } = 0; + public bool Status { get; set; } = false; + } + + public class ErrorSet + { + public int TotalCount { get; set; } = 0; + public int CorrectCount { get; set; } = 0; + public Dictionary Errores { get; set; } = new Dictionary(); + public List ErrorArray { get; set; } = new List(); + public List CorrectArray { get; set; } = new List(); + + public void InitErrorSetData() + { + foreach (var item in Errores) + { + if(item.Value.Status == true) CorrectArray.Add(item.Value.ID); + else ErrorArray.Add(item.Value.ID); + } + } + + public void AddErrorQuestion(int id) + { + if (Errores.ContainsKey(id)) + { + TotalCount++; + ErrorArray.Add(id); + } + else + { + Errores.Add(id, new ErrorInfo { ID = id }); + } + } + + public void AddCorrectQuestion(int id) + { + if (Errores.ContainsKey(id)) + { + TotalCount++; + CorrectCount++; + Errores[id].Status = true; + + ErrorArray.Remove(id); + CorrectArray.Add(id); + } + } + + + public void AddErrorQuestion(QuestionData question) + { + if (Errores.ContainsKey(question.Id)) + { + TotalCount++; + ErrorArray.Add(question.Id); + } + else + { + Errores.Add(question.Id, new ErrorInfo { ID = question.Id }); + } + } + + public void AddCorrectQuestion(QuestionData question) + { + if (Errores.ContainsKey(question.Id)) + { + TotalCount++; + CorrectCount++; + Errores[question.Id].Status = true; + + ErrorArray.Remove(question.Id); + CorrectArray.Add(question.Id); + } + } + } +} diff --git a/StudentManager/Common/HomeWorkManager.cs b/StudentManager/Common/HomeWorkManager.cs new file mode 100644 index 0000000..8afdd7f --- /dev/null +++ b/StudentManager/Common/HomeWorkManager.cs @@ -0,0 +1,37 @@ +using DryIoc.ImTools; +using StudentManager.Data; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; + +namespace StudentManager.Common +{ + public static class HomeWorkManager + { + public static HomeWork CommonHomeWork { get; set; } = new HomeWork(); + + public static void Create(StudentInfo student,int lesson, int workNum = 10) + { + HomeWork work = new HomeWork { Lesson = lesson}; + foreach(var item in student.ErrorSet.ErrorArray) + { + work.AddHomeWork(item); + } + + if (CommonHomeWork.QuestionInfo.Count > 0) + { + work.Append(CommonHomeWork); + } + + } + + + public static void Public() + { + + } + } +} diff --git a/StudentManager/Common/HomeWorkSet.cs b/StudentManager/Common/HomeWorkSet.cs new file mode 100644 index 0000000..ad562e0 --- /dev/null +++ b/StudentManager/Common/HomeWorkSet.cs @@ -0,0 +1,80 @@ +using DryIoc.ImTools; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StudentManager.Common +{ + public class HomeWork + { + public int Lesson { get; set; } = 0; + public bool Status { get; set; } = false; + public HashSet QuestionInfo { get; set; } = new HashSet(); + + public void AddHomeWork(ErrorInfo workInfo) + { + QuestionInfo.Add(workInfo); + } + + public void AddHomeWork(int id) + { + QuestionInfo.Add(new ErrorInfo { ID = id }); + } + + public void RemoveHomeWork(ErrorInfo workInfo) + { + QuestionInfo.Remove(workInfo); + } + + public void Append(HomeWork homeWork) + { + foreach (var item in homeWork.QuestionInfo) + { + QuestionInfo.Add(item); + } + + } + } + + public class HomeWorkSet + { + private Dictionary HomeWorks { get; set; } = new Dictionary(); + + + public void AddHomeWork(HomeWork homeWork) + { + HomeWorks.Add(homeWork.Lesson, homeWork); + } + + + public void RemoveHomeWork(HomeWork homeWork) + { + HomeWorks.Remove(homeWork.Lesson); + } + + public HomeWork Get(int cursonId) + { + return HomeWorks[cursonId]; + } + + public List GetAll() + { + return HomeWorks.Values.ToList(); + } + + public ObservableCollection GetAllByColl() + { + ObservableCollection works = new ObservableCollection(); + + foreach (var item in HomeWorks) + { + works.Add(item.Value); + } + return works; + } + } + +} diff --git a/StudentManager/Data/CursonQuestionsData.cs b/StudentManager/Data/CursonQuestionsData.cs index 74946b0..54e18d8 100644 --- a/StudentManager/Data/CursonQuestionsData.cs +++ b/StudentManager/Data/CursonQuestionsData.cs @@ -18,6 +18,6 @@ namespace StudentManager.Data public int Status { get; set; } = 0; - public string TableName { get => "users"; set => throw new NotImplementedException(); } + //public string TableName { get => "users"; set => throw new NotImplementedException(); } } } diff --git a/StudentManager/Data/IDataCommon.cs b/StudentManager/Data/IDataCommon.cs index 5ce7b12..b08ebe8 100644 --- a/StudentManager/Data/IDataCommon.cs +++ b/StudentManager/Data/IDataCommon.cs @@ -8,6 +8,6 @@ namespace StudentManager.Data { public interface IDataCommon { - public string TableName { get; set; } + //public string TableName { get; set; } } } diff --git a/StudentManager/Data/QuestionData.cs b/StudentManager/Data/QuestionData.cs index e38bfed..cc7fe7e 100644 --- a/StudentManager/Data/QuestionData.cs +++ b/StudentManager/Data/QuestionData.cs @@ -34,6 +34,6 @@ namespace StudentManager.Data public QStatus Status { get; set; } = QStatus.published; - public string TableName { get => "questions"; set => throw new NotImplementedException(); } + //public string TableName { get => "questions"; set => throw new NotImplementedException(); } } } diff --git a/StudentManager/Data/QuestionLib.cs b/StudentManager/Data/QuestionLib.cs new file mode 100644 index 0000000..2317fca --- /dev/null +++ b/StudentManager/Data/QuestionLib.cs @@ -0,0 +1,63 @@ +using Microsoft.VisualBasic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; + +namespace StudentManager.Data +{ + public static class QuestionLib + { + public static string LibPath = "C:\\Users\\zc\\Desktop\\FileLib\\"; + public static string FileName = "questionLib.dbqi"; + public static Dictionary QuestionDic { get; set; } = new Dictionary(); + + public static void Load() + { + QuestionDic.Clear(); + + Debug.Assert(Path.Exists(LibPath)); + string file = File.ReadAllText(LibPath + FileName); + QuestionDic = JsonSerializer.Deserialize>(file); + } + public static void Save() + { + File.WriteAllText((LibPath + FileName), JsonSerializer.Serialize(QuestionDic)); + } + + public static void Test() + { + QuestionDic.Add(1, new QuestionData + { + Id = 1, + Type = "test" + }); + } + + public static QuestionData Get(int id) + { + if (!QuestionDic.ContainsKey(id)) return null; + + return QuestionDic[id]; + } + + public static void Add(QuestionData question) + { + QuestionDic.Add(question.Id, question); + } + + public static void Remove(QuestionData question) + { + QuestionDic.Remove(question.Id); + } + + public static void Remove(int id) + { + QuestionDic.Remove(id); + } + } +} diff --git a/StudentManager/Data/StudentData.cs b/StudentManager/Data/StudentData.cs index 2f744bd..883fdf8 100644 --- a/StudentManager/Data/StudentData.cs +++ b/StudentManager/Data/StudentData.cs @@ -24,6 +24,6 @@ namespace StudentManager.Data - public string TableName { get => "users"; set => throw new NotImplementedException(); } + //public string TableName { get => "users"; set => throw new NotImplementedException(); } } } diff --git a/StudentManager/Data/StudentInfo.cs b/StudentManager/Data/StudentInfo.cs new file mode 100644 index 0000000..62c61da --- /dev/null +++ b/StudentManager/Data/StudentInfo.cs @@ -0,0 +1,79 @@ +using StudentManager.Common; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; + +namespace StudentManager.Data +{ + public static class StudentLib + { + public static string LibPath = "C:\\Users\\zc\\Desktop\\FileLib\\"; + public static string FileName = "studentLib.dbsi"; + public static Dictionary StudentDic { get; set; } = new Dictionary(); + + public static void Add(StudentInfo studentInfo) + { + StudentDic.Add(studentInfo.UID, studentInfo); + } + + + public static void Load() + { + StudentDic.Clear(); + + Debug.Assert(Path.Exists(LibPath)); + string file = File.ReadAllText(LibPath + FileName); + StudentDic = JsonSerializer.Deserialize>(file); + } + + public static void Save() + { + File.WriteAllText((LibPath + FileName), JsonSerializer.Serialize(StudentDic)); + } + + public static void Test() + { + StudentDic.Add(1, new StudentInfo + { + UID = 123, + Name = "John Doe", + Gender = "Male", + Contact = "123-456-7890", + Address = "123 Main St", + Grade = 10, + }); + } + + public static void Remove(StudentInfo studentInfo) + { + StudentDic.Remove(studentInfo.UID); + } + + public static void Remove(int id) + { + StudentDic.Remove(id); + } + } + + public class StudentInfo + { + public int UID { get; set; } = 1; + public string Name { get; set; } = "Name"; + public string Gender { get; set; } = "Gender"; + public string Contact { get; set; } = "Contact"; + public string Address { get; set; } = "Address"; + public int Grade { get; set; } = 1; + + public ErrorSet ErrorSet { get; set; } = new ErrorSet(); + public HomeWorkSet HomeWorkSet { get; set; } = new HomeWorkSet(); + + public HomeWork CurentHomeWork { get; set; } = new HomeWork(); + + + } +} diff --git a/StudentManager/Editor/CheckView.xaml b/StudentManager/Editor/CheckView.xaml index 24f2f96..dee11da 100644 --- a/StudentManager/Editor/CheckView.xaml +++ b/StudentManager/Editor/CheckView.xaml @@ -31,7 +31,17 @@ - + + + + + + + + diff --git a/StudentManager/Editor/CheckView.xaml.cs b/StudentManager/Editor/CheckView.xaml.cs index a99b67b..6154cab 100644 --- a/StudentManager/Editor/CheckView.xaml.cs +++ b/StudentManager/Editor/CheckView.xaml.cs @@ -1,4 +1,5 @@ -using System; +using StudentManager.Model; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -24,5 +25,14 @@ namespace StudentManager.Editor { InitializeComponent(); } - } + + 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 7440aa8..ba4abec 100644 --- a/StudentManager/Editor/DetailCheckView.xaml +++ b/StudentManager/Editor/DetailCheckView.xaml @@ -10,6 +10,21 @@ + + + + + + + + + + + + + @@ -20,7 +35,6 @@ -