Forráskód Böngészése

統測活動 決賽名單計算追加「班級流水號」欄位

jeff 7 hónapja
szülő
commit
355af09ce8

+ 3 - 1
TEAMModelOS.Function/IESServiceBusTrigger.cs

@@ -3251,9 +3251,11 @@ namespace TEAMModelOS.Function
                                     if (jointGroupIds.Count > 0)
                                     {
                                         string scope = "private";
+                                        int classCnt = 0;
                                         foreach (string jointGroupId in jointGroupIds)
                                         {
-                                            List<JointEventGroupDb> addResult = await JointService.CreatePassJointCourseBySchedule(client, jointEvent.id, jointGroupId, jointEventSchedule.id, scope, true);
+                                            object addResult = await JointService.CreatePassJointCourseBySchedule(client, jointEvent.id, jointGroupId, jointEventSchedule.id, scope, true, classCnt);
+                                            classCnt = Int32.Parse(addResult.GetType().GetProperty("classCnt").GetValue(addResult).ToString());
                                         }
                                     }
                                 }

+ 9 - 15
TEAMModelOS.SDK/Models/Service/JointService.cs

@@ -288,7 +288,8 @@ namespace TEAMModelOS.SDK.Models.Service
 
         //以JointSchedule為單位,判斷班級/課程名單是否完成並生成決賽名單
         /// <param name="mode">updDb true:更新DB false:不更新DB</param>
-        public static async Task<List<JointEventGroupDb>> CreatePassJointCourseBySchedule(CosmosClient client, string jointEventId, string jointGroupId, string jointScheduleId, string scope, bool updDb)
+        /// <param name="classCnt"> 班級流水號 (此次活動參加的班級數)
+        public static async Task<object> CreatePassJointCourseBySchedule(CosmosClient client, string jointEventId, string jointGroupId, string jointScheduleId, string scope, bool updDb, int classCnt)
         {
             List<JointEventGroupDb> result = new List<JointEventGroupDb>();
             //0. 取得jointEvent、JointEventSchedule
@@ -416,7 +417,6 @@ namespace TEAMModelOS.SDK.Models.Service
             //5. 決賽課程生成
             ///生成資料製作
             List<JointEventGroupDb> jointCourseCreates = new List<JointEventGroupDb>(); //要生成的老師課程名單
-            Dictionary<string, int> jointGroupClassCntDic = new Dictionary<string, int>(); //各jointGroup的班級數目 => 用來做個決賽班級的流水號
             foreach (JointEventGroupDb jointEventCourseRow in jointEventCourse)
             {
                 foreach (JointEventGroupBase.JointEventGroupCourse course in jointEventCourseRow.courseLists)
@@ -431,9 +431,6 @@ namespace TEAMModelOS.SDK.Models.Service
                             JointEventGroupDb jointCourseCreateRow = jointCourseCreates.Where(c => c.jointEventId.Equals(jointEventCourseRow.jointEventId) && c.jointGroupId.Equals(jointEventCourseRow.jointGroupId) && c.creatorId.Equals(jointEventCourseRow.creatorId)).FirstOrDefault();
                             if (jointCourseCreateRow == null)
                             {
-                                ///各jointGroup的班級數目計算
-                                if (jointGroupClassCntDic.ContainsKey(jointEventCourseRow.jointGroupId)) jointGroupClassCntDic[jointEventCourseRow.jointGroupId]++;
-                                else jointGroupClassCntDic.Add(jointEventCourseRow.jointGroupId, 1);
                                 ///DB 老師決賽document
                                 JointEventGroupDb finalEventCourse = new JointEventGroupDb();
                                 finalEventCourse.jointEventId = jointEventCourseRow.jointEventId;
@@ -448,12 +445,13 @@ namespace TEAMModelOS.SDK.Models.Service
                                 finalEventCourse.schoolId = jointEventCourseRow.schoolId;
                                 finalEventCourse.schoolName = jointEventCourseRow.schoolName;
                                 finalEventCourse.jointScheduleId = finalSchedule.id;
+                                classCnt++;
                                 finalEventCourse.courseLists.Add(new JointEventGroupBase.JointEventGroupCourse()
                                 {
                                     courseId = courseId,
                                     courseName = courseName,
                                     groupLists = new List<JointEventGroupBase.JointEventGroupCourseGroup>() {
-                                        new() { id = group.id, name = group.name, no = jointGroupClassCntDic[jointEventCourseRow.jointGroupId].ToString() }
+                                        new() { id = group.id, name = group.name, no = classCnt.ToString() }
                                     }
                                 });
                                 finalEventCourse.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
@@ -464,17 +462,15 @@ namespace TEAMModelOS.SDK.Models.Service
                                 JointEventGroupBase.JointEventGroupCourse courseRowNow = jointCourseCreateRow.courseLists.Where(c => c.courseId.Equals(courseId)).FirstOrDefault();
                                 if (courseRowNow == null)
                                 {
-                                    ///各jointGroup的班級數目計算
-                                    if (jointGroupClassCntDic.ContainsKey(jointEventCourseRow.jointGroupId)) jointGroupClassCntDic[jointEventCourseRow.jointGroupId]++;
-                                    else jointGroupClassCntDic.Add(jointEventCourseRow.jointGroupId, 1);
                                     ///DB 老師決賽課程資料
+                                    classCnt++;
                                     jointCourseCreateRow.courseLists.Add(
                                         new JointEventGroupBase.JointEventGroupCourse
                                         {
                                             courseId = courseId,
                                             courseName = courseName,
                                             groupLists = new List<JointEventGroupBase.JointEventGroupCourseGroup>() {
-                                                            new() { id = group.id, name = group.name, no = jointGroupClassCntDic[jointEventCourseRow.jointGroupId].ToString() }
+                                                            new() { id = group.id, name = group.name, no = classCnt.ToString() }
                                             }
                                         }
                                     );
@@ -484,12 +480,10 @@ namespace TEAMModelOS.SDK.Models.Service
                                     JointEventGroupBase.JointEventGroupCourseGroup groupRowNow = courseRowNow.groupLists.Where(g => g.id.Equals(group.id)).FirstOrDefault();
                                     if (groupRowNow == null)
                                     {
-                                        ///各jointGroup的班級數目計算
-                                        if (jointGroupClassCntDic.ContainsKey(jointEventCourseRow.jointGroupId)) jointGroupClassCntDic[jointEventCourseRow.jointGroupId]++;
-                                        else jointGroupClassCntDic.Add(jointEventCourseRow.jointGroupId, 1);
                                         ///DB 老師決賽班級資料
+                                        classCnt++;
                                         courseRowNow.groupLists.Add(
-                                            new() { id = group.id, name = group.name, no = jointGroupClassCntDic[jointEventCourseRow.jointGroupId].ToString() }
+                                            new() { id = group.id, name = group.name, no = classCnt.ToString() }
                                         );
                                     }
                                 }
@@ -528,7 +522,7 @@ namespace TEAMModelOS.SDK.Models.Service
                 }
             }
 
-            return result;
+            return new { result = result, classCnt = classCnt };
         }
         //判斷某課程名單是否已完成評量
         //回傳值: 班級ID 或 課程名單ID 列表

+ 1 - 0
TEAMModelOS/ClientApp/public/lang/en-US.js

@@ -8053,6 +8053,7 @@ const LANG_EN_US = {
         jointGroup: 'Group',
         course: 'Course',
         courseGroup: 'Class',
+        courseGroupNo: 'ClassNo',
         schoolName: 'School',
         Warning01: 'For designated review, please enter the TEAM Model user number and check to confirm it is the correct TEAM Model ID',
         check: 'check',

+ 1 - 0
TEAMModelOS/ClientApp/public/lang/zh-CN.js

@@ -8054,6 +8054,7 @@ const LANG_ZH_CN = {
         jointGroup: '报名群组',
         course: '课程',
         courseGroup: '课程名单',
+        courseGroupNo: '课程名单流水号',
         schoolName: '学校',
         Warning01: '指定评审,请输入醍摩豆用户编号,检查确认为正确醍摩豆ID',
         check: '检查',

+ 1 - 0
TEAMModelOS/ClientApp/public/lang/zh-TW.js

@@ -8054,6 +8054,7 @@ const LANG_ZH_TW = {
         jointGroup: '報名群組',
         course: '課程',
         courseGroup: '課程名單',
+        courseGroupNo: '課程名單流水號',
         schoolName: '學校',
         Warning01: '指定評審,請輸入醍摩豆用戶編號,檢查確認為正確醍摩豆ID',
         check: '檢查',

+ 3 - 2
TEAMModelOS/ClientApp/src/view/htcommunity/htMgtHome.vue

@@ -496,6 +496,7 @@ export default {
                                           courseName: courseName,
                                           groupId: courseGroupId,
                                           groupName: courseGroupName,
+                                          groupNo: (g.no !== null) ? g.no : " ",
                                           stuNum: g.stuNum,
                                           goFinal: goFinal,
                                           countryId: item.countryId,
@@ -532,8 +533,8 @@ export default {
       exportExcel(type) {
         //老師報名資料
           if (type == 'teacherCourse') {
-              let titles = [this.$t('htcommunity.jointGroup'), this.$t('htcommunity.location'), this.$t('htcommunity.schoolName'), this.$t('htcommunity.teacherName'), this.$t('htcommunity.tmid'), this.$t('htcommunity.course'), this.$t('htcommunity.courseGroup'), this.$t('htcommunity.stuNumber'), this.$t('htcommunity.jointTime'), this.$t('htcommunity.finalQualification')];
-              let keys = ['jointGroupName', 'location', 'schoolName', 'creatorName', 'creatorId', 'courseName', 'groupName', 'stuNum', 'createTime', 'goFinal'];
+              let titles = [this.$t('htcommunity.jointGroup'), this.$t('htcommunity.location'), this.$t('htcommunity.schoolName'), this.$t('htcommunity.teacherName'), this.$t('htcommunity.tmid'), this.$t('htcommunity.course'), this.$t('htcommunity.courseGroup'), this.$t('htcommunity.courseGroupNo'), this.$t('htcommunity.stuNumber'), this.$t('htcommunity.jointTime'), this.$t('htcommunity.finalQualification')];
+              let keys = ['jointGroupName', 'location', 'schoolName', 'creatorName', 'creatorId', 'courseName', 'groupName', 'groupNo', 'stuNum', 'createTime', 'goFinal'];
               const params = {
                   title: titles,
                   key: keys,

+ 9 - 3
TEAMModelOS/Controllers/Teacher/JointEventController.cs

@@ -608,9 +608,12 @@ namespace TEAMModelOS.Controllers.Common
                     string jointScheduleId = jointEvent.schedule.Where(s => s.type.Equals("exam") && s.examType.Equals("regular")).Select(s => s.id).FirstOrDefault(); //取得熱身賽的行程ID
                     if (!string.IsNullOrWhiteSpace(jointScheduleId) && jointGroupIds.Count > 0)
                     {
+                        int classCnt = 0;
                         foreach (string jointGId in jointGroupIds)
                         {
-                            List<JointEventGroupDb> addResult = await JointService.CreatePassJointCourseBySchedule(client, jointEventId, jointGId, jointScheduleId, scope, false);
+                            object exeResult = await JointService.CreatePassJointCourseBySchedule(client, jointEventId, jointGId, jointScheduleId, scope, false, classCnt);
+                            classCnt = Int32.Parse(exeResult.GetType().GetProperty("classCnt").GetValue(exeResult).ToString());
+                            List<JointEventGroupDb> addResult = exeResult.GetType().GetProperty("result").GetValue(exeResult).ToJsonString().ToObject<List<JointEventGroupDb>>();
                             finalCourse = finalCourse.Union(addResult).ToList();
                         }
                     }
@@ -1436,9 +1439,12 @@ namespace TEAMModelOS.Controllers.Common
             List<string> jointGroupIds = jointEvent.groups.Select(g => g.id).ToList();
             if(jointGroupIds.Count > 0)
             {
-                foreach(string jointGroupId in jointGroupIds)
+                int classCnt = 0;
+                foreach (string jointGroupId in jointGroupIds)
                 {
-                    List<JointEventGroupDb> addResult = await JointService.CreatePassJointCourseBySchedule(client, jointEventId, jointGroupId, jointScheduleId, scope, true);
+                    object exeResult = await JointService.CreatePassJointCourseBySchedule(client, jointEventId, jointGroupId, jointScheduleId, scope, true, classCnt);
+                    classCnt = Int32.Parse(exeResult.GetType().GetProperty("classCnt").GetValue(exeResult).ToString());
+                    List<JointEventGroupDb> addResult = exeResult.GetType().GetProperty("result").GetValue(exeResult).ToJsonString().ToObject<List<JointEventGroupDb>>();
                     result = result.Union(addResult).ToList();
                 }
             }