浏览代码

处理学生未作答的情况

zhouj1203@hotmail.com 4 年之前
父节点
当前提交
f85bd5b3fd
共有 1 个文件被更改,包括 63 次插入56 次删除
  1. 63 56
      TEAMModelOS/Controllers/Common/ExamController.cs

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

@@ -390,87 +390,94 @@ namespace TEAMModelOS.Controllers
                                 if (rule > 0)
                                 {
                                     int falseCount = 0;
-                                    foreach (string obj in ans[i])
+                                    if (ans[i].Count > 0)
                                     {
-                                        if (!standard[i].Contains(obj))
+                                        foreach (string obj in ans[i])
                                         {
-                                            falseCount++;
-                                        }
-                                    }
-                                    switch (rule)
-                                    {
-                                        case 1:
-                                            if (ans[i].Count == standard[i].Count)
+                                            if (!standard[i].Contains(obj))
                                             {
-                                                if (falseCount == 0)
+                                                falseCount++;
+                                            }
+                                        }
+                                        switch (rule)
+                                        {
+                                            case 1:
+                                                if (ans[i].Count == standard[i].Count)
                                                 {
-                                                    result.studentScores[newIndex][i] = points[i];
+                                                    if (falseCount == 0)
+                                                    {
+                                                        result.studentScores[newIndex][i] = points[i];
+                                                    }
+                                                    else
+                                                    {
+                                                        result.studentScores[newIndex][i] = 0;
+                                                    }
                                                 }
                                                 else
                                                 {
                                                     result.studentScores[newIndex][i] = 0;
                                                 }
-                                            }
-                                            else
-                                            {
-                                                result.studentScores[newIndex][i] = 0;
-                                            }
-                                            break;
-                                        case 2:
-                                            if (falseCount > 0)
-                                            {
-                                                result.studentScores[newIndex][i] = 0;
-                                            }
-                                            else
-                                            {
-                                                if (ans[i].Count == standard[i].Count)
+                                                break;
+                                            case 2:
+                                                if (falseCount > 0)
                                                 {
-                                                    result.studentScores[newIndex][i] = points[i];
+                                                    result.studentScores[newIndex][i] = 0;
                                                 }
                                                 else
                                                 {
-                                                    result.studentScores[newIndex][i] = points[i] / 2;
-                                                }
+                                                    if (ans[i].Count == standard[i].Count)
+                                                    {
+                                                        result.studentScores[newIndex][i] = points[i];
+                                                    }
+                                                    else
+                                                    {
+                                                        result.studentScores[newIndex][i] = points[i] / 2;
+                                                    }
 
-                                            }
-                                            break;
-                                        case 3:
-                                            if (falseCount > 0)
-                                            {
-                                                result.studentScores[newIndex][i] = 0;
-                                            }
-                                            else
-                                            {
-                                                if (ans[i].Count == standard[i].Count)
+                                                }
+                                                break;
+                                            case 3:
+                                                if (falseCount > 0)
                                                 {
-                                                    result.studentScores[newIndex][i] = points[i];
+                                                    result.studentScores[newIndex][i] = 0;
                                                 }
                                                 else
                                                 {
-                                                    result.studentScores[newIndex][i] = System.Math.Round((double)ans[i].Count / standard[i].Count * points[i], 1);
-                                                }
+                                                    if (ans[i].Count == standard[i].Count)
+                                                    {
+                                                        result.studentScores[newIndex][i] = points[i];
+                                                    }
+                                                    else
+                                                    {
+                                                        result.studentScores[newIndex][i] = System.Math.Round((double)ans[i].Count / standard[i].Count * points[i], 1);
+                                                    }
 
-                                            }
-                                            break;
-                                        case 4:
-                                            if (ans[i].Count == standard[i].Count)
-                                            {
-                                                result.studentScores[newIndex][i] = points[i];
-                                            }
-                                            else
-                                            {
-                                                double persent = (double)(standard[i].Count - 2 * falseCount) / standard[i].Count;
-                                                if (persent <= 0)
+                                                }
+                                                break;
+                                            case 4:
+                                                if (ans[i].Count == standard[i].Count)
                                                 {
-                                                    result.studentScores[newIndex][i] = 0;
+                                                    result.studentScores[newIndex][i] = points[i];
                                                 }
                                                 else
                                                 {
-                                                    result.studentScores[newIndex][i] = System.Math.Round(persent * points[i], 1);
+                                                    double persent = (double)(standard[i].Count - 2 * falseCount) / standard[i].Count;
+                                                    if (persent <= 0)
+                                                    {
+                                                        result.studentScores[newIndex][i] = 0;
+                                                    }
+                                                    else
+                                                    {
+                                                        result.studentScores[newIndex][i] = System.Math.Round(persent * points[i], 1);
+                                                    }
                                                 }
-                                            }
-                                            break;
+                                                break;
+                                        }
+                                    }
+                                    else {
+                                        result.studentScores[newIndex][i] = 0;
                                     }
+                                    
                                 }
                             }
                         }