|
@@ -379,9 +379,9 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
- [AuthToken(Roles = "teacher,admin")]
|
|
|
+ //[AuthToken(Roles = "teacher,admin")]
|
|
|
[HttpPost("get-exam-point")]
|
|
|
- [Authorize(Roles = "IES")]
|
|
|
+ //[Authorize(Roles = "IES")]
|
|
|
public async Task<IActionResult> getExamPoint(JsonElement request)
|
|
|
{
|
|
|
try
|
|
@@ -397,7 +397,9 @@ namespace TEAMModelOS.Controllers
|
|
|
List<string> clds = classId.ToObject<List<string>>().ToList();
|
|
|
List<string> clas = classId.ToObject<List<string>>().ToList();
|
|
|
List<ExamSubject> subs = [];
|
|
|
+ List<PaperSimple> paperSimples = [];
|
|
|
List<(string id,string type)> source = [];
|
|
|
+ List<(string id, double score)> averages = [];
|
|
|
//获取学校基本信息
|
|
|
School schoolBase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(code.GetString(), new PartitionKey("Base"));
|
|
|
var period = schoolBase.period.Find(x => x.id.Equals($"{periodId}"));
|
|
@@ -437,7 +439,7 @@ namespace TEAMModelOS.Controllers
|
|
|
string classInfos = string.Join(" or ", strs);
|
|
|
|
|
|
(List<RMember> members, List<RGroupList> groups) = await GroupListService.GetMemberByListids(_coreAPIHttpService, client, _dingDing, clds, $"{code}");
|
|
|
- var queryExam = $"select c.id,c.subjects,c.source from c where c.period.id = '{periodId}' and ({classInfos}) " +
|
|
|
+ var queryExam = $"select c.id,c.subjects,c.source,c.average,c.papers from c where c.period.id = '{periodId}' and ({classInfos}) " +
|
|
|
$"and c.qamode <> 2 and c.progress = 'finish' and c.scope = 'school' and c.startTime > {semesterData.date.ToUnixTimeMilliseconds()} and c.startTime < {semesterData.nextSemester.ToUnixTimeMilliseconds()} ";
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIteratorSql(queryText: queryExam, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{code}") }))
|
|
|
{
|
|
@@ -453,13 +455,21 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
subs.AddRange(subject.ToObject<List<ExamSubject>>());
|
|
|
}
|
|
|
+ if (account.TryGetProperty("papers", out JsonElement papers))
|
|
|
+ {
|
|
|
+ paperSimples.AddRange(papers.ToObject<List<PaperSimple>>());
|
|
|
+ }
|
|
|
source.Add((account.GetProperty("id").GetString(), account.GetProperty("source").GetString()));
|
|
|
+ averages.Add((account.GetProperty("id").GetString(), account.GetProperty("average").GetDouble()));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
subs = subs.Where((x, i) => subs.FindIndex(z => z.id == x.id) == i).ToList();
|
|
|
List<ExamClassResult> classResults = new();
|
|
|
List<ExamClassResult> results = new();
|
|
|
+
|
|
|
+ var point = paperSimples.FirstOrDefault().point.Sum();
|
|
|
+ var gradeAverageRate = Math.Round(averages.Select(c => c.score).Sum() / averages.Count / point,4);
|
|
|
if (clas.Count == 0)
|
|
|
{
|
|
|
var queryClass = $"select value(c) from c where c.examId in ({string.Join(",", ids.Select(o => $"'{o}'"))})";
|
|
@@ -494,10 +504,11 @@ namespace TEAMModelOS.Controllers
|
|
|
x.Key,
|
|
|
cc = x.ToList().Count,
|
|
|
students = x.ToList().SelectMany(z => z.studentIds).Distinct().ToList(),
|
|
|
+ classRate = Math.Round(x.ToList().Select(z => z.average).Sum() / x.ToList().Count,2)
|
|
|
//score = x.ToList().Select(k => k.sum).Aggregate((current, next) => current.Zip(next, (a, b) => a + b).ToList()),
|
|
|
//gRate = Math.Round( x.ToList().SelectMany(k => k.sum).Sum() / x.ToList().Count / members.Count, 2)
|
|
|
});
|
|
|
- List<(string sub, List<(string id, double score)> subScore,int cc)> stuScore = [];
|
|
|
+ List<(string sub, List<(string id, double score)> subScore,int cc,double average)> stuScore = [];
|
|
|
foreach (var es in examScore) {
|
|
|
List<(string id, double score)> subScore = [];
|
|
|
foreach (var sId in es.students) {
|
|
@@ -505,7 +516,7 @@ namespace TEAMModelOS.Controllers
|
|
|
var totalScore = classResults.Where(c => c.subjectId.Equals(es.Key) && c.studentIds.Contains(sId)).ToList().Select(z => z.sum[z.studentIds.IndexOf(sId)]).Sum();
|
|
|
subScore.Add((sId, Math.Round(totalScore / count,2)));
|
|
|
}
|
|
|
- stuScore.Add((es.Key, subScore,es.cc));
|
|
|
+ stuScore.Add((es.Key, subScore,es.cc,es.classRate));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -517,17 +528,17 @@ namespace TEAMModelOS.Controllers
|
|
|
classRate = x.ToList().GroupBy(z => z.info.id).Select(m => new {
|
|
|
classId = m.Key,
|
|
|
className = groups.Where(k => k.id.Equals(m.Key)).FirstOrDefault().name,
|
|
|
- rate = Math.Round(m.ToList().SelectMany(j => j.sum).Sum() / m.ToList().Count /m.ToList().SelectMany(z => z.studentIds).Distinct().ToList().Count,2)
|
|
|
- }),
|
|
|
+ rate = Math.Round(m.ToList().Select(k => k.average).Sum() / m.ToList().Count,2)
|
|
|
+ })
|
|
|
//score = x.ToList().Select(k => k.sum).Aggregate((current, next) => current.Zip(next, (a, b) => a + b).ToList()),
|
|
|
- gRate = Math.Round(x.ToList().SelectMany(k => k.sum).Sum() / x.ToList().Count / members.Count, 2)
|
|
|
+ //gRate = Math.Round(x.ToList().SelectMany(k => k.sum).Sum() / x.ToList().Count / members.Count, 2)
|
|
|
}) ;
|
|
|
var gradeRate = examAllScore.Select(x => new
|
|
|
{
|
|
|
subjectId = x.Key,
|
|
|
subjectName = subs.Where(z => z.id.Equals(x.Key)).FirstOrDefault().name,
|
|
|
- x.classRate,
|
|
|
- x.gRate
|
|
|
+ x.classRate
|
|
|
+ //x.gRate
|
|
|
});
|
|
|
|
|
|
if (request.TryGetProperty("studentId", out JsonElement studentId) && !string.IsNullOrWhiteSpace($"{studentId}"))
|
|
@@ -536,22 +547,22 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
subjectId = x.sub,
|
|
|
subjectName = subs.Where(z => z.id.Equals(x.sub)).FirstOrDefault().name,
|
|
|
- classRate = Math.Round(x.subScore.Select(z => z.score).Sum() / x.cc / x.subScore.Count, 2),
|
|
|
+ classRate = Math.Round(x.average / point, 4),
|
|
|
rank = x.subScore.OrderByDescending(x => x.score).Select(z => z.id).ToList().IndexOf(studentId.GetString()) + 1,
|
|
|
stuRate = x.subScore.OrderByDescending(x => x.score).Select(z => new
|
|
|
{
|
|
|
z.id,
|
|
|
members.Where(s => s.id.Equals(z.id)).FirstOrDefault().name,
|
|
|
- rate = Math.Round(z.score, 2)
|
|
|
+ rate = Math.Round(z.score / point, 4)
|
|
|
}).ToList().Take(10),
|
|
|
sper = x.subScore.Where(c => c.id.Equals(studentId.GetString())).Select(z => new
|
|
|
{
|
|
|
z.id,
|
|
|
members.Where(s => s.id.Equals(z.id)).FirstOrDefault().name,
|
|
|
- rate = Math.Round(z.score, 2)
|
|
|
+ rate = Math.Round(z.score / point, 4)
|
|
|
})
|
|
|
});
|
|
|
- return Ok(new { orderScore, typeCount, gradeRate, pCount = members.Count, code = 200 });
|
|
|
+ return Ok(new { orderScore, typeCount, gradeRate, pCount = members.Count, gradeAverageRate, point, code = 200 });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -559,14 +570,14 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
subjectId = x.sub,
|
|
|
subjectName = subs.Where(z => z.id.Equals(x.sub)).FirstOrDefault().name,
|
|
|
- classRate = Math.Round(x.subScore.Select(z => z.score).Sum() / x.cc / x.subScore.Count,2),
|
|
|
+ classRate = Math.Round(x.average / point,4),
|
|
|
stuRate = x.subScore.OrderByDescending(x => x.score).Select(z => new
|
|
|
{
|
|
|
z.id,
|
|
|
- rate = Math.Round(z.score , 2)
|
|
|
+ rate = Math.Round(z.score / point, 4)
|
|
|
}).ToList().Take(10)
|
|
|
});
|
|
|
- return Ok(new { orderScore, typeCount, gradeRate, pCount = members.Count, code = 200 });
|
|
|
+ return Ok(new { orderScore, typeCount, gradeRate, pCount = members.Count, gradeAverageRate, point, code = 200 });
|
|
|
}
|
|
|
|
|
|
}
|