CrazyIter_Bin 1 ano atrás
pai
commit
c7ec5842d9

+ 3 - 3
TEAMModelBI/TEAMModelBI.csproj

@@ -65,9 +65,9 @@
 		<SpaRoot>ClientApp\</SpaRoot>
 		<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
 		<UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
-		<Version>5.2404.17</Version>
-		<AssemblyVersion>5.2404.17.1</AssemblyVersion>
-		<FileVersion>5.2404.17.1</FileVersion>
+		<Version>5.2404.24</Version>
+		<AssemblyVersion>5.2404.24.1</AssemblyVersion>
+		<FileVersion>5.2404.24.1</FileVersion>
 		<Description>TEAMModelBI(BI)</Description>
 		<PackageReleaseNotes>BI版本说明版本切换标记2022000908</PackageReleaseNotes>
 		<PackageId>TEAMModelBI</PackageId>

+ 3 - 3
TEAMModelOS.FunctionV4/TEAMModelOS.FunctionV4.csproj

@@ -5,9 +5,9 @@
 		<OutputType>Exe</OutputType>
 		<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
 		<SignAssembly>true</SignAssembly>
-		<Version>5.2404.17</Version>
-		<AssemblyVersion>5.2404.17.1</AssemblyVersion>
-		<FileVersion>5.2404.17.1</FileVersion>
+		<Version>5.2404.24</Version>
+		<AssemblyVersion>5.2404.24.1</AssemblyVersion>
+		<FileVersion>5.2404.24.1</FileVersion>
 		<PackageId>TEAMModelOS.FunctionV4</PackageId>
 		<Authors>teammodel</Authors>
 		<Company>醍摩豆(成都)信息技术有限公司</Company>

+ 19 - 0
TEAMModelOS.SDK/Extension/HttpContextExtensions.cs

@@ -206,6 +206,25 @@ namespace TEAMModelOS.SDK.Extension
             }
         }
         /// <summary>
+        /// 取得X-Auth-Key值
+        /// </summary>        
+        /// <param name="key">Key Name</param>
+        /// <returns></returns>
+        public static string GetAuthorization(this HttpContext httpContext)
+        {
+            try
+            {
+                if (httpContext.Request.Headers.TryGetValue("Authorization", out StringValues value))
+                    return value.ToString();
+                else
+                    return null;
+            }
+            catch
+            {
+                return null;
+            }
+        }
+        /// <summary>
         /// 取得AuthToken權杖資訊
         /// </summary>        
         /// <param name="key">Key Name</param>

+ 2 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/ItemInfo.cs

@@ -36,5 +36,7 @@ namespace TEAMModelOS.SDK.Models
         public string subject { get; set; }
         public string gradeName { get; set;}
         public string grade { get; set; }
+        public string description {  get; set; }
+        public new List<MoofenItemInfo> children { get; set; }=new List<MoofenItemInfo>();
     }
 }

+ 3 - 3
TEAMModelOS.SDK/TEAMModelOS.SDK.csproj

@@ -2,9 +2,9 @@
 
 	<PropertyGroup>
 		<TargetFramework>net6.0</TargetFramework>
-		<Version>5.2404.17</Version>
-		<AssemblyVersion>5.2404.17.1</AssemblyVersion>
-		<FileVersion>5.2404.17.1</FileVersion>
+		<Version>5.2404.24</Version>
+		<AssemblyVersion>5.2404.24.1</AssemblyVersion>
+		<FileVersion>5.2404.24.1</FileVersion>
 		<PackageReleaseNotes>发版</PackageReleaseNotes>
 	</PropertyGroup>
 

+ 97 - 10
TEAMModelOS/Controllers/Third/Moofen/MoofenController.cs

@@ -24,6 +24,8 @@ using System.Net.Http.Headers;
 using HTEXLib.COMM.Helpers;
 using TEAMModelOS.SDK.DI;
 using HTEXLib.Helpers.ShapeHelpers;
+using HtmlAgilityPack;
+using Top.Api.Util;
 namespace TEAMModelOS.Controllers.Third.Moofen
 {
     [ProducesResponseType(StatusCodes.Status200OK)]
@@ -44,10 +46,8 @@ namespace TEAMModelOS.Controllers.Third.Moofen
         }
 
         [HttpPost("moofen/question")]
-#if !DEBUG
-        [AuthToken(Roles = "teacher,admin")]
-        [Authorize(Roles = "IES")]
-#endif
+        //[AuthToken(Roles = "teacher,admin")]
+        //[Authorize(Roles = "IES")]
         public async Task<IActionResult> Question(JsonElement json) 
         {
             try {
@@ -121,13 +121,71 @@ namespace TEAMModelOS.Controllers.Third.Moofen
                     string content = await response.Content.ReadAsStringAsync();
 
                     var data = content.ToObject<JsonElement>();
-                    if (data.TryGetProperty("data", out JsonElement _data)  && _data.TryGetProperty("data", out JsonElement __data))
+                    int count = 0;
+                    if (data.TryGetProperty("data", out JsonElement _data) )
                     {
-                        List<MoofenQuestion> questions = __data.ToObject<List<MoofenQuestion>>();
+                        if (_data.TryGetProperty("total", out JsonElement _total)  && int.TryParse($"{_total}", out count))
+                        if ( _data.TryGetProperty("data", out JsonElement __data))
+                        {
+                            List<MoofenQuestion> questions = __data.ToObject<List<MoofenQuestion>>();
+                            items= MoofenQS(questions, $"{subject}", pquestion: null);
+                            //foreach (var item in items) 
+                            //{
+                            //    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
+                            //    var contentAI = new StringContent(JsonSerializer.Serialize(new
+                            //    {
+                            //        appId = "5ac43c20-221e-4564-829d-15680ad761df",
+                            //        sessionId = "",
+                            //        text = item.description,
+                            //    }), Encoding.UTF8, "application/json");
+                            //    var httpreq = new HttpRequestMessage(HttpMethod.Post, url) { Content = contentAI };
+                            //    var authtoken = HttpContext.GetXAuth("AuthToken");
+                            //    if (!httpClient.DefaultRequestHeaders.Contains("X-Auth-Authtoken"))
+                            //    {
+                            //        httpClient.DefaultRequestHeaders.Add("X-Auth-Authtoken", authtoken);
+                            //    }
+                            //    var AuthorizationToken = HttpContext.GetAuthorization();
+                            //    if (httpClient.DefaultRequestHeaders.Contains("Authorization"))
+                            //    {
+                            //        httpClient.DefaultRequestHeaders.Remove("Authorization");
+                            //    }
+                            //    httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {AuthorizationToken}");
+                            //    httpClient.DefaultRequestHeaders.AcceptCharset.Add(new StringWithQualityHeaderValue("utf-8"));
+                            //    var responseAI = await httpClient.SendAsync(httpreq, HttpCompletionOption.ResponseHeadersRead);
+                            //    StringBuilder dataAI = new StringBuilder();
+                            //    // 读取响应内容的异步流
+                            //    using (var responseStream = await response.Content.ReadAsStreamAsync())
+                            //    {
+                            //        //Debug.Print("============start response use minseconds=" + (DateTime.Now - d).TotalMilliseconds + "  =================\r\n");
+                            //        // 逐块读取并处理响应内容
+                            //        var buffer = new byte[1024];
+                            //        int bytesRead;
+                            //        while ((bytesRead = await responseStream.ReadAsync(buffer, 0, buffer.Length)) > 0)
+                            //        {
+                            //            // 处理响应内容
+                            //            string contentData = System.Text.Encoding.UTF8.GetString(buffer, 0, bytesRead);
+
+
+                            //            if (contentData.Contains("data:"))
+                            //            {
+                            //                contentData = contentData.Replace("data:", "").Replace("[DONE]", "");
 
-                        items= MoofenQS(questions,$"{subject}");
+                            //            }
+                            //            if (contentData.Contains("[DONE]"))
+                            //            {
+                            //                contentData = contentData.Replace("data:", "").Replace("[DONE]", "");
+
+                            //            }
+                            //            dataAI.Append(contentData);
+                            //        }
+                            //    }
+                            //    item.explain=dataAI.ToString(); 
+                            //}
+
+                        }
                     }
-                    return Ok(new { code = 200, data, items });
+                   
+                    return Ok(new { code = 200, data, items , count });
                 }
                 else
                 {
@@ -140,7 +198,7 @@ namespace TEAMModelOS.Controllers.Third.Moofen
                 return Ok(new { code = 500,msg=$"{ex.Message}" });
             }
         }
-        private List<MoofenItemInfo> MoofenQS(List<MoofenQuestion> questions, string subject, string pid = null)
+        private List<MoofenItemInfo> MoofenQS(List<MoofenQuestion> questions, string subject,string pquestion, string pid = null)
         {
             List<MoofenItemInfo> items = new List<MoofenItemInfo>();
 
@@ -152,6 +210,7 @@ namespace TEAMModelOS.Controllers.Third.Moofen
                     foreach (MoofenQuestion question in questions) { 
                         question.questionCode= $"{pid}_{index}";
                         index++;
+
                     }
                 }
                 Parallel.ForEach(questions, x => {
@@ -169,6 +228,10 @@ namespace TEAMModelOS.Controllers.Third.Moofen
                         pid=pid
 
                     };
+                    StringBuilder description = new StringBuilder($"科目:{subject}") ;
+                    if (!string.IsNullOrWhiteSpace(pquestion)) {
+                        description.AppendLine($"综合题:{pquestion}");
+                    }
                     //处理年级转换
                     if (!string.IsNullOrWhiteSpace(x.scope?.grade?.code) ) {
                         item.gradeIds= new List<string>() { x.scope?.grade?.code };
@@ -195,6 +258,7 @@ namespace TEAMModelOS.Controllers.Third.Moofen
                                     item.opts=x.options.Count();
                                 }
                                 item.field=1;
+                                description.AppendLine("题型:选择题");
                                 break;
                             //填空
                             case "F":
@@ -206,6 +270,7 @@ namespace TEAMModelOS.Controllers.Third.Moofen
                                 }
                                 item.type="complete";
                                 item.field=2;
+                                description.AppendLine("题型:填空题");
                                 break;
                             //问答
                             case "Q":
@@ -214,6 +279,7 @@ namespace TEAMModelOS.Controllers.Third.Moofen
                                     item.answer=new List<string>() { x.content };
                                 }
                                 item.type="subjective";
+                                description.AppendLine("题型:问答题");
                                 item.field=4;
                                 break;
                             //写作
@@ -223,15 +289,18 @@ namespace TEAMModelOS.Controllers.Third.Moofen
                                     item.answer=new List<string>() { x.content };
                                 }
                                 item.type="subjective";
+                                description.AppendLine("题型:写作题");
                                 item.field=6;
                                 break;
                             //综合
                             case "S":
                                 item.type="compose";
+
                                 item.field=3;
                                 if (x.questions.IsNotEmpty() && x.questions.Count>0) {
-                                   item.children.AddRange(MoofenQS(x.questions, subject,item.id));
+                                   item.children.AddRange(MoofenQS(x.questions,subject: subject,pquestion: item.question,pid: item.id));
                                 }
+                                description.AppendLine("题型:综合题");
                                 break;
                         }
                     }
@@ -256,6 +325,24 @@ namespace TEAMModelOS.Controllers.Third.Moofen
                         }
                     }
                     string unhtml = HtmlHelper.DoUselessTag(sb.ToString());
+                    description.AppendLine($"题干:{item.question}");
+                    if (item.option.IsNotEmpty()) 
+                    {
+                        description.AppendLine($"选项:");
+                        foreach (var option in item.option) { 
+                            description.AppendLine($"{option.code}:{option.value}");
+                        }
+                    }
+                    if(item.answer.IsNotEmpty()) 
+                    {
+                        description.AppendLine($"答案:{string.Join(",",item.answer)}");
+                    }
+                    if (item.knowledge.IsNotEmpty()) {
+                        description.AppendLine($"知识点:{string.Join(",", item.knowledge)}");
+                    }
+                    HtmlDocument doc = new HtmlDocument();
+                    doc.LoadHtml(description.ToString());
+                    item.description = doc.DocumentNode.InnerText;
                     item.shaCode= ShaHashHelper.GetSHA1(unhtml);
                     items.Add(item);
                 });

+ 1 - 1
TEAMModelOS/Filter/RequestAuditFilter.cs

@@ -201,7 +201,7 @@ namespace TEAMModelOS.Filter
 
                 }
                 else {
-                    if ($"{httpRequest.Path}".Contains("image-quant", StringComparison.OrdinalIgnoreCase))
+                    if ($"{httpRequest.Path}".Contains("image-quant", StringComparison.OrdinalIgnoreCase)||$"{httpRequest.Path}".Contains("parse-html", StringComparison.OrdinalIgnoreCase))
                     {
                         parameters=_param;
                     }

+ 4 - 4
TEAMModelOS/TEAMModelOS.csproj

@@ -79,11 +79,11 @@
 		<SpaRoot>ClientApp\</SpaRoot>
 		<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
 		<UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
-		<Version>5.2404.17</Version>
-		<AssemblyVersion>5.2404.17.1</AssemblyVersion>
-		<FileVersion>5.2404.17.1</FileVersion>
+		<Version>5.2404.24</Version>
+		<AssemblyVersion>5.2404.24.1</AssemblyVersion>
+		<FileVersion>5.2404.24.1</FileVersion>
 		<Description>TEAMModelOS(IES5)</Description>
-		<PackageReleaseNotes>IES版本说明版本切换标记5.2404.17.1</PackageReleaseNotes>
+		<PackageReleaseNotes>IES版本说明版本切换标记5.2404.24.1</PackageReleaseNotes>
 		<PackageId>TEAMModelOS</PackageId>
 		<Authors>teammodel</Authors>
 		<Company>醍摩豆(成都)信息技术有限公司</Company>

+ 1 - 1
TEAMModelOS/appsettings.Development.json

@@ -18,7 +18,7 @@
     "IdTokenSalt": "8263692E2213497BB55E74792B7900B4",
     "HttpTrigger": "https://teammodelosfunction-test.chinacloudsites.cn/api/",
     //"HttpTrigger": "http://localhost:7071/api/"
-    "Version": "5.2404.17.1"
+    "Version": "5.2404.24.1"
   },
   "Azure": {
 

+ 1 - 1
TEAMModelOS/appsettings.json

@@ -18,7 +18,7 @@
     "Exp": 86400,
     "IdTokenSalt": "8263692E2213497BB55E74792B7900B4",
     "HttpTrigger": "https://teammodelosfunction.chinacloudsites.cn/api/",
-    "Version": "5.2404.17.1"
+    "Version": "5.2404.24.1"
   },
   "Azure": {
     "Storage": {