|
@@ -26,6 +26,7 @@ using DocumentFormat.OpenXml.Drawing;
|
|
|
using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Engineering;
|
|
|
using static System.Runtime.CompilerServices.RuntimeHelpers;
|
|
|
+using TEAMModelOS.SDK.Models.Service;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers.Common
|
|
|
{
|
|
@@ -506,8 +507,41 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
jointCourse.creatorName = creatorName;
|
|
|
}
|
|
|
jointCourse.courseLists = courseLists;
|
|
|
-
|
|
|
await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<JointEventGroupDb>(jointCourse, new PartitionKey("JointCourse"));
|
|
|
+
|
|
|
+ //取得該老師報名該活動該組別且progress="going"的JointExam並生成Exam
|
|
|
+ List<JointExam> jointExams = new List<JointExam>();
|
|
|
+ ///個人
|
|
|
+ if (jointCourse.scope.Equals("private"))
|
|
|
+ {
|
|
|
+ StringBuilder sqlJointExam = new($"SELECT * FROM c WHERE c.jointEventId = '{jointCourse.jointEventId}' AND c.jointGroupId = '{jointCourse.jointGroupId}' AND c.progress = 'going' AND c.examType = 'regular' ");
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIteratorSql(queryText: sqlJointExam.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("JointExam") }))
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.Content);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ {
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+ {
|
|
|
+ jointExams.Add(obj.ToObject<JointExam>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ///學校[待做]
|
|
|
+ else if (scope.Equals("school"))
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ //Exam生成邏輯
|
|
|
+ if (jointExams.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var info in jointExams)
|
|
|
+ {
|
|
|
+ //生成所有報名教師個人評量
|
|
|
+ await JointService.GenerateExamFromJointExamAsync(client, _azureStorage, _serviceBus, _coreAPIHttpService, _azureRedis, _configuration, _dingDing, info);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return Ok(new { errCode = "", err = "", jointCourse });
|
|
|
}
|
|
|
catch (Exception e)
|
|
@@ -760,6 +794,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
if (classes != null) jointExam.classes = classes;
|
|
|
if (stuLists != null) jointExam.stuLists = stuLists;
|
|
|
}
|
|
|
+ jointExam.pk = "JointExam";
|
|
|
jointExam.code = "JointExam";
|
|
|
jointExam.id = jointExamId;
|
|
|
jointExam.jointEventId = jointEventId;
|
|
@@ -776,7 +811,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
jointExam.examOverwrite = jointEventSchedule.examOverwrite;
|
|
|
jointExam.startTime = jointEventSchedule.startTime;
|
|
|
jointExam.endTime = jointEventSchedule.endTime;
|
|
|
- jointExam.progress = (jointExam.startTime > now) ? "pending" : (jointExam.endTime > now) ? "finish" : "going";
|
|
|
+ jointExam.progress = (jointExam.startTime > now) ? "pending" : (now > jointExam.endTime) ? "finish" : "going";
|
|
|
jointExam.updateTime = now;
|
|
|
|
|
|
await client.GetContainer(Constant.TEAMModelOS, "Common").UpsertItemAsync<JointExam>(jointExam, new PartitionKey("JointExam"));
|