Jelajahi Sumber

Merge branch 'develop' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into develop

jeff 9 bulan lalu
induk
melakukan
8475cf80e8

+ 9 - 0
TEAMModelOS.Extension/HTEX.ScreenClient/Program.cs

@@ -15,6 +15,15 @@ namespace HTEX.ScreenClient
         {
            
             var builder = WebApplication.CreateBuilder(args);
+            //防止编译后的appsettings.json 文件内容,在重新部署的时候,因为不同的环境导致被覆盖的问题,
+            //所以在正式环境中指定appsettings-prod.json一个本地开发环境不存在的文件,以达到不会被覆盖的问题,
+            //即使在生产环境中未配置appsettings-prod.json 也不影响启动,因为会按照appsettings.json的配置启动
+#if !DEBUG
+            builder.Host.ConfigureAppConfiguration((context, config) => {
+                 config.SetBasePath(Directory.GetCurrentDirectory());
+                 config.AddJsonFile("appsettings-prod.json", optional: true, reloadOnChange: true);
+             });
+#endif
             builder.WebHost.UseKestrel(options =>
             {
                 // options.ListenAnyIP(CheckOrNewPort(1883), options => {/*options.UseHttps("Crt/iteden.pfx", "iteden");*/ });

+ 72 - 3
TEAMModelOS.SDK/Models/Cosmos/Common/LessonRecord.cs

@@ -1,4 +1,5 @@
-using System;
+using Google.Protobuf.Collections;
+using System;
 using System.Collections.Generic;
 using System.Text;
 using System.Text.Json;
@@ -288,7 +289,13 @@ namespace TEAMModelOS.SDK.Models
         /// 差異化學習
         /// </summary>
         public int diffential { get; set; } = 0;
+        /// <summary>
+        /// 只會有 1跟0,有進行1個以上的智慧評分活動就是1,反之是0
+        /// </summary>
         public int smartRating { get; set; } = 0;
+        /// <summary>
+        /// 只會有 1跟0,有進行1個以上的協作活動就是1,反之是0
+        /// </summary>
         public int cowork { get; set; }
      
 
@@ -445,17 +452,71 @@ namespace TEAMModelOS.SDK.Models
         /// 互动分类
         /// </summary>
         public LearningCategory learningCategory { get; set; }
+        /// <summary>
+        /// 差異化推送總數
+        /// </summary>
         public int diffPushCount { get; set; }
+        /// <summary>
+        /// 挑人總數
+        /// </summary>
         public int pickOutCount { get; set;}
+        /// <summary>
+        /// 搶權總數
+        /// </summary>
         public int buzzInCount { get; set; }
+        /// <summary>
+        /// 智慧評分活動數
+        /// </summary>
         public int smartRatingCount { get; set;}
+        /// <summary>
+        /// 智慧評分活動參與人數
+        /// </summary>
         public int clientSmartRatingCount { get; set;}
+        /// <summary>
+        /// 协作任务数
+        /// </summary>
         public int coworkTaskCount { get; set;}
+        /// <summary>
+        /// 协作成果数
+        /// </summary>
         public int coworkGroupCount { get; set;}
+        /// <summary>
+        /// 全班参与度
+        /// </summary>
         public int engagementIndexAverge { get; set;}
+        /// <summary>
+        /// 分組平均參與率
+        /// </summary>
         public List<double> grpEngagement { get; set; } = new List<double>();
 
-        ///暂未解析的字段  highRankPerPoint  highRankGrpPoint  highRankExam lowRankExam  highRankEngagement  lowRankEngagement  engagmentDistribution
+        /// <summary>
+        /// 個人計分排名
+        /// </summary>
+        public List<string> highRankPerPoint { get; set;}= new List<string>();
+        /// <summary>
+        /// 小組計分排名
+        /// </summary>
+        public List<string> highRankGrpPoint { get; set; } = new List<string>();
+        /// <summary>
+        /// 測驗表現較好者排名
+        /// </summary>
+        public List<string> highRankExam { get; set; } = new List<string>();
+        /// <summary>
+        /// 測驗表現較弱者排名
+        /// </summary>
+        public List<string> lowRankExam { get; set; } = new List<string>();
+        /// <summary>
+        /// 參與率較高者
+        /// </summary>
+        public List<string> highRankEngagement { get; set; } = new List<string>();
+        /// <summary>
+        /// 參與率較低者
+        /// </summary>
+        public List<string> lowRankEngagement { get; set; } = new List<string>();
+        /// <summary>
+        /// 參與率分布圖數據(HT畫圖表用)
+        /// </summary>
+        public List<string> engagmentDistribution { get; set; } = new List<string>();
     }
 
     public class QuizSummaryList
@@ -503,9 +564,17 @@ namespace TEAMModelOS.SDK.Models
 
         public string name { get; set; }//學生姓名
 
-
+        /// <summary>
+        /// 學生個人智慧評分參與度
+        /// </summary>
         public double smartRatingContribute { get; set; }
+        /// <summary>
+        /// 學生個人協作參與度
+        /// </summary>
         public double coworkContribute { get; set; }
+        /// <summary>
+        /// 學生個人總參與度
+        /// </summary>
         public double engagementIndex { get; set; }
     }
 

+ 11 - 1
TEAMModelOS.SDK/Models/Service/GenPDFService.cs

@@ -519,7 +519,17 @@ namespace TEAMModelOS.SDK
             }
             return (null, null, null);
         }
-
+        /// <summary>
+        /// 生成PDF导出模板的数据文件。
+        /// </summary>
+        /// <param name="_azureRedis"></param>
+        /// <param name="_configuration"></param>
+        /// <param name="_artId"></param>
+        /// <param name="art"></param>
+        /// <param name="studentPdfs"></param>
+        /// <param name="_httpClient"></param>
+        /// <param name="dingDing"></param>
+        /// <returns></returns>
         public static async Task PushScreenTask(AzureRedisFactory _azureRedis, IConfiguration _configuration, string _artId, 
             ArtEvaluation art, List<ArtStudentPdf> studentPdfs,IHttpClientFactory _httpClient,DingDing dingDing)
         {

+ 102 - 0
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -41,6 +41,11 @@ using ClouDASLibx;
 using Azure.Storage.Blobs.Models;
 using System.IO;
 using TEAMModelOS.SDK.Helper.Common.StringHelper;
+using Microsoft.AspNetCore.SignalR;
+using static SKIT.FlurlHttpClient.Wechat.TenpayV3.Models.CreateApplyForSubjectApplymentRequest.Types;
+using TEAMModelOS.Controllers.Analysis;
+using DocumentFormat.OpenXml.Office2010.Excel;
+using DocumentFormat.OpenXml.Wordprocessing;
 
 
 namespace TEAMModelOS.Controllers
@@ -369,6 +374,103 @@ namespace TEAMModelOS.Controllers
 
             }
         }
+
+        [ProducesDefaultResponseType]
+        [AuthToken(Roles = "teacher,admin")]
+        [HttpPost("get-exam-point")]
+        [Authorize(Roles = "IES")]
+        public async Task<IActionResult> getExamPoint(JsonElement request)
+        {
+            try
+            {
+                if (!request.TryGetProperty("classIds", out JsonElement classId)) return BadRequest();
+                if (!request.TryGetProperty("school", out JsonElement code)) return BadRequest();
+                if (!request.TryGetProperty("startTime", out JsonElement startTime)) return BadRequest();
+                if (!request.TryGetProperty("endTime", out JsonElement endTime)) return BadRequest();
+                if (!request.TryGetProperty("periodId", out JsonElement periodId)) return BadRequest();              
+                var client = _azureCosmos.GetCosmosClient();
+                List<string> ids = new List<string>();
+                List<string> clds = classId.ToObject<List<string>>().ToList();
+                var queryExam = $"select c.id from c where c.period.id = '{periodId}' and array_contains(c.classes,'{clds[0]}') " +
+                    $"and c.qamode <> 2 and c.progress = 'finish' and c.scope = 'school' and c.startTime > {startTime} and c.startTime < {endTime} ";
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIteratorSql(queryText: queryExam, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{code}") }))
+                {
+                    using var json = await JsonDocument.ParseAsync(item.Content);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                    {
+                        var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
+                        while (accounts.MoveNext())
+                        {
+                            JsonElement account = accounts.Current;
+                            ids.Add(account.GetProperty("id").GetString());
+                        }
+                    }
+                }
+                var queryClass = $"select value(c) from c where c.info.id = '{clds[0]}'and c.examId in ({string.Join(",", ids.Select(o => $"'{o}'"))})";
+                List<ExamClassResult> classResults = new();
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIteratorSql<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
+                {
+                    classResults.Add(item);
+                }
+
+                //计算几次合并
+               
+                var examScore = classResults.GroupBy(c => c.subjectId).Select(x => new
+                {
+                    x.Key,
+                    cc = x.ToList().Count,
+                    students = x.ToList().SelectMany(z => z.studentIds).Distinct().ToList(),
+                    score = x.ToList().Select(k => k.sum).Aggregate((current, next) => current.Zip(next, (a, b) => a + b).ToList())
+                }) ;
+
+                List<(string sub, List<(string id, double score)> subScore,int cc)> stuScore = [];
+                foreach (var ss in examScore) {
+                    List<(string id, double score)> subScore = [];
+                    foreach (var item in ss.students) {
+                        int index = ss.students.IndexOf(item);
+                        subScore.Add((item, ss.score[index]));
+                    }
+                    stuScore.Add((ss.Key, subScore,ss.cc));
+
+                }
+                if (request.TryGetProperty("studentId", out JsonElement studentId) && !string.IsNullOrWhiteSpace($"{studentId}"))
+                {
+                    var orderScore = stuScore.Select(x => new
+                    {
+                        x.sub,
+                        classRate = x.subScore.Select(z => z.score).Sum() / x.subScore.Count,
+                        rank = x.subScore.OrderByDescending(x => x.score).Select(z => z.id).ToList().IndexOf(studentId.GetString()) + 1,
+                        stuRate = x.subScore.OrderByDescending(x => x.score).Select(z => new
+                        {
+                            z.id,
+                            per = z.score / x.cc
+                        }).ToList().Take(10)
+                    }) ;
+                    return Ok(new { orderScore, code = 200 });
+                }
+                else {
+                    var orderScore = stuScore.Select(x => new
+                    {
+                        x.sub,
+                        classRate = x.subScore.Select(z => z.score).Sum() / x.subScore.Count,
+                        stuRate = x.subScore.OrderByDescending(x => x.score).Select(z => new
+                        {
+                            z.id,
+                            per = z.score / x.cc
+                        }).ToList().Take(10)
+                    });
+                    return Ok(new { orderScore, code = 200 });
+                }
+                            
+
+            }
+            catch (Exception e)
+            {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/get-exam-point()\n{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+
+            }
+        }
         //TODO blob 批量删除
         /// <summary>
         /// 删除

+ 3 - 2
TEAMModelOS/Controllers/Student/OverallEducationController.cs

@@ -98,7 +98,8 @@ namespace TEAMModelOS.Controllers
 #endif
         public async Task<IActionResult> Overview(JsonElement json)
         {
-            try {
+            try
+            {
                 json.TryGetProperty("studentYear", out JsonElement _studentYear);
                 json.TryGetProperty("grades", out JsonElement _grades);
                 json.TryGetProperty("school", out JsonElement _school);
@@ -764,7 +765,7 @@ namespace TEAMModelOS.Controllers
             }
             catch (Exception ex)
             {
-              await  _dingDing.SendBotMsg($"{ex.Message}\n{ex.StackTrace}",GroupNames.成都开发測試群組);
+              await  _dingDing.SendBotMsg($"{_option.Location},{ex.Message}\n{ex.StackTrace},{json.ToJsonString()}",GroupNames.成都开发測試群組);
 
             }
             return Ok();