|
@@ -1,8 +1,16 @@
|
|
|
using Azure.Cosmos;
|
|
|
+using Azure.Storage.Blobs.Models;
|
|
|
+using DocumentFormat.OpenXml.Drawing.Charts;
|
|
|
+using DocumentFormat.OpenXml.Office2010.Excel;
|
|
|
using HTEXLib.COMM.Helpers;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
+using Microsoft.OData.Edm;
|
|
|
+using Newtonsoft.Json;
|
|
|
+using OpenXmlPowerTools;
|
|
|
+using OpenXmlPowerTools.HtmlToWml.CSS;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Net.Http;
|
|
|
using System.Text;
|
|
@@ -11,6 +19,8 @@ using System.Threading.Tasks;
|
|
|
using TEAMModelOS.Models;
|
|
|
using TEAMModelOS.SDK.DI;
|
|
|
using TEAMModelOS.SDK.Extension;
|
|
|
+using TEAMModelOS.SDK.Models.Cosmos;
|
|
|
+using TEAMModelOS.SDK.Models.Cosmos.Student;
|
|
|
using static TEAMModelOS.SDK.Models.Teacher;
|
|
|
|
|
|
namespace TEAMModelOS.SDK.Models
|
|
@@ -56,14 +66,15 @@ namespace TEAMModelOS.SDK.Models
|
|
|
SchoolTeacher schoolTeacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<SchoolTeacher>(teacher.id, new PartitionKey($"Teacher-{school.id}"));
|
|
|
if (schoolTeacher != null)
|
|
|
{
|
|
|
- if (!schoolTeacher.roles.IsEmpty() )
|
|
|
+ if (!schoolTeacher.roles.IsEmpty())
|
|
|
{
|
|
|
if (!schoolTeacher.roles.Contains("teacher"))
|
|
|
{
|
|
|
schoolTeacher.roles.Add("teacher");
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
schoolTeacher.roles = new List<string> { "teacher" };
|
|
|
}
|
|
|
schoolTeacher.status = "join";
|
|
@@ -91,7 +102,7 @@ namespace TEAMModelOS.SDK.Models
|
|
|
createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
|
ttl = -1
|
|
|
};
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(schoolTeacher,new PartitionKey(schoolTeacher.code));
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync(schoolTeacher, new PartitionKey(schoolTeacher.code));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -131,7 +142,7 @@ namespace TEAMModelOS.SDK.Models
|
|
|
{
|
|
|
if (scBind.pid.Equals("1249"))
|
|
|
{
|
|
|
- groupName =$"第三批教师培训组";
|
|
|
+ groupName = $"第三批教师培训组";
|
|
|
}
|
|
|
nickname = scTeachers[0].TeacherName;
|
|
|
if (!string.IsNullOrEmpty(groupName))
|
|
@@ -150,14 +161,14 @@ namespace TEAMModelOS.SDK.Models
|
|
|
//不在研修名单
|
|
|
if (meber == null || !meber.Any())
|
|
|
{
|
|
|
- yxtrain[0].members.Add(new Member { id = teacher.id, type = 1, groupId = groupId, groupName = groupName,nickname= nickname });
|
|
|
- await GroupListService.UpsertList(yxtrain[0], _azureCosmos, _configuration, _serviceBus,"web");
|
|
|
+ yxtrain[0].members.Add(new Member { id = teacher.id, type = 1, groupId = groupId, groupName = groupName, nickname = nickname });
|
|
|
+ await GroupListService.UpsertList(yxtrain[0], _azureCosmos, _configuration, _serviceBus, "web");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(meber.First().groupId) || string.IsNullOrEmpty(meber.First().groupName))
|
|
|
{
|
|
|
- meber.ToList().ForEach(x => { x.groupId = groupId; x.groupName = groupName;x.nickname = string.IsNullOrWhiteSpace(x.nickname)? nickname:x.nickname; });
|
|
|
+ meber.ToList().ForEach(x => { x.groupId = groupId; x.groupName = groupName; x.nickname = string.IsNullOrWhiteSpace(x.nickname) ? nickname : x.nickname; });
|
|
|
await GroupListService.UpsertList(yxtrain[0], _azureCosmos, _configuration, _serviceBus, "web");
|
|
|
}
|
|
|
}
|
|
@@ -233,7 +244,7 @@ namespace TEAMModelOS.SDK.Models
|
|
|
return (setting.accessConfig, area, setting);
|
|
|
}
|
|
|
}
|
|
|
- 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)
|
|
|
+ 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)
|
|
|
{
|
|
|
List<string> abilityNos = new();
|
|
|
var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
|
|
@@ -269,7 +280,7 @@ namespace TEAMModelOS.SDK.Models
|
|
|
dict = new Dictionary<string, object>() { { "accessConfig", setting.accessConfig }, { "pxid", pxid }, { "areaId", setting.id } };
|
|
|
}
|
|
|
|
|
|
- (int status, string json) = await ScsStudyApisService.GetDiagnosisListByProject_V2(_httpClient, _dingDing, _azureStorage, setting.id ,setting.accessConfig,pxid, teachers[0].schoolCode);
|
|
|
+ (int status, string json) = await ScsStudyApisService.GetDiagnosisListByProject_V2(_httpClient, _dingDing, _azureStorage, setting.id, setting.accessConfig, pxid, teachers[0].schoolCode);
|
|
|
//(int status, string json) = await httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetDiagnosisListByProject_V2");
|
|
|
if (status == 200)
|
|
|
{
|
|
@@ -296,13 +307,13 @@ namespace TEAMModelOS.SDK.Models
|
|
|
return abilities;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
//5.3.1.22学员校本教研PDF(每人可以返回多条)批量回写-UploadSBTARPDFListV2
|
|
|
- public async static Task<(int t53122OK, List<CodeValue> msgs, List<OfflineRecord> allRightOfflineRecords)> check53122(TeacherTrain teacherTrain, List<CodeValue> msgs,string school,
|
|
|
- string schoolPrefix,string sas, AzureStorageFactory _azureStorage)
|
|
|
+ public async static Task<(int t53122OK, List<CodeValue> msgs, List<OfflineRecord> allRightOfflineRecords)> check53122(TeacherTrain teacherTrain, List<CodeValue> msgs, string school,
|
|
|
+ string schoolPrefix, string sas, AzureStorageFactory _azureStorage)
|
|
|
{
|
|
|
int t53122OK = 1;
|
|
|
if (teacherTrain.offlineRecords.Count <= 0)
|
|
@@ -317,27 +328,30 @@ namespace TEAMModelOS.SDK.Models
|
|
|
t53122OK = 0;
|
|
|
msgs.Add(new CodeValue("offlineRecord-url", $"需要上传的校本研修作业至少有一个。"));
|
|
|
}
|
|
|
- if (teacherTrain.offlineReport==null) {
|
|
|
+ if (teacherTrain.offlineReport == null)
|
|
|
+ {
|
|
|
t53122OK = 0;
|
|
|
msgs.Add(new CodeValue("offlineReport", $"校本研修汇总报告未生成。"));
|
|
|
|
|
|
}
|
|
|
List<string> unexistUrl = new List<string>();
|
|
|
- foreach (var url in hasUrl) {
|
|
|
+ foreach (var url in hasUrl)
|
|
|
+ {
|
|
|
string blobItem = url.url.Replace($"{schoolPrefix}/", "");
|
|
|
bool Exist = await _azureStorage.GetBlobContainerClient(school).GetBlobClient(blobItem).ExistsAsync();
|
|
|
if (!Exist)
|
|
|
{
|
|
|
unexistUrl.Add($"{url.url}?{sas}");
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
allRightOfflineRecords.Add(url);
|
|
|
}
|
|
|
}
|
|
|
if (unexistUrl.Any() && hasUrl.Count() > 0 && hasUrl.Count() == unexistUrl.Count)
|
|
|
{
|
|
|
t53122OK = 0;
|
|
|
- msgs.Add(new CodeValue("offlineRecord-url-unexist", $"校本研修文件不存在,{string.Join(" , " ,unexistUrl)}"));
|
|
|
+ msgs.Add(new CodeValue("offlineRecord-url-unexist", $"校本研修文件不存在,{string.Join(" , ", unexistUrl)}"));
|
|
|
}
|
|
|
|
|
|
//不需要检查每一个校本研修的文件记录。
|
|
@@ -354,7 +368,7 @@ namespace TEAMModelOS.SDK.Models
|
|
|
}
|
|
|
|
|
|
//5.3.1.17学员课堂实录批量回写-UploadKTSLList
|
|
|
- public async static Task<(int t53117OK, List<CodeValue> msgs)> check53117(TeacherTrain teacherTrain, List<CodeValue> msgs, string school,
|
|
|
+ public async static Task<(int t53117OK, List<CodeValue> msgs)> check53117(TeacherTrain teacherTrain, List<CodeValue> msgs, string school,
|
|
|
string schoolPrefix, string sas, AzureStorageFactory _azureStorage)
|
|
|
{
|
|
|
//校验 基本情况是否满足
|
|
@@ -370,7 +384,8 @@ namespace TEAMModelOS.SDK.Models
|
|
|
t53117OK = 0;
|
|
|
}
|
|
|
|
|
|
- teacherTrain.teacherClasses.ForEach(x => {
|
|
|
+ teacherTrain.teacherClasses.ForEach(x =>
|
|
|
+ {
|
|
|
if (string.IsNullOrWhiteSpace(x.url))
|
|
|
{
|
|
|
t53117OK = 0;
|
|
@@ -395,7 +410,7 @@ namespace TEAMModelOS.SDK.Models
|
|
|
return (t53117OK, msgs);
|
|
|
}
|
|
|
//5.3.1.12学员培训基本情况批量回写-UpdateTeacherListSituation
|
|
|
- public static (int t53112OK, List<CodeValue> msgs) check53112(TeacherTrain teacherTrain, List<CodeValue> msgs)
|
|
|
+ public static (int t53112OK, List<CodeValue> msgs) check53112(TeacherTrain teacherTrain, List<CodeValue> msgs)
|
|
|
{
|
|
|
//校验 基本情况是否满足
|
|
|
int t53112OK = 1;
|
|
@@ -426,7 +441,7 @@ namespace TEAMModelOS.SDK.Models
|
|
|
return (t53112OK, msgs);
|
|
|
}
|
|
|
//5.3.1.13学员能力点测评结果批量回写-UpdateTeacherListDiagnosis
|
|
|
- public async static Task<(int t53113OK, List<CodeValue> msgs, List<AbilitySub> abilitySubs, List<AbilitySub> allRightAbility)> check53113(AzureCosmosFactory _azureCosmos,TeacherTrain teacherTrain, ScTeacherDiagnosis diagnosis,
|
|
|
+ public async static Task<(int t53113OK, List<CodeValue> msgs, List<AbilitySub> abilitySubs, List<AbilitySub> allRightAbility)> check53113(AzureCosmosFactory _azureCosmos, TeacherTrain teacherTrain, ScTeacherDiagnosis diagnosis,
|
|
|
List<CodeValue> msgs, string school,
|
|
|
string schoolPrefix, string sas, AzureStorageFactory _azureStorage)
|
|
|
{
|
|
@@ -450,7 +465,8 @@ namespace TEAMModelOS.SDK.Models
|
|
|
msgs.Add(new CodeValue("teacherAilities", $"已学习能力点:0"));
|
|
|
t53113OK = 0;
|
|
|
}
|
|
|
- try {
|
|
|
+ try
|
|
|
+ {
|
|
|
if (diagnosis != null)
|
|
|
{
|
|
|
if (!string.IsNullOrWhiteSpace(diagnosis.abilityNos))
|
|
@@ -459,7 +475,7 @@ namespace TEAMModelOS.SDK.Models
|
|
|
if (nos.Count > 0 && teacherTrain.currency.teacherAilities.Count > 0)
|
|
|
{
|
|
|
var notin = nos.Except(teacherTrain.currency.teacherAilities.Select(x => x.no).Where(z => !string.IsNullOrWhiteSpace(z)));
|
|
|
- if (notin.Any() )
|
|
|
+ if (notin.Any())
|
|
|
{
|
|
|
msgs.Add(new CodeValue("diagnosisNos", $"省平台勾选的能力点编号为学习完成:省平台:{string.Join(",", nos.OrderBy(x => x))}" + $" ,已学习:{string.Join(",", teacherTrain.currency.teacherAilities.Select(x => x.no).OrderBy(x => x))} "));
|
|
|
t53113OK = 0;
|
|
@@ -481,7 +497,8 @@ namespace TEAMModelOS.SDK.Models
|
|
|
|
|
|
if (abilitySubs.Count() <= 3)
|
|
|
{
|
|
|
- abilitySubs.ForEach(ab => {
|
|
|
+ abilitySubs.ForEach(ab =>
|
|
|
+ {
|
|
|
var x = teacherTrain.currency.teacherAilities.Find(x => x.id.Equals(ab.id));
|
|
|
if (x == null || !ab.uploads.Any())
|
|
|
{
|
|
@@ -550,7 +567,8 @@ namespace TEAMModelOS.SDK.Models
|
|
|
t53113OK = 0;
|
|
|
///少于三个的,需要判断另外的不满足情况的
|
|
|
abilitySubs.RemoveAll(x => x.uploads.Count > 0);
|
|
|
- abilitySubs.ForEach(ab => {
|
|
|
+ abilitySubs.ForEach(ab =>
|
|
|
+ {
|
|
|
var x = teacherTrain.currency.teacherAilities.Find(x => x.id.Equals(ab.id));
|
|
|
if (x == null || !ab.uploads.Any())
|
|
|
{
|
|
@@ -607,7 +625,8 @@ namespace TEAMModelOS.SDK.Models
|
|
|
un_msg.Add(new CodeValue("uploads-url", $"{x.no},{x.name}上传的认证材料文件失效:{string.Join(" , ", urlUn)}"));
|
|
|
}
|
|
|
}
|
|
|
- if (allRightAbility.Count<3) {
|
|
|
+ if (allRightAbility.Count < 3)
|
|
|
+ {
|
|
|
t53113OK = 0;
|
|
|
msgs.AddRange(un_msg);
|
|
|
}
|
|
@@ -632,7 +651,9 @@ namespace TEAMModelOS.SDK.Models
|
|
|
msgs.Add(new CodeValue("teacherAilities", $"未同步省平台挑选的能力点"));
|
|
|
t53113OK = 0;
|
|
|
}
|
|
|
- } catch (Exception ex) {
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
throw new Exception($"{ex.StackTrace},{ex.Message}");
|
|
|
}
|
|
|
if (allRightAbility.Count < 3)
|
|
@@ -643,5 +664,241 @@ namespace TEAMModelOS.SDK.Models
|
|
|
|
|
|
return (t53113OK, msgs, abilitySubs, allRightAbility);
|
|
|
}
|
|
|
+
|
|
|
+ //推送作答数据
|
|
|
+ public static async Task<(string id, int code)> pushAnswers(CosmosClient client, AzureStorageFactory _azureStorage, IHttpClientFactory _httpClient, string activityId, string code)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(activityId))
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ ExamInfo info = null;
|
|
|
+ var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(activityId.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
+ if (response.Status == 200)
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
+ info = json.ToObject<ExamInfo>();
|
|
|
+ }
|
|
|
+ List<ExamClassResult> classResults = new();
|
|
|
+ if (info.scope.Equals("school", StringComparison.OrdinalIgnoreCase))
|
|
|
+ {
|
|
|
+ var queryResult = $"select value(c) where c.examId ='{activityId}' and c.pk = 'ExamClassResult' ";
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryResult,
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.school}") }))
|
|
|
+ {
|
|
|
+ classResults.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var queryResult = $"select value(c) where c.examId ='{activityId}' and c.pk = 'ExamClassResult' ";
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryResult,
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
|
|
|
+ {
|
|
|
+ classResults.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果单个活动包含多个科目
|
|
|
+ var (grade, per) = await GetGradeAsync(client, info);
|
|
|
+ var (currSemester, studyYear, currSemesterDate, date, nextSemester) = SchoolService.GetSemester(per, info.startTime);
|
|
|
+ int no = 0;
|
|
|
+ foreach (var subject in info.subjects)
|
|
|
+ {
|
|
|
+ //获取试题详细信息
|
|
|
+ BlobDownloadResult index_json;
|
|
|
+ if (info.scope.Equals("school"))
|
|
|
+ {
|
|
|
+ index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ index_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
|
|
|
+ }
|
|
|
+ JsonElement RecordingJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_json.Content.ToString()))).RootElement;
|
|
|
+ RecordingJson.TryGetProperty("slides", out JsonElement slides);
|
|
|
+ var sdes = slides.ToObject<List<Slides>>();
|
|
|
+ List<string> urls = new();
|
|
|
+ foreach (var ne in sdes)
|
|
|
+ {
|
|
|
+ if (!ne.type.Equals("compose"))
|
|
|
+ {
|
|
|
+ urls.Add(ne.url);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取整体的题目ID集合
|
|
|
+ List<string> ids = new();
|
|
|
+ List<(string id, string type, double score, int difficulty, string choices, string answer)> itemInfos = new();
|
|
|
+ int index = 1;
|
|
|
+ foreach (string url in urls)
|
|
|
+ {
|
|
|
+ string id = url.Replace(".json", "");
|
|
|
+ BlobDownloadResult index_item_json;
|
|
|
+ if (info.scope.Equals("school"))
|
|
|
+ {
|
|
|
+ index_item_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ index_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
|
|
|
+ }
|
|
|
+ JsonElement itemJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_item_json.Content.ToString()))).RootElement;
|
|
|
+ itemJson.TryGetProperty("exercise", out JsonElement exercise);
|
|
|
+ var item_json = exercise.ToObject<Exercise>();
|
|
|
+ string type = item_json.type;
|
|
|
+ int level = item_json.level;
|
|
|
+ double score = item_json.score;
|
|
|
+ var ans = item_json.answer;
|
|
|
+ if (itemJson.TryGetProperty("item", out JsonElement item))
|
|
|
+ {
|
|
|
+ var itemInfo_json = item.ToObject<List<itemInfo>>();
|
|
|
+ StringBuilder sb = new();
|
|
|
+ StringBuilder an = new();
|
|
|
+ itemInfo_json.FirstOrDefault().option.Select(c => c.code).ToList().ForEach(z =>
|
|
|
+ {
|
|
|
+ sb.Append(z);
|
|
|
+ });
|
|
|
+ ans.ForEach(z =>
|
|
|
+ {
|
|
|
+ an.Append(z);
|
|
|
+ });
|
|
|
+ itemInfos.Add((index.ToString(), type, score, level, sb.ToString(), an.ToString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ //学生作答信息
|
|
|
+ List<(string stuId, List<(string questionNo, double score, string answer)> ansDt)> stuAns = new();
|
|
|
+ foreach (ExamClassResult classResult in classResults)
|
|
|
+ {
|
|
|
+ if (classResult.subjectId.Equals(subject.id)) {
|
|
|
+ int stuCount = 0;
|
|
|
+ foreach (var stu in classResult.studentIds)
|
|
|
+ {
|
|
|
+ int itemCount = 0;
|
|
|
+ List<(string questionNo, double score, string answer)> ansDt = new();
|
|
|
+ foreach (var itemNo in classResult.studentAnswers[stuCount])
|
|
|
+ {
|
|
|
+
|
|
|
+ ansDt.Add(((itemCount + 1).ToString(), classResult.studentScores[stuCount][itemCount], itemNo));
|
|
|
+ itemCount++;
|
|
|
+ }
|
|
|
+ stuAns.Add((stu, ansDt));
|
|
|
+ stuCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var jsonString = new
|
|
|
+ {
|
|
|
+
|
|
|
+ examDate = info.startTime,
|
|
|
+ //todo 不同学段年级数量不一致
|
|
|
+ grade,
|
|
|
+ subName = subject.name,
|
|
|
+ totalScore = info.papers[no].point.Sum(),
|
|
|
+ termCode = currSemester.start == 1 ? 1 : 2,
|
|
|
+ data = new
|
|
|
+ {
|
|
|
+ items = itemInfos.Select(c => new
|
|
|
+ {
|
|
|
+ questionNo = c.id,
|
|
|
+ c.type,
|
|
|
+ c.score,
|
|
|
+ c.difficulty,
|
|
|
+ c.choices,
|
|
|
+ c.answer
|
|
|
+ }),
|
|
|
+ stuDate = stuAns.Select(c => new
|
|
|
+ {
|
|
|
+
|
|
|
+ stuNo = c.stuId,
|
|
|
+ scoreData = c.ansDt.Select(z => new
|
|
|
+ {
|
|
|
+ z.questionNo,
|
|
|
+ z.score,
|
|
|
+ z.answer
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ var key = Md5Hash.GetMd5String("TMD" + info.school);
|
|
|
+ string connect = $"http://www.moofen.net/esi/tmd/exam/{info.school}/{key}";
|
|
|
+ var htc = _httpClient.CreateClient();
|
|
|
+ string paramJson = JsonConvert.SerializeObject(jsonString);
|
|
|
+ var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
|
|
|
+ var ansResponse = await htc.PostAsync(connect, content);
|
|
|
+ if ((int)ansResponse.StatusCode == 200)
|
|
|
+ {
|
|
|
+ return (activityId, 200);
|
|
|
+ }
|
|
|
+ no++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (CosmosException)
|
|
|
+ {
|
|
|
+ return (activityId, 500);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return (activityId, 404);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static async Task<(string gId, Period per)> GetGradeAsync(CosmosClient client, ExamInfo info)
|
|
|
+ {
|
|
|
+ if (info.grades.Count > 0)
|
|
|
+ {
|
|
|
+ var schresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(info.school, new PartitionKey("Base"));
|
|
|
+ string grade = "";
|
|
|
+ School sc = new();
|
|
|
+ if (schresponse.Status == 200)
|
|
|
+ {
|
|
|
+ using var schjson = await JsonDocument.ParseAsync(schresponse.ContentStream);
|
|
|
+ sc = schjson.ToObject<School>();
|
|
|
+ }
|
|
|
+ var period = sc.period.Where(x => x.id.Equals(info.period.id)).FirstOrDefault();
|
|
|
+ var pType = sc.period.FirstOrDefault(c => c.id.Equals(info.period.id)).periodType;
|
|
|
+ int pcount = (int)(sc.period.Where(c => c.periodType.Equals("primary")).FirstOrDefault()?.grades.Count);
|
|
|
+ int jcount = (int)(sc.period.Where(c => c.periodType.Equals("junior")).FirstOrDefault()?.grades.Count);
|
|
|
+ if (pType.Equals("primary"))
|
|
|
+ {
|
|
|
+ grade = (int.Parse(info.grades.FirstOrDefault().id) + 1).ToString();
|
|
|
+ }
|
|
|
+ else if (pType.Equals("junior"))
|
|
|
+ {
|
|
|
+ grade = (int.Parse(info.grades.FirstOrDefault().id) + 1 + pcount).ToString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ grade = (int.Parse(info.grades.FirstOrDefault().id) + 1 + pcount + jcount).ToString();
|
|
|
+ }
|
|
|
+ return (grade, period);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return ("", new Period());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private class item
|
|
|
+ {
|
|
|
+ public string questionNo { get; set; }
|
|
|
+ public string type { get; set; }
|
|
|
+ public double score { get; set; }
|
|
|
+ public int difficulty { get; set; }
|
|
|
+ public string choices { get; set; }
|
|
|
+ public string answer { get; set; }
|
|
|
+ }
|
|
|
+
|
|
|
+ private class itemInfo
|
|
|
+ {
|
|
|
+ public List<opt> option { get; set; } = new();
|
|
|
+
|
|
|
+ }
|
|
|
+ private class opt
|
|
|
+ {
|
|
|
+ public string code { get; set; }
|
|
|
+ public double value { get; set; }
|
|
|
+ }
|
|
|
}
|
|
|
}
|