last
This commit is contained in:
parent
f19c955def
commit
da9c3b7041
@ -25,6 +25,7 @@ namespace StudentManager
|
||||
containerRegistry.RegisterForNavigation<DetailView>();
|
||||
containerRegistry.RegisterForNavigation<DetailCheckView>();
|
||||
containerRegistry.RegisterForNavigation<AddQuestionView>();
|
||||
containerRegistry.RegisterForNavigation<AddHomeWork>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,12 @@ namespace StudentManager.Common
|
||||
};
|
||||
}
|
||||
|
||||
public List<int> GetErrorsList()
|
||||
{
|
||||
return ErrorArray;
|
||||
}
|
||||
|
||||
|
||||
public ObservableCollection<DetailErrorInfo> GetDetailErrorQuestionList()
|
||||
{
|
||||
ObservableCollection<DetailErrorInfo> list = new ObservableCollection<DetailErrorInfo>();
|
||||
|
@ -14,5 +14,13 @@ namespace StudentManager.Common
|
||||
StudentLib.Save();
|
||||
QuestionLib.Save();
|
||||
}
|
||||
|
||||
public static void FreashAllInfo()
|
||||
{
|
||||
StudentLib.FreshAllStudentInfo();
|
||||
QuestionLib.FreshAllQuestion();
|
||||
|
||||
SaveAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,29 +13,11 @@ namespace StudentManager.Common
|
||||
{
|
||||
public static HomeWork CommonHomeWork { get; set; } = new HomeWork();
|
||||
|
||||
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)
|
||||
{
|
||||
work.AddHomeWork(item);
|
||||
}
|
||||
|
||||
if (appedCommonWork && CommonHomeWork.Questions.Count > 0)
|
||||
{
|
||||
work.Append(CommonHomeWork);
|
||||
}
|
||||
|
||||
Public(work);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void Public(HomeWork homeWork)
|
||||
public static void PublicHomework(uint lesson, bool appedCommonWork = false, bool appendErrorSet = false, int workNum = -1)
|
||||
{
|
||||
foreach (var item in StudentLib.StudentDic)
|
||||
{
|
||||
item.Value.PublicHomeWork(homeWork);
|
||||
item.Value.PublicHomeWork(lesson, appedCommonWork, appendErrorSet, workNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace StudentManager.Common
|
||||
|
||||
public class HomeWork
|
||||
{
|
||||
public int Lesson { get; set; } = 0;
|
||||
public uint Lesson { get; set; } = 0;
|
||||
public bool Status { get; set; } = false;
|
||||
public DateTime DateTime { get; set; } = DateTime.Now;
|
||||
public List<QuestionBase> Questions { get; set; } = new List<QuestionBase>();
|
||||
@ -118,7 +118,7 @@ namespace StudentManager.Common
|
||||
public bool Status { get; set; } = false;
|
||||
|
||||
public DateTime DateTime { get; set; } = DateTime.Now;
|
||||
public int Lesson { get; set; } = 0;
|
||||
public uint Lesson { get; set; } = 0;
|
||||
|
||||
public int ErrorCount { get; set; } = 0;
|
||||
public int CorrectCount { get; set; } = 0;
|
||||
@ -128,7 +128,7 @@ namespace StudentManager.Common
|
||||
public class HomeWorkSet
|
||||
{
|
||||
[JsonInclude]
|
||||
private Dictionary<int, HomeWork> HomeWorks { get; set; } = new Dictionary<int, HomeWork>();
|
||||
private Dictionary<uint, HomeWork> HomeWorks { get; set; } = new Dictionary<uint, HomeWork>();
|
||||
public int TotalCount { get; set; } = 0;
|
||||
|
||||
|
||||
@ -138,7 +138,7 @@ namespace StudentManager.Common
|
||||
TotalCount = HomeWorks.Count;
|
||||
}
|
||||
|
||||
public ObservableCollection<DetailHomeWorkInfo> GetDetailHomeWorkList(int lesson)
|
||||
public ObservableCollection<DetailHomeWorkInfo> GetDetailHomeWorkList(uint lesson)
|
||||
{
|
||||
ObservableCollection<DetailHomeWorkInfo> list = new ObservableCollection<DetailHomeWorkInfo>();
|
||||
foreach (var item in HomeWorks[lesson].Questions)
|
||||
@ -188,7 +188,7 @@ namespace StudentManager.Common
|
||||
HomeWorks.Remove(homeWork.Lesson);
|
||||
}
|
||||
|
||||
public HomeWork Get(int cursonId)
|
||||
public HomeWork Get(uint cursonId)
|
||||
{
|
||||
if (HomeWorks.ContainsKey(cursonId)) return HomeWorks[cursonId];
|
||||
return null;
|
||||
@ -196,7 +196,7 @@ namespace StudentManager.Common
|
||||
|
||||
public HomeWork GetLast()
|
||||
{
|
||||
return HomeWorks[TotalCount];
|
||||
return HomeWorks[(uint)TotalCount];
|
||||
}
|
||||
|
||||
public List<HomeWork> GetAll()
|
||||
|
@ -38,7 +38,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).CurronHomeWorkIndex = (UInt16)reader[8];
|
||||
(data as StudentData).CurronHomeWorkIndex = (uint)reader[8];
|
||||
(data as StudentData).Password = reader[9].ToString();
|
||||
(data as StudentData).Birthdate = (DateTime)reader[10];
|
||||
(data as StudentData).HWQTotalCount = (uint)reader[11];
|
||||
@ -59,7 +59,8 @@ namespace StudentManager.Common
|
||||
(data as QuestionData).Category = reader[5].ToString();
|
||||
(data as QuestionData).Tags = reader[6].ToString();
|
||||
(data as QuestionData).Source = reader[7].ToString();
|
||||
Enum.TryParse(reader[8].ToString(), true, out qStatus);
|
||||
(data as QuestionData).Lesson = (uint)reader[8];
|
||||
Enum.TryParse(reader[9].ToString(), true, out qStatus);
|
||||
(data as QuestionData).Status = qStatus;
|
||||
}
|
||||
else if (typeof(T) == typeof(CursonQuestionsData))
|
||||
@ -68,7 +69,7 @@ namespace StudentManager.Common
|
||||
(data as CursonQuestionsData).UID = (int)reader[0];
|
||||
(data as CursonQuestionsData).ProblemIDS = string.IsNullOrEmpty(reader[1].ToString()) ? Array.Empty<int>() : JsonConvert.DeserializeObject<int[]>(reader[1].ToString());
|
||||
(data as CursonQuestionsData).CorrectIDS = string.IsNullOrEmpty(reader[2].ToString()) ? Array.Empty<int>() : JsonConvert.DeserializeObject<int[]>(reader[2].ToString());
|
||||
(data as CursonQuestionsData).Lesson = (byte)reader[3];
|
||||
(data as CursonQuestionsData).Lesson = (uint)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;
|
||||
@ -244,6 +245,8 @@ namespace StudentManager.Common
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
}
|
||||
//string sql = $"insert into {stableName}"
|
||||
}
|
||||
@ -253,7 +256,7 @@ namespace StudentManager.Common
|
||||
}
|
||||
finally
|
||||
{
|
||||
cmd.Dispose();
|
||||
//cmd.Dispose();
|
||||
connection.Close();
|
||||
}
|
||||
}
|
||||
@ -315,7 +318,7 @@ namespace StudentManager.Common
|
||||
}
|
||||
}
|
||||
|
||||
internal static void UpdateHomework(long UID, int lesson, string totalArray, string correctArray, DateTime dateTime, bool status)
|
||||
internal static void UpdateHomework(long UID, uint lesson, string totalArray, string correctArray, DateTime dateTime, bool status)
|
||||
{
|
||||
using (MySqlConnection connection = new MySqlConnection(config))
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ namespace StudentManager.Data
|
||||
public int[] CorrectIDS { get; set; } = { };
|
||||
public DateTime DateTime { get; set; } = DateTime.Now;
|
||||
|
||||
public int Lesson { get; set; } = 0;
|
||||
public uint Lesson { get; set; } = 0;
|
||||
public int TotalCount { get; set; } = 0;
|
||||
public int CorrectCount { get; set; } = 0;
|
||||
public int Status { get; set; } = 0;
|
||||
|
@ -38,8 +38,9 @@ namespace StudentManager.Data
|
||||
public string Category { get; set; } = string.Empty;
|
||||
public string Tags { get; set; } = "默认";
|
||||
public string Source { get; set; } = string.Empty;
|
||||
public int Lesson { get; set; } = 0;
|
||||
public uint Lesson { get; set; } = 0;
|
||||
public QStatus Status { get; set; } = QStatus.published;
|
||||
public DateTime UpdateTime { get; set; } = DateTime.MinValue;
|
||||
|
||||
|
||||
//public string TableName { get => "questions"; set => throw new NotImplementedException(); }
|
||||
|
@ -10,13 +10,26 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using static Mysqlx.Crud.UpdateOperation.Types;
|
||||
|
||||
namespace StudentManager.Data
|
||||
{
|
||||
public class QuestionSetDesc
|
||||
{
|
||||
public uint TotalQuestions { get; set; } = 0;
|
||||
public DateTime UpdateTime { get; set; } = DateTime.Now;
|
||||
public uint Lesson { get; set; } = 0;
|
||||
}
|
||||
|
||||
|
||||
public static class QuestionLib
|
||||
{
|
||||
public static string FileName = "questionLib.dbqi";
|
||||
public static string TableDicFileName = "questionTableDicLib.dbqi";
|
||||
public static string TableDescFileName = "questionTableDescLib.dbqi";
|
||||
public static Dictionary<int, QuestionData> QuestionDic { get; set; } = new Dictionary<int, QuestionData>();
|
||||
public static Dictionary<uint, QuestionSetDesc> QuestionTableDesc { get; set; } = new Dictionary<uint, QuestionSetDesc>();
|
||||
public static Dictionary<uint, Dictionary<int, QuestionData>> QuestionTableDic { get; set; } = new Dictionary<uint, Dictionary<int, QuestionData>>();
|
||||
public static int TotalCount { get; set; } = 0;
|
||||
|
||||
public static int GetQuestionCount()
|
||||
@ -29,18 +42,58 @@ namespace StudentManager.Data
|
||||
QuestionDic.Clear();
|
||||
|
||||
Debug.Assert(Path.Exists(StudentLib.LibPath));
|
||||
|
||||
if (!Path.Exists(StudentLib.LibPath + FileName))
|
||||
File.WriteAllText((StudentLib.LibPath + FileName), "");
|
||||
string file = File.ReadAllText(StudentLib.LibPath + FileName);
|
||||
QuestionDic = JsonSerializer.Deserialize<Dictionary<int, QuestionData>>(file);
|
||||
if (file.Length != 0)
|
||||
QuestionDic = JsonSerializer.Deserialize<Dictionary<int, QuestionData>>(file);
|
||||
|
||||
if (!Path.Exists(StudentLib.LibPath + TableDicFileName))
|
||||
File.WriteAllText((StudentLib.LibPath + TableDicFileName), "");
|
||||
|
||||
file = File.ReadAllText(StudentLib.LibPath + TableDicFileName);
|
||||
if (file.Length != 0)
|
||||
QuestionTableDic = JsonSerializer.Deserialize<Dictionary<uint, Dictionary<int, QuestionData>>>(file);
|
||||
|
||||
if (!Path.Exists(StudentLib.LibPath + TableDescFileName))
|
||||
File.WriteAllText((StudentLib.LibPath + TableDescFileName), "");
|
||||
file = File.ReadAllText(StudentLib.LibPath + TableDescFileName);
|
||||
if (file.Length != 0)
|
||||
QuestionTableDesc = JsonSerializer.Deserialize<Dictionary<uint, QuestionSetDesc>>(file);
|
||||
}
|
||||
public static void Save()
|
||||
{
|
||||
File.WriteAllText((StudentLib.LibPath + FileName), JsonSerializer.Serialize(QuestionDic));
|
||||
File.WriteAllText((StudentLib.LibPath + TableDicFileName), JsonSerializer.Serialize(QuestionTableDic));
|
||||
File.WriteAllText((StudentLib.LibPath + TableDescFileName), JsonSerializer.Serialize(QuestionTableDesc));
|
||||
}
|
||||
|
||||
public static void FreshAllQuestion()
|
||||
{
|
||||
|
||||
QuestionDic.Clear ();
|
||||
QuestionTableDic.Clear ();
|
||||
QuestionTableDesc.Clear ();
|
||||
SQLHelper.Query<QuestionData>().ForEach(x => QuestionDic.Add(x.Id, x));
|
||||
}
|
||||
SQLHelper.Query<QuestionData>().ForEach(x => {
|
||||
if (!QuestionTableDic.ContainsKey(x.Lesson))
|
||||
{
|
||||
QuestionTableDic[x.Lesson] = new Dictionary<int, QuestionData>();
|
||||
}
|
||||
QuestionTableDic[x.Lesson][x.Id] = x;
|
||||
});
|
||||
|
||||
foreach (var QuestionTables in QuestionTableDic)
|
||||
{
|
||||
DateTime update = DateTime.MinValue;
|
||||
foreach(var item in QuestionTables.Value)
|
||||
{
|
||||
update = update > item.Value.UpdateTime ? item.Value.UpdateTime : update;
|
||||
}
|
||||
QuestionTableDesc.Add(QuestionTables.Key, new QuestionSetDesc{ TotalQuestions = (uint)QuestionTables.Value.Count ,UpdateTime = update, Lesson = QuestionTables.Key });
|
||||
}
|
||||
}
|
||||
|
||||
public static ObservableCollection<QuestionData> GetAllQuestion()
|
||||
{
|
||||
@ -51,6 +104,15 @@ namespace StudentManager.Data
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public static ObservableCollection<QuestionData> GetAllQuestionByLesson(uint lesson)
|
||||
{
|
||||
var list = new ObservableCollection<QuestionData>();
|
||||
foreach (QuestionData data in QuestionTableDic[lesson].Values)
|
||||
{
|
||||
list.Add(data);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static QuestionData Get(int id)
|
||||
{
|
||||
@ -59,9 +121,26 @@ namespace StudentManager.Data
|
||||
return QuestionDic[id];
|
||||
}
|
||||
|
||||
public static QuestionData Get(uint lesson , int id)
|
||||
{
|
||||
if (!QuestionDic.ContainsKey(id)) return null;
|
||||
|
||||
return QuestionDic[id];
|
||||
}
|
||||
|
||||
public static void Add(QuestionData question)
|
||||
{
|
||||
QuestionDic.Add(question.Id, question);
|
||||
|
||||
if (!QuestionTableDic.ContainsKey(question.Lesson))
|
||||
{
|
||||
QuestionTableDic[question.Lesson] = new Dictionary<int, QuestionData>();
|
||||
}
|
||||
QuestionTableDic[question.Lesson][question.Id] = question;
|
||||
|
||||
QuestionTableDesc[question.Lesson].UpdateTime = DateTime.Now;
|
||||
QuestionTableDesc[question.Lesson].TotalQuestions = (uint)QuestionTableDic[question.Lesson].Count;
|
||||
|
||||
SQLHelper.Add(question);
|
||||
}
|
||||
|
||||
@ -69,6 +148,9 @@ namespace StudentManager.Data
|
||||
{
|
||||
if (question == null) throw new NullReferenceException();
|
||||
QuestionDic.Remove(question.Id);
|
||||
|
||||
QuestionTableDic[question.Lesson].Remove(question.Id);
|
||||
QuestionTableDesc[question.Lesson].TotalQuestions = (uint)QuestionTableDic[question.Lesson].Count;
|
||||
}
|
||||
|
||||
public static void Remove(int id)
|
||||
|
@ -30,7 +30,7 @@ namespace StudentManager.Data
|
||||
public int CorrectionCount { get; set; } = 0;
|
||||
|
||||
// HomeWork
|
||||
public int CurronHomeWorkIndex { get; set; } = 0;
|
||||
public uint CurronHomeWorkIndex { get; set; } = 0;
|
||||
|
||||
// HomeWorkSet
|
||||
public uint HWQTotalCount { get; set; } = 0;
|
||||
|
@ -120,12 +120,33 @@ namespace StudentManager.Data
|
||||
public ErrorSet ErrorSet { get; set; } = new ErrorSet();
|
||||
public HomeWorkSet HomeWorkSet { get; set; } = new HomeWorkSet();
|
||||
|
||||
public int CurrentHomeWorkIndex = 0;
|
||||
public uint CurrentHomeWorkIndex = 0;
|
||||
public HomeWork CurentHomeWork { get; set; } = new HomeWork();
|
||||
|
||||
public void PublicHomeWork(HomeWork homeWork)
|
||||
public void PublicHomeWork(uint lesson, bool appendCommonWork = false, bool appendErrorSet = false, int workNum = -1)
|
||||
{
|
||||
HomeWork homeWork = new HomeWork();
|
||||
homeWork.Lesson = (uint)(HomeWorkSet.TotalCount + 1) ;
|
||||
homeWork.DateTime = DateTime.Now;
|
||||
if(appendErrorSet)
|
||||
{
|
||||
ErrorSet.ErrorArray.ForEach(error =>
|
||||
homeWork.AddHomeWork(error));
|
||||
}
|
||||
if(appendCommonWork)
|
||||
{
|
||||
foreach (var item in QuestionLib.GetAllQuestionByLesson(lesson))
|
||||
{
|
||||
homeWork.AddHomeWork(item.Id);
|
||||
}
|
||||
}
|
||||
if (workNum != -1)
|
||||
{
|
||||
|
||||
}
|
||||
HomeWorkSet.AddHomeWork(homeWork);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
61
StudentManager/Editor/AddHomeWork.xaml
Normal file
61
StudentManager/Editor/AddHomeWork.xaml
Normal file
@ -0,0 +1,61 @@
|
||||
<UserControl x:Class="StudentManager.Editor.AddHomeWork"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:StudentManager.Editor"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="150"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel VerticalAlignment="Stretch" >
|
||||
<CheckBox Margin="5" Content="是否加入公共题库" IsChecked="{Binding IsAddPublicQuestionsLib}"/>
|
||||
<CheckBox Margin="5" Content="是否需要纠错" IsChecked="{Binding IsNeedErrorset}"/>
|
||||
<CheckBox Margin="5" Content="是否控制题目数量" IsChecked="{Binding IsControlQuestionNum}"/>
|
||||
<StackPanel Margin="5" Orientation="Horizontal">
|
||||
<TextBlock Text=" 课程章节序号 "/>
|
||||
<TextBox Text="{Binding PublicLesson}" MinWidth="50"/>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="5" Orientation="Horizontal">
|
||||
<TextBlock Text=" 问题数量 "/>
|
||||
<TextBox Text="{Binding QuestionCount}" MinWidth="50"/>
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<ScrollViewer Grid.Column="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
||||
<ItemsControl Grid.Row="1" ItemsSource="{Binding HomeworkTestData}" HorizontalAlignment="Center">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Background="#55aaaaaa" BorderBrush="Gray" BorderThickness="1" Padding="5" Height="50" Width="100" Margin="5">
|
||||
<TextBlock Margin="1" TextWrapping="Wrap" FontSize="12" Foreground="White" Text="{Binding Stem}" TextAlignment="Center"/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
|
||||
|
||||
</Grid>
|
||||
<Button Grid.Row="1" DockPanel.Dock="Bottom" Content="发布作业"
|
||||
Command="{Binding PublicHomeWorkCommand}"/>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
28
StudentManager/Editor/AddHomeWork.xaml.cs
Normal file
28
StudentManager/Editor/AddHomeWork.xaml.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace StudentManager.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// AddHomeWork.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AddHomeWork : UserControl
|
||||
{
|
||||
public AddHomeWork()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:StudentManager.Editor"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:dt="clr-namespace:StudentManager.Data"
|
||||
@ -36,17 +37,24 @@
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<DockPanel LastChildFill="False">
|
||||
<ListView DockPanel.Dock="Top"
|
||||
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
|
||||
|
||||
<TextBlock Text="Lesson" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<TextBox Text="{Binding Lesson}"/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<!--<ListView DockPanel.Dock="Top"
|
||||
ItemsSource="{Binding ADDQuestionDatas}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Disabled">
|
||||
|
||||
<!--<i:Interaction.Triggers>
|
||||
--><!--<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="SelectionChanged">
|
||||
<i:InvokeCommandAction
|
||||
CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListBox}}"
|
||||
Command="{Binding DataContext.SelectedCommand ,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"/>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>-->
|
||||
</i:Interaction.Triggers>--><!--
|
||||
|
||||
<ListView.View >
|
||||
|
||||
@ -139,8 +147,11 @@
|
||||
</GridViewColumn>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</ListView>-->
|
||||
|
||||
|
||||
<DataGrid DockPanel.Dock="Top" ItemsSource="{Binding ADDQuestionDatas}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" CanUserDeleteRows="True"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Disabled"/>
|
||||
<Grid HorizontalAlignment="Stretch" DockPanel.Dock="Bottom">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
|
@ -69,7 +69,13 @@
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
|
||||
<Button DockPanel.Dock="Bottom" Content="提交" Command="{Binding SubmitHomeWorkCommand}"/>
|
||||
<!--<DataGrid DockPanel.Dock="Top" ItemsSource="{Binding HomeWork}" CanUserAddRows="False" CanUserDeleteRows="False" >
|
||||
--><!--<DataGrid.Columns>
|
||||
<DataGridCheckBoxColumn Header="正确?" Binding="{Binding Status}" />
|
||||
</DataGrid.Columns>--><!--
|
||||
</DataGrid>-->
|
||||
|
||||
<Button DockPanel.Dock="Bottom" MinHeight=" 50" Content="提交" Command="{Binding SubmitHomeWorkCommand}"/>
|
||||
</DockPanel>
|
||||
</DockPanel>
|
||||
|
||||
|
@ -33,6 +33,8 @@
|
||||
|
||||
<Button Margin="5" HorizontalAlignment="Stretch" DockPanel.Dock="Bottom" Content="保存"
|
||||
Command="{Binding SaveAllCommand}"/>
|
||||
<Button Margin="5" HorizontalAlignment="Stretch" DockPanel.Dock="Bottom" Content="刷新数据"
|
||||
Command="{Binding FreshAllCommand}"/>
|
||||
</DockPanel>
|
||||
|
||||
<ContentControl Grid.Column="1" prism:RegionManager.RegionName="{x:Static extent:PrismManager.MainRegionName}"/>
|
||||
|
@ -24,7 +24,7 @@
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>-->
|
||||
|
||||
<ListView.View>
|
||||
<!--<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn
|
||||
DisplayMemberBinding="{Binding Id}"
|
||||
@ -60,7 +60,13 @@
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView.View>-->
|
||||
|
||||
|
||||
</ListView>
|
||||
|
||||
<DataGrid ItemsSource="{Binding QuestionDatas}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" CanUserDeleteRows="False" CanUserAddRows="False" IsReadOnly="True"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Disabled"/>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
@ -57,6 +57,9 @@ namespace StudentManager.Model
|
||||
private ObservableCollection<QuestionData> questionDatas = new ObservableCollection<QuestionData>();
|
||||
public ObservableCollection<QuestionData> QuestionDatas { get { return questionDatas; } private set { questionDatas = value; RaisePropertyChanged(); } }
|
||||
|
||||
private ObservableCollection<QuestionData> homeworkTestData = new ObservableCollection<QuestionData>();
|
||||
public ObservableCollection<QuestionData> HomeworkTestData { get { return homeworkTestData; } private set { homeworkTestData = value; RaisePropertyChanged(); } }
|
||||
|
||||
private ObservableCollection<QuestionData> preToRemove = new ObservableCollection<QuestionData>();
|
||||
private ObservableCollection<QuestionData> addQuestionDatas = new ObservableCollection<QuestionData>();
|
||||
public ObservableCollection<QuestionData> ADDQuestionDatas { get { return addQuestionDatas; } private set { addQuestionDatas = value; RaisePropertyChanged(); } }
|
||||
@ -125,6 +128,59 @@ namespace StudentManager.Model
|
||||
set { errorSet = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private uint lesson;
|
||||
|
||||
public uint Lesson
|
||||
{
|
||||
get { return lesson; }
|
||||
set { lesson = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private bool isAddPublicQuestionsLib;
|
||||
|
||||
public bool IsAddPublicQuestionsLib
|
||||
{
|
||||
get { return isAddPublicQuestionsLib; }
|
||||
set { isAddPublicQuestionsLib = value; OnPublicHomeworkSelectionChanged(); RaisePropertyChanged(); }
|
||||
|
||||
}
|
||||
|
||||
private bool isNeedErrorset;
|
||||
|
||||
public bool IsNeedErrorset
|
||||
{
|
||||
get { return isNeedErrorset; }
|
||||
set { isNeedErrorset = value; OnPublicHomeworkSelectionChanged(); RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private bool isControlQuestionNum;
|
||||
|
||||
public bool IsControlQuestionNum
|
||||
{
|
||||
get { return isControlQuestionNum; }
|
||||
set { isControlQuestionNum = value; OnPublicHomeworkSelectionChanged(); RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private uint publicLesson;
|
||||
|
||||
public uint PublicLesson
|
||||
{
|
||||
get { return publicLesson; }
|
||||
set { publicLesson = value; OnPublicHomeworkSelectionChanged(); RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private int questionCount;
|
||||
|
||||
public int QuestionCount
|
||||
{
|
||||
get { return questionCount; }
|
||||
set { questionCount = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -142,6 +198,8 @@ namespace StudentManager.Model
|
||||
public DelegateCommand SubmitAddQuestionsCommand { get; set; }
|
||||
public DelegateCommand ClearnAddQuestionsCommand { get; set; }
|
||||
public DelegateCommand SaveAllCommand { get; set; }
|
||||
public DelegateCommand PublicHomeWorkCommand { get; set; }
|
||||
public DelegateCommand FreshAllCommand { get; set; }
|
||||
|
||||
Students(IRegionManager regionManager)
|
||||
{
|
||||
@ -214,15 +272,21 @@ namespace StudentManager.Model
|
||||
});
|
||||
|
||||
SaveAllCommand = new DelegateCommand(() => FileSystem.SaveAll());
|
||||
FreshAllCommand = new DelegateCommand(() => FileSystem.FreashAllInfo());
|
||||
PublicHomeWorkCommand = new DelegateCommand(() =>
|
||||
{
|
||||
HomeWorkManager.PublicHomework(PublicLesson, IsAddPublicQuestionsLib, isNeedErrorset);
|
||||
});
|
||||
|
||||
SubmitAddQuestionsCommand = new DelegateCommand(() =>
|
||||
{
|
||||
|
||||
Debug.Assert(Lesson != 0);
|
||||
|
||||
foreach (var item in ADDQuestionDatas)
|
||||
{
|
||||
item.Id = ConvertToHashInt(item.Stem);
|
||||
|
||||
item.Lesson = Lesson;
|
||||
if (!(QuestionLib.Get(item.Id) == null)) continue;
|
||||
if (string.IsNullOrEmpty(item.Stem) || string.IsNullOrEmpty(item.Source) || string.IsNullOrEmpty(item.Answer)) continue;
|
||||
QuestionLib.Add(item);
|
||||
@ -233,6 +297,8 @@ namespace StudentManager.Model
|
||||
{
|
||||
ADDQuestionDatas.Remove(item);
|
||||
}
|
||||
|
||||
QuestionLib.Save();
|
||||
});
|
||||
|
||||
|
||||
@ -315,7 +381,7 @@ namespace StudentManager.Model
|
||||
menuBars.Add(new MenuBar() { Icon = "CodeGreaterThanOrEqual", Title = "详情", NameSpace = "DetailView" });
|
||||
menuBars.Add(new MenuBar() { Icon = "CodeGreaterThanOrEqual", Title = "题库", NameSpace = "QuestionsView" });
|
||||
menuBars.Add(new MenuBar() { Icon = "CodeGreaterThanOrEqual", Title = "审批", NameSpace = "CheckView" });
|
||||
//menuBars.Add(new MenuBar() { Icon = "CodeGreaterThanOrEqual", Title = "出题", NameSpace = "QuestionsView" });
|
||||
menuBars.Add(new MenuBar() { Icon = "CodeGreaterThanOrEqual", Title = "发布家庭作业", NameSpace = "AddHomeWork" });
|
||||
menuBars.Add(new MenuBar() { Icon = "CodeGreaterThanOrEqual", Title = "出题", NameSpace = "AddQuestionView" });
|
||||
}
|
||||
|
||||
@ -323,10 +389,37 @@ namespace StudentManager.Model
|
||||
{
|
||||
StudentLib.Load();
|
||||
QuestionLib.Load();
|
||||
Reload();
|
||||
}
|
||||
|
||||
private void Reload()
|
||||
{
|
||||
studentDatas.Clear();
|
||||
questionDatas.Clear();
|
||||
studentDatas = StudentLib.GetAllStudents();
|
||||
questionDatas = QuestionLib.GetAllQuestion();
|
||||
}
|
||||
|
||||
|
||||
private void OnPublicHomeworkSelectionChanged()
|
||||
{
|
||||
HomeworkTestData.Clear();
|
||||
if (IsAddPublicQuestionsLib)
|
||||
{
|
||||
HomeworkTestData = QuestionLib.GetAllQuestionByLesson(PublicLesson);
|
||||
}
|
||||
if (IsNeedErrorset)
|
||||
{
|
||||
if (SelectedStudent != null)
|
||||
{
|
||||
foreach (var item in SelectedStudent.ErrorSet.GetDetailErrorQuestionList())
|
||||
{
|
||||
homeworkTestData.Add(item.QuestionData);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.6.1" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="5.1.0" />
|
||||
<PackageReference Include="MySql.Data" Version="9.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
|
@ -7,6 +7,9 @@
|
||||
</ApplicationDefinition>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="Editor\AddHomeWork.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Editor\AddQuestionView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@ -30,6 +33,9 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Editor\AddHomeWork.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Editor\AddQuestionView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
|
Loading…
Reference in New Issue
Block a user