|
@@ -280,8 +280,6 @@ namespace TEAMModelOS.Controllers
|
|
|
if (_update.ValueKind.Equals(JsonValueKind.Array)) {
|
|
|
update= _update.ToObject<HashSet<string>>();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
Area area = null;
|
|
@@ -366,7 +364,7 @@ namespace TEAMModelOS.Controllers
|
|
|
[AuthToken(Roles = "teacher,admin,area")]
|
|
|
public async Task<IActionResult> StatisticsTeacher(JsonElement request) {
|
|
|
//{"tmdid":"1595321354","school":"hbcn"}
|
|
|
- var (userid, name, picture, school) = HttpContext.GetAuthTokenInfo();
|
|
|
+ var (_userid, name, picture, school) = HttpContext.GetAuthTokenInfo();
|
|
|
if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
request.TryGetProperty("update", out JsonElement _update);
|
|
@@ -375,6 +373,15 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
update = _update.ToObject<HashSet<string>>();
|
|
|
}
|
|
|
+ request.TryGetProperty("tmdid", out JsonElement _tmdid);
|
|
|
+ string tmdid = "";
|
|
|
+ if (_tmdid.ValueKind.Equals(JsonValueKind.String))
|
|
|
+ {
|
|
|
+ tmdid = $"{_tmdid}";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ tmdid = $"{_userid}";
|
|
|
+ }
|
|
|
Area area = null;
|
|
|
string sql = $"select value(c) from c where c.standard='{standard}'";
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: sql,
|
|
@@ -419,7 +426,7 @@ namespace TEAMModelOS.Controllers
|
|
|
TeacherTrain teacherTrain = null;
|
|
|
try
|
|
|
{
|
|
|
- teacherTrain= await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<TeacherTrain>(userid, new PartitionKey($"TeacherTrain-{school}"));
|
|
|
+ teacherTrain= await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<TeacherTrain>(tmdid, new PartitionKey($"TeacherTrain-{school}"));
|
|
|
teacherTrain.name = name;
|
|
|
teacherTrain.picture=picture;
|
|
|
if (update!=null && update.Count > 0) {
|
|
@@ -433,9 +440,9 @@ namespace TEAMModelOS.Controllers
|
|
|
teacherTrain = await StatisticsService.StatisticsTeacher(new TeacherTrain
|
|
|
{
|
|
|
pk= "TeacherTrain",
|
|
|
- id = userid,
|
|
|
+ id = tmdid,
|
|
|
code = $"TeacherTrain-{school}",
|
|
|
- tmdid = userid,
|
|
|
+ tmdid = tmdid,
|
|
|
school = school,
|
|
|
name= name,
|
|
|
picture= picture,
|
|
@@ -449,307 +456,6 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- /// <summary>
|
|
|
- /// 对某个订阅的能力点进行操作
|
|
|
- /// </summary>
|
|
|
- /// <param name="request"></param>
|
|
|
- /// <returns></returns>
|
|
|
- [ProducesDefaultResponseType]
|
|
|
- [HttpPost("statistics-self")]
|
|
|
- [AuthToken(Roles = "teacher,admin,area")]
|
|
|
- public async Task<IActionResult> StatisticsSelf(JsonElement request)
|
|
|
- {
|
|
|
- var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
|
- if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
|
- var client = _azureCosmos.GetCosmosClient();
|
|
|
- Area area = null;
|
|
|
- string sql = $"select value(c) from c where c.standard='{standard}'";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: sql,
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
|
|
|
- {
|
|
|
- area = item;
|
|
|
- }
|
|
|
- AreaSetting setting = null;
|
|
|
- if (area != null)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- //优先找校级
|
|
|
- setting = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<AreaSetting>(school, new PartitionKey("AreaSetting"));
|
|
|
- }
|
|
|
- catch (CosmosException)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- setting = await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<AreaSetting>(area.id, new PartitionKey("AreaSetting"));
|
|
|
- }
|
|
|
- catch (CosmosException)
|
|
|
- {
|
|
|
- setting = null;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (setting == null)
|
|
|
- {
|
|
|
- setting = new AreaSetting
|
|
|
- {
|
|
|
- allTime = 50,
|
|
|
- classTime = 5,
|
|
|
- submitTime = 15,
|
|
|
- onlineTime = 20,
|
|
|
- offlineTime = 10,
|
|
|
- lessonMinutes = 45,
|
|
|
- };
|
|
|
- }
|
|
|
- if (!request.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
|
|
|
- if (!request.TryGetProperty("school", out JsonElement _school)) return BadRequest();
|
|
|
- //总学时
|
|
|
- int alltime = 0;
|
|
|
- //能力点订阅数量
|
|
|
- int subCount = 0;
|
|
|
- //已学能力点
|
|
|
- int allAbilityCount = 0;
|
|
|
- //已通过自测的能力点数量
|
|
|
- int hasAbilityExercise = 0;
|
|
|
- //线上研修
|
|
|
- int onlineTime = 0;
|
|
|
- //线下研修
|
|
|
- int offlinelTime = 0;
|
|
|
- //认证材料
|
|
|
- int schoolScoreTime = 0;
|
|
|
- //课堂实录
|
|
|
- int classVideoTime = 0;
|
|
|
- //校级研修参与
|
|
|
- int offlineSchoolJoinCount = 0;
|
|
|
- //校级研修完成
|
|
|
- int offlineSchoolDoneCount = 0;
|
|
|
- //区级研修参与
|
|
|
- int offlineAreaJoinCount = 0;
|
|
|
- //区级研修完成
|
|
|
- int offlineAreaDoneCount = 0;
|
|
|
-
|
|
|
- int uploadTotalCount = 0;
|
|
|
- int uploadDoneCount = 0;
|
|
|
- int surveyJoinCount = 0;
|
|
|
- int voteJoinCount = 0;
|
|
|
- int examJoinCount = 0;
|
|
|
- int surveyDoneCount = 0;
|
|
|
- int voteDoneCount = 0;
|
|
|
- int examDoneCount = 0;
|
|
|
- int surveyAreaJoinCount = 0;
|
|
|
- int voteAreaJoinCount = 0;
|
|
|
- int examAreaJoinCount = 0;
|
|
|
- int surveyAreaDoneCount = 0;
|
|
|
- int voteAreaDoneCount = 0;
|
|
|
- int examAreaDoneCount = 0;
|
|
|
- int videoTime = 0;
|
|
|
- HashSet<string> abilityIds = new HashSet<string>();
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
|
- .GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{_school}-{_tmdid}") }))
|
|
|
- {
|
|
|
- if (item.uploads.IsNotEmpty())
|
|
|
- {
|
|
|
- uploadDoneCount += item.uploads.Count;
|
|
|
- }
|
|
|
- subCount += 1;
|
|
|
- if (item.exerciseScore > 0)
|
|
|
- {
|
|
|
- hasAbilityExercise += 1;
|
|
|
- }
|
|
|
- allAbilityCount += item.abilityCount;
|
|
|
-
|
|
|
- int vtime = (int)item.videoRcds.Sum(x => x.time);
|
|
|
- videoTime += vtime;
|
|
|
- int lesson = vtime / setting.lessonMinutes;
|
|
|
- onlineTime += lesson;
|
|
|
- if (item.otherScore.IsNotEmpty())
|
|
|
- {
|
|
|
- var schoolScore = item.otherScore.Where(x => x.roleType.Equals("school")).FirstOrDefault();
|
|
|
- if (schoolScore != null && schoolScore.score > 0)
|
|
|
- {
|
|
|
- schoolScoreTime += 5;
|
|
|
- }
|
|
|
- }
|
|
|
- abilityIds.Add(item.id);
|
|
|
- }
|
|
|
- if (abilityIds.Count>0)
|
|
|
- {
|
|
|
- string queryText = $"SELECT c.stds FROM c WHERE c.id IN ({string.Join(",", abilityIds.Select(o => $"'{o}'"))})";
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal")
|
|
|
- .GetItemQueryIterator<Ability>(queryText: queryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{standard}") }))
|
|
|
- {
|
|
|
- item.stds.ForEach(x =>
|
|
|
- {
|
|
|
- if (x.task.IsNotEmpty())
|
|
|
- {
|
|
|
- uploadTotalCount += 1;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //owner: school area
|
|
|
- //线下 学校研修活动
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
|
- .GetItemQueryIterator<StuActivity>(queryText: $"select c.owner, c.taskStatus from c where c.type = 'Study' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Activity-{_tmdid}") }))
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(item.owner))
|
|
|
- {
|
|
|
- if (item.owner.Equals("school"))
|
|
|
- {
|
|
|
- offlineSchoolJoinCount += 1;
|
|
|
- if (item.taskStatus > 0)
|
|
|
- {
|
|
|
- offlinelTime += 1;
|
|
|
- offlineSchoolDoneCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (item.owner.Equals("area"))
|
|
|
- {
|
|
|
- offlineAreaJoinCount += 1;
|
|
|
- if (item.taskStatus > 0)
|
|
|
- {
|
|
|
- offlinelTime += 1;
|
|
|
- offlineSchoolDoneCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //问卷调查
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
|
- .GetItemQueryIterator<StuActivity>(queryText: $"select c.owner, c.taskStatus from c where c.type = 'Survey' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Activity-{_tmdid}") }))
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(item.owner))
|
|
|
- {
|
|
|
- if (item.owner.Equals("school"))
|
|
|
- {
|
|
|
- surveyJoinCount += 1;
|
|
|
- if (item.taskStatus > 0)
|
|
|
- {
|
|
|
- surveyDoneCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (item.owner.Equals("area"))
|
|
|
- {
|
|
|
- surveyAreaJoinCount += 1;
|
|
|
- if (item.taskStatus > 0)
|
|
|
- {
|
|
|
- surveyAreaDoneCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //评量检测
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
|
- .GetItemQueryIterator<StuActivity>(queryText: $"select c.owner, c.taskStatus from c where c.type = 'ExamLite' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Activity-{_tmdid}") }))
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(item.owner))
|
|
|
- {
|
|
|
- if (item.owner.Equals("school"))
|
|
|
- {
|
|
|
- examJoinCount += 1;
|
|
|
- if (item.taskStatus > 0)
|
|
|
- {
|
|
|
- examDoneCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (item.owner.Equals("area"))
|
|
|
- {
|
|
|
- examAreaJoinCount += 1;
|
|
|
- if (item.taskStatus > 0)
|
|
|
- {
|
|
|
- examAreaDoneCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //投票活动
|
|
|
- await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
|
- .GetItemQueryIterator<StuActivity>(queryText: $"select c.owner, c.taskStatus from c where c.type = 'Vote' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Activity-{_tmdid}") }))
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(item.owner))
|
|
|
- {
|
|
|
- if (item.owner.Equals("school"))
|
|
|
- {
|
|
|
- voteJoinCount += 1;
|
|
|
- if (item.taskStatus > 0)
|
|
|
- {
|
|
|
- voteDoneCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (item.owner.Equals("area"))
|
|
|
- {
|
|
|
- voteAreaJoinCount += 1;
|
|
|
- if (item.taskStatus > 0)
|
|
|
- {
|
|
|
- voteAreaDoneCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- string code = $"ClassVideo-{_school}";
|
|
|
- try
|
|
|
- {
|
|
|
- ClassVideo classVideo = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<ClassVideo>($"{_tmdid}", new PartitionKey(code));
|
|
|
- if (classVideo != null && classVideo.files.IsNotEmpty())
|
|
|
- {
|
|
|
- //2021.11.17 15:05,与J哥确认,取课堂实录第一个。前端也只show第一个视频。
|
|
|
- var files = classVideo.files[0];
|
|
|
- if (files.score > 0)
|
|
|
- {
|
|
|
- classVideoTime += 5;
|
|
|
- }
|
|
|
- //classVideo.files.ForEach(x =>
|
|
|
- //{
|
|
|
- // if (x.score > 0)
|
|
|
- // {
|
|
|
- // classVideoTime += 1;
|
|
|
- // }
|
|
|
- //});
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- classVideoTime = 0;
|
|
|
- }
|
|
|
- //处理单项 超标准 学时
|
|
|
- alltime += onlineTime >= setting.onlineTime ? setting.onlineTime : onlineTime;
|
|
|
- alltime += offlinelTime >= setting.offlineTime ? setting.offlineTime : offlinelTime;
|
|
|
- alltime += schoolScoreTime >= setting.submitTime ? setting.submitTime : schoolScoreTime;
|
|
|
- alltime += classVideoTime >= setting.classTime ? setting.classTime : classVideoTime;
|
|
|
- return Ok(new
|
|
|
- {
|
|
|
- alltime,
|
|
|
- subCount,
|
|
|
- allAbilityCount,
|
|
|
- onlineTime,
|
|
|
- schoolScoreTime,
|
|
|
- classVideoTime,
|
|
|
- hasAbilityExercise,
|
|
|
- offlinelTime,
|
|
|
-
|
|
|
- offlineAreaDoneCount,
|
|
|
- offlineAreaJoinCount,
|
|
|
- offlineSchoolDoneCount,
|
|
|
- offlineSchoolJoinCount,
|
|
|
- uploadDoneCount,
|
|
|
- uploadTotalCount,
|
|
|
- surveyDoneCount,
|
|
|
- surveyJoinCount,
|
|
|
- voteDoneCount,
|
|
|
- voteJoinCount,
|
|
|
- examJoinCount,
|
|
|
- examDoneCount,
|
|
|
- surveyAreaDoneCount,
|
|
|
- surveyAreaJoinCount,
|
|
|
- voteAreaDoneCount,
|
|
|
- voteAreaJoinCount,
|
|
|
- examAreaJoinCount,
|
|
|
- examAreaDoneCount,
|
|
|
- videoTime,
|
|
|
- setting
|
|
|
- });
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
}
|