|
@@ -39,7 +39,7 @@ namespace TEAMModelFunction
|
|
data = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<ActivityData>(adid, new Azure.Cosmos.PartitionKey($"{adcode}"));
|
|
data = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<ActivityData>(adid, new Azure.Cosmos.PartitionKey($"{adcode}"));
|
|
}
|
|
}
|
|
} catch { data = null; }
|
|
} catch { data = null; }
|
|
- await _dingDing.SendBotMsg($"问卷调查【{survey.name}-{survey.id}---{survey.ttl}】正在操作", GroupNames.成都开发測試群組);
|
|
|
|
|
|
+ await _dingDing.SendBotMsg($"问卷调查【{survey.name}-{survey.id}-ttl={survey.ttl}】正在操作", GroupNames.成都开发測試群組);
|
|
if (survey.ttl >= 1)
|
|
if (survey.ttl >= 1)
|
|
{
|
|
{
|
|
|
|
|
|
@@ -163,61 +163,66 @@ namespace TEAMModelFunction
|
|
await _azureStorage.UploadFileByContainer(survey.owner, cods.ToJsonString(), "survey", $"{survey.id}/record.json");
|
|
await _azureStorage.UploadFileByContainer(survey.owner, cods.ToJsonString(), "survey", $"{survey.id}/record.json");
|
|
//结算每道题的答题情况
|
|
//结算每道题的答题情况
|
|
|
|
|
|
- var ContainerClient = _azureStorage.GetBlobContainerClient(survey.owner);
|
|
|
|
|
|
+ var ContainerClient = _azureStorage.GetBlobContainerClient(survey.owner);
|
|
var route = ContainerClient.Uri.ToString();
|
|
var route = ContainerClient.Uri.ToString();
|
|
- List<BlobItem> items = await ContainerClient.List($"survey/{survey.id}/urecord");
|
|
|
|
- List<SurveyRecord> surveyRecords = new List<SurveyRecord>();
|
|
|
|
|
|
+
|
|
//获取
|
|
//获取
|
|
|
|
|
|
- foreach (BlobItem item in items)
|
|
|
|
- {
|
|
|
|
- BlobAuth blobAuth = _azureStorage.GetBlobSasUriRead(survey.owner, $"{item.Name}");
|
|
|
|
- var url = $"{route}/{item.Name}?{blobAuth.sas}";
|
|
|
|
- var response = await _clientFactory.CreateClient().GetAsync(new Uri(url));
|
|
|
|
- var json = await JsonDocument.ParseAsync(await response.Content.ReadAsStreamAsync());
|
|
|
|
- var Record = json.RootElement.ToObject<SurveyRecord>();
|
|
|
|
- surveyRecords.Add(Record);
|
|
|
|
- }
|
|
|
|
- List<Task<string>> tasks = new List<Task<string>>();
|
|
|
|
- for (int index = 0; index < survey.ans.Count; index++)
|
|
|
|
- {
|
|
|
|
- string url = $"{survey.id}/qrecord/{index}.json";
|
|
|
|
- QuestionRecord question = new QuestionRecord() { index = index };
|
|
|
|
- foreach (SurveyRecord record in surveyRecords)
|
|
|
|
|
|
+ try {
|
|
|
|
+ List<BlobItem> items = await ContainerClient.List($"survey/{survey.id}/urecord");
|
|
|
|
+ List<SurveyRecord> surveyRecords = new List<SurveyRecord>();
|
|
|
|
+ foreach (BlobItem item in items)
|
|
{
|
|
{
|
|
- if (record.ans.Count == survey.ans.Count)
|
|
|
|
|
|
+ BlobAuth blobAuth = _azureStorage.GetBlobSasUriRead(survey.owner, $"{item.Name}");
|
|
|
|
+ var url = $"{route}/{item.Name}?{blobAuth.sas}";
|
|
|
|
+ var response = await _clientFactory.CreateClient().GetAsync(new Uri(url));
|
|
|
|
+ var json = await JsonDocument.ParseAsync(await response.Content.ReadAsStreamAsync());
|
|
|
|
+ var Record = json.RootElement.ToObject<SurveyRecord>();
|
|
|
|
+ surveyRecords.Add(Record);
|
|
|
|
+ }
|
|
|
|
+ await _dingDing.SendBotMsg($"问卷调查问题结算数据{surveyRecords.ToJsonString()}", GroupNames.成都开发測試群組);
|
|
|
|
+ for (int index = 0; index < survey.ans.Count; index++)
|
|
|
|
+ {
|
|
|
|
+ string url = $"{survey.id}/qrecord/{index}.json";
|
|
|
|
+ QuestionRecord question = new QuestionRecord() { index = index };
|
|
|
|
+ foreach (SurveyRecord record in surveyRecords)
|
|
{
|
|
{
|
|
- foreach (var an in record.ans[index])
|
|
|
|
|
|
+ if (record.ans.Count == survey.ans.Count)
|
|
{
|
|
{
|
|
- //
|
|
|
|
- if (question.opt.ContainsKey(an))
|
|
|
|
- {
|
|
|
|
- if (question.opt[an] != null)
|
|
|
|
- {
|
|
|
|
- question.opt[an].Add(record.userid);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- question.opt[an] = new HashSet<string>() { record.userid };
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
|
|
+ foreach (var an in record.ans[index])
|
|
{
|
|
{
|
|
- if (survey.ans[index].Contains(an))
|
|
|
|
|
|
+ //
|
|
|
|
+ if (question.opt.ContainsKey(an))
|
|
{
|
|
{
|
|
- //如果是客观题code
|
|
|
|
- question.opt.Add(an, new HashSet<string> { record.userid });
|
|
|
|
|
|
+ if (question.opt[an] != null)
|
|
|
|
+ {
|
|
|
|
+ question.opt[an].Add(record.userid);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ question.opt[an] = new HashSet<string>() { record.userid };
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- //如果不是客观code
|
|
|
|
- question.other[record.userid] = an;
|
|
|
|
|
|
+ if (survey.ans[index].Contains(an))
|
|
|
|
+ {
|
|
|
|
+ //如果是客观题code
|
|
|
|
+ question.opt.Add(an, new HashSet<string> { record.userid });
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ //如果不是客观code
|
|
|
|
+ question.other[record.userid] = an;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ await _azureStorage.UploadFileByContainer(survey.owner, question.ToJsonString(), "survey", url);
|
|
}
|
|
}
|
|
- tasks.Add(_azureStorage.UploadFileByContainer(survey.owner, question.ToJsonString(), "survey", url, false));
|
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
+ await _dingDing.SendBotMsg($"问卷调查问题结算异常{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(survey.recordUrl))
|
|
if (string.IsNullOrEmpty(survey.recordUrl))
|
|
{
|
|
{
|
|
@@ -227,9 +232,9 @@ namespace TEAMModelFunction
|
|
else
|
|
else
|
|
{
|
|
{
|
|
//异动,且已经有结算记录则不必再继续。
|
|
//异动,且已经有结算记录则不必再继续。
|
|
- break;
|
|
|
|
|
|
+ //break;
|
|
}
|
|
}
|
|
- await Task.WhenAll(tasks);
|
|
|
|
|
|
+ // await Task.WhenAll(tasks);
|
|
//更新结束状态
|
|
//更新结束状态
|
|
data.progress = "finish";
|
|
data.progress = "finish";
|
|
if (survey.scope == "school")
|
|
if (survey.scope == "school")
|
|
@@ -240,6 +245,8 @@ namespace TEAMModelFunction
|
|
{
|
|
{
|
|
await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<ActivityData>(data, data.id, new Azure.Cosmos.PartitionKey(data.code));
|
|
await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<ActivityData>(data, data.id, new Azure.Cosmos.PartitionKey(data.code));
|
|
}
|
|
}
|
|
|
|
+ _azureRedis.GetRedisClient(8).KeyDelete($"Survey:Record:{survey.id}");
|
|
|
|
+ _azureRedis.GetRedisClient(8).KeyDelete($"Survey:Submit:{survey.id}");
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|