ThirdService.cs 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  1. using Azure.Cosmos;
  2. using Azure.Storage.Blobs.Models;
  3. using DocumentFormat.OpenXml.Drawing.Charts;
  4. using DocumentFormat.OpenXml.Office2010.Excel;
  5. using HTEXLib.COMM.Helpers;
  6. using Microsoft.Extensions.Configuration;
  7. using Microsoft.OData.Edm;
  8. using Newtonsoft.Json;
  9. using OpenXmlPowerTools;
  10. using OpenXmlPowerTools.HtmlToWml.CSS;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Net;
  16. using System.Net.Http;
  17. using System.Net.Http.Headers;
  18. using System.Text;
  19. using System.Text.Json;
  20. using System.Threading.Tasks;
  21. using TEAMModelOS.Models;
  22. using TEAMModelOS.SDK.DI;
  23. using TEAMModelOS.SDK.Extension;
  24. using TEAMModelOS.SDK.Models.Cosmos;
  25. using TEAMModelOS.SDK.Models.Cosmos.Student;
  26. using static TEAMModelOS.SDK.Models.Teacher;
  27. namespace TEAMModelOS.SDK.Models
  28. {
  29. public static class ThirdService
  30. {
  31. //自动加入学校,加入培训名单,并根据学科进行分组
  32. public static async Task<ScTeacher> GetScTeacher(ScBindData scBind, Teacher teacher, AzureStorageFactory _azureStorage, AzureCosmosFactory _azureCosmos, AzureServiceBusFactory _serviceBus, IConfiguration _configuration, DingDing _dingDing)
  33. {
  34. var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
  35. List<ScSchool> schools = await table.FindListByDict<ScSchool>(new Dictionary<string, object> { { "PartitionKey", "ScSchool" }, { "RowKey", scBind.sid } });
  36. List<ScTeacher> scTeachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object> { { "PartitionKey", "ScTeacher" }, { "TID", scBind.userid }, { "RowKey", $"{scBind.pxid}" } });
  37. if (schools.IsNotEmpty())
  38. {
  39. ScSchool scSchool = schools[0];
  40. if (!string.IsNullOrEmpty(scSchool.schoolCode))
  41. {
  42. try
  43. {
  44. School school = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(scSchool.schoolCode, new PartitionKey("Base"));
  45. if (school != null)
  46. {
  47. if (scTeachers.IsNotEmpty())
  48. {
  49. if (string.IsNullOrEmpty(scTeachers[0].tmdid))
  50. {
  51. scTeachers[0].tmdid = teacher.id;
  52. scTeachers[0].schoolCode = scSchool.schoolCode;
  53. scTeachers[0].areaId = school.areaId;
  54. await table.SaveOrUpdate<ScTeacher>(scTeachers[0]);
  55. }
  56. }
  57. var sc = teacher.schools.Find(x => x.schoolId.Equals(scSchool.schoolCode));
  58. if (sc != null)
  59. {
  60. if (string.IsNullOrEmpty(sc.status) || !sc.status.Equals("join"))
  61. {
  62. sc.status = "join";
  63. try
  64. {
  65. SchoolTeacher schoolTeacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SchoolTeacher>(teacher.id, new PartitionKey($"Teacher-{school.id}"));
  66. if (schoolTeacher != null)
  67. {
  68. if (!schoolTeacher.roles.IsEmpty())
  69. {
  70. if (!schoolTeacher.roles.Contains("teacher"))
  71. {
  72. schoolTeacher.roles.Add("teacher");
  73. }
  74. }
  75. else
  76. {
  77. schoolTeacher.roles = new List<string> { "teacher" };
  78. }
  79. schoolTeacher.status = "join";
  80. schoolTeacher.pk = "Teacher";
  81. schoolTeacher.name = teacher.name;
  82. schoolTeacher.picture = teacher.picture;
  83. schoolTeacher.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
  84. schoolTeacher.ttl = -1;
  85. schoolTeacher.permissions = schoolTeacher.permissions.IsNotEmpty() ? schoolTeacher.permissions : new List<string>();
  86. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(schoolTeacher, new PartitionKey(schoolTeacher.code));
  87. }
  88. }
  89. catch (CosmosException)
  90. {
  91. SchoolTeacher schoolTeacher = new SchoolTeacher
  92. {
  93. id = teacher.id,
  94. code = $"Teacher-{school.id}",
  95. roles = new List<string> { "teacher" },
  96. permissions = new List<string>(),
  97. pk = "Teacher",
  98. name = teacher.name,
  99. picture = teacher.picture,
  100. status = "join",
  101. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
  102. ttl = -1
  103. };
  104. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(schoolTeacher, new PartitionKey(schoolTeacher.code));
  105. }
  106. }
  107. }
  108. else
  109. {
  110. teacher.schools.Add(new Teacher.TeacherSchool { schoolId = school.id, name = school.name, areaId = school.areaId, picture = school.picture, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), status = "join" });
  111. SchoolTeacher schoolTeacher = new SchoolTeacher
  112. {
  113. id = teacher.id,
  114. code = $"Teacher-{school.id}",
  115. roles = new List<string> { "teacher" },
  116. permissions = new List<string>(),
  117. pk = "Teacher",
  118. name = teacher.name,
  119. picture = teacher.picture,
  120. status = "join",
  121. createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
  122. };
  123. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(schoolTeacher, new PartitionKey(schoolTeacher.code));
  124. }
  125. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(teacher, teacher.id, new PartitionKey("Base"));
  126. //处理培训名单
  127. StringBuilder queryText = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='yxtrain'");
  128. List<GroupList> yxtrain = new List<GroupList>();
  129. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: queryText.ToString(),
  130. requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{scSchool.schoolCode}") }))
  131. {
  132. yxtrain.Add(item);
  133. }
  134. if (yxtrain.IsNotEmpty())
  135. {
  136. string nickname = teacher.name;
  137. string groupName = null;
  138. string groupId = Guid.NewGuid().ToString();
  139. if (scTeachers.IsNotEmpty())
  140. {
  141. if (scBind.pid.Equals("1249"))
  142. {
  143. groupName = $"第三批教师培训组";
  144. }
  145. nickname = scTeachers[0].TeacherName;
  146. if (!string.IsNullOrEmpty(groupName))
  147. {
  148. var mebers = yxtrain.SelectMany(x => x.members).Where(y => !string.IsNullOrEmpty(y.groupName) && y.groupName.Equals(groupName));
  149. if (mebers != null && mebers.Count() > 0)
  150. {
  151. groupId = mebers.First().groupId;
  152. }
  153. }
  154. else { groupId = null; }
  155. }
  156. else { groupId = null; }
  157. var meber = yxtrain.SelectMany(x => x.members).Where(y => y.id.Equals(teacher.id));
  158. //不在研修名单
  159. if (meber == null || !meber.Any())
  160. {
  161. yxtrain[0].members.Add(new Member { id = teacher.id, type = 1, groupId = groupId, groupName = groupName, nickname = nickname });
  162. await GroupListService.UpsertList(yxtrain[0], _azureCosmos, _configuration, _serviceBus, "web");
  163. }
  164. else
  165. {
  166. if (string.IsNullOrEmpty(meber.First().groupId) || string.IsNullOrEmpty(meber.First().groupName))
  167. {
  168. meber.ToList().ForEach(x => { x.groupId = groupId; x.groupName = groupName; x.nickname = string.IsNullOrWhiteSpace(x.nickname) ? nickname : x.nickname; });
  169. await GroupListService.UpsertList(yxtrain[0], _azureCosmos, _configuration, _serviceBus, "web");
  170. }
  171. }
  172. }
  173. else
  174. {
  175. string nickname = teacher.name;
  176. string groupName = null;
  177. if (scTeachers.IsNotEmpty())
  178. {
  179. groupName = scTeachers[0].TeacherXK;
  180. nickname = scTeachers[0].TeacherName;
  181. }
  182. string groupId = null;
  183. if (!string.IsNullOrEmpty(groupName))
  184. {
  185. groupId = Guid.NewGuid().ToString();
  186. }
  187. GroupList groupList = new()
  188. {
  189. id = Guid.NewGuid().ToString(),
  190. code = $"GroupList-{scSchool.schoolCode}",
  191. creatorId = teacher.id,
  192. type = "yxtrain",
  193. year = DateTimeOffset.UtcNow.Year,
  194. expire = 0,
  195. members = new List<Member> { new Member { id = teacher.id, type = 1, groupId = groupId, groupName = groupName, nickname = nickname } },
  196. scope = "school",
  197. school = scSchool.schoolCode,
  198. name = "研修名单",
  199. pk = "GroupList",
  200. ttl = -1
  201. };
  202. await GroupListService.UpsertList(groupList, _azureCosmos, _configuration, _serviceBus, "web");
  203. }
  204. }
  205. }
  206. catch (Exception ex)
  207. {
  208. await _dingDing.SendBotMsg($"OS\n自动加入学校,加入研修名单出现异常:,{ex.Message}\n{ex.StackTrace}GetScTeacher", GroupNames.醍摩豆服務運維群組);
  209. }
  210. }
  211. }
  212. return null;
  213. }
  214. public static async Task<(string accessConfig, Area area, AreaSetting setting)> GetAccessConfig(CosmosClient client, string standard)
  215. {
  216. Area area = null;
  217. await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").
  218. GetItemQueryIterator<Area>($"select value(c) from c where c.standard='{standard}'", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base-Area") }))
  219. {
  220. area = item;
  221. break;
  222. }
  223. AreaSetting setting = null;
  224. if (area != null)
  225. {
  226. try
  227. {
  228. setting = await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<AreaSetting>(area.id, new PartitionKey("AreaSetting"));
  229. }
  230. catch (CosmosException)
  231. {
  232. setting = null;
  233. }
  234. }
  235. if (setting == null || string.IsNullOrEmpty(setting.accessConfig))
  236. {
  237. return (null, null, null);
  238. }
  239. else
  240. {
  241. return (setting.accessConfig, area, setting);
  242. }
  243. }
  244. public static async Task<List<Ability>> GetDiagnosisList(CosmosClient client, string standard, DingDing _dingDing, AreaSetting setting, HttpClient _httpClient, Teacher teacher, TEAMModelOS.Models.Option _option, AzureStorageFactory _azureStorage)
  245. {
  246. List<string> abilityNos = new();
  247. var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
  248. setting.accessConfig.ToObject<JsonElement>().TryGetProperty("config", out JsonElement _config);
  249. if ($"{_config}".Equals("scsyxpt"))
  250. {
  251. var binds = teacher.binds.FindAll(x => x.type.Equals("scsyxpt"));
  252. var datas = binds.SelectMany(x => x.data).Where(y => y.Contains("scsyxpt"));
  253. HashSet<string> pxids = new();
  254. if (datas != null)
  255. {
  256. datas.ToList().ForEach(x =>
  257. {
  258. var data = x.ToObject<ScBindData>();
  259. if (!string.IsNullOrEmpty(data?.pxid))
  260. {
  261. pxids.Add(data.pxid);
  262. }
  263. });
  264. }
  265. foreach (var pxid in pxids)
  266. {
  267. List<ScTeacher> teachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object> { { "PartitionKey", "ScTeacher" }, { "PXID", pxid } });
  268. Dictionary<string, object> dict = new();
  269. if (teachers.IsNotEmpty())
  270. {
  271. dict = new Dictionary<string, object>() { { "accessConfig", setting.accessConfig }, { "pxid", pxid }, { "areaId", setting.id }, { "schoolCode", teachers[0].schoolCode } };
  272. }
  273. else
  274. {
  275. dict = new Dictionary<string, object>() { { "accessConfig", setting.accessConfig }, { "pxid", pxid }, { "areaId", setting.id } };
  276. }
  277. (int status, string json) = await ScsStudyApisService.GetDiagnosisListByProject_V2(_httpClient, _dingDing, _azureStorage, setting.id, setting.accessConfig, pxid, teachers[0].schoolCode);
  278. //(int status, string json) = await httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetDiagnosisListByProject_V2");
  279. if (status == 200)
  280. {
  281. List<string> nos = json.ToObject<List<string>>();
  282. if (nos.IsNotEmpty())
  283. {
  284. abilityNos.AddRange(nos);
  285. }
  286. }
  287. }
  288. }
  289. //获取能力点
  290. List<Ability> abilities = null;
  291. if (abilityNos.IsNotEmpty())
  292. {
  293. abilities = new List<Ability>();
  294. StringBuilder sql = new StringBuilder($"select value(c) from c where c.no in ({string.Join(",", abilityNos.Select(x => $"'{x}'"))})");
  295. await foreach (var item in client.GetContainer("TEAMModelOS", "Normal")
  296. .GetItemQueryIterator<Ability>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{standard}") }))
  297. {
  298. abilities.Add(item);
  299. }
  300. }
  301. return abilities;
  302. }
  303. //5.3.1.22学员校本教研PDF(每人可以返回多条)批量回写-UploadSBTARPDFListV2
  304. public async static Task<(int t53122OK, List<CodeValue> msgs, List<OfflineRecord> allRightOfflineRecords)> check53122(TeacherTrain teacherTrain, List<CodeValue> msgs, string school,
  305. string schoolPrefix, string sas, AzureStorageFactory _azureStorage)
  306. {
  307. int t53122OK = 1;
  308. if (teacherTrain.offlineRecords.Count <= 0)
  309. {
  310. t53122OK = 0;
  311. msgs.Add(new CodeValue("offlineRecord-count", $"文件个数为0"));
  312. }
  313. List<OfflineRecord> allRightOfflineRecords = new List<OfflineRecord>();
  314. var hasUrl = teacherTrain.offlineRecords.Where(x => !string.IsNullOrWhiteSpace(x.url) && x.size > 0);
  315. if (!hasUrl.Any())
  316. {
  317. t53122OK = 0;
  318. msgs.Add(new CodeValue("offlineRecord-url", $"需要上传的校本研修作业至少有一个。"));
  319. }
  320. if (teacherTrain.offlineReport == null)
  321. {
  322. t53122OK = 0;
  323. msgs.Add(new CodeValue("offlineReport", $"校本研修汇总报告未生成。"));
  324. }
  325. List<string> unexistUrl = new List<string>();
  326. foreach (var url in hasUrl)
  327. {
  328. string blobItem = url.url.Replace($"{schoolPrefix}/", "");
  329. bool Exist = await _azureStorage.GetBlobContainerClient(school).GetBlobClient(blobItem).ExistsAsync();
  330. if (!Exist)
  331. {
  332. unexistUrl.Add($"{url.url}?{sas}");
  333. }
  334. else
  335. {
  336. allRightOfflineRecords.Add(url);
  337. }
  338. }
  339. if (unexistUrl.Any() && hasUrl.Count() > 0 && hasUrl.Count() == unexistUrl.Count)
  340. {
  341. t53122OK = 0;
  342. msgs.Add(new CodeValue("offlineRecord-url-unexist", $"校本研修文件不存在,{string.Join(" , ", unexistUrl)}"));
  343. }
  344. //不需要检查每一个校本研修的文件记录。
  345. //teacherTrain.offlineRecords.ForEach(x => {
  346. // if (string.IsNullOrEmpty(x.url)) {
  347. // msgs.Add(new CodeValue("offlineRecord-url", $"链接为空"));
  348. // }
  349. // if (x.size<=0)
  350. // {
  351. // msgs.Add(new CodeValue("offlineRecord-size", $"文件大小"));
  352. // }
  353. //});
  354. return (t53122OK, msgs, allRightOfflineRecords);
  355. }
  356. //5.3.1.17学员课堂实录批量回写-UploadKTSLList
  357. public async static Task<(int t53117OK, List<CodeValue> msgs)> check53117(TeacherTrain teacherTrain, List<CodeValue> msgs, string school,
  358. string schoolPrefix, string sas, AzureStorageFactory _azureStorage)
  359. {
  360. //校验 基本情况是否满足
  361. int t53117OK = 1;
  362. if (teacherTrain.classTime <= 0)
  363. {
  364. msgs.Add(new CodeValue("classTime", $"未获得学时:{teacherTrain.classTime}"));
  365. t53117OK = 0;
  366. }
  367. if (teacherTrain.teacherClasses.Count() <= 0)
  368. {
  369. msgs.Add(new CodeValue("teacherClasses", $"未上传课堂实录:{teacherTrain.teacherClasses.Count()}个视频"));
  370. t53117OK = 0;
  371. }
  372. teacherTrain.teacherClasses.ForEach(x =>
  373. {
  374. if (string.IsNullOrWhiteSpace(x.url))
  375. {
  376. t53117OK = 0;
  377. msgs.Add(new CodeValue("teacherClasses", $"课堂实录链接无效"));
  378. }
  379. });
  380. List<string> unexistUrl = new List<string>();
  381. foreach (var url in teacherTrain.teacherClasses)
  382. {
  383. string blobItem = url.url.Replace($"{schoolPrefix}/", "");
  384. bool Exist = await _azureStorage.GetBlobContainerClient(school).GetBlobClient(blobItem).ExistsAsync();
  385. if (!Exist)
  386. {
  387. unexistUrl.Add($"{url.url}?{sas}");
  388. }
  389. }
  390. if (unexistUrl.Any())
  391. {
  392. t53117OK = 0;
  393. msgs.Add(new CodeValue("teacherClasses-url-unexist", $"课堂实录文件不存在,{string.Join(" , ", unexistUrl)}"));
  394. }
  395. return (t53117OK, msgs);
  396. }
  397. //5.3.1.12学员培训基本情况批量回写-UpdateTeacherListSituation
  398. public static (int t53112OK, List<CodeValue> msgs) check53112(TeacherTrain teacherTrain, List<CodeValue> msgs)
  399. {
  400. //校验 基本情况是否满足
  401. int t53112OK = 1;
  402. if (teacherTrain.finalScore <= 0)
  403. {
  404. //总体认定结果0、未认定 1、合格 2、优秀 3、不合格 4、其他
  405. msgs.Add(new CodeValue("finalScore", $"最终评定结果参数:{teacherTrain.finalScore}"));
  406. t53112OK = 0;
  407. }
  408. //if (string.IsNullOrEmpty(teacherTrain.summary) || teacherTrain.summary.Length > 300)
  409. //{
  410. // string msg = string.IsNullOrEmpty(teacherTrain.summary) ? "未填写" : teacherTrain.summary.Length > 300 ? "字数超过300." : "";
  411. // msgs.Add(new CodeValue("summary", $"教师培训总结:{msg}"));
  412. // t53112OK = 0;
  413. //}
  414. if (!string.IsNullOrEmpty(teacherTrain.summary) && teacherTrain.summary.Length > 300)
  415. {
  416. //string msg = string.IsNullOrEmpty(teacherTrain.summary) ? "未填写" : teacherTrain.summary.Length > 300 ? "字数超过300." : "";
  417. msgs.Add(new CodeValue("summary", $"教师培训总结:字数超过300."));
  418. t53112OK = 0;
  419. }
  420. if (teacherTrain.totalTime <= 0)
  421. {
  422. msgs.Add(new CodeValue("totalTime", $"未获得学时:{teacherTrain.totalTime}"));
  423. t53112OK = 0;
  424. }
  425. return (t53112OK, msgs);
  426. }
  427. //5.3.1.13学员能力点测评结果批量回写-UpdateTeacherListDiagnosis
  428. public async static Task<(int t53113OK, List<CodeValue> msgs, List<AbilitySub> abilitySubs, List<AbilitySub> allRightAbility)> check53113(AzureCosmosFactory _azureCosmos, TeacherTrain teacherTrain, ScTeacherDiagnosis diagnosis,
  429. List<CodeValue> msgs, string school,
  430. string schoolPrefix, string sas, AzureStorageFactory _azureStorage)
  431. {
  432. //校验 基本情况是否满足
  433. int t53113OK = 1;
  434. List<AbilitySub> allRightAbility = new List<AbilitySub>();
  435. List<AbilitySub> abilitySubs = new List<AbilitySub>();
  436. if (teacherTrain.currency.videoTime <= 0)
  437. {
  438. msgs.Add(new CodeValue("videoTime", $"视频学习时长:{teacherTrain.currency.videoTime}"));
  439. t53113OK = 0;
  440. }
  441. if (teacherTrain.currency.submitTime <= 0)
  442. {
  443. msgs.Add(new CodeValue("submitTime", $"认证材料学习:{teacherTrain.currency.submitTime}"));
  444. t53113OK = 0;
  445. }
  446. if (teacherTrain.currency.teacherAilities.Count <= 0)
  447. {
  448. msgs.Add(new CodeValue("teacherAilities", $"已学习能力点:0"));
  449. t53113OK = 0;
  450. }
  451. try
  452. {
  453. if (diagnosis != null)
  454. {
  455. if (!string.IsNullOrWhiteSpace(diagnosis.abilityNos))
  456. {
  457. List<string> nos = diagnosis.abilityNos.ToObject<List<string>>();
  458. if (nos.Count > 0 && teacherTrain.currency.teacherAilities.Count > 0)
  459. {
  460. var notin = nos.Except(teacherTrain.currency.teacherAilities.Select(x => x.no).Where(z => !string.IsNullOrWhiteSpace(z)));
  461. if (notin.Any())
  462. {
  463. msgs.Add(new CodeValue("diagnosisNos", $"省平台勾选的能力点编号为学习完成:省平台:{string.Join(",", nos.OrderBy(x => x))}" + $" ,已学习:{string.Join(",", teacherTrain.currency.teacherAilities.Select(x => x.no).OrderBy(x => x))} "));
  464. t53113OK = 0;
  465. }
  466. else
  467. {
  468. string insql = "";
  469. if (teacherTrain.currency.teacherAilities.IsNotEmpty())
  470. {
  471. var abilites = teacherTrain.currency.teacherAilities.Where(c => !string.IsNullOrWhiteSpace(c.no) && nos.Contains(c.no));
  472. insql = $" where c.id in ({string.Join(",", abilites.Select(o => $"'{o.id}'"))})";
  473. }
  474. //认证材料
  475. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
  476. .GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c {insql}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{teacherTrain.school}-{teacherTrain.id}") }))
  477. {
  478. abilitySubs.Add(item);
  479. }
  480. if (abilitySubs.Count() <= 3)
  481. {
  482. abilitySubs.ForEach(ab =>
  483. {
  484. var x = teacherTrain.currency.teacherAilities.Find(x => x.id.Equals(ab.id));
  485. if (x == null || !ab.uploads.Any())
  486. {
  487. t53113OK = 0;
  488. msgs.Add(new CodeValue("uploads", $"未上传认证材料:{x.no},{x.name}"));
  489. }
  490. if (x.zpscore <= 0)
  491. {
  492. t53113OK = 0;
  493. msgs.Add(new CodeValue("zpscore", $"认证材料,没有完成自评:{x.no},{x.name},{x.zpscore}"));
  494. }
  495. if (x.hpscore <= 0)
  496. {
  497. x.hpscore = 1;
  498. }
  499. if (x.xzscore <= 0)
  500. {
  501. x.xzscore = 1;
  502. }
  503. });
  504. foreach (AbilitySub abilitySub in abilitySubs)
  505. {
  506. //当前能力点上传的文件是否完全有效
  507. bool isAllRight = true;
  508. List<string> urlUn = new List<string>();
  509. foreach (var subUpload in abilitySub.uploads)
  510. {
  511. foreach (var url in subUpload.urls)
  512. {
  513. string blobItem = url.url.Replace($"{schoolPrefix}/", "");
  514. bool Exist = await _azureStorage.GetBlobContainerClient(school).GetBlobClient(blobItem).ExistsAsync();
  515. if (!Exist)
  516. {
  517. isAllRight = false;
  518. urlUn.Add($"{url.url}?{sas}");
  519. }
  520. }
  521. }
  522. if (isAllRight)
  523. {
  524. allRightAbility.Add(abilitySub);
  525. }
  526. else
  527. {
  528. t53113OK = 0;
  529. var x = teacherTrain.currency.teacherAilities.Find(x => x.id.Equals(abilitySub.id));
  530. msgs.Add(new CodeValue("uploads-url", $"{x.no},{x.name}上传的认证材料文件失效:{string.Join(" , ", urlUn)}"));
  531. }
  532. }
  533. }
  534. else
  535. {
  536. //一个都没上传
  537. if (!abilitySubs.SelectMany(upsl => upsl.uploads).Any())
  538. {
  539. t53113OK = 0;
  540. msgs.Add(new CodeValue("uploads-all", $"没有上传认证材料。"));
  541. }
  542. else
  543. {
  544. //检查上传了认证材料的能力点,超过三个的。
  545. var uploaded = abilitySubs.FindAll(x => x.uploads.Count > 0);
  546. //不足三个的则需要记录
  547. if (uploaded.Count < 3)
  548. {
  549. t53113OK = 0;
  550. ///少于三个的,需要判断另外的不满足情况的
  551. abilitySubs.RemoveAll(x => x.uploads.Count > 0);
  552. abilitySubs.ForEach(ab =>
  553. {
  554. var x = teacherTrain.currency.teacherAilities.Find(x => x.id.Equals(ab.id));
  555. if (x == null || !ab.uploads.Any())
  556. {
  557. t53113OK = 0;
  558. msgs.Add(new CodeValue("uploads", $"未上传认证材料:{x.no},{x.name}"));
  559. }
  560. if (x.zpscore <= 0)
  561. {
  562. t53113OK = 0;
  563. msgs.Add(new CodeValue("zpscore", $"认证材料,没有完成自评:{x.no},{x.name},{x.zpscore}"));
  564. }
  565. if (x.hpscore <= 0)
  566. {
  567. t53113OK = 0;
  568. //如果只有三个,且互评为未评状态,则直接为合格。
  569. x.hpscore = 1;
  570. msgs.Add(new CodeValue("hpscore", $"认证材料,没有完成互评:{x.no},{x.name},{x.hpscore}"));
  571. }
  572. if (x.xzscore <= 0)
  573. {
  574. t53113OK = 0;
  575. msgs.Add(new CodeValue("xzscore", $"认证材料,没有完成小组评:{x.no},{x.name},{x.xzscore}"));
  576. }
  577. });
  578. }
  579. ///如果上传的文件,失效导致不满足3个能力点
  580. List<CodeValue> un_msg = new List<CodeValue>();
  581. //检查已经上传的文件是否正确。
  582. foreach (AbilitySub abilitySub in uploaded)
  583. {
  584. //当前能力点上传的文件是否完全有效
  585. bool isAllRight = true;
  586. List<string> urlUn = new List<string>();
  587. foreach (var subUpload in abilitySub.uploads)
  588. {
  589. foreach (var url in subUpload.urls)
  590. {
  591. string blobItem = url.url.Replace($"{schoolPrefix}/", "");
  592. bool Exist = await _azureStorage.GetBlobContainerClient(school).GetBlobClient(blobItem).ExistsAsync();
  593. if (!Exist)
  594. {
  595. isAllRight = false;
  596. urlUn.Add($"{url.url}?{sas}");
  597. }
  598. }
  599. }
  600. if (isAllRight)
  601. {
  602. allRightAbility.Add(abilitySub);
  603. }
  604. else
  605. {
  606. var x = teacherTrain.currency.teacherAilities.Find(x => x.id.Equals(abilitySub.id));
  607. un_msg.Add(new CodeValue("uploads-url", $"{x.no},{x.name}上传的认证材料文件失效:{string.Join(" , ", urlUn)}"));
  608. }
  609. }
  610. if (allRightAbility.Count < 3)
  611. {
  612. t53113OK = 0;
  613. msgs.AddRange(un_msg);
  614. }
  615. }
  616. }
  617. }
  618. }
  619. else
  620. {
  621. msgs.Add(new CodeValue("teacherAilities", $"未同步省平台挑选的能力点"));
  622. t53113OK = 0;
  623. }
  624. }
  625. else
  626. {
  627. msgs.Add(new CodeValue("teacherAilities", $"未同步省平台挑选的能力点"));
  628. t53113OK = 0;
  629. }
  630. }
  631. else
  632. {
  633. msgs.Add(new CodeValue("teacherAilities", $"未同步省平台挑选的能力点"));
  634. t53113OK = 0;
  635. }
  636. }
  637. catch (Exception ex)
  638. {
  639. throw new Exception($"{ex.StackTrace},{ex.Message}");
  640. }
  641. if (allRightAbility.Count < 3)
  642. {
  643. t53113OK = 0;
  644. msgs.Add(new CodeValue("uploads-count", $"完整上传且有效的认证材料的 能力点数量小于3,当前数量:{allRightAbility.Count}"));
  645. }
  646. return (t53113OK, msgs, abilitySubs, allRightAbility);
  647. }
  648. //推送作答数据
  649. public static async Task<(string id, int code)> pushAnswers(CosmosClient client, AzureStorageFactory _azureStorage, IHttpClientFactory _httpClient, string activityId, string code)
  650. {
  651. if (string.IsNullOrEmpty(activityId))
  652. {
  653. try
  654. {
  655. ExamInfo info = null;
  656. var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(activityId.ToString(), new PartitionKey($"Exam-{code}"));
  657. if (response.Status == 200)
  658. {
  659. using var json = await JsonDocument.ParseAsync(response.ContentStream);
  660. info = json.ToObject<ExamInfo>();
  661. }
  662. List<ExamClassResult> classResults = new();
  663. if (info.scope.Equals("school", StringComparison.OrdinalIgnoreCase))
  664. {
  665. var queryResult = $"select value(c) where c.examId ='{activityId}' and c.pk = 'ExamClassResult' ";
  666. await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryResult,
  667. requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.school}") }))
  668. {
  669. classResults.Add(item);
  670. }
  671. }
  672. else
  673. {
  674. var queryResult = $"select value(c) where c.examId ='{activityId}' and c.pk = 'ExamClassResult' ";
  675. await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryResult,
  676. requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
  677. {
  678. classResults.Add(item);
  679. }
  680. }
  681. //如果单个活动包含多个科目
  682. var (grade, per) = await GetGradeAsync(client, info);
  683. var (currSemester, studyYear, currSemesterDate, date, nextSemester) = SchoolService.GetSemester(per, info.startTime);
  684. int no = 0;
  685. foreach (var subject in info.subjects)
  686. {
  687. //获取试题详细信息
  688. BlobDownloadResult index_json;
  689. if (info.scope.Equals("school"))
  690. {
  691. index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
  692. }
  693. else
  694. {
  695. index_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
  696. }
  697. JsonElement RecordingJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_json.Content.ToString()))).RootElement;
  698. RecordingJson.TryGetProperty("slides", out JsonElement slides);
  699. var sdes = slides.ToObject<List<Slides>>();
  700. List<string> urls = new();
  701. foreach (var ne in sdes)
  702. {
  703. if (!ne.type.Equals("compose"))
  704. {
  705. urls.Add(ne.url);
  706. }
  707. }
  708. // 获取整体的题目ID集合
  709. List<string> ids = new();
  710. List<(string id, string type, double score, int difficulty, string choices, string answer)> itemInfos = new();
  711. int index = 1;
  712. foreach (string url in urls)
  713. {
  714. string id = url.Replace(".json", "");
  715. BlobDownloadResult index_item_json;
  716. if (info.scope.Equals("school"))
  717. {
  718. index_item_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
  719. }
  720. else
  721. {
  722. index_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
  723. }
  724. JsonElement itemJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_item_json.Content.ToString()))).RootElement;
  725. itemJson.TryGetProperty("exercise", out JsonElement exercise);
  726. var item_json = exercise.ToObject<Exercise>();
  727. string type = item_json.type;
  728. int level = item_json.level;
  729. double score = item_json.score;
  730. var ans = item_json.answer;
  731. if (itemJson.TryGetProperty("item", out JsonElement item))
  732. {
  733. var itemInfo_json = item.ToObject<List<itemInfo>>();
  734. StringBuilder sb = new();
  735. StringBuilder an = new();
  736. itemInfo_json.FirstOrDefault().option.Select(c => c.code).ToList().ForEach(z =>
  737. {
  738. sb.Append(z);
  739. });
  740. ans.ForEach(z =>
  741. {
  742. an.Append(z);
  743. });
  744. itemInfos.Add((index.ToString(), type, score, level, sb.ToString(), an.ToString()));
  745. }
  746. index++;
  747. }
  748. //学生作答信息
  749. List<(string stuId, List<(string questionNo, double score, string answer)> ansDt)> stuAns = new();
  750. foreach (ExamClassResult classResult in classResults)
  751. {
  752. if (classResult.subjectId.Equals(subject.id)) {
  753. int stuCount = 0;
  754. foreach (var stu in classResult.studentIds)
  755. {
  756. int itemCount = 0;
  757. List<(string questionNo, double score, string answer)> ansDt = new();
  758. foreach (var itemNo in classResult.studentAnswers[stuCount])
  759. {
  760. ansDt.Add(((itemCount + 1).ToString(), classResult.studentScores[stuCount][itemCount], itemNo));
  761. itemCount++;
  762. }
  763. stuAns.Add((stu, ansDt));
  764. stuCount++;
  765. }
  766. }
  767. }
  768. var jsonString = new
  769. {
  770. examDate = info.startTime,
  771. //todo 不同学段年级数量不一致
  772. grade,
  773. subName = subject.name,
  774. totalScore = info.papers[no].point.Sum(),
  775. termCode = currSemester.start == 1 ? 1 : 2,
  776. data = new
  777. {
  778. items = itemInfos.Select(c => new
  779. {
  780. questionNo = c.id,
  781. c.type,
  782. c.score,
  783. c.difficulty,
  784. c.choices,
  785. c.answer
  786. }),
  787. stuDate = stuAns.Select(c => new
  788. {
  789. stuNo = c.stuId,
  790. scoreData = c.ansDt.Select(z => new
  791. {
  792. z.questionNo,
  793. z.score,
  794. z.answer
  795. })
  796. })
  797. }
  798. };
  799. var key = Md5Hash.GetMd5String("TMD" + info.school);
  800. string connect = $"http://www.moofen.net/esi/tmd/exam/{info.school}/{key}";
  801. var htc = _httpClient.CreateClient();
  802. string paramJson = JsonConvert.SerializeObject(jsonString);
  803. var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
  804. var ansResponse = await htc.PostAsync(connect, content);
  805. if ((int)ansResponse.StatusCode == 200)
  806. {
  807. return (activityId, 200);
  808. }
  809. no++;
  810. }
  811. }
  812. catch (CosmosException)
  813. {
  814. return (activityId, 500);
  815. }
  816. }
  817. return (activityId, 404);
  818. }
  819. public static async Task<(string gId, Period per)> GetGradeAsync(CosmosClient client, ExamInfo info)
  820. {
  821. if (info.grades.Count > 0)
  822. {
  823. var schresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(info.school, new PartitionKey("Base"));
  824. string grade = "";
  825. School sc = new();
  826. if (schresponse.Status == 200)
  827. {
  828. using var schjson = await JsonDocument.ParseAsync(schresponse.ContentStream);
  829. sc = schjson.ToObject<School>();
  830. }
  831. var period = sc.period.Where(x => x.id.Equals(info.period.id)).FirstOrDefault();
  832. var pType = sc.period.FirstOrDefault(c => c.id.Equals(info.period.id)).periodType;
  833. //int pcount = (int)(sc.period.Where(c => c.periodType.Equals("primary")).FirstOrDefault()?.grades.Count);
  834. //int jcount = (int)(sc.period.Where(c => c.periodType.Equals("junior")).FirstOrDefault()?.grades.Count);
  835. if (pType.Equals("primary"))
  836. {
  837. grade = (int.Parse(info.grades.FirstOrDefault().id) + 1).ToString();
  838. }
  839. else if (pType.Equals("junior"))
  840. {
  841. grade = (int.Parse(info.grades.FirstOrDefault().id) + 7).ToString();
  842. }
  843. else
  844. {
  845. grade = (int.Parse(info.grades.FirstOrDefault().id) + 10).ToString();
  846. }
  847. return (grade, period);
  848. }
  849. else
  850. {
  851. return ("", new Period());
  852. }
  853. }
  854. public static async Task<string> CreateMoofenExam(IHttpClientFactory _httpClient, JsonElement json,DingDing _ding)
  855. {
  856. string content = string.Empty;
  857. try {
  858. Dictionary<string, string> dict = new Dictionary<string, string>();
  859. if (json.TryGetProperty("examName", out JsonElement examName) && !string.IsNullOrWhiteSpace($"{examName}"))
  860. {
  861. dict.Add("examName", $"{examName}");
  862. }
  863. if (json.TryGetProperty("examCategory", out JsonElement examCategory) && !string.IsNullOrWhiteSpace($"{examCategory}"))
  864. {
  865. dict.Add("examCategory", $"{examCategory}");
  866. }
  867. if (json.TryGetProperty("grade", out JsonElement grade) && !string.IsNullOrWhiteSpace($"{grade}"))
  868. {
  869. dict.Add("grade", $"{grade}");
  870. }
  871. if (json.TryGetProperty("term", out JsonElement term) && !string.IsNullOrWhiteSpace($"{term}"))
  872. {
  873. dict.Add("term", $"{term}");
  874. }
  875. if (json.TryGetProperty("examType", out JsonElement examType) && !string.IsNullOrWhiteSpace($"{examType}"))
  876. {
  877. dict.Add("examType", $"{examType}");
  878. }
  879. if (json.TryGetProperty("examDate", out JsonElement examDate) && !string.IsNullOrWhiteSpace($"{examDate}"))
  880. {
  881. dict.Add("examDate", $"{examDate}");
  882. }
  883. if (json.TryGetProperty("schId", out JsonElement schId) && !string.IsNullOrWhiteSpace($"{schId}"))
  884. {
  885. dict.Add("schId", $"{schId}");
  886. }
  887. if (json.TryGetProperty("boeId", out JsonElement boeId) && !string.IsNullOrWhiteSpace($"{boeId}"))
  888. {
  889. dict.Add("boeId", $"{boeId}");
  890. }
  891. if (json.TryGetProperty("subjects", out JsonElement subjects) && subjects.ValueKind.Equals(JsonValueKind.Array))
  892. {
  893. dict.Add("subjects", $"{subjects}");
  894. }
  895. dict.Add("signKey", "TMD");
  896. var keys = dict.Keys.OrderBy(x => x);
  897. var parmas = string.Join("&", keys.Select(x => $"{x}={dict[x]}"));
  898. //var signtime = DateTimeOffset.UtcNow.GetGMTTime(8).ToUnixTimeSeconds();
  899. //parmas = $"{parmas}&signtime={signtime}";
  900. string sign = Md5Hash.Encrypt(parmas);
  901. dict.Add("sign", $"{sign}");
  902. dict.Remove("signKey");
  903. //var pkeys = dict.Keys;
  904. string url = "https://www.moofen.net/oss/esi/exam/tmodel/create";
  905. //parmas = string.Join("&", pkeys.Select(x => $"{x}={dict[x]}"));
  906. var httpClient = _httpClient.CreateClient();
  907. var request = new HttpRequestMessage
  908. {
  909. Method = new HttpMethod("POST"),
  910. RequestUri = new Uri(url),
  911. Content = new StringContent(JsonConvert.SerializeObject(dict))
  912. };
  913. // 设置请求头中的Content-Type
  914. // httpClient.DefaultRequestHeaders.Add("Content-Type", "application/x-www-form-urlencoded");
  915. var mediaTypeHeader = new MediaTypeHeaderValue("application/json")
  916. {
  917. CharSet = "UTF-8"
  918. };
  919. httpClient.Timeout = new TimeSpan(0,0,10);
  920. request.Content.Headers.ContentType = mediaTypeHeader;
  921. HttpResponseMessage response = await _httpClient.CreateClient().SendAsync(request);
  922. if (response.StatusCode.Equals(HttpStatusCode.OK)) {
  923. content = await response.Content.ReadAsStringAsync();
  924. var data = content.ToObject<JsonElement>();
  925. if (data.TryGetProperty("data", out JsonElement _data)) {
  926. return _data.ToString();
  927. }
  928. }
  929. } catch (Exception e) {
  930. await _ding.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},ThirdService/CreateMoofenExam()\n{e.Message}\n{e.StackTrace}", GroupNames.成都开发測試群組);
  931. }
  932. return "";
  933. }
  934. public static async Task<List<stuAns>> CreateMoofenExamResult(IHttpClientFactory _httpClient, JsonElement json, DingDing _ding)
  935. {
  936. string content = string.Empty;
  937. List<stuAns> ans = new();
  938. try
  939. {
  940. Dictionary<string, string> dict = new Dictionary<string, string>();
  941. if (json.TryGetProperty("examCode", out JsonElement examCode) && !string.IsNullOrWhiteSpace($"{examCode}"))
  942. {
  943. dict.Add("examCode", $"{examCode}");
  944. }
  945. if (json.TryGetProperty("subjects", out JsonElement subjects) && subjects.ValueKind.Equals(JsonValueKind.Array))
  946. {
  947. dict.Add("subjects", $"{subjects}");
  948. }
  949. dict.Add("signKey", "TMD");
  950. var keys = dict.Keys.OrderBy(x => x);
  951. var parmas = string.Join("&", keys.Select(x => $"{x}={dict[x]}"));
  952. //var signtime = DateTimeOffset.UtcNow.GetGMTTime(8).ToUnixTimeSeconds();
  953. //parmas = $"{parmas}&signtime={signtime}";
  954. string sign = Md5Hash.Encrypt(parmas);
  955. dict.Add("sign", $"{sign}");
  956. dict.Remove("signKey");
  957. //var pkeys = dict.Keys;
  958. string url = "https://www.moofen.net/oss/esi/exam/tmodel/result";
  959. //parmas = string.Join("&", pkeys.Select(x => $"{x}={dict[x]}"));
  960. var httpClient = _httpClient.CreateClient();
  961. var request = new HttpRequestMessage
  962. {
  963. Method = new HttpMethod("POST"),
  964. RequestUri = new Uri(url),
  965. Content = new StringContent(JsonConvert.SerializeObject(dict))
  966. };
  967. // 设置请求头中的Content-Type
  968. // httpClient.DefaultRequestHeaders.Add("Content-Type", "application/x-www-form-urlencoded");
  969. var mediaTypeHeader = new MediaTypeHeaderValue("application/json")
  970. {
  971. CharSet = "UTF-8"
  972. };
  973. httpClient.Timeout = new TimeSpan(0, 0, 10);
  974. request.Content.Headers.ContentType = mediaTypeHeader;
  975. HttpResponseMessage response = await _httpClient.CreateClient().SendAsync(request);
  976. if (response.StatusCode.Equals(HttpStatusCode.OK))
  977. {
  978. content = await response.Content.ReadAsStringAsync();
  979. var data = content.ToObject<JsonElement>();
  980. if (data.TryGetProperty("data", out JsonElement _data))
  981. {
  982. ans = _data.ToObject<List<stuAns>>();
  983. return ans;
  984. }
  985. }
  986. }
  987. catch (Exception e)
  988. {
  989. await _ding.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},ThirdService/CreateMoofenExamResult()\n{e.Message}\n{e.StackTrace}", GroupNames.成都开发測試群組);
  990. }
  991. return ans;
  992. }
  993. /* private class item
  994. {
  995. public string questionNo { get; set; }
  996. public string type { get; set; }
  997. public double score { get; set; }
  998. public int difficulty { get; set; }
  999. public string choices { get; set; }
  1000. public string answer { get; set; }
  1001. }*/
  1002. private class itemInfo
  1003. {
  1004. public List<opt> option { get; set; } = new();
  1005. }
  1006. private class opt
  1007. {
  1008. public string code { get; set; }
  1009. public double value { get; set; }
  1010. }
  1011. public class stuAns {
  1012. public string stuNo { get; set; }
  1013. public List<moofenAns> scoreData { get; set; } = new List<moofenAns>();
  1014. public string subject { get; set; }
  1015. }
  1016. public class moofenAns
  1017. {
  1018. public string questionNo { get; set; }
  1019. public double score { get; set; }
  1020. public string answer { get; set; }
  1021. }
  1022. }
  1023. }