Commit 32f95555 authored by liudong1993's avatar liudong1993

1

parent 9ac13a06
......@@ -91,6 +91,16 @@ namespace EduSpider.Model.Extend
/// 分组排序
/// </summary>
public int GroupNum { get; set; }
/// <summary>
/// 一试得分
/// </summary>
public decimal AScore { get; set; }
/// <summary>
/// 一试排名
/// </summary>
public decimal ARank { get; set; }
}
/// <summary>
......
......@@ -105,6 +105,48 @@ namespace EduSpider.Services
}
}
//组装一试 二试 排名
if (examModel.Type == 2)
{
var sExamList = Exam_ScoreRepository.GetList(new RB_Exam_Score_Extend() { ExamId = examId }).ToList();//当前考试的所有信息
foreach (var item in sExamList) {
item.ScoreList = JsonHelper.Deserialize<List<ExamQScoreModel>>(item.Content);
foreach (var qitem in item.ScoreList)
{
var qmodel = qlist.Where(x => x.Sort == qitem.Sort).FirstOrDefault();
qitem.Difficulty = qmodel?.Difficulty ?? "";
qitem.KnowledgePoint = qmodel?.KnowledgePoint ?? "";
qitem.QScore = qmodel?.Score ?? 0;
qitem.GroupName = qmodel?.GroupName ?? "";
}
}
var groupList = sExamModel.ScoreList.Select(x => x.GroupName).ToList();
foreach (var groupName in groupList)
{
foreach (var qitem in sExamList) {
//计算一试得分
qitem.AScore = qitem.ScoreList.Where(x => x.GroupName == groupName).Sum(x => x.Score);
}
//看分组排名
int Rank = 1;
sExamList.OrderByDescending(x => x.AScore).GroupBy(x => x.AScore).ToList().ForEach(x =>
{
x.ToList().ForEach(y =>
{
y.ARank = Rank;
});
Rank += x.Count();
});
sExamModel?.ScoreList.Where(x => x.GroupName == groupName).ToList().ForEach(x =>
{
x.AScore = sExamList.Where(x => x.StuId == stuId).FirstOrDefault()?.AScore ?? 0;
x.ARank = sExamList.Where(x => x.StuId == stuId).FirstOrDefault()?.ARank ?? 0;
});
}
}
//开始组装数据
return new
......@@ -141,6 +183,8 @@ namespace EduSpider.Services
GroupModuleList = examModel.Type == 2 ? sExamModel?.ScoreList.GroupBy(z => new { z.GroupName }).Select(z => new
{
GroupName = z.Key,
TScore = z.FirstOrDefault().AScore,//总分
Rank = z.FirstOrDefault().ARank,//排名
GroupList = z.GroupBy(x => new { x.KnowledgePoint }).Select(x => new
{
Module = x.Key.KnowledgePoint.Length > 6 ? x.Key.KnowledgePoint.Substring(0, 6) + ".." : x.Key.KnowledgePoint,
......
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