new struct of system
This commit is contained in:
parent
1e914941de
commit
82960a6ebe
86
StudentManager/Common/ErrorSet.cs
Normal file
86
StudentManager/Common/ErrorSet.cs
Normal file
@ -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<int, ErrorInfo> Errores { get; set; } = new Dictionary<int, ErrorInfo>();
|
||||
public List<int> ErrorArray { get; set; } = new List<int>();
|
||||
public List<int> CorrectArray { get; set; } = new List<int>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
37
StudentManager/Common/HomeWorkManager.cs
Normal file
37
StudentManager/Common/HomeWorkManager.cs
Normal file
@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
80
StudentManager/Common/HomeWorkSet.cs
Normal file
80
StudentManager/Common/HomeWorkSet.cs
Normal file
@ -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<ErrorInfo> QuestionInfo { get; set; } = new HashSet<ErrorInfo>();
|
||||
|
||||
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<int, HomeWork> HomeWorks { get; set; } = new Dictionary<int, HomeWork>();
|
||||
|
||||
|
||||
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<HomeWork> GetAll()
|
||||
{
|
||||
return HomeWorks.Values.ToList();
|
||||
}
|
||||
|
||||
public ObservableCollection<HomeWork> GetAllByColl()
|
||||
{
|
||||
ObservableCollection <HomeWork> works = new ObservableCollection<HomeWork >();
|
||||
|
||||
foreach (var item in HomeWorks)
|
||||
{
|
||||
works.Add(item.Value);
|
||||
}
|
||||
return works;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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(); }
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,6 @@ namespace StudentManager.Data
|
||||
{
|
||||
public interface IDataCommon
|
||||
{
|
||||
public string TableName { get; set; }
|
||||
//public string TableName { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -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(); }
|
||||
}
|
||||
}
|
||||
|
63
StudentManager/Data/QuestionLib.cs
Normal file
63
StudentManager/Data/QuestionLib.cs
Normal file
@ -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<int, QuestionData> QuestionDic { get; set; } = new Dictionary<int, QuestionData>();
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
QuestionDic.Clear();
|
||||
|
||||
Debug.Assert(Path.Exists(LibPath));
|
||||
string file = File.ReadAllText(LibPath + FileName);
|
||||
QuestionDic = JsonSerializer.Deserialize<Dictionary<int, QuestionData>>(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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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(); }
|
||||
}
|
||||
}
|
||||
|
79
StudentManager/Data/StudentInfo.cs
Normal file
79
StudentManager/Data/StudentInfo.cs
Normal file
@ -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<int, StudentInfo> StudentDic { get; set; } = new Dictionary<int, StudentInfo>();
|
||||
|
||||
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<Dictionary<int, StudentInfo>>(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();
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -31,7 +31,17 @@
|
||||
<Grid Grid.Column="1">
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding SelectedStudent.Name}"/>
|
||||
<ListBox ItemsSource="{Binding CQDatas}">
|
||||
<ListBox ItemsSource="{Binding CQDatas}"
|
||||
SelectionChanged="ListBox_SelectionChanged">
|
||||
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="MouseDoubleClick">
|
||||
<i:InvokeCommandAction
|
||||
CommandParameter="DetailCheckView"
|
||||
Command="{Binding DataContext.RegionTo ,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"/>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,21 @@
|
||||
<Grid>
|
||||
<DockPanel LastChildFill="False">
|
||||
|
||||
<ListBox ItemsSource="{Binding CQDatas}"
|
||||
SelectedItem="{Binding SelectedStudent}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
<i:InvokeCommandAction
|
||||
Command="{Binding DataContext.SelectedCommand ,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"/>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Lesson}"/>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<ListBox DockPanel.Dock="Top" ItemsSource="{Binding StudentCQDatas}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
@ -20,7 +35,6 @@
|
||||
</DockPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
|
||||
</ListBox>
|
||||
<Button DockPanel.Dock="Bottom" Content="提交"/>
|
||||
</DockPanel>
|
||||
|
@ -137,6 +137,13 @@ namespace StudentManager.Model
|
||||
|
||||
QueryAll();
|
||||
|
||||
|
||||
|
||||
StudentLib.Test();
|
||||
StudentLib.Save();
|
||||
|
||||
QuestionLib.Test();
|
||||
QuestionLib.Save();
|
||||
}
|
||||
|
||||
private void RegionToDCV()
|
||||
|
Loading…
Reference in New Issue
Block a user