|
@@ -543,6 +543,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
string jointEventId = (request.TryGetProperty("jointEventId", out JsonElement _jointEventId)) ? _jointEventId.ToString() : string.Empty;
|
|
string jointEventId = (request.TryGetProperty("jointEventId", out JsonElement _jointEventId)) ? _jointEventId.ToString() : string.Empty;
|
|
string jointGroupId = (request.TryGetProperty("jointGroupId", out JsonElement _jointGroupId)) ? _jointGroupId.ToString() : string.Empty;
|
|
string jointGroupId = (request.TryGetProperty("jointGroupId", out JsonElement _jointGroupId)) ? _jointGroupId.ToString() : string.Empty;
|
|
string type = (request.TryGetProperty("type", out JsonElement _type)) ? _type.ToString() : "regular"; //預設取得報名名單
|
|
string type = (request.TryGetProperty("type", out JsonElement _type)) ? _type.ToString() : "regular"; //預設取得報名名單
|
|
|
|
+ bool getFinalCourseFlg = (request.TryGetProperty("getFinal", out JsonElement _getFinal)) ? _getFinal.GetBoolean() : false; //是否要取得可晉級名單
|
|
if (string.IsNullOrWhiteSpace(jointEventId)) return BadRequest();
|
|
if (string.IsNullOrWhiteSpace(jointEventId)) return BadRequest();
|
|
//取得活動
|
|
//取得活動
|
|
JointEvent jointEvent = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<JointEvent>(jointEventId, new PartitionKey("JointEvent"));
|
|
JointEvent jointEvent = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<JointEvent>(jointEventId, new PartitionKey("JointEvent"));
|
|
@@ -597,6 +598,24 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //取得可晉級決賽名單
|
|
|
|
+ List<JointEventGroupDb> finalCourse = new List<JointEventGroupDb>();
|
|
|
|
+ if (getFinalCourseFlg)
|
|
|
|
+ {
|
|
|
|
+ string scope = "private";
|
|
|
|
+ List<string> jointGroupIds = jointEvent.groups.Select(g => g.id).ToList();
|
|
|
|
+ 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)
|
|
|
|
+ {
|
|
|
|
+ foreach (string jointGId in jointGroupIds)
|
|
|
|
+ {
|
|
|
|
+ List<JointEventGroupDb> addResult = await JointService.CreatePassJointCourseBySchedule(client, jointEventId, jointGId, jointScheduleId, scope, false);
|
|
|
|
+ finalCourse = finalCourse.Union(addResult).ToList();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//取得各課程名單(班級)人數
|
|
//取得各課程名單(班級)人數
|
|
Dictionary<string, int> groupStuNumDic = new Dictionary<string, int>(); //各課程名單(各班級)人數 key:班級ID val:人數
|
|
Dictionary<string, int> groupStuNumDic = new Dictionary<string, int>(); //各課程名單(各班級)人數 key:班級ID val:人數
|
|
StringBuilder stringBuilderGList = new($"SELECT c.id, ARRAY_LENGTH(c.members) as stuNum FROM c WHERE ARRAY_CONTAINS({JsonSerializer.Serialize(groupIdList)}, c.id) ");
|
|
StringBuilder stringBuilderGList = new($"SELECT c.id, ARRAY_LENGTH(c.members) as stuNum FROM c WHERE ARRAY_CONTAINS({JsonSerializer.Serialize(groupIdList)}, c.id) ");
|
|
@@ -615,18 +634,27 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
foreach(JointEventGroupDto jointCourse in JointCourseDto)
|
|
foreach(JointEventGroupDto jointCourse in JointCourseDto)
|
|
{
|
|
{
|
|
- foreach(JointEventGroupDto.JointEventGroupCourseDto cInfo in jointCourse.courseLists)
|
|
|
|
|
|
+ JointEventGroupDb finalJointCourseNow = finalCourse.Where(c => c.jointEventId.Equals(jointCourse.jointEventId) && c.jointGroupId.Equals(jointCourse.jointGroupId) && c.creatorId.Equals(jointCourse.creatorId)).FirstOrDefault(); //取得決賽老師資料
|
|
|
|
+ foreach (JointEventGroupDto.JointEventGroupCourseDto cInfo in jointCourse.courseLists)
|
|
{
|
|
{
|
|
|
|
+ JointEventGroupBase.JointEventGroupCourse finalCInfo = (finalJointCourseNow != null) ? finalJointCourseNow.courseLists.Where(c => c.courseId.Equals(cInfo.courseId)).FirstOrDefault() : null;
|
|
foreach (JointEventGroupDto.JointEventGroupCourseGroupDto gInfo in cInfo.groupLists)
|
|
foreach (JointEventGroupDto.JointEventGroupCourseGroupDto gInfo in cInfo.groupLists)
|
|
{
|
|
{
|
|
|
|
+ //班級人數
|
|
if(groupStuNumDic.ContainsKey(gInfo.id))
|
|
if(groupStuNumDic.ContainsKey(gInfo.id))
|
|
{
|
|
{
|
|
gInfo.stuNum = groupStuNumDic[gInfo.id];
|
|
gInfo.stuNum = groupStuNumDic[gInfo.id];
|
|
}
|
|
}
|
|
|
|
+ //是否可晉級決賽
|
|
|
|
+ JointEventGroupBase.JointEventGroupCourseGroup finalGInfo = (finalCInfo != null) ? finalCInfo.groupLists.Where(g => g.id.Equals(gInfo.id)).FirstOrDefault() : null;
|
|
|
|
+ if(finalGInfo != null)
|
|
|
|
+ {
|
|
|
|
+ gInfo.goFinal = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return Ok(new { data = JointCourseDto });
|
|
return Ok(new { data = JointCourseDto });
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
@@ -1410,7 +1438,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
{
|
|
{
|
|
foreach(string jointGroupId in jointGroupIds)
|
|
foreach(string jointGroupId in jointGroupIds)
|
|
{
|
|
{
|
|
- List<JointEventGroupDb> addResult = await JointService.CreatePassJointCourseBySchedule(client, jointEventId, jointGroupId, jointScheduleId, scope);
|
|
|
|
|
|
+ List<JointEventGroupDb> addResult = await JointService.CreatePassJointCourseBySchedule(client, jointEventId, jointGroupId, jointScheduleId, scope, true);
|
|
result = result.Union(addResult).ToList();
|
|
result = result.Union(addResult).ToList();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1633,6 +1661,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
public string id { get; set; }
|
|
public string id { get; set; }
|
|
public string name { get; set; }
|
|
public string name { get; set; }
|
|
public int stuNum { get; set; }
|
|
public int stuNum { get; set; }
|
|
|
|
+ public bool goFinal { get; set; } //是否可參加決賽
|
|
public List<object> schedule { get; set; } = new List<object>(); //已完成的行程
|
|
public List<object> schedule { get; set; } = new List<object>(); //已完成的行程
|
|
}
|
|
}
|
|
}
|
|
}
|