黄贺彬 3 meses atrás
pai
commit
94182f4b65

+ 1 - 0
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Controllers/ManageController.cs

@@ -788,6 +788,7 @@ namespace IES.ExamServer.Controllers
                                         x.periodId= groupListItem.periodId;
                                         x.roundId=setting.id;
                                         x.className= groupListItem.name;
+                                        x.year= groupListItem.year;
                                     });
                                     members.AddRange(groupListItem.members);
                                 }

+ 92 - 7
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Controllers/StudentController.cs

@@ -33,7 +33,91 @@ namespace IES.ExamServer.Controllers
             _connectionService=connectionService;
             _liteDBFactory=liteDBFactory;
         }
+        /// <summary>
+        ///  学生提交音乐作答
+        /// </summary>
+        /// <param name="json"></param>
+        /// <returns></returns>
+        [HttpPost("submit-music-ai-result")]
+        [AuthToken("student")]
+        public IActionResult SubmitMusicAIResult(JsonNode json) 
+        {
+            int finished = int.Parse($"{json["finished"]}");
+            string evaluationId = $"{json["evaluationId"]}";
+            string taskId = $"{json["taskId"]}";
+            string questionId = $"{json["questionId"]}";
+            long costTime = int.Parse($"{json["costTime"]}");
+            string settingId = $"{json["settingId"]}";
+            var token = GetAuthTokenInfo();
+            EvaluationRoundSetting? setting = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationRoundSetting>().FindOne(x => x.id!.Equals(settingId) && evaluationId.Equals(x.evaluationId) && x.activate==1);
+            EvaluationClient? evaluationClient = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().FindOne(x => evaluationId.Equals(x.id));
+            if (evaluationClient!=null && setting!=null && setting.activate==1)
+            {
+                string resultId = ShaHashHelper.GetSHA1(evaluationId+_connectionService?.serverDevice?.school?.id+token.id);
+                EvaluationStudentResult studentResult = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationStudentResult>()
+                .FindOne(x => resultId.Equals(x.id) && token.id.Equals(x.studentId) && evaluationId.Equals(x.evaluationId));
+                if (studentResult!=null)
+                {
+                    long now = DateTimeOffset.Now.ToUnixTimeMilliseconds();
+                    //判断开始时间
+                    if ((setting.startline>0 && setting.startline>now)|| evaluationClient.stime>now)
+                    {
+                        //未到开始时间
+                        return Ok(new { msg = "未到开始时间。", code = 1 });
+                    }
+
+                    //判断截止时间
+                    long deadline;
+                    if (setting.countdownType==2)
+                    {
+
+                        deadline= studentResult.startTime+setting.countdown;
+                    }
+                    else
+                    {
+                        deadline= setting.startline+setting.countdown;
 
+                    }
+                    deadline+= 10*60*1000;//漂移10分钟,允许学生延迟提交,但是前端页面显示的截止时间是准的,时间一到,可自动提交。
+                                          //已过截止时间
+                                          //if ((deadline>0&&deadline<now)|| evaluationClient.etime<now)
+                                          //{
+                                          //    return Ok(new { msg = "已过截止时间。", code = 2 });
+                                          //}    
+                    if (!string.IsNullOrWhiteSpace(questionId)  && !string.IsNullOrWhiteSpace(taskId) && costTime>0)
+                    {
+                        var result = new EvaluationMusicAIResult()
+                        {
+                            taskId = taskId,
+                            questionId = questionId,
+                            costTime = costTime,
+                            finished = finished,
+                            submitTime = now,
+                            questionName=!string.IsNullOrWhiteSpace(evaluationClient?.music?.questionName) ? evaluationClient.music.questionName : null,
+                            evaluationId=evaluationId,
+                            createTime=now,
+                            pushed=0//强制重新推送
+                        };
+                        studentResult.musicAIResult= result;
+                        _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationMusicAIResult>().Upsert(result);
+                        _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationStudentResult>().Upsert(studentResult);
+                        return Ok(new { code = 200, studentResult = studentResult, msg = "提交成功!" });
+                    }
+                    else
+                    {
+                        return Ok(new { msg = "提交失败,请检查参数。", code = 3 });
+                    }
+                }
+                else
+                {
+                    return Ok(new { msg = "未找到该学生的作答信息。", code = 4 });
+                }
+            }
+            else { 
+                return Ok(new { msg = "未匹配到正则开考的评测。", code = 5 });
+            }
+          
+        }
         /// <summary>
         ///  学生提交科目作答
         /// </summary>
@@ -48,7 +132,7 @@ namespace IES.ExamServer.Controllers
             string examId = $"{json["examId"]}";
             string subjectId = $"{json["subjectId"]}";
             string paperId = $"{json["paperId"]}";
-            int costTime = int.Parse($"{json["costTime"]}");
+            long costTime = int.Parse($"{json["costTime"]}");
             string settingId = $"{json["settingId"]}";
             var token = GetAuthTokenInfo();
             EvaluationRoundSetting? setting = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationRoundSetting>().FindOne(x => x.id!.Equals(settingId) && evaluationId.Equals(x.evaluationId) && x.activate==1);
@@ -81,11 +165,12 @@ namespace IES.ExamServer.Controllers
 
                     }
                     deadline+= 10*60*1000;//漂移10分钟,允许学生延迟提交,但是前端页面显示的截止时间是准的,时间一到,可自动提交。
-                    if ((deadline>0&&deadline<now)|| evaluationClient.etime<now)
-                    {
-                        //已过截止时间
-                        return Ok(new { msg = "已过截止时间。", code = 2 });
-                    }
+                    //已过截止时间
+                    //if ((deadline>0&&deadline<now)|| evaluationClient.etime<now)
+                    //{
+                       
+                    //    return Ok(new { msg = "已过截止时间。", code = 2 });
+                    //}
                     if (!string.IsNullOrWhiteSpace(subjectId)  && !string.IsNullOrWhiteSpace(examId) && !string.IsNullOrWhiteSpace(paperId)&& costTime>0)
                     {
                        
@@ -226,7 +311,7 @@ namespace IES.ExamServer.Controllers
                         {
                             if (evaluationId.Equals(member.evaluationId))
                             {
-                                string x_auth_token = JwtAuthExtension.CreateAuthToken("www.teammodel.cn", studentId, studentName, picture: string.Empty, ExamConstant.JwtSecretKey, ExamConstant.ScopeStudent, 8, schoolID: school?.id, new string[] { "student" }, expire: 1);
+                                string x_auth_token = JwtAuthExtension.CreateAuthToken("www.teammodel.cn", studentId, studentName, picture: string.Empty, ExamConstant.JwtSecretKey, ExamConstant.ScopeStudent, 8, schoolID: school?.id, new string[] { "student" },expire: 1, year: member.year);
                                 return Ok(new { code = 200, x_auth_token = x_auth_token });
                             }
                             else

+ 2 - 1
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Helpers/JwtAuthExtension.cs

@@ -46,6 +46,8 @@ namespace IES.ExamServer
                 { "roles",roles}, // 登入者的角色,角色類型 (Admin、Teacher、Student) 
                 { "scope",scope},  //登入者的入口类型。 (teacher 教师端登录的醍摩豆ID、tmduser学生端登录的醍摩豆ID、student学生端登录校内账号的学生ID)
                 { "timezone",timezone},
+                { "website","IES"},
+                { "year",year},
                 { JwtRegisteredClaimNames.Jti,Guid.NewGuid().ToString()}
             };
             // 建立一組對稱式加密的金鑰,主要用於 JWT 簽章之用
@@ -60,7 +62,6 @@ namespace IES.ExamServer
             var tokenHandler = new JwtSecurityTokenHandler();
             //var securityToken = tokenHandler.CreateToken(tokenDescriptor);
             var serializeToken = tokenHandler.WriteToken(secToken);
-
             return serializeToken;
         }
     }

+ 6 - 0
TEAMModelOS.Extension/IES.Exam/IES.ExamServer/Models/EvaluationStudent.cs

@@ -42,6 +42,7 @@
         /// 开考轮次的id
         /// </summary>
         public string? roundId { get; set; }
+        public int year { get; set; }
     }
     public class EvaluationGroupList
     {
@@ -69,6 +70,7 @@
         ///教学班teach ,行政班(学生搜寻classId动态返回)class 
         /// </summary>
         public string type { get; set; } = "class";
+        public int year { get; set; }
         /// <summary>
         /// 成员
         /// </summary>
@@ -232,6 +234,10 @@
     /// </summary>
     public class EvaluationMusicAIResult :  EvaluationResult
     {
+        /// <summary>
+        /// 作答id
+        /// </summary>
+       public string? id { get; set; }
         /// <summary>
         /// quota_22 的acId  
         /// </summary>

+ 1 - 0
TEAMModelOS.Function/IESServiceBusTrigger.cs

@@ -1644,6 +1644,7 @@ namespace TEAMModelOS.Function
                                             lessonRecord.clientInteractionAverge = lessonBase.summary.clientInteractionAverge;
                                             lessonRecord.examCount = lessonBase.summary.examCount;
                                             lessonRecord.totalInteractPoint = lessonBase.summary.totalInteractPoint;
+                                            lessonRecord.engagementIndexAverge= lessonBase.summary.engagementIndexAverge;
                                             lessonRecord.learningCategory = lessonBase.summary.learningCategory;
                                             if (lessonRecord.learningCategory == null)
                                             {

+ 5 - 1
TEAMModelOS.SDK/Models/Cosmos/Common/LessonRecord.cs

@@ -193,6 +193,10 @@ namespace TEAMModelOS.SDK.Models
         /// 学生互动率
         /// </summary>
         public double clientInteractionAverge { get; set; } = 0;
+        /// <summary>
+        /// 全班参与度
+        /// </summary>
+        public int engagementIndexAverge { get; set; }
 
         public int examCount { get; set; }
         /// <summary>
@@ -928,7 +932,7 @@ namespace TEAMModelOS.SDK.Models
         /// <summary>
         /// 时间点
         /// </summary>
-        //  public double Time{ get; set; }
+          public double Time{ get; set; }
         /// <summary>
         /// 事件ID
         /// </summary>