|
@@ -35,11 +35,13 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
private readonly Option _option;
|
|
|
private const string CacheCosmosPrefix = "Analysis:";
|
|
|
private const int timeoutSeconds = 3600;
|
|
|
- public AchievementController(AzureCosmosFactory azureCosmos, DingDing dingDing, IOptionsSnapshot<Option> option)
|
|
|
+ public readonly AzureStorageFactory _azureStorage;
|
|
|
+ public AchievementController(AzureCosmosFactory azureCosmos, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage)
|
|
|
{
|
|
|
_azureCosmos = azureCosmos;
|
|
|
_dingDing = dingDing;
|
|
|
_option = option?.Value;
|
|
|
+ _azureStorage = azureStorage;
|
|
|
|
|
|
|
|
|
}
|
|
@@ -118,7 +120,8 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
exams = await FindExamResultRedis(dict, "FindExamResultRedis");
|
|
|
}*/
|
|
|
List<string> subjectCouns = JsonExtensions.ToObject<List<string>>(subjectCode.ToJsonString());
|
|
|
- for (int i =0;i < subjectCouns.Count;i++ ) {
|
|
|
+ for (int i = 0; i < subjectCouns.Count; i++)
|
|
|
+ {
|
|
|
if (RedisHelper.Exists(CacheCosmosPrefix + "examResult" + subjectCouns[i]))
|
|
|
{
|
|
|
ExamResultDto result = RedisHelper.HGet<ExamResultDto>(CacheCosmosPrefix + "examResult" + subjectCouns[i], ShaHashHelper.GetSHA1(code.ToString()));
|
|
@@ -578,7 +581,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
}*/
|
|
|
return builder.build();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
[HttpPost("ExerciseScatter")]
|
|
|
public async Task<BaseResponse> ExerciseScatter(JsonElement request)
|
|
@@ -606,9 +609,9 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
info = await FindExerciseScatterRedis(dict, "ExerciseScatter");
|
|
|
builder.Data(info);
|
|
|
}*/
|
|
|
- return null ;
|
|
|
+ return null;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
public async Task<Dictionary<string, dynamic>> FindKnowledgePointRedis(Dictionary<string, object> dict, string method)
|
|
@@ -896,10 +899,11 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
}
|
|
|
valuew[2] = itemNos[0..^1];
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
valuew[2] = itemNos;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
});
|
|
|
int rhwC = 0;
|
|
|
int rhlC = 0;
|
|
@@ -1004,7 +1008,8 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
values[4] = "0";
|
|
|
values[5] = "0";
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
double stuPser = anwPoint / po;
|
|
|
values[3] = po.ToString();
|
|
|
values[4] = anwPoint.ToString();
|
|
@@ -1022,11 +1027,12 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
{
|
|
|
knowPer.Add("0");
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
knowPser = anwGPoint / poG;
|
|
|
knowPer.Add(knowPser.ToString("0.00"));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//错题关系表
|
|
|
valuew[3] = knowPser.ToString("0.00");
|
|
|
valuew[4] = wrongCount.ToString();
|
|
@@ -1089,11 +1095,12 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
//double classPser = anwCPoint / cpo;
|
|
|
knowledgeClass.Add("0");
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
double classPser = anwCPoint / cpo;
|
|
|
knowledgeClass.Add(classPser.ToString("0.00"));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
classMap.Add(knowledgeName[k], knowledgeClass);
|
|
|
per.Add(persent.ToString("0.00"));
|
|
@@ -1175,12 +1182,12 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
/// RedisHelper.Instance.CurrentDeserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
|
|
|
List<ExamInfoDto> info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "FindExamInfo",
|
|
|
ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindExamInfoRedis(dict, "FindExamInfo"); });
|
|
|
-
|
|
|
+
|
|
|
builder.Data(info);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
- // throw new BizException(e.Message);
|
|
|
+ // throw new BizException(e.Message);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -1288,31 +1295,31 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
|
|
|
return builder.build();
|
|
|
}
|
|
|
- /* public async Task<List<Paper>> FindExamPaperRedis(Dictionary<string, object> dict, string method)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- List<Paper> info = await _azureCosmos.FindByDict<Paper>(dict);
|
|
|
- if (RedisHelper.Instance != null)
|
|
|
- {
|
|
|
- if (!RedisHelper.Exists(CacheCosmosPrefix + method))
|
|
|
- {
|
|
|
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
|
|
|
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
|
|
|
- }
|
|
|
- }
|
|
|
- return info;
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- throw new BizException(e.Message);
|
|
|
+ /* public async Task<List<Paper>> FindExamPaperRedis(Dictionary<string, object> dict, string method)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ List<Paper> info = await _azureCosmos.FindByDict<Paper>(dict);
|
|
|
+ if (RedisHelper.Instance != null)
|
|
|
+ {
|
|
|
+ if (!RedisHelper.Exists(CacheCosmosPrefix + method))
|
|
|
+ {
|
|
|
+ await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
|
|
|
+ await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ throw new BizException(e.Message);
|
|
|
|
|
|
- }
|
|
|
- }*/
|
|
|
+ }
|
|
|
+ }*/
|
|
|
[HttpPost("FindExamAnswer")]
|
|
|
public BaseResponse FindExamAnswer(JsonElement request)
|
|
|
{
|
|
@@ -1412,7 +1419,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
}
|
|
|
public async Task<List<Dictionary<string, dynamic>>> FindHomeStatisticsRedis(Dictionary<string, object> dict, string method)
|
|
|
{
|
|
|
- return new List<Dictionary<string, dynamic>>();
|
|
|
+ return new List<Dictionary<string, dynamic>>();
|
|
|
//request.@params.TryGetValue("subjectCode", out object subjectCode);
|
|
|
// dict.TryGetValue("schoolCode", out object schoolCode);
|
|
|
// dict.TryGetValue("code", out object code);
|
|
@@ -1796,11 +1803,13 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
}
|
|
|
|
|
|
[HttpPost("getAnalysis")]
|
|
|
- public async Task<IActionResult> getAnalysis(JsonElement request) {
|
|
|
+ public async Task<IActionResult> getAnalysis(JsonElement request)
|
|
|
+ {
|
|
|
//获取评测的ID
|
|
|
if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
- try {
|
|
|
+ try
|
|
|
+ {
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
//获取本次评测所有科目结算结果
|
|
|
ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
@@ -1836,30 +1845,35 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
}
|
|
|
//获取进线标准
|
|
|
int touch = 0;
|
|
|
- foreach (Period period in school.period) {
|
|
|
- if (info.period.id.Equals(period.id)) {
|
|
|
+ foreach (Period period in school.period)
|
|
|
+ {
|
|
|
+ if (info.period.id.Equals(period.id))
|
|
|
+ {
|
|
|
touch = period.analysis.touch;
|
|
|
}
|
|
|
}
|
|
|
//获取进线人数
|
|
|
|
|
|
- int personCount = (int)System.Math.Round( info.stuCount * (touch / 100.0), MidpointRounding.AwayFromZero);
|
|
|
-
|
|
|
+ int personCount = (int)System.Math.Round(info.stuCount * (touch / 100.0), MidpointRounding.AwayFromZero);
|
|
|
+
|
|
|
StudentAnalysis analysis = new StudentAnalysis();
|
|
|
List<ClassAnalysis> classAnalyses = new List<ClassAnalysis>();
|
|
|
- /* //声明年级所有科目总分
|
|
|
- List<double> total = new List<double>();*/
|
|
|
+ /* //声明年级所有科目总分
|
|
|
+ List<double> total = new List<double>();*/
|
|
|
//以班级为单位
|
|
|
List<double> stuTotals = new List<double>();
|
|
|
List<dynamic> classes = new List<dynamic>();
|
|
|
HashSet<string> idName = new HashSet<string>();
|
|
|
- foreach (ExamResult examResult in examResults) {
|
|
|
- foreach (string ids in examResult.studentIds) {
|
|
|
+ foreach (ExamResult examResult in examResults)
|
|
|
+ {
|
|
|
+ foreach (string ids in examResult.studentIds)
|
|
|
+ {
|
|
|
idName.Add(ids);
|
|
|
}
|
|
|
}
|
|
|
- foreach (string s in info.targetClassIds) {
|
|
|
-
|
|
|
+ foreach (string s in info.targetClassIds)
|
|
|
+ {
|
|
|
+
|
|
|
//存放每个班级学生总分
|
|
|
List<double> totalClass = new List<double>();
|
|
|
ClassAnalysis classAnalysis = new ClassAnalysis();
|
|
@@ -1869,17 +1883,18 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
{
|
|
|
using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
|
|
|
Class classroom = json.ToObject<Class>();
|
|
|
- classes.Add(new {name=classroom.name,id=s });
|
|
|
+ classes.Add(new { name = classroom.name, id = s });
|
|
|
//初始化参考人数
|
|
|
int count = 0;
|
|
|
-
|
|
|
+
|
|
|
foreach (StudentSimple stu in classroom.students)
|
|
|
{
|
|
|
if (idName.Contains(stu.id))
|
|
|
{
|
|
|
count++;
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
continue;
|
|
|
}
|
|
|
classAnalysis.studentIds.Add(stu.id);
|
|
@@ -1890,7 +1905,8 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
foreach (ExamResult examResult in examResults)
|
|
|
{
|
|
|
int index = examResult.studentIds.IndexOf(stu.id);
|
|
|
- if (index >= 0) {
|
|
|
+ if (index >= 0)
|
|
|
+ {
|
|
|
stuTotal = stuTotal + examResult.studentScores[index].Sum();
|
|
|
}
|
|
|
}
|
|
@@ -1904,7 +1920,8 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
}
|
|
|
/* //声明单个班级单科总分
|
|
|
double subjectTotal = 0;*/
|
|
|
- info.subjects.ForEach(sub => {
|
|
|
+ info.subjects.ForEach(sub =>
|
|
|
+ {
|
|
|
//初始化及格人数
|
|
|
int i = 0;
|
|
|
//初始化单科总分
|
|
@@ -1951,8 +1968,8 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
double percentClass = i / (result.studentIds.Count * 1.0);
|
|
|
double averageClass = sumClass / (result.studentIds.Count * 1.0);
|
|
|
//total += averageClass;
|
|
|
- subjectScore.passPercent= percentClass;
|
|
|
- subjectScore.averageScore= averageClass;
|
|
|
+ subjectScore.passPercent = percentClass;
|
|
|
+ subjectScore.averageScore = averageClass;
|
|
|
classAnalysis.subjects.Add(subjectScore);
|
|
|
//analysis.scores.Add(score);
|
|
|
}
|
|
@@ -1986,18 +2003,21 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
stuTotals.Sort(delegate (double s1, double s2) { return s2.CompareTo(s1); });
|
|
|
ipoint = stuTotals[personCount];
|
|
|
//补充班级总平均分/进行人数/标准差
|
|
|
- foreach (ClassAnalysis classAnalysis in classAnalyses) {
|
|
|
+ foreach (ClassAnalysis classAnalysis in classAnalyses)
|
|
|
+ {
|
|
|
//初始化进线人数
|
|
|
int i = 0;
|
|
|
//初始化班级总分
|
|
|
double score = 0;
|
|
|
//标准差
|
|
|
double powSum = 0;
|
|
|
- foreach (double sc in classAnalysis.total) {
|
|
|
- if (sc > ipoint) {
|
|
|
+ foreach (double sc in classAnalysis.total)
|
|
|
+ {
|
|
|
+ if (sc > ipoint)
|
|
|
+ {
|
|
|
i++;
|
|
|
}
|
|
|
- score = score + sc;
|
|
|
+ score = score + sc;
|
|
|
}
|
|
|
//总平均分
|
|
|
double totalAverage = 0;
|
|
@@ -2007,7 +2027,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
{
|
|
|
powSum += Math.Pow(sc - totalAverage, 2);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var pow = Math.Pow(powSum / classAnalysis.stuCount, 0.5);
|
|
|
|
|
|
classAnalysis.standardDeviation = pow;
|
|
@@ -2015,9 +2035,10 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
classAnalysis.lineCount = i;
|
|
|
}
|
|
|
//处理全科年级PR值
|
|
|
- foreach (double no in analysis.total) {
|
|
|
+ foreach (double no in analysis.total)
|
|
|
+ {
|
|
|
int index = stuTotals.IndexOf(no);
|
|
|
- int GPR = 100 - (100 * (index+1) - 50) / analysis.total.Count;
|
|
|
+ int GPR = 100 - (100 * (index + 1) - 50) / analysis.total.Count;
|
|
|
analysis.gpr.Add(GPR);
|
|
|
}
|
|
|
List<GradeAnalysis> gradeAnalyses = new List<GradeAnalysis>();
|
|
@@ -2037,12 +2058,14 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
return BadRequest();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
- private List<GradeAnalysis> GetGradeAnalyses(ExamInfo info, List<ExamResult> examResults, List<ExamClassResult> examClassResults,StudentAnalysis analysis) {
|
|
|
+ private List<GradeAnalysis> GetGradeAnalyses(ExamInfo info, List<ExamResult> examResults, List<ExamClassResult> examClassResults, StudentAnalysis analysis)
|
|
|
+ {
|
|
|
List<GradeAnalysis> gradeAnalyses = new List<GradeAnalysis>();
|
|
|
-
|
|
|
- info.grades.ForEach(g => {
|
|
|
+
|
|
|
+ info.grades.ForEach(g =>
|
|
|
+ {
|
|
|
GradeAnalysis gradeAnalysis = new GradeAnalysis();
|
|
|
gradeAnalysis.gradeId = g.id;
|
|
|
//初始化单个年级总分
|
|
@@ -2074,8 +2097,10 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
//存放单科每个班级学生总分
|
|
|
List<double> totalClass = new List<double>();
|
|
|
//存放学生单科记录
|
|
|
- foreach (Score score in analysis.scores) {
|
|
|
- if (score.subjectId.Equals(sub.id)) {
|
|
|
+ foreach (Score score in analysis.scores)
|
|
|
+ {
|
|
|
+ if (score.subjectId.Equals(sub.id))
|
|
|
+ {
|
|
|
//处理每个班级各个学生各科总分
|
|
|
foreach (ExamClassResult result in examClassResults)
|
|
|
{
|
|
@@ -2098,11 +2123,11 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
}
|
|
|
}
|
|
|
//处理班级及格率以及均分
|
|
|
- double persentClass = i / (count*1.0);
|
|
|
+ double persentClass = i / (count * 1.0);
|
|
|
double averageClass = sumClass / (count * 1.0);
|
|
|
gradeScore += averageClass;
|
|
|
- subjectScore.passPercent= persentClass;
|
|
|
- subjectScore.averageScore= averageClass;
|
|
|
+ subjectScore.passPercent = persentClass;
|
|
|
+ subjectScore.averageScore = averageClass;
|
|
|
gradeAnalysis.subjects.Add(subjectScore);
|
|
|
gradeAnalyses.Add(gradeAnalysis);
|
|
|
//处理单科科年级PR
|
|
@@ -2116,18 +2141,19 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
}
|
|
|
//analysis.scores.Add(score);
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
});
|
|
|
- foreach (GradeAnalysis grade in gradeAnalyses) {
|
|
|
+ foreach (GradeAnalysis grade in gradeAnalyses)
|
|
|
+ {
|
|
|
grade.GradeaverageScore = gradeScore / grade.subjects.Count;
|
|
|
}
|
|
|
- });
|
|
|
+ });
|
|
|
return gradeAnalyses;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
//落点分析
|
|
|
- private List<Dictionary<string, dynamic>> getPointAnalysis(List<ExamResult> exams,ExamInfo exam)
|
|
|
+ private List<Dictionary<string, dynamic>> getPointAnalysis(List<ExamResult> exams, ExamInfo exam)
|
|
|
{
|
|
|
List<Dictionary<string, dynamic>> scatterAnalysis = new List<Dictionary<string, dynamic>>();
|
|
|
List<string> key = new List<string>
|
|
@@ -2147,10 +2173,10 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
//key.Add("areaName");
|
|
|
if (exams.Count > 0)
|
|
|
{
|
|
|
- /* //提取班级信息
|
|
|
- List<Dictionary<string, int[]>> classToName = exams[0].classes;
|
|
|
- //提取学生ID信息
|
|
|
- List<string> idToName = exams[0].ids;*/
|
|
|
+ /* //提取班级信息
|
|
|
+ List<Dictionary<string, int[]>> classToName = exams[0].classes;
|
|
|
+ //提取学生ID信息
|
|
|
+ List<string> idToName = exams[0].ids;*/
|
|
|
exams.ForEach(e =>
|
|
|
{
|
|
|
Dictionary<string, object> detail = new Dictionary<string, object>
|
|
@@ -2261,7 +2287,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
Console.WriteLine("---------------------" + ex.Message + "--------------------------");
|
|
|
}
|
|
|
|
|
|
- });
|
|
|
+ });
|
|
|
return scatterAnalysis;
|
|
|
}
|
|
|
else return scatterAnalysis;
|
|
@@ -2270,7 +2296,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
|
|
|
private List<Dictionary<string, dynamic>> getExerciseScatter(List<ExamResult> exams, ExamInfo exam)
|
|
|
{
|
|
|
- /* ResponseBuilder builder = ResponseBuilder.custom();*/
|
|
|
+ /* ResponseBuilder builder = ResponseBuilder.custom();*/
|
|
|
List<string> classList = new List<string>();
|
|
|
List<Dictionary<string, object>> exerciseScatter = new List<Dictionary<string, object>>();
|
|
|
//Dictionary<string, object> scatterAnalysis = new Dictionary<string, object>();
|
|
@@ -2320,10 +2346,10 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
Qnum++;
|
|
|
}
|
|
|
});
|
|
|
- /* Dictionary<string, object> detail = new Dictionary<string, object>
|
|
|
- {
|
|
|
- { "keys", key }
|
|
|
- };*/
|
|
|
+ /* Dictionary<string, object> detail = new Dictionary<string, object>
|
|
|
+ {
|
|
|
+ { "keys", key }
|
|
|
+ };*/
|
|
|
List<List<string>> datas = new List<List<string>>();
|
|
|
List<string[]> itemAnalysis = new List<string[]>();
|
|
|
Dictionary<string, object> subject = new Dictionary<string, object>
|
|
@@ -2346,37 +2372,37 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
}
|
|
|
int qCount = 0;
|
|
|
//int right = 0;
|
|
|
-/* //c.Keys遍历key值
|
|
|
- foreach (string keys in c.Keys)
|
|
|
- {
|
|
|
- classList.Add(keys);
|
|
|
- }*/
|
|
|
+ /* //c.Keys遍历key值
|
|
|
+ foreach (string keys in c.Keys)
|
|
|
+ {
|
|
|
+ classList.Add(keys);
|
|
|
+ }*/
|
|
|
//每个班级得分占比
|
|
|
|
|
|
- for (int i = c.range[0]; i <= c.range[1]; i++)
|
|
|
+ for (int i = c.range[0]; i <= c.range[1]; i++)
|
|
|
+ {
|
|
|
+ if (e.studentScores[i].Sum() > 0)
|
|
|
{
|
|
|
- if (e.studentScores[i].Sum() > 0)
|
|
|
+ for (int j = 0; j < e.studentScores[i].Count; j++)
|
|
|
{
|
|
|
- for (int j = 0; j < e.studentScores[i].Count; j++)
|
|
|
+ if (e.studentScores[i][j] > 0)
|
|
|
{
|
|
|
- if (e.studentScores[i][j] > 0)
|
|
|
- {
|
|
|
- //记录班级每题得分数
|
|
|
- answerCount[j] = answerCount[j] + 1;
|
|
|
- //记录年级每题得分数
|
|
|
- gradeAnswer[j] = gradeAnswer[j] + 1;
|
|
|
-
|
|
|
- //right++;
|
|
|
- }
|
|
|
+ //记录班级每题得分数
|
|
|
+ answerCount[j] = answerCount[j] + 1;
|
|
|
+ //记录年级每题得分数
|
|
|
+ gradeAnswer[j] = gradeAnswer[j] + 1;
|
|
|
+
|
|
|
+ //right++;
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- qCount++;
|
|
|
- }
|
|
|
-
|
|
|
- peopleCount = c.range[1] - c.range[0] + 1 - qCount;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ qCount++;
|
|
|
+ }
|
|
|
+
|
|
|
+ peopleCount = c.range[1] - c.range[0] + 1 - qCount;
|
|
|
+ }
|
|
|
foreach (int p in answerCount)
|
|
|
{
|
|
|
var t = Math.Floor(Math.Round(decimal.Parse((p * 1.0 / peopleCount).ToString("0.000")), 2) * 100);
|
|
@@ -2437,7 +2463,8 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
values[18] = itemAnalysis[k][8];
|
|
|
values[19] = itemAnalysis[k][9];
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
values[4] = "-";
|
|
|
values[5] = "-";
|
|
|
values[12] = "-";
|
|
@@ -2448,9 +2475,9 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
values[17] = "-";
|
|
|
values[18] = "-";
|
|
|
values[19] = "-";
|
|
|
- }
|
|
|
+ }
|
|
|
values[7] = grasdepersent[k];
|
|
|
- values[8] = grasdepersent[k];
|
|
|
+ values[8] = grasdepersent[k];
|
|
|
values[20] = quality[k].ToString();
|
|
|
values[21] = answer[k].ToString();
|
|
|
string pointName = "";
|
|
@@ -2483,10 +2510,130 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
// throw new BizException(ex.Message);
|
|
|
}
|
|
|
|
|
|
- });
|
|
|
+ });
|
|
|
return exerciseScatter;
|
|
|
}
|
|
|
else return exerciseScatter;
|
|
|
}
|
|
|
+
|
|
|
+ [HttpPost("point")]
|
|
|
+ public async Task<IActionResult> point(JsonElement request)
|
|
|
+ {
|
|
|
+ //获取评测的ID
|
|
|
+ if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ //获取本次评测所有科目结算结果
|
|
|
+ ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
+ School school = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<School>(code.ToString(), new PartitionKey($"Base"));
|
|
|
+ List<ExamResult> examResults = new List<ExamResult>();
|
|
|
+ var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes from c where c.examId = '{id}' ";
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
|
|
|
+ {
|
|
|
+ /*using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+ {
|
|
|
+ examResults.Add(obj.ToObject<ExamResult>());
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ examResults.Add(item);
|
|
|
+ }
|
|
|
+ //获取本次评测所有班级作答结果
|
|
|
+ List<ExamClassResult> examClassResults = new List<ExamClassResult>();
|
|
|
+ var queryClass = $"select c.id,c.code,c.name,c.school,c.examId,c.year,c.scope,c.pk,c.subjectId,c.studentScores,c.studentIds,c.gradeId,c.info,c.studentAnswers,c.sum,c.progress from c where c.examId = '{id}' ";
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
|
|
|
+ {
|
|
|
+ examClassResults.Add(item);
|
|
|
+ /*using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+ {
|
|
|
+ examClassResults.Add(obj.ToObject<ExamClassResult>());
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+ int m = 0;
|
|
|
+ foreach (ExamSubject subject in info.subjects) {
|
|
|
+ foreach (ExamClassResult classResult in examClassResults)
|
|
|
+ {
|
|
|
+ if (subject.id.Equals(classResult.subjectId)) {
|
|
|
+ int k = 0;
|
|
|
+ foreach (string stu in classResult.studentIds)
|
|
|
+ {
|
|
|
+ int n = 0;
|
|
|
+ List<List<string>> ans = new List<List<string>>();
|
|
|
+ foreach (List<string> simple in info.papers[m].answers) {
|
|
|
+ List<string> option = new List<string>();
|
|
|
+ if (simple.Count > 0)
|
|
|
+ {
|
|
|
+ List<string> opt = new List<string>{ "A", "B", "C", "D" };
|
|
|
+ int rd=new Random().Next(0,3);
|
|
|
+ if (rd == 1 || rd == 2)
|
|
|
+ {
|
|
|
+ option.AddRange(simple);
|
|
|
+ classResult.studentScores[k][n] = info.papers[m].point[n];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ simple.ForEach(x => { opt.Remove(x); });
|
|
|
+ option.Add(opt[new Random().Next(0, opt.Count-1)]);
|
|
|
+ classResult.studentScores[k][n] = 0;
|
|
|
+ }
|
|
|
+ ans.Add(option);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ classResult.studentScores[k][n] = new Random().Next(0, (int)info.papers[m].point[n]) * 1.0;
|
|
|
+ }
|
|
|
+ n++;
|
|
|
+ }
|
|
|
+ string FileName = classResult.examId + "/" + classResult.subjectId + "/" + stu;
|
|
|
+ string blob = await _azureStorage.UploadFileByContainer(code.ToString(), ans.ToJsonString(), "exam", FileName + "/" + "ans.json");
|
|
|
+ classResult.studentAnswers[k].Add(blob);
|
|
|
+ classResult.sum[k] = classResult.studentScores[k].Sum();
|
|
|
+ k++;
|
|
|
+ }
|
|
|
+ //await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
|
|
|
+ bool flag = true;
|
|
|
+ foreach (List<double> scores in classResult.studentScores)
|
|
|
+ {
|
|
|
+ foreach (double score in scores)
|
|
|
+ {
|
|
|
+ if (score == -1)
|
|
|
+ {
|
|
|
+ flag = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (flag)
|
|
|
+ {
|
|
|
+ //ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{school}"));
|
|
|
+ classResult.progress = true;
|
|
|
+/* info.subjects.ForEach(s =>
|
|
|
+ {
|
|
|
+ s.classCount += 1;
|
|
|
+ });*/
|
|
|
+ info.subjects[m].classCount += 1;
|
|
|
+
|
|
|
+ }
|
|
|
+ await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"ExamClassResult-{code}"));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ m++;
|
|
|
+ await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
+ return Ok(new { examClassResults });
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/getAnalysis()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|