|
@@ -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 });
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -2054,6 +2065,7 @@ namespace TEAMModelOS.Controllers
|
|
|
var (_, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
|
//string code = school_code.ToString().Substring(5);
|
|
|
//ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{school_code}"));
|
|
|
+ Dictionary<string, List<string>> examClassResultCodeIdDic = new Dictionary<string, List<string>>(); //examClassResult code對應ID表 ※取得閱卷變更結果用
|
|
|
List<ExamClassResult> examClassResults = new List<ExamClassResult>();
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamClassResult>(queryText: $"select c.id,c.subjectId,c.code,c.scIds,c.info,c.studentIds,c.studentAnswers,c.studentScores,c.mark,c.status from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.info.id = '{classId}'",
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school_code}") }))
|
|
@@ -2066,6 +2078,8 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
ids.AddRange(result.studentIds);
|
|
|
//codes.AddRange(result.scIds);
|
|
|
+ if(!examClassResultCodeIdDic.ContainsKey(result.code)) examClassResultCodeIdDic.Add(result.code, new List<string>() { result.id });
|
|
|
+ else if (!examClassResultCodeIdDic[result.code].Contains(result.id)) examClassResultCodeIdDic[result.code].Add(result.id);
|
|
|
}
|
|
|
List<string> cid = new()
|
|
|
{
|
|
@@ -2190,7 +2204,26 @@ namespace TEAMModelOS.Controllers
|
|
|
return Ok(new { props });
|
|
|
}
|
|
|
}*/
|
|
|
- return Ok(new { examClassResults, ufos, delIds });
|
|
|
+ //取得教師批改紀錄 ※目前只有統測評量有紀錄
|
|
|
+ List<ExamClassResultMark> markResult = new List<ExamClassResultMark>();
|
|
|
+ foreach(KeyValuePair<string, List<string>> seed in examClassResultCodeIdDic) {
|
|
|
+ string code = seed.Key.Replace("ExamClassResult", "ExamClassResultMark");
|
|
|
+ List<string> idList = seed.Value;
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryStreamIteratorSql(queryText: $"SELECT * FROM c where c.id in ({string.Join(",", idList.Select(o => $"'{o}'"))}) and c.pk = 'ExamClassResultMark'",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.Content);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+ {
|
|
|
+ markResult.Add(obj.ToObject<ExamClassResultMark>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(new { examClassResults, ufos, delIds, markResult });
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|