瀏覽代碼

修正悉心稱成績統計時會卡住的問題 / 修改評量成績的計算方式改成百分比 / 修改課堂記錄完整模式三種百分比可以輸入三位數

upon 11 月之前
父節點
當前提交
2e80f7f21b

+ 9 - 0
TEAMModelOS.SDK/Models/Cosmos/School/ScoreCalc.cs

@@ -372,6 +372,10 @@ namespace TEAMModelOS.SDK.Models.Cosmos.School
     /// </summary>
     public class ExamItem
     {
+        public ExamItem()
+        {            
+            point = new List<double>();
+        }
         /// <summary>
         /// 評量id
         /// </summary>
@@ -392,6 +396,11 @@ namespace TEAMModelOS.SDK.Models.Cosmos.School
         /// 開始時間
         /// </summary>
         public long startTime { get; set; }
+        /// <summary>
+        /// 每題的滿分分數
+        /// </summary>
+        public List<double> point { get; set; }
+        
 
     }
     /// <summary>

+ 6 - 6
TEAMModelOS/ClientApp/src/view/mycourse/score/ScoreBody.vue

@@ -392,9 +392,9 @@
                               <div>
                                 ( <input type="text" v-model="Proportion.ScoreCalcAct.attendRate.score"
                                   @input="onRateChange('attend')"
-                                  style="width: 20px; height: 20px; box-sizing: border-box;"
+                                  style="width: 30px; height: 20px; box-sizing: border-box;"
                                   :style="{ color: Proportion.ScoreCalcAct.attendRate.color, margin: '0px 5px', border: 'none', background: 'none' }"
-                                  maxlength="2">
+                                  maxlength="3">
                                 %)
                               </div>
                             </div>
@@ -412,9 +412,9 @@
                               <div>
                                 ( <input type="text" v-model="Proportion.ScoreCalcAct.pointRate.score"
                                   @input="onRateChange('point')"
-                                  style="width: 20px; height: 20px; box-sizing: border-box;"
+                                  style="width: 30px; height: 20px; box-sizing: border-box;"
                                   :style="{ color: Proportion.ScoreCalcAct.pointRate.color, margin: '0px 5px', border: 'none', background: 'none' }"
-                                  maxlength="2">
+                                  maxlength="3">
                                 %)
                               </div>
                             </div>
@@ -433,9 +433,9 @@
                               <div>
                                 ( <input type="text" v-model="Proportion.ScoreCalcAct.interactRate.score"
                                   @input="onRateChange('interact')"
-                                  style="width: 20px; height: 20px; box-sizing: border-box;"
+                                  style="width: 30px; height: 20px; box-sizing: border-box;"
                                   :style="{ color: Proportion.ScoreCalcAct.interactRate.color, margin: '0px 5px', border: 'none', background: 'none' }"
-                                  maxlength="2">
+                                  maxlength="3">
                                 %)
                               </div>
                             </div>

+ 20 - 14
TEAMModelOS/Controllers/Both/ScoreCalcController.cs

@@ -3,7 +3,7 @@ using Azure.Core;
 using Azure.Cosmos;
 using Azure.Messaging.ServiceBus;
 using Azure.Storage.Blobs.Models;
-using DinkToPdf.Contracts; 
+using DinkToPdf.Contracts;
 using HTEXLib.COMM.Helpers;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Hosting;
@@ -1999,12 +1999,12 @@ namespace TEAMModelOS.Controllers
                 {
                     code = $"LessonRecord-{schoolId}";// 組合區域碼
                     tbname = "School";
-                    school = $"{schoolId}";                    
+                    school = $"{schoolId}";
                     //只查询某个老师的课例
-                    if (string.IsNullOrWhiteSpace($"{teammodelId}"))                                                            
+                    if (string.IsNullOrWhiteSpace($"{teammodelId}"))
                     {
-                        return false;                        
-                    }                   
+                        return false;
+                    }
                 }
                 else
                 {
@@ -2015,7 +2015,7 @@ namespace TEAMModelOS.Controllers
             {
                 code = $"LessonRecord";
                 tbname = "Teacher";
-                if (string.IsNullOrEmpty($"{teammodelId}"))                
+                if (string.IsNullOrEmpty($"{teammodelId}"))
                 {
                     //如果不传tmdid, 则必须传递,课程id或者名单列表
                     // 如果不传递tmdid
@@ -2132,7 +2132,7 @@ namespace TEAMModelOS.Controllers
             #endregion
 
             List<ScoreLessonBase> lessonBases = new List<ScoreLessonBase>();
-            string blobname = "";         
+            string blobname = "";
 
             foreach (var item in lessonRecords)
             {// 先檢查課堂紀錄是否存在再取資料
@@ -2155,7 +2155,7 @@ namespace TEAMModelOS.Controllers
                         }
                     }
                 }
-                else 
+                else
                 { // 個人課程
                     List<CourseTask_ta> ctList = new();
                     // 檢查這個課程的助教跟教授裡面有沒有包含傳進來的teammodelId   有的話用教授取blob的資料
@@ -2185,11 +2185,11 @@ namespace TEAMModelOS.Controllers
                             }
                         }
                     }
-                    else { return false; }
+                    //else { return false; }
+
+
+                }
 
-                    
-                }                
-                
             }
             List<ScoreLessonBase> lessonBasesCalcList = new List<ScoreLessonBase>();
             // 重新比對資料以防  班級人數跟分數的數量對不上             
@@ -2288,7 +2288,7 @@ namespace TEAMModelOS.Controllers
                 sb_examIds.Append($"'{examItem[i].examId}',");
             }
             // 取評量名稱
-            string sql_examName = $"SELECT c.id as examId, c.name, c.startTime FROM c where c.pk = 'Exam' and c.id in ({sb_examIds.ToString().Remove(sb_examIds.Length - 1, 1)})";
+            string sql_examName = $"SELECT c.id as examId, c.name, c.startTime, b.point FROM c join b in c.papers where c.pk = 'Exam' and c.id in ({sb_examIds.ToString().Remove(sb_examIds.Length - 1, 1)})";
             //string sql_examName = $"SELECT c.id as examId, c.name FROM c where c.pk = 'Exam' and c.id in ({sb_examIds.ToString().Remove(sb_examIds.Length - 1, 1)})";
             await foreach (var item in clientCommon.GetItemQueryIterator<ExamItem>(queryText: sql_examName))
             {
@@ -2304,6 +2304,11 @@ namespace TEAMModelOS.Controllers
                 ExamItem examItemCalc = new ExamItem();
                 examItemCalc.examId = examItem[i].examId;
                 examItemCalc.sum = new List<double>();
+                // 先計算出每個評量的總分
+                var totalPoints = examItemNameStartTime
+                .Where(exam => exam.examId == examItem[i].examId)
+                .SelectMany(exam => exam.point)
+                .Sum();
 
                 // 設定分數的預設值
                 for (int f = 0; f < members.Count; f++)
@@ -2318,7 +2323,8 @@ namespace TEAMModelOS.Controllers
                         //如果有比對中學生id再把分數設定過來
                         if (examItem[i].studentIds[j] == members[k].id)
                         {
-                            examItemCalc.sum[k] = examItem[i].sum[j];
+                            // 用每個評量的總分計算出每個學生評量的百分比分數
+                            examItemCalc.sum[k] = 100 / totalPoints * examItem[i].sum[j];
                         }
                     }
                 }