Commit b08793cd authored by 黄奎's avatar 黄奎

页面修改

parent 98c1e4b0
......@@ -286,8 +286,16 @@ namespace Edu.Common
/// <returns></returns>
public static int CalcMinutes(DateTime start, DateTime end)
{
int minutes = Convert.ToInt32((end - start).TotalSeconds);
minutes /= 60;
int minutes = 0;
try
{
minutes = Convert.ToInt32((end - start).TotalSeconds);
minutes /= 60;
}
catch
{
}
return minutes;
}
......
......@@ -66,5 +66,20 @@ namespace Edu.Model.Entity.Exam
/// 是否作答错误(1-是)
/// </summary>
public int IsWrong { get; set; }
/// <summary>
/// 学生答案
/// </summary>
public string StudentAnswer { get; set; }
/// <summary>
/// 学生得分
/// </summary>
public decimal Score { get; set; }
/// <summary>
/// 学生得分
/// </summary>
public decimal StudentScore { get; set; }
}
}
......@@ -10,5 +10,24 @@ namespace Edu.Model.ViewModel.Exam
/// </summary>
public class RB_Student_Practice_Extend : RB_Student_Practice
{
/// <summary>
/// 错题数量
/// </summary>
public int WrongCount { get; set; }
/// <summary>
/// 开始编号
/// </summary>
public int StartId { get; set; }
/// <summary>
/// 是否只查询错题
/// </summary>
public int IsQueryWrong { get; set; }
/// <summary>
/// 分类编号
/// </summary>
public string QCategoryIds { get; set; }
}
}
......@@ -862,6 +862,7 @@ namespace Edu.Module.Exam
string MyUseTime = "";//用时
decimal MyScore = 0;//得分
int MyRank = 0;//排名
int MyTimes = 0;//测评次数
if (tempList != null && tempList.Count > 0)
{
var least = tempList?.OrderBy(qitem => qitem.ExamMinutes)?.FirstOrDefault();
......@@ -874,6 +875,7 @@ namespace Edu.Module.Exam
MyScore = myLast.Score;
MyRank = tempList?.FindIndex(qitem => qitem.StudentId == query.StudentId) ?? 0;
}
MyTimes = tempList?.Where(qitem => qitem.StudentId == query.StudentId)?.Count() ?? 0;
}
var obj = new
{
......@@ -885,6 +887,7 @@ namespace Edu.Module.Exam
MyUseTime,
MyScore,
MyRank,
MyTimes,
};
result.Add(obj);
}
......@@ -903,20 +906,23 @@ namespace Edu.Module.Exam
public List<object> GetAppBankDetailsPageModule(int pageIndex, int pageSize, out long rowsCount, RB_Question_ViewModel query)
{
List<object> result = new List<object>();
var questionList = questionRepository.GetQuestionPageListRepository(pageIndex, pageSize, out rowsCount, query);
var questionList = questionRepository.GetQuestionPageListRepository(pageIndex, pageSize, out rowsCount, query)?.OrderBy(qitem=>qitem.Category)?.ToList();
if (questionList != null && questionList.Count > 0)
{
foreach (var item in questionList)
{
decimal Score = 5;
var QuestionContentObj = analysisQuestion.ParsingQuestion(item.QuestionTypeKey, item.QuestionContent, isNoAnswer: true);
List<object> quesAnswerList = new List<object>();
if (item.QuestionTypeKey == "listening" || item.QuestionTypeKey == "reading-comprehensio")
{
try
{
var listenList = JsonHelper.DeserializeObject<List<SubAnswerItem>>(item.Answer);
if (listenList != null && listenList.Count > 0)
{
Score = 5 * listenList.Count;
foreach (var subItem in listenList)
{
quesAnswerList.Add(subItem.SubAnswer);
......@@ -946,6 +952,7 @@ namespace Edu.Module.Exam
Common.Plugin.LogHelper.Write(ex, "GetAppQuestionCategoryListModule_Answer:" + Common.Plugin.JsonHelper.Serialize(item));
}
}
var obj = new
{
item.QuestionId,
......@@ -961,6 +968,7 @@ namespace Edu.Module.Exam
QuestionAnswerList = quesAnswerList,
StundetAnswer = new List<string>(),
item.Answer,
Score,
};
result.Add(obj);
}
......@@ -1009,6 +1017,7 @@ namespace Edu.Module.Exam
/// <returns></returns>
public bool SetStudentStartExamModule(RB_Student_Exam_Extend model)
{
model.StartTime = DateTime.Now;
model.Times = student_ExamRepository.GetStudentExamTimesRepository(model);
var newId = student_ExamRepository.Insert(model);
model.Id = newId;
......@@ -1023,30 +1032,170 @@ namespace Edu.Module.Exam
public bool SetStudentExamModule(RB_Student_Exam_Extend model)
{
bool flag = false;
if (model.Id > 0)
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Student_Exam_Extend.EndTime),model.EndTime}
};
flag = student_ExamRepository.Update(fileds, new WhereHelper(nameof(RB_Student_Exam_Extend.Id), model.Id));
}
else
{
var newId = student_ExamRepository.Insert(model);
model.Id = newId;
flag = newId > 0;
}
if (flag && model.ExamDetailsList != null && model.ExamDetailsList.Count > 0)
{ nameof(RB_Student_Exam_Extend.EndTime),DateTime.Now}
};
decimal totalScore = 0;
if (model.ExamDetailsList != null && model.ExamDetailsList.Count > 0)
{
totalScore = model.ExamDetailsList.Sum(qitem => qitem.StudentScore);
foreach (var item in model.ExamDetailsList)
{
item.ExamId = model.Id;
student_ExamDetailsRepository.Insert(item);
if (item.QuestionTypeKey == "listening" || item.QuestionTypeKey == "reading-comprehensio")
{
decimal tempScore = 0;
try
{
var reading_AnswerList = Common.Plugin.JsonHelper.DeserializeObject<List<SubAnswerItem>>(item.Answer.ToString());
var reading_Stu_AnswerList = Common.Plugin.JsonHelper.DeserializeObject<List<SubAnswerItem>>(item.StudentAnswer.ToString());
if (reading_AnswerList != null && reading_Stu_AnswerList != null
&& reading_AnswerList.Count > 0 && reading_Stu_AnswerList.Count > 0
&& reading_AnswerList.Count == reading_Stu_AnswerList.Count)
{
for (var i = 0; i < reading_AnswerList.Count; i++)
{
if (reading_AnswerList[i].SubQuestionKey != "fill-in" && reading_AnswerList[i].SubQuestionKey != "short-answer")
{
if (reading_AnswerList[i].SubAnswer == reading_Stu_AnswerList[i].SubAnswer)
{
tempScore += 5;
}
}
}
}
}
catch
{
}
item.StudentScore = tempScore;
}
else
{
if (item.IsWrong == 0)
{
item.StudentScore = item.Score;
}
}
}
//int totalPage = 0;
//int pageSize = 30;
//if (model.ExamDetailsList.Count % pageSize == 0)
//{
// totalPage = model.ExamDetailsList.Count % pageSize;
//}
//else
//{
// totalPage = model.ExamDetailsList.Count % pageSize + 1;
//}
//int pageIndex = 1;
//while (pageIndex <= totalPage)
//{
// var tempList = model.ExamDetailsList.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
// if (tempList != null && tempList.Count > 0)
// {
// // flag = student_ExamDetailsRepository.BatchStudentExamDetailsRepository(tempList);
// }
//}
flag = student_ExamDetailsRepository.BatchStudentExamDetailsRepository(model.ExamDetailsList);
}
fileds.Add(nameof(RB_Student_Exam_Extend.Score), totalScore);
flag = student_ExamRepository.Update(fileds, new WhereHelper(nameof(RB_Student_Exam_Extend.Id), model.Id));
return flag;
}
/// <summary>
/// 获取学员练习错题统计
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public object GetPracticeWrongStaticModule(RB_Student_Practice_Extend query)
{
int readingWrongTotalCount = 0;
int readingWrongFinishCount = 0;
int readingWrongStartId = 0;
int listeningWrongTotalCount = 0;
int listeningWrongFinishCount = 0;
int listeningWrongStartId = 0;
int grammarWrongTotalCount = 0;
int grammarWrongFinishCount = 0;
int grammarWrongStartId = 0;
int wordsWrongTotalCount = 0;
int wordsWrongFinishCount = 0;
int wordsWrongStartId = 0;
var list= student_PracticeRepository.GetStudentPracticeWrongStaticRepository(query);
if (list != null && list.Count > 0)
{
var tempReadingList = list?.Where(qitem => qitem.Category == Common.Enum.Course.QuestionCategoryEnum.ReadingChoose)?.ToList();
if (tempReadingList != null && tempReadingList.Count > 0)
{
readingWrongTotalCount = tempReadingList.Sum(qitem => qitem.WrongCount);
}
var tempListeningList = list?.Where(qitem => qitem.Category == Common.Enum.Course.QuestionCategoryEnum.Listening)?.ToList();
if (tempListeningList != null && tempListeningList.Count > 0)
{
listeningWrongTotalCount = tempListeningList.Sum(qitem => qitem.WrongCount);
}
var tempGrammarList= list?.Where(qitem => qitem.Category == Common.Enum.Course.QuestionCategoryEnum.ChooseGrammarUse)?.ToList();
if (tempGrammarList != null && tempGrammarList.Count > 0)
{
grammarWrongTotalCount = tempGrammarList.Sum(qitem => qitem.WrongCount);
}
var tempWordsList= list?.Where(qitem =>
qitem.Category == Common.Enum.Course.QuestionCategoryEnum.ChooseWord
|| qitem.Category == Common.Enum.Course.QuestionCategoryEnum.ChooseMean
|| qitem.Category == Common.Enum.Course.QuestionCategoryEnum.ChooseWordUse
)?.ToList();
if (tempWordsList != null && tempWordsList.Count > 0)
{
wordsWrongTotalCount = tempWordsList.Sum(qitem => qitem.WrongCount);
}
}
var obj = new
{
readingWrongTotalCount,
readingWrongFinishCount,
readingWrongStartId,
listeningWrongTotalCount,
listeningWrongFinishCount,
listeningWrongStartId,
grammarWrongTotalCount,
grammarWrongFinishCount,
grammarWrongStartId,
wordsWrongTotalCount,
wordsWrongFinishCount,
wordsWrongStartId
};
return obj;
}
/// <summary>
/// 获取练习错题分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Student_Practice_Extend> GetPracticeWrongPageModule(int pageIndex, int pageSize, out long rowsCount, RB_Student_Practice_Extend query)
{
var list = student_PracticeRepository.GetStudentPracticePageRepository(pageIndex, pageSize, out rowsCount, query);
if (list != null && list.Count > 0)
{
}
return list;
}
#endregion
}
}
......@@ -38,5 +38,19 @@ WHERE 1=1
}
return Get<RB_Student_ExamDetails_Extend>(builder.ToString()).ToList();
}
/// <summary>
/// 批量提交考试
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public bool BatchStudentExamDetailsRepository(List<RB_Student_ExamDetails_Extend> list)
{
StringBuilder builder = new StringBuilder();
builder.Append("INSERT INTO RB_Student_ExamDetails (ExamId,QuestionId,Title,QuestionContent,QuestionTypeId,QuestionTypeKey,Answer,AnswerParse,IsAnswer,IsWrong,StudentAnswer,Score,StudentScore) ");
builder.Append(" VALUES(@ExamId,@QuestionId,@Title,@QuestionContent,@QuestionTypeId,@QuestionTypeKey,@Answer,@AnswerParse,@IsAnswer,@IsWrong,@StudentAnswer,@Score,@StudentScore) ");
return base.Execute(builder.ToString(), list) > 0;
}
}
}
......@@ -77,8 +77,45 @@ WHERE 1=1
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Student_Practice_Extend.LevelType), (int)query.LevelType);
}
if (query.IsQueryWrong == 1)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Student_Practice_Extend.IsWrong), 1);
}
if (!string.IsNullOrEmpty(query.QCategoryIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Student_Practice_Extend.Category), query.QCategoryIds);
}
}
return GetPage<RB_Student_Practice_Extend>(pageIndex, pageSize, out rowsCount, builder.ToString()).ToList();
}
/// <summary>
/// 获取学员练习错题统计
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Student_Practice_Extend> GetStudentPracticeWrongStaticRepository(RB_Student_Practice_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT Category,COUNT(1) AS WrongCount
FROM rb_student_practice
WHERE 1=1
");
builder.AppendFormat(" AND IsWrong=1 ");
if (query != null)
{
if (query.StudentId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_Practice_Extend.StudentId), query.StudentId);
}
if (query.LevelType > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Student_Practice_Extend.LevelType), (int)query.LevelType);
}
}
builder.AppendFormat(" GROUP BY Category ");
return Get<RB_Student_Practice_Extend>(builder.ToString()).ToList();
}
}
}
......@@ -1140,7 +1140,6 @@ namespace Edu.WebApi.Controllers.Exam
Id = base.ParmJObj.GetInt("Id"),
BankId = base.ParmJObj.GetInt("BankId"),
StudentId = base.ParmJObj.GetInt("StudentId"),
StartTime = base.ParmJObj.GetDateTime("StartTime"),
CreateTime = DateTime.Now,
GroupId = base.ParmJObj.GetInt("GroupId")
};
......@@ -1191,6 +1190,8 @@ namespace Edu.WebApi.Controllers.Exam
AnswerParse=sObj.GetStringValue("AnswerParse"),
IsAnswer=sObj.GetInt("IsAnswer"),
IsWrong=sObj.GetInt("IsWrong"),
StudentAnswer=sObj.GetStringValue("StudentAnswer"),
Score=sObj.GetDecimal("Score"),
};
model.ExamDetailsList.Add(sModel);
}
......@@ -1200,6 +1201,42 @@ namespace Edu.WebApi.Controllers.Exam
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 获取错题练习统计
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetPracticeWrongStatic()
{
var query = new RB_Student_Practice_Extend()
{
StudentId= base.ParmJObj.GetInt("StudentId"),
LevelType= (LevelTypeEnum)base.ParmJObj.GetInt("LevelType"),
};
var obj = courseExamModule.GetPracticeWrongStaticModule(query);
return ApiResult.Success(data: obj);
}
/// <summary>
/// 获取错题分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetPracticeWrongPage()
{
var pageModel = JsonHelper.DeserializeObject<ResultPageModel>(RequestParm.Msg.ToString());
var query = new RB_Student_Practice_Extend()
{
StudentId = base.ParmJObj.GetInt("StudentId"),
LevelType = (LevelTypeEnum)base.ParmJObj.GetInt("LevelType"),
StartId=base.ParmJObj.GetInt("StartId"),
};
query.IsQueryWrong = 1;
var list = courseExamModule.GetPracticeWrongPageModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
pageModel.Count = rowsCount;
pageModel.PageData = list;
return ApiResult.Success(data: pageModel);
}
#endregion
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment