|
@@ -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 列表
|