This commit is contained in:
wangxiner55 2024-09-20 19:07:08 +08:00
parent 8672bd5fc8
commit f19c955def
11 changed files with 278 additions and 76 deletions

View File

@ -149,7 +149,7 @@ namespace StudentManager.Common
if (id.QuestionBase.Status == false || ErrorArray.Contains(id.QuestionBase.ID)) return;
if ((id.CorrectCount - id.CorrectCount) <= CorrectThresholds)
if ((id.CorrectCount - id.ErrorCount) <= CorrectThresholds)
{
id.QuestionBase.Status = false;
CorrectArray.Remove(id.QuestionBase.ID);
@ -162,7 +162,7 @@ namespace StudentManager.Common
if (id.QuestionBase.Status == true || CorrectArray.Contains(id.QuestionBase.ID)) return;
if ((id.CorrectCount - id.CorrectCount) > CorrectThresholds)
if ((id.CorrectCount - id.ErrorCount) > CorrectThresholds)
{
id.QuestionBase.Status = true;
ErrorArray.Remove(id.QuestionBase.ID);
@ -175,11 +175,11 @@ namespace StudentManager.Common
AddCorrectQuestion(new QuestionBase { ID = question.Id });
}
public void QueryErrorSet(int id)
public void QueryErrorSet(long id)
{
Errores.Clear();
SQLHelper.Query<UserQuestionData>(Tables.UQTable, id).ForEach(x =>
SQLHelper.Query<UserQuestionData>(id).ForEach(x =>
{
AddQuestion(new QuestionBase { ID = x.PID, Status = x.Status });
});

View File

@ -0,0 +1,18 @@
using StudentManager.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StudentManager.Common
{
public static class FileSystem
{
public static void SaveAll()
{
StudentLib.Save();
QuestionLib.Save();
}
}
}

View File

@ -215,11 +215,11 @@ namespace StudentManager.Common
return works;
}
public void FreshAllHomeWork(int id)
public void FreshAllHomeWork(long id)
{
HomeWorks.Clear();
SQLHelper.Query<CursonQuestionsData>(Tables.CQTable, id).ForEach(x =>
SQLHelper.Query<CursonQuestionsData>(id).ForEach(x =>
{
List<QuestionBase> Questions = new List<QuestionBase>();
x.ProblemIDS.ForEach(y => Questions.Add(new QuestionBase { ID = y, Status = x.CorrectIDS.Contains(y) }));

View File

@ -1,14 +1,12 @@
using DryIoc.ImTools;
using Google.Protobuf.WellKnownTypes;
using MySql.Data.MySqlClient;
using Newtonsoft.Json;
using StudentManager.Common;
using StudentManager.Data;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;
using Enum = System.Enum;
using System.Security.Cryptography;
namespace StudentManager.Common
{
@ -32,7 +30,7 @@ namespace StudentManager.Common
{
if (typeof(T) == typeof(StudentData))
{
(data as StudentData).UID = (int)reader[0];
(data as StudentData).UID = (long)reader[0];
(data as StudentData).Name = reader[1].ToString();
(data as StudentData).Gender = reader[2].ToString();
(data as StudentData).Contact = reader[3].ToString();
@ -40,14 +38,20 @@ 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];
(data as StudentData).CurronHomeWorkIndex = (UInt16)reader[8];
(data as StudentData).Password = reader[9].ToString();
(data as StudentData).Birthdate = (DateTime)reader[10];
(data as StudentData).HWQTotalCount = (uint)reader[11];
(data as StudentData).HWQTotalErrorCount = (uint)reader[12];
}
else if (typeof(T) == typeof(QuestionData))
{
DifficultyLevel dLevel = DifficultyLevel.easy;
QStatus qStatus = QStatus.published;
QType qType = QType.;
(data as QuestionData).Id = (int)reader[0];
(data as QuestionData).Type = reader[1].ToString();
Enum.TryParse(reader[1].ToString(), true, out qType);
(data as QuestionData).Type = qType;
(data as QuestionData).Stem = reader[2].ToString();
(data as QuestionData).Answer = reader[3].ToString();
Enum.TryParse(reader[4].ToString(), true, out dLevel);
@ -80,11 +84,11 @@ namespace StudentManager.Common
//for (int i = 0; i < reader.FieldCount; ++i)
//{
// data?.GetType().GetProperties().ForEach(x => { x.SetValue(reader[i].GetType(), reader[i]); });
//}
}
//for (int i = 0; i < reader.FieldCount; ++i)
//{
// data?.GetType().GetProperties().ForEach(x => { x.SetValue(reader[i].GetType(), reader[i]); });
//}
}
}
@ -98,6 +102,14 @@ namespace StudentManager.Common
public static class SQLHelper
{
private static Dictionary<System.Type, string> TypeMap = new Dictionary<System.Type, string>
{
{ typeof(QuestionData), "questions" },
{ typeof(CursonQuestionsData), "curson_questions" },
{ typeof(StudentData), "users" },
{ typeof(UserQuestionData), "user_data" },
};
static string config = "server=8.137.125.29;port=3306;user=StudentManager;password=wangxin55;database=studentmanager";
static MySqlConnection connection = null;
static MySqlCommand cmd = null;
@ -105,13 +117,16 @@ namespace StudentManager.Common
// update ** set ** = '**',... where ** = **;
// insert into ** values('**','**'...);
// delete from ** where ** = **;
public static List<T> Query<T>(string tableName, int id = -1, params string[] queryParams) where T : IDataCommon, new()
public static List<T> Query<T>(long id = 9999999, params string[] queryParams) where T : IDataCommon, new()
{
string tableName = string.Empty;
TypeMap.TryGetValue(typeof(T), out tableName);
connection = new MySqlConnection(config);
List<T> result = new List<T>();
string idName = typeof(T) == typeof(StudentData) ? "user_id" : typeof(T) == typeof(QuestionData) ? "problem_id" : "user_id";
string idName = typeof(T) == typeof(StudentData) ? "user_id" : typeof(T) == typeof(QuestionData) ? "problem_id" : "user_id";
try
{
connection.Open();
@ -121,13 +136,13 @@ namespace StudentManager.Common
string filedList = string.Join(",", queryParams);
queryStr = $"select {filedList} from {tableName};";
if (id != -1)
if (id != 9999999)
queryStr = $@"select {filedList} from {tableName} WHERE {idName} = {id};";
}
else
{
queryStr = $"select * from {tableName};";
if (id != -1)
if (id != 9999999)
queryStr = $@"select * from {tableName} WHERE {idName} = {id};";
}
@ -157,7 +172,7 @@ namespace StudentManager.Common
}
}
public static List<T> UnionQuery<T>(int id = -1, string tableName = "questions", string otherTable = "user_data") where T : IDataCommon, new()
public static List<T> UnionQuery<T>(int id = 9999999, string tableName = "questions", string otherTable = "user_data") where T : IDataCommon, new()
{
connection = new MySqlConnection(config);
@ -165,9 +180,9 @@ namespace StudentManager.Common
try
{
connection.Open();
connection = new MySqlConnection(config);
string queryStr = "";
if(id == -1)
if (id == 9999999)
queryStr = $@"SELECT u.user_id, q.* FROM {otherTable} u JOIN {tableName} q ON u.problem_id = q.problem_id";
else
queryStr = $@"SELECT q.* FROM {tableName} q JOIN {otherTable} u ON q.problem_id = u.problem_id WHERE u.user_id = {id}";
@ -198,10 +213,39 @@ namespace StudentManager.Common
}
}
public static void Add()
public static void Add<T>(T value)
{
connection = new MySqlConnection(config);
try
{
string stableName = string.Empty;
TypeMap.TryGetValue(typeof(T), out stableName);
connection.Open();
if (typeof(T) == typeof(QuestionData))
{
var ques = value as QuestionData;
string sql = $"INSERT INTO {stableName} " +
$"(problem_id, problem_type, problem_stem, problem_answer, difficulty_level, category, tags, source, lesson, status) " +
$"VALUES (@Id, @Type, @Stem, @Answer, @DifficultyLevel, @Category, @Tags, @Source, @Lesson, @Status)";
MySqlCommand cmd = new MySqlCommand(sql, connection);
cmd.Parameters.AddWithValue("@Id", ques.Id);
cmd.Parameters.AddWithValue("@Type", ques.Type.ToString());
cmd.Parameters.AddWithValue("@Stem", ques.Stem);
cmd.Parameters.AddWithValue("@Answer", ques.Answer);
cmd.Parameters.AddWithValue("@DifficultyLevel", ques.DifficultyLevel.ToString());
cmd.Parameters.AddWithValue("@Category", ques.Category);
cmd.Parameters.AddWithValue("@Tags", ques.Tags);
cmd.Parameters.AddWithValue("@Source", ques.Source);
cmd.Parameters.AddWithValue("@Lesson", ques.Lesson);
cmd.Parameters.AddWithValue("@Status", ques.Status.ToString());
cmd.ExecuteNonQuery();
}
//string sql = $"insert into {stableName}"
}
catch (Exception ex)
{
@ -209,7 +253,100 @@ namespace StudentManager.Common
}
finally
{
cmd.Dispose();
connection.Close();
}
}
internal static void UpdateErrorSet(long UID, int PID, bool status)
{
using (MySqlConnection connection = new MySqlConnection(config))
{
try
{
connection.Open();
// 检查记录是否存在
string checkQuery = "SELECT COUNT(*) FROM user_data WHERE user_id = @user_id AND problem_id = @problem_id";
using (MySqlCommand checkCmd = new MySqlCommand(checkQuery, connection))
{
checkCmd.Parameters.AddWithValue("@user_id", UID);
checkCmd.Parameters.AddWithValue("@problem_id", PID);
int recordCount = Convert.ToInt32(checkCmd.ExecuteScalar());
if (recordCount > 0)
{
// 记录存在,执行更新操作
string updateQuery = "UPDATE user_data SET status = @status WHERE user_id = @user_id AND problem_id = @problem_id";
using (MySqlCommand updateCmd = new MySqlCommand(updateQuery, connection))
{
updateCmd.Parameters.AddWithValue("@user_id", UID);
updateCmd.Parameters.AddWithValue("@problem_id", PID);
updateCmd.Parameters.AddWithValue("@status", status);
updateCmd.ExecuteNonQuery();
}
}
else
{
if (status == false)
{
string updateQuery = $"INSERT INTO user_data (user_id, problem_id) VALUES (@user_id, @problem_id)";
using (MySqlCommand updateCmd = new MySqlCommand(updateQuery, connection))
{
updateCmd.Parameters.AddWithValue("@user_id", UID);
updateCmd.Parameters.AddWithValue("@problem_id", PID);
updateCmd.ExecuteNonQuery();
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
connection.Close();
}
}
}
internal static void UpdateHomework(long UID, int lesson, string totalArray, string correctArray, DateTime dateTime, bool status)
{
using (MySqlConnection connection = new MySqlConnection(config))
{
try
{
connection.Open();
string updateQuery = "UPDATE curson_questions SET status = @status, problem_ids = @problem_ids, " +
"correct_ids = @correct_ids, update_time = @update_time WHERE user_id = @user_id AND lesson = @lesson";
using (MySqlCommand updateCmd = new MySqlCommand(updateQuery, connection))
{
updateCmd.Parameters.AddWithValue("@user_id", UID);
updateCmd.Parameters.AddWithValue("@lesson", lesson);
updateCmd.Parameters.AddWithValue("@status", status);
updateCmd.Parameters.AddWithValue("@problem_ids", totalArray);
updateCmd.Parameters.AddWithValue("@correct_ids", correctArray);
updateCmd.Parameters.AddWithValue("@update_time", dateTime);
updateCmd.ExecuteNonQuery();
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
connection.Close();
}
}
}
}

View File

@ -31,12 +31,12 @@ namespace StudentManager.Data
public class QuestionData : IDataCommon
{
public int Id { get; set; } = 0;
public string Type { get; set; } = string.Empty;
public QType Type { get; set; } = QType.;
public string Stem { get; set; } = string.Empty;
public string Answer { get; set; } = String.Empty;
public DifficultyLevel DifficultyLevel { get; set; } = DifficultyLevel.easy;
public string Category { get; set; } = string.Empty;
public string Tags { get; set; } = string.Empty;
public string Tags { get; set; } = "默认";
public string Source { get; set; } = string.Empty;
public int Lesson { get; set; } = 0;
public QStatus Status { get; set; } = QStatus.published;

View File

@ -39,7 +39,7 @@ namespace StudentManager.Data
public static void FreshAllQuestion()
{
SQLHelper.Query<QuestionData>(Tables.QuesTable).ForEach(x => QuestionDic.Add(x.Id, x));
SQLHelper.Query<QuestionData>().ForEach(x => QuestionDic.Add(x.Id, x));
}
public static ObservableCollection<QuestionData> GetAllQuestion()
@ -62,6 +62,7 @@ namespace StudentManager.Data
public static void Add(QuestionData question)
{
QuestionDic.Add(question.Id, question);
SQLHelper.Add(question);
}
public static void Remove(QuestionData question)

View File

@ -6,24 +6,41 @@ using System.Threading.Tasks;
namespace StudentManager.Data
{
public enum Gender
{
,
,
}
public class StudentData : IDataCommon
{
public int UID { get; set; } = 1;
// Count info
public long UID { get; set; } = 1;
public string Password { get; set; } = "123456";
// Base info
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 DateTime Birthdate { get; set; } = DateTime.Now;
// Error Set
public int TotalsQuestions { get; set; } = 0;
public int CorrectionCount { get; set; } = 0;
public int HomeWork { get; set; } = 0;
// HomeWork
public int CurronHomeWorkIndex { get; set; } = 0;
// HomeWorkSet
public uint HWQTotalCount { get; set; } = 0;
public uint HWQTotalErrorCount { get; set; } = 0;
// Extension
public float ErrorRate { get; set; } = 0;
public float CorrectRate { get; set; } = 0;
public int UnCorrectCount { get; set; } = 0;
//public string TableName { get => "users"; set => throw new NotImplementedException(); }
}
}

View File

@ -16,7 +16,7 @@ namespace StudentManager.Data
{
public static string LibPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.Desktop)}\\FileLib\\";
public static string FileName = "studentLib.dbsi";
public static Dictionary<int, StudentInfo> StudentDic { get; set; } = new Dictionary<int, StudentInfo>();
public static Dictionary<long, StudentInfo> StudentDic { get; set; } = new Dictionary<long, StudentInfo>();
public static void Add(StudentInfo studentInfo)
{
@ -30,7 +30,7 @@ namespace StudentManager.Data
Debug.Assert(Path.Exists(LibPath));
string file = File.ReadAllText(LibPath + FileName);
StudentDic = JsonSerializer.Deserialize<Dictionary<int, StudentInfo>>(file);
StudentDic = JsonSerializer.Deserialize<Dictionary<long, StudentInfo>>(file);
}
public static void Save()
@ -43,7 +43,7 @@ namespace StudentManager.Data
{
StudentDic.Clear();
SQLHelper.Query<StudentData>(Tables.UserTable).ForEach(x =>
SQLHelper.Query<StudentData>().ForEach(x =>
StudentDic.Add(x.UID, new StudentInfo
{
UID = x.UID,
@ -51,7 +51,7 @@ namespace StudentManager.Data
Address = x.Address,
Contact = x.Contact,
Grade = x.Grade,
CurrentHomeWorkIndex = x.HomeWork,
CurrentHomeWorkIndex = x.CurronHomeWorkIndex,
}));
foreach (var item in StudentDic)
@ -70,12 +70,12 @@ namespace StudentManager.Data
return list;
}
public static StudentInfo QueryStudentDetailInfo(int uid)
public static StudentInfo QueryStudentDetailInfo(long uid)
{
return GetStudentDetailInfo(Get(uid));
}
public static StudentInfo Get(int uid)
public static StudentInfo Get(long uid)
{
if (!StudentDic.ContainsKey(uid)) return null;
return StudentDic[uid];
@ -86,7 +86,7 @@ namespace StudentManager.Data
StudentDic.Remove(studentInfo.UID);
}
public static void Remove(int id)
public static void Remove(long id)
{
StudentDic.Remove(id);
}
@ -108,7 +108,7 @@ namespace StudentManager.Data
public class StudentInfo
{
public int UID { get; set; } = 1;
public long UID { get; set; } = 1;
public string Name { get; set; } = "Name";
public string Gender { get; set; } = "Gender";
public string Contact { get; set; } = "Contact";

View File

@ -55,7 +55,7 @@
<GridViewColumn Header="类型">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ComboBox SelectedIndex="0" ItemsSource="{Binding Source={StaticResource TypeEnumValues}}"/>
<ComboBox SelectedItem="{Binding Type, Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource TypeEnumValues}}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
@ -76,7 +76,7 @@
<GridViewColumn Header="难度">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ComboBox SelectedIndex="0" ItemsSource="{Binding Source={StaticResource DifficultyEnumValues}}"/>
<ComboBox SelectedItem="{Binding DifficultyLevel, Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource DifficultyEnumValues}}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
@ -97,7 +97,7 @@
<GridViewColumn Header="状态">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ComboBox SelectedIndex="0" ItemsSource="{Binding Source={StaticResource PublishEnumValues}}"/>
<ComboBox SelectedItem="{Binding Status, Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource PublishEnumValues}}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
@ -124,14 +124,16 @@
<StackPanel>
<Button Content="删除" Style="{StaticResource MaterialDesignFlatButton}" Padding="5" Foreground="White"
Command="{Binding DataContext.RemoveNewColumnCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"/>
/>
</StackPanel>
</DataTemplate>
</GridViewColumn.HeaderTemplate>
<GridViewColumn.CellTemplate>
<DataTemplate>
<Button Content="删除" Style="{StaticResource MaterialDesignFlatButton}" Padding="5"
Command="{Binding DataContext.RemoveNewColumnCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"/>
Command="{Binding DataContext.RemoveNewColumnCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}"
CommandParameter="{Binding}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>

View File

@ -21,8 +21,8 @@
</Grid.ColumnDefinitions>
<ItemsControl ItemsSource="{Binding MenuBars}">
<DockPanel LastChildFill="False">
<ItemsControl DockPanel.Dock="Top" ItemsSource="{Binding MenuBars}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Content="{Binding Title}" Command="{Binding DataContext.RegionTo, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
@ -31,6 +31,10 @@
</ItemsControl.ItemTemplate>
</ItemsControl>
<Button Margin="5" HorizontalAlignment="Stretch" DockPanel.Dock="Bottom" Content="保存"
Command="{Binding SaveAllCommand}"/>
</DockPanel>
<ContentControl Grid.Column="1" prism:RegionManager.RegionName="{x:Static extent:PrismManager.MainRegionName}"/>
</Grid>
</Window>

View File

@ -1,4 +1,5 @@
using Mysqlx.Crud;
using Newtonsoft.Json;
using Org.BouncyCastle.Utilities;
using StudentManager.Common;
using StudentManager.Data;
@ -68,7 +69,7 @@ namespace StudentManager.Model
private ObservableCollection<DetailHomeWorkSetInfo> homeWorkSet = new ObservableCollection<DetailHomeWorkSetInfo>();
public ObservableCollection<DetailHomeWorkSetInfo> HomeWorkSet { get { return homeWorkSet; } private set { homeWorkSet = value; RaisePropertyChanged(); } }
public ObservableCollection<DetailHomeWorkSetInfo> HomeWorkSet { get { return homeWorkSet; } private set { homeWorkSet = value; RaisePropertyChanged(); } }
private ObservableCollection<DetailHomeWorkInfo> homeWork = new ObservableCollection<DetailHomeWorkInfo>();
public ObservableCollection<DetailHomeWorkInfo> HomeWork { get { return homeWork; } private set { homeWork = value; RaisePropertyChanged(); } }
@ -140,14 +141,16 @@ namespace StudentManager.Model
public DelegateCommand AddNewColumnCommand { get; set; }
public DelegateCommand SubmitAddQuestionsCommand { get; set; }
public DelegateCommand ClearnAddQuestionsCommand { get; set; }
public DelegateCommand SaveAllCommand { get; set; }
Students(IRegionManager regionManager)
{
CreateMenuBar();
RegionTo = new DelegateCommand<string>((x) => {
RegionTo = new DelegateCommand<string>((x) =>
{
regionManager.Regions[PrismManager.MainRegionName].RequestNavigate(x.ToString());
if(x == "DetailCheckView")
if (x == "DetailCheckView")
{
RegionToDetailCheckView();
}
@ -176,14 +179,14 @@ namespace StudentManager.Model
HomeWorkSelectedCommand = new DelegateCommand<DetailHomeWorkInfo>((e) =>
{
if(e == null) return;
if (e == null) return;
//HomeWork =
});
DeleteQuestionCommand = new DelegateCommand<QuestionData>((x) =>
{
if(x == null) return;
var c = MessageBox.Show("确定删除吗?","确认",MessageBoxButton.OKCancel);
if (x == null) return;
var c = MessageBox.Show("确定删除吗?", "确认", MessageBoxButton.OKCancel);
if (c != MessageBoxResult.OK) return;
QuestionLib.Remove(x);
QuestionDatas = QuestionLib.GetAllQuestion();
@ -210,6 +213,8 @@ namespace StudentManager.Model
ADDQuestionDatas.Clear();
});
SaveAllCommand = new DelegateCommand(() => FileSystem.SaveAll());
SubmitAddQuestionsCommand = new DelegateCommand(() =>
{
@ -225,10 +230,10 @@ namespace StudentManager.Model
}
foreach (var item in preToRemove)
{
ADDQuestionDatas.Remove(item);
}
});
{
ADDQuestionDatas.Remove(item);
}
});
Load();
@ -245,8 +250,6 @@ namespace StudentManager.Model
this.regionManager = regionManager;
SaveAll();
}
private int ConvertToHashInt(string item)
@ -258,15 +261,39 @@ namespace StudentManager.Model
private void SubmitHomeWork()
{
// update error set and local homework
SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).Questions.ForEach(x =>
{
x.Status = HomeWork.FirstOrDefault(hw => hw.PID == x.ID).Status;
if (x.Status != HomeWork.FirstOrDefault(hw => hw.PID == x.ID).Status)
{
x.Status = HomeWork.FirstOrDefault(hw => hw.PID == x.ID).Status;
SelectedStudent.ErrorSet.AddQuestion(x);
SQLHelper.UpdateErrorSet(SelectedStudent.UID, x.ID, x.Status);
}
});
// update homework other info and online info
SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).Status = true;
SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).DateTime = DateTime.Now;
List<int> correctHomeworkArray = new List<int>();
List<int> totalHomeworkArray = new List<int>();
SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).Questions.ForEach(x =>
{
totalHomeworkArray.Add(x.ID);
if (x.Status != false) correctHomeworkArray.Add(x.ID);
});
SQLHelper.UpdateHomework(SelectedStudent.UID, SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).Lesson,
JsonConvert.SerializeObject(totalHomeworkArray),
JsonConvert.SerializeObject(correctHomeworkArray), SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).DateTime,
SelectedStudent.HomeWorkSet.Get(SelectedHomeWorkSet.Lesson).Status);
}
private void RegionToDetailView()
{
if(selectedStudent == null) return;
if (selectedStudent == null) return;
ErrorSet = selectedStudent.ErrorSet.GetDetailErrorSetInfo();
HomeWorkSet = selectedStudent.HomeWorkSet.GetDetailHomeWorkSetList();
}
@ -300,10 +327,6 @@ namespace StudentManager.Model
questionDatas = QuestionLib.GetAllQuestion();
}
private void SaveAll()
{
StudentLib.Save();
QuestionLib.Save();
}
}
}