Преглед изворни кода

学生端返回错题数量,缺考率调整

zhouj1203@hotmail.com пре 3 година
родитељ
комит
180742bfd2

+ 27 - 22
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -418,7 +418,7 @@ namespace TEAMModelOS.FunctionV4
                                     fno++;
                                 }
                                 //判断均分是否发生变化,便于实时的更新评测基本信息
-                                if (info.sRate != settlement.rate || info.average != settlement.score || info.sStatus != newStatus)
+                                if (info.sRate != settlement.rate || info.average != settlement.score || info.sStatus != newStatus || info.qRate != settlement.qrate)
                                 {
                                     info.sRate = settlement.rate;
                                     info.average = settlement.score;
@@ -474,7 +474,8 @@ namespace TEAMModelOS.FunctionV4
                     int index = 0;
                     if (classResult.status.Count > 0)
                     {
-                        foreach (var sta in classResult.status) {
+                        foreach (var sta in classResult.status)
+                        {
                             if (sta == 1)
                             {
                                 for (int i = 0; i < classResult.studentScores[index].Count; i++)
@@ -485,27 +486,28 @@ namespace TEAMModelOS.FunctionV4
                                     }
                                 }
                             }
-                            else if (sta == 0) {
-                                foreach (var ans in classResult.studentAnswers)
+                            else if (sta == 0)
+                            {
+                                var ans = classResult.studentScores[index];
+                                //该学生缺考,历史数据的判定
+                                if (ans.Count == 0)
                                 {
-                                    //该学生缺考,历史数据的判定
-                                    if (ans.Count == 0)
+                                    for (int i = 0; i < classResult.studentScores[index].Count; i++)
                                     {
-                                        for (int i = 0; i < classResult.studentScores[index].Count; i++)
+                                        if (classResult.studentScores[index][i] == -1)
                                         {
-                                            if (classResult.studentScores[index][i] == -1)
-                                            {
-                                                classResult.studentScores[index][i] = 0;
-                                            }
+                                            classResult.studentScores[index][i] = 0;
                                         }
-                                        classResult.status[index] = 1;
                                     }
+                                    classResult.status[index] = 1;
                                 }
+
                             }
                             index++;
                         }
                     }
-                    else {
+                    else
+                    {
                         foreach (var ans in classResult.studentAnswers)
                         {
                             //该学生缺考,历史数据的判定
@@ -522,7 +524,7 @@ namespace TEAMModelOS.FunctionV4
                             }
                             index++;
                         }
-                    }                   
+                    }
                     foreach (List<double> sc in classResult.studentScores)
                     {
                         List<double> newSc = new List<double>();
@@ -589,15 +591,18 @@ namespace TEAMModelOS.FunctionV4
                 foreach (string id in examResults[0].studentIds)
                 {
                     //计算整体缺考人数
-                    foreach (var ec in examClassResults) { 
+                    foreach (var ec in examClassResults)
+                    {
                         int index = ec.studentIds.IndexOf(id);
-                        if (index > -1) {
-                            if (ec.status[index] == 1) {
+                        if (index > -1)
+                        {
+                            if (ec.status[index] == 1)
+                            {
                                 qk++;
                                 break;
                             }
                         }
-                    }                
+                    }
                     double sc = 0;
                     foreach (ExamResult result in examResults)
                     {
@@ -640,8 +645,8 @@ namespace TEAMModelOS.FunctionV4
                 List<string> plId = new List<string>();
                 List<List<List<string>>> opth = new List<List<List<string>>>();
                 List<List<List<string>>> optl = new List<List<List<string>>>();
-                List<double> akp  =  await knowledgeCount(info, subject, _dingDing, no, classResults, rhwCount, rhw, rhlCount, rhl, _azureCosmos);
-                List<double> afp  = await fieldCount(info, subject, _dingDing, no, classResults, rhwCount, rhw, rhlCount, rhl, _azureCosmos);
+                List<double> akp = await knowledgeCount(info, subject, _dingDing, no, classResults, rhwCount, rhw, rhlCount, rhl, _azureCosmos);
+                List<double> afp = await fieldCount(info, subject, _dingDing, no, classResults, rhwCount, rhw, rhlCount, rhl, _azureCosmos);
                 int PHCount = 0;
                 int PLCount = 0;
                 foreach (ExamClassResult classResult in classResults)
@@ -930,7 +935,7 @@ namespace TEAMModelOS.FunctionV4
                                             {
                                                 if (classResult.studentScores[index].Count > 0)
                                                 {
-                                                    score += classResult.studentScores[index][n] == -1 ? 0 : classResult.studentScores[index][n]* itemPersent;
+                                                    score += classResult.studentScores[index][n] == -1 ? 0 : classResult.studentScores[index][n] * itemPersent;
                                                     if (classResult.studentScores[index].Sum() >= rhw && phcount < rhwCount)
                                                     {
                                                         if (classResult.studentScores[index][n] <= 0)
@@ -1114,7 +1119,7 @@ namespace TEAMModelOS.FunctionV4
                 {
                     double score = 0;
                     double allScore = 0;
-                    
+
                     int count = 0;
                     foreach (ExamClassResult result in classResults)
                     {

+ 63 - 1
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -1612,6 +1612,12 @@ namespace TEAMModelOS.Controllers
                         }
                     }
                 }
+                //查询结果
+                List<ExamResult> results = new();
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
+                {
+                    results.Add(item);
+                }
                 List<List<string>> stuAns = new();
                 List<List<double>> stuScore = new();
                 List<List<List<Details>>> mark = new();
@@ -1647,12 +1653,22 @@ namespace TEAMModelOS.Controllers
                     know = s.know;
                     fp = s.filed;
                 }
+                List<List<double>> wno = new();
+                foreach (ExamResult exam in results) {
+                    int num = 0;
+                    //确定当前循环科目索引位置
+                    int index = subId.IndexOf(exam.subjectId);
+                    //根据索引找到试卷分数
+                    List<double> points = papers[index].point;
+                    List<double> wn = await getWrongNum(exam, points);
+                    wno.Add(wn);
+                }
                 if (papers.IsNotEmpty())
                 {
                     var knowledge = know.Select(k => new { k.kn, k.kps, k.ckps, k.akps });
                     var filed = fp.Select(k => new { k.fs, k.fps, k.cfps, k.afps });
                     //papers = papers
-                    return Ok(new { papers, subjects, stuScore, stuAns, mark, total, claId = infoIds, knowledge, filed, average, status = 200 });
+                    return Ok(new { papers, subjects, stuScore, stuAns, mark, total, claId = infoIds, knowledge, filed, average, wno, status = 200 });
                 }
                 else
                 {
@@ -3494,6 +3510,52 @@ namespace TEAMModelOS.Controllers
             }
             return (ansBlob, scores);
         }
+
+        private Task<List<double>> getWrongNum(ExamResult result, List<double> points)
+        {
+            int num = 0;
+            List<double> wn = new List<double>();
+            foreach (var point in points)
+            {
+                int wnum = 0;
+                double p = point * 0.8;
+                foreach (ClassRange range in result.classes)
+                {
+                    for (int i = range.range[0]; i <= range.range[1]; i++)
+                    {
+                        //判断推送的数据中,学生正常得分数据
+                        if (result.studentScores[i].Count > 0)
+                        {
+                            if (result.studentScores[i][num] < point)
+                            {
+                                if (result.studentScores[i][num] < p)
+                                {
+                                    wnum++;
+                                }
+                                else
+                                {
+                                    continue;
+                                }
+                            }
+                            else
+                            {
+                                continue;
+                            }
+                        }
+                        else
+                        {
+                            wnum++;
+                        }
+
+
+                    }
+                }
+                wn.Add(wnum);
+                num++;
+            }
+            return Task.FromResult(wn);
+        }
+
     }
     public class stus
     {