|
@@ -49,7 +49,8 @@ namespace TEAMModelOS.SDK
|
|
|
|
|
|
public static async Task DoChange(TeacherTrainChange change, AzureCosmosFactory _azureCosmos)
|
|
|
{
|
|
|
- if (change.tmdids.IsNotEmpty() && change.update.Count() > 0 && !string.IsNullOrEmpty(change.school)) {
|
|
|
+ if (change.tmdids.IsNotEmpty() && change.update.Count() > 0 && !string.IsNullOrEmpty(change.school))
|
|
|
+ {
|
|
|
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
string insql = $"where c.id in ({string.Join(",", change.tmdids.Select(x => $"'{x}'"))})";
|
|
@@ -89,10 +90,11 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- public static async Task SendServiceBus((string standard, List<string> tmdids, string school, List<string> update, int statistics)list, IConfiguration _configuration, AzureServiceBusFactory _serviceBus, CosmosClient client) {
|
|
|
+ public static async Task SendServiceBus((string standard, List<string> tmdids, string school, List<string> update, int statistics) list, IConfiguration _configuration, AzureServiceBusFactory _serviceBus, CosmosClient client)
|
|
|
+ {
|
|
|
if (list.tmdids.IsNotEmpty() && list.update.IsNotEmpty())
|
|
|
{
|
|
|
- string insql = $"where c.id in ({string.Join(",", list. tmdids.Select(x => $"'{x}'"))})";
|
|
|
+ string insql = $"where c.id in ({string.Join(",", list.tmdids.Select(x => $"'{x}'"))})";
|
|
|
string selsql = $"select value(c) from c {insql} ";
|
|
|
List<TeacherTrain> teacherTrains = new List<TeacherTrain>();
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<TeacherTrain>(queryText: selsql,
|
|
@@ -145,7 +147,7 @@ namespace TEAMModelOS.SDK
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
- public static async Task GetAreaAndAreaSetting( string schoolId, string _standard, CosmosClient client, HttpContext httpContext)
|
|
|
+ public static async Task GetAreaAndAreaSetting(string schoolId, string _standard, CosmosClient client, HttpContext httpContext)
|
|
|
{
|
|
|
School school = null;
|
|
|
AreaSetting setting = null;
|
|
@@ -154,36 +156,38 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
standard = _standard;
|
|
|
}
|
|
|
- else if(!string.IsNullOrEmpty(schoolId)) {
|
|
|
+ else if (!string.IsNullOrEmpty(schoolId))
|
|
|
+ {
|
|
|
//优先找校级
|
|
|
setting = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<AreaSetting>(schoolId, new PartitionKey("AreaSetting"));
|
|
|
//优先找校级
|
|
|
school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(schoolId, new PartitionKey("Base"));
|
|
|
}
|
|
|
}
|
|
|
- public static async Task<List<(List<TeacherTrain> trains, List<RGroupList> yxtrain)>> StatisticsArea(AreaSetting setting, Area area, CosmosClient client, DingDing _dingDing, HashSet<string> updates)
|
|
|
+ public static async Task<List<(List<TeacherTrain> trains, List<RGroupList> yxtrain)>> StatisticsArea(AreaSetting setting, Area area, CosmosClient client, DingDing _dingDing, HashSet<string> updates)
|
|
|
{
|
|
|
- List<(List<TeacherTrain> trains, List<RGroupList> yxtrain)> teacherTrains = new List<(List<TeacherTrain> trains, List<RGroupList> yxtrain)>() ;
|
|
|
+ List<(List<TeacherTrain> trains, List<RGroupList> yxtrain)> teacherTrains = new List<(List<TeacherTrain> trains, List<RGroupList> yxtrain)>();
|
|
|
List<School> schools = new List<School>();
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School")
|
|
|
.GetItemQueryIterator<School>(queryText: $"select value(c) from c where c.areaId='{area.id}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
{
|
|
|
schools.Add(item);
|
|
|
}
|
|
|
- await foreach ((List<TeacherTrain> trains, List<RGroupList> yxtrain) tarain in GetStatisticsSchool(schools, setting, area, client,_dingDing,updates))
|
|
|
+ await foreach ((List<TeacherTrain> trains, List<RGroupList> yxtrain) tarain in GetStatisticsSchool(schools, setting, area, client, _dingDing, updates))
|
|
|
{
|
|
|
teacherTrains.Add(tarain);
|
|
|
}
|
|
|
return teacherTrains;
|
|
|
}
|
|
|
- private static async IAsyncEnumerable<(List<TeacherTrain> trains, List<RGroupList> yxtrain)> GetStatisticsSchool(List<School> schools, AreaSetting setting, Area area, CosmosClient client, DingDing _dingDing, HashSet<string> updates)
|
|
|
+ private static async IAsyncEnumerable<(List<TeacherTrain> trains, List<RGroupList> yxtrain)> GetStatisticsSchool(List<School> schools, AreaSetting setting, Area area, CosmosClient client, DingDing _dingDing, HashSet<string> updates)
|
|
|
{
|
|
|
foreach (var school in schools)
|
|
|
{
|
|
|
- yield return await StatisticsSchool(school.id, setting, area, client,_dingDing,updates);
|
|
|
+ yield return await StatisticsSchool(school.id, setting, area, client, _dingDing, updates);
|
|
|
}
|
|
|
}
|
|
|
- public static async Task<(List<TeacherTrain> trains, List<RGroupList> yxtrain)> StatisticsSchool(string school, AreaSetting setting, Area area, CosmosClient client,DingDing _dingDing,HashSet<string> updates) {
|
|
|
+ public static async Task<(List<TeacherTrain> trains, List<RGroupList> yxtrain)> StatisticsSchool(string school, AreaSetting setting, Area area, CosmosClient client, DingDing _dingDing, HashSet<string> updates)
|
|
|
+ {
|
|
|
List<RGroupList> yxtrain = await GroupListService.GetGroupListMemberByType(client, "yxtrain", new List<string> { "school" }, $"{school}", _dingDing);
|
|
|
List<TeacherTrain> trains = new List<TeacherTrain>();
|
|
|
var members = yxtrain.SelectMany(x => x.members).ToList();
|
|
@@ -191,29 +195,34 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
return (trains, yxtrain);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher")
|
|
|
- .GetItemQueryIterator<TeacherTrain>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherTrain-{school}") })) {
|
|
|
-
|
|
|
+ .GetItemQueryIterator<TeacherTrain>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherTrain-{school}") }))
|
|
|
+ {
|
|
|
+
|
|
|
trains.Add(item);
|
|
|
}
|
|
|
- if (updates != null) {
|
|
|
+ if (updates != null)
|
|
|
+ {
|
|
|
foreach (var up in updates)
|
|
|
{
|
|
|
trains.ForEach(x => x.update.Add(up));
|
|
|
}
|
|
|
}
|
|
|
var update = trains.FindAll(x => x.update.Count() > 0);
|
|
|
- var noupdate = trains.FindAll(x => x.update.Count() <=0);
|
|
|
-
|
|
|
+ var noupdate = trains.FindAll(x => x.update.Count() <= 0);
|
|
|
+
|
|
|
var unStatistics = members.Select(x => x.id).Except(trains.Select(x => x.id));
|
|
|
List<TeacherTrain> teacherTrains = new List<TeacherTrain>();
|
|
|
List<TeacherTrain> returnTrains = new List<TeacherTrain>();
|
|
|
- if (update.IsNotEmpty()) {
|
|
|
+ if (update.IsNotEmpty())
|
|
|
+ {
|
|
|
teacherTrains.AddRange(update);
|
|
|
}
|
|
|
- if (unStatistics != null) {
|
|
|
- foreach (string x in unStatistics) {
|
|
|
+ if (unStatistics != null)
|
|
|
+ {
|
|
|
+ foreach (string x in unStatistics)
|
|
|
+ {
|
|
|
var member = members.Find(y => y.id.Equals(x));
|
|
|
teacherTrains.Add(new TeacherTrain
|
|
|
{
|
|
@@ -222,9 +231,9 @@ namespace TEAMModelOS.SDK
|
|
|
code = $"TeacherTrain-{school}",
|
|
|
tmdid = x,
|
|
|
name = member.name,
|
|
|
- picture=member.picture,
|
|
|
+ picture = member.picture,
|
|
|
school = school,
|
|
|
- update = new HashSet<string> { TeacherAbility,TeacherClass,OfflineRecord }
|
|
|
+ update = new HashSet<string> { TeacherAbility, TeacherClass, OfflineRecord }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -234,7 +243,7 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
studies.Add(item);
|
|
|
}
|
|
|
- returnTrains = await GetStatisticsTeacher(teacherTrains, setting, area, client,studies);
|
|
|
+ returnTrains = await GetStatisticsTeacher(teacherTrains, setting, area, client, studies);
|
|
|
//await foreach (var tarain in GetStatisticsTeacher(teacherTrains, setting, area, client))
|
|
|
//{
|
|
|
// returnTrains.Add(tarain);
|
|
@@ -246,7 +255,7 @@ namespace TEAMModelOS.SDK
|
|
|
//移除不在研修名单的人员
|
|
|
returnTrains.RemoveAll(x => !members.Select(y => y.id).Contains(x.id));
|
|
|
returnTrains.ForEach(x => {
|
|
|
- var mbm= members.Find(y => y.id.Equals(x.id));
|
|
|
+ var mbm = members.Find(y => y.id.Equals(x.id));
|
|
|
if (mbm != null)
|
|
|
{
|
|
|
x.groupName = mbm?.groupName;
|
|
@@ -255,14 +264,14 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- return (returnTrains, yxtrain);
|
|
|
+ return (returnTrains, yxtrain);
|
|
|
}
|
|
|
private static async Task<List<TeacherTrain>> GetStatisticsTeacher(List<TeacherTrain> trains, AreaSetting setting, Area area, CosmosClient client, List<Study> studies)
|
|
|
{
|
|
|
List<Task<TeacherTrain>> teachers = new List<Task<TeacherTrain>>();
|
|
|
foreach (var train in trains)
|
|
|
{
|
|
|
- teachers.Add(StatisticsTeacher(train, setting, area, client,studies)); //yield return await StatisticsTeacher( train, setting, area, client);
|
|
|
+ teachers.Add(StatisticsTeacher(train, setting, area, client, studies)); //yield return await StatisticsTeacher( train, setting, area, client);
|
|
|
}
|
|
|
int pagesize = 50;
|
|
|
if (teachers.Count <= pagesize)
|
|
@@ -278,17 +287,20 @@ namespace TEAMModelOS.SDK
|
|
|
await Task.WhenAll(lists);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return trains;
|
|
|
}
|
|
|
- public static async Task<TeacherTrain> StatisticsTeacher(TeacherTrain train, AreaSetting setting, Area area, CosmosClient client,List<Study> studies) {
|
|
|
+ public static async Task<TeacherTrain> StatisticsTeacher(TeacherTrain train, AreaSetting setting, Area area, CosmosClient client, List<Study> studies)
|
|
|
+ {
|
|
|
string _school = train.school;
|
|
|
string _tmdid = train.tmdid;
|
|
|
- // TeacherTrain teacher_train = null;
|
|
|
+ // TeacherTrain teacher_train = null;
|
|
|
List<Task<TeacherTrain>> teachers = new List<Task<TeacherTrain>>();
|
|
|
- if (train.update.Count > 0) {
|
|
|
- foreach (string property in train.update) {
|
|
|
- teachers.Add(DoProperty(train.update, property, setting, area, client, train,studies));
|
|
|
+ if (train.update.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (string property in train.update)
|
|
|
+ {
|
|
|
+ teachers.Add(DoProperty(train.update, property, setting, area, client, train, studies));
|
|
|
}
|
|
|
int pagesize = 50;
|
|
|
if (teachers.Count <= pagesize)
|
|
@@ -322,19 +334,21 @@ namespace TEAMModelOS.SDK
|
|
|
train.finalScore = 0;
|
|
|
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
//学时<=0 则是为
|
|
|
train.finalScore = -1;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync<TeacherTrain>(train, new PartitionKey($"TeacherTrain-{_school}"));
|
|
|
return train;
|
|
|
}
|
|
|
- private static async Task<TeacherTrain> DoProperty(HashSet<string> updateProperty,string property, AreaSetting setting, Area area, CosmosClient client, TeacherTrain train ,List<Study> studies )
|
|
|
+ private static async Task<TeacherTrain> DoProperty(HashSet<string> updateProperty, string property, AreaSetting setting, Area area, CosmosClient client, TeacherTrain train, List<Study> studies)
|
|
|
{
|
|
|
string _school = train.school;
|
|
|
string _tmdid = train.tmdid;
|
|
|
- switch (property) {
|
|
|
+ switch (property)
|
|
|
+ {
|
|
|
case TeacherAbility:
|
|
|
train = await DoTeacherAbility(train, setting, area, client, _school, _tmdid);
|
|
|
train.update.Remove(TeacherAbility);
|
|
@@ -346,7 +360,7 @@ namespace TEAMModelOS.SDK
|
|
|
break;
|
|
|
//线下研修
|
|
|
case OfflineRecord:
|
|
|
- train = await DoOfflineRecord(train, setting, area, client, _school, _tmdid,studies);
|
|
|
+ train = await DoOfflineRecord(train, setting, area, client, _school, _tmdid, studies);
|
|
|
train.update.Remove(OfflineRecord);
|
|
|
break;
|
|
|
//投票
|
|
@@ -374,9 +388,10 @@ namespace TEAMModelOS.SDK
|
|
|
break;
|
|
|
}
|
|
|
return train;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
- public static async Task<TeacherTrain> DoTeacherVote(TeacherTrain train, AreaSetting setting, Area area, CosmosClient client, string _school, string _tmdid) {
|
|
|
+ public static async Task<TeacherTrain> DoTeacherVote(TeacherTrain train, AreaSetting setting, Area area, CosmosClient client, string _school, string _tmdid)
|
|
|
+ {
|
|
|
int voteJoin = 0;
|
|
|
int voteDone = 0;
|
|
|
int voteAreaJoin = 0;
|
|
@@ -495,7 +510,8 @@ namespace TEAMModelOS.SDK
|
|
|
/// <param name="_school"></param>
|
|
|
/// <param name="_tmdid"></param>
|
|
|
/// <returns></returns>
|
|
|
- public static async Task<TeacherTrain> DoOfflineRecord(TeacherTrain train, AreaSetting setting, Area area, CosmosClient client, string _school, string _tmdid, List<Study> studies) {
|
|
|
+ public static async Task<TeacherTrain> DoOfflineRecord(TeacherTrain train, AreaSetting setting, Area area, CosmosClient client, string _school, string _tmdid, List<Study> studies)
|
|
|
+ {
|
|
|
//owner: school area
|
|
|
//线下 学校研修活动
|
|
|
List<StuActivity> activities = new List<StuActivity>();
|
|
@@ -505,7 +521,8 @@ namespace TEAMModelOS.SDK
|
|
|
activities.Add(item);
|
|
|
}
|
|
|
string insql = "";
|
|
|
- if (studies.IsEmpty()) {
|
|
|
+ if (studies.IsEmpty())
|
|
|
+ {
|
|
|
studies = new List<Study>();
|
|
|
if (activities.IsNotEmpty())
|
|
|
{
|
|
@@ -517,9 +534,9 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
List<StudyRecord> studyRecords = new List<StudyRecord>();
|
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher")
|
|
|
.GetItemQueryIterator<StudyRecord>(queryText: $"select value(c) from c {insql} ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StudyRecord-{_tmdid}") }))
|
|
@@ -527,17 +544,19 @@ namespace TEAMModelOS.SDK
|
|
|
studyRecords.Add(item);
|
|
|
}
|
|
|
List<HomeworkRecord> homeworkRecords = new List<HomeworkRecord>();
|
|
|
- List<Study> workids= studies.FindAll(x => !string.IsNullOrEmpty(x.workId));
|
|
|
-
|
|
|
- bool haswork=false;
|
|
|
- List<string > workidSubmits = new List<string >();
|
|
|
- if (workids.IsNotEmpty()) {
|
|
|
+ List<Study> workids = studies.FindAll(x => !string.IsNullOrEmpty(x.workId));
|
|
|
+
|
|
|
+ bool haswork = false;
|
|
|
+ List<string> workidSubmits = new List<string>();
|
|
|
+ if (workids.IsNotEmpty())
|
|
|
+ {
|
|
|
string rcdsql = $" where c.id in ({string.Join(",", workids.Select(o => $"'{o.workId}'"))})";
|
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher")
|
|
|
.GetItemQueryIterator<HomeworkRecord>(queryText: $"select value(c) from c {rcdsql} ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"HomeworkRecord-{_tmdid}") }))
|
|
|
{
|
|
|
- var content= item.content.FindAll(x => x.prime);
|
|
|
- if (content.IsNotEmpty()) {
|
|
|
+ var content = item.content.FindAll(x => x.prime);
|
|
|
+ if (content.IsNotEmpty())
|
|
|
+ {
|
|
|
workidSubmits.Add(item.id);
|
|
|
}
|
|
|
homeworkRecords.Add(item);
|
|
@@ -547,33 +566,37 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
//如果交了至少一份作业
|
|
|
//一份作业都没有交
|
|
|
-
|
|
|
+
|
|
|
//标记是否计算所有学时。
|
|
|
- bool getAll= false;
|
|
|
+ bool getAll = false;
|
|
|
if (haswork)
|
|
|
{
|
|
|
//如果有作业就需要检查是否至少交了一份作业。 如果交了一份,并且通过了,则可以计算全部。具体查看mark qweorrty
|
|
|
getAll = false;
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
//如果没有作业,则计算全部学时。
|
|
|
- getAll= true;
|
|
|
+ getAll = true;
|
|
|
}
|
|
|
activities.ForEach(item => {
|
|
|
Study study = studies.Find(y => y.id.Equals(item.id) && !string.IsNullOrEmpty(y.workId));
|
|
|
- if (study != null) {
|
|
|
+ if (study != null)
|
|
|
+ {
|
|
|
StudyRecord studyRecord = studyRecords.Find(y => y.id.Equals(item.id));
|
|
|
- if (studyRecord!=null && studyRecord.status > 0) {
|
|
|
+ if (studyRecord != null && studyRecord.status > 0)
|
|
|
+ {
|
|
|
//mark qweorrty
|
|
|
var submit = workidSubmits.Find(y => y.Equals(study.workId));
|
|
|
- if (submit != null) {
|
|
|
+ if (submit != null)
|
|
|
+ {
|
|
|
getAll = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
List<OfflineRecord> offlines = new List<OfflineRecord>();
|
|
|
-
|
|
|
+
|
|
|
activities.ForEach(item =>
|
|
|
{
|
|
|
Study study = studies.Find(y => y.id.Equals(item.id));
|
|
@@ -586,10 +609,11 @@ namespace TEAMModelOS.SDK
|
|
|
name = item.name,
|
|
|
done = item.taskStatus,
|
|
|
owner = item.owner,
|
|
|
- sethour=study.hour
|
|
|
+ sethour = study.hour
|
|
|
};
|
|
|
bool workOk = false;
|
|
|
- if (!string.IsNullOrEmpty(study.workId)) {
|
|
|
+ if (!string.IsNullOrEmpty(study.workId))
|
|
|
+ {
|
|
|
HomeworkRecord homeworkRecord = homeworkRecords.Find(y => y.id.Equals(study.workId));
|
|
|
Attachment attachment = homeworkRecord != null ? homeworkRecord.content.Find(x => x.prime) : null;
|
|
|
record.haswork = 1;
|
|
@@ -602,7 +626,8 @@ namespace TEAMModelOS.SDK
|
|
|
workOk = true;
|
|
|
}
|
|
|
}
|
|
|
- if (studyRecord != null) {
|
|
|
+ if (studyRecord != null)
|
|
|
+ {
|
|
|
if (getAll)
|
|
|
{
|
|
|
record.hour = studyRecord.status == 1 ? study.hour : 0;
|
|
@@ -616,7 +641,8 @@ namespace TEAMModelOS.SDK
|
|
|
record.score = -1;
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
if (workOk && !string.IsNullOrEmpty(study.workId))
|
|
|
{
|
|
|
record.hour = studyRecord.status == 1 ? study.hour : 0;
|
|
@@ -636,7 +662,8 @@ namespace TEAMModelOS.SDK
|
|
|
record.hour = 0;
|
|
|
record.score = studyRecord.status;
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
record.hour = studyRecord.status == 1 ? study.hour : 0;
|
|
|
record.score = studyRecord.status;
|
|
|
if (record.score >= 0)
|
|
@@ -653,9 +680,9 @@ namespace TEAMModelOS.SDK
|
|
|
offlines.Add(record);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
//标记已经有需要提交作业的线下研修活动。则需要检查至少有一次的作业提交记录。否则不能获得学时。
|
|
|
- int sum = offlines.Select(x => x.hour).Sum();
|
|
|
+ int sum = offlines.Select(x => x.hour).Sum();
|
|
|
//if (haswork)
|
|
|
//{
|
|
|
// var workd= homeworkRecords.Where(z=>z.content.IsNotEmpty()).SelectMany(x => x.content).Where(y => y.prime);
|
|
@@ -672,9 +699,10 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
train.offlineTime = 0;
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
train.offlineTime = sum > setting.offlineTime ? setting.offlineTime : sum;
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
train.offlineRecords = offlines;
|
|
|
return train;
|
|
@@ -693,8 +721,12 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
string code = $"ClassVideo-{_school}";
|
|
|
ClassVideo classVideo = null;
|
|
|
- try { classVideo = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<ClassVideo>($"{_tmdid}", new PartitionKey(code));
|
|
|
- } catch (Exception ex) {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ classVideo = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<ClassVideo>($"{_tmdid}", new PartitionKey(code));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
classVideo = null;
|
|
|
}
|
|
|
if (classVideo != null && classVideo.files.IsNotEmpty())
|
|
@@ -711,21 +743,23 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
train.teacherClasses = new List<TeacherClass> { new Models.TeacherClass { url = files.url, score = files.score, hash = files.hash, name = files.name, size = files.size } };
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
train.classTime = 0;
|
|
|
}
|
|
|
return train;
|
|
|
}
|
|
|
-
|
|
|
- public static async Task<TeacherTrain> DoTeacherAbility(TeacherTrain train, AreaSetting setting,Area area , CosmosClient client,string _school,string _tmdid) {
|
|
|
+
|
|
|
+ public static async Task<TeacherTrain> DoTeacherAbility(TeacherTrain train, AreaSetting setting, Area area, CosmosClient client, string _school, string _tmdid)
|
|
|
+ {
|
|
|
//视频播放
|
|
|
- List<string> abilityIds = new List<string> ();
|
|
|
+ List<string> abilityIds = new List<string>();
|
|
|
TeacherFile file = null;
|
|
|
try
|
|
|
{
|
|
|
file = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<TeacherFile>(_tmdid, new PartitionKey($"TeacherFile-{_school}"));
|
|
|
}
|
|
|
- catch (CosmosException )
|
|
|
+ catch (CosmosException)
|
|
|
{
|
|
|
file = new TeacherFile
|
|
|
{
|
|
@@ -738,19 +772,20 @@ namespace TEAMModelOS.SDK
|
|
|
await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<TeacherFile>(file, new PartitionKey($"TeacherFile-{_school}"));
|
|
|
}
|
|
|
|
|
|
- List<AbilitySub> abilitySubs= new List<AbilitySub> ();
|
|
|
+ List<AbilitySub> abilitySubs = new List<AbilitySub>();
|
|
|
//认证材料
|
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher")
|
|
|
.GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{_school}-{_tmdid}") }))
|
|
|
{
|
|
|
abilitySubs.Add(item);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
List<Ability> abilities = new List<Ability>();
|
|
|
string insql = "";
|
|
|
- if (abilitySubs.IsNotEmpty()) {
|
|
|
- insql =$" where c.id in ({string.Join(",", abilitySubs.Select(o => $"'{o.id}'"))})";
|
|
|
-
|
|
|
+ if (abilitySubs.IsNotEmpty())
|
|
|
+ {
|
|
|
+ insql = $" where c.id in ({string.Join(",", abilitySubs.Select(o => $"'{o.id}'"))})";
|
|
|
+
|
|
|
}
|
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Normal")
|
|
|
.GetItemQueryIterator<Ability>(queryText: $"select c.comid, c.id,c.name,c.currency,c.no,c.dimension,c.hour,c.stds,c.abilityCount from c {insql} ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
|
|
@@ -758,8 +793,9 @@ namespace TEAMModelOS.SDK
|
|
|
abilities.Add(item);
|
|
|
|
|
|
}
|
|
|
- List<Debate> debates= new List<Debate>();
|
|
|
- if (abilities.IsNotEmpty()) {
|
|
|
+ List<Debate> debates = new List<Debate>();
|
|
|
+ if (abilities.IsNotEmpty())
|
|
|
+ {
|
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "School")
|
|
|
.GetItemQueryIterator<Debate>(queryText: $"select distinct value(c) from c join b in c.replies where b.tmdid='{_tmdid}'and c.source='uploadscore' and c.comid in ({string.Join(",", abilities.Select(o => $"'{o.comid}'"))})",
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Debate-{_school}") }))
|
|
@@ -767,16 +803,17 @@ namespace TEAMModelOS.SDK
|
|
|
debates.Add(item);
|
|
|
}
|
|
|
}
|
|
|
- Currency currency= new Currency();
|
|
|
+ Currency currency = new Currency();
|
|
|
Currency currencyAll = new Currency();
|
|
|
|
|
|
|
|
|
abilitySubs.ForEach(item => {
|
|
|
int currencyInt = item.from == 1 ? 1 : 0;
|
|
|
- Ability ability = abilities.Find(x=>x.id.Equals(item.id));
|
|
|
- if (ability != null) {
|
|
|
+ Ability ability = abilities.Find(x => x.id.Equals(item.id));
|
|
|
+ if (ability != null)
|
|
|
+ {
|
|
|
+
|
|
|
|
|
|
-
|
|
|
|
|
|
if (ability != null)
|
|
|
{
|
|
@@ -818,25 +855,28 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
|
|
|
List<TeacherHprecord> hprecords = new List<TeacherHprecord>();
|
|
|
- List<Debate> debateOrthers = debates.FindAll(x => x.comid.Equals(ability.comid) && x.replies.IsNotEmpty() );
|
|
|
+ List<Debate> debateOrthers = debates.FindAll(x => x.comid.Equals(ability.comid) && x.replies.IsNotEmpty());
|
|
|
int debateOrther = -1;
|
|
|
List<string> replyIds = new List<string>();
|
|
|
- if (debateOrthers.IsNotEmpty()) {
|
|
|
+ if (debateOrthers.IsNotEmpty())
|
|
|
+ {
|
|
|
debateOrther = debateOrthers.Count;
|
|
|
- var replies= debateOrthers.SelectMany(x => x.replies).Where(z => z.tmdid.Equals(_tmdid));
|
|
|
- if (replies != null && replies.Count() > 0) {
|
|
|
+ var replies = debateOrthers.SelectMany(x => x.replies).Where(z => z.tmdid.Equals(_tmdid));
|
|
|
+ if (replies != null && replies.Count() > 0)
|
|
|
+ {
|
|
|
replyIds = replies.Select(x => x.id).ToList();
|
|
|
}
|
|
|
}
|
|
|
TeacherAbility teacherAbility = new Models.TeacherAbility
|
|
|
- { replyIds = replyIds,
|
|
|
+ {
|
|
|
+ replyIds = replyIds,
|
|
|
debateOrther = debateOrther,
|
|
|
id = ability.id,
|
|
|
currency = currencyInt,
|
|
|
no = ability.no,
|
|
|
name = ability.name,
|
|
|
dimension = ability.dimension,
|
|
|
- zpscore = item.self==0?1:item.self,
|
|
|
+ zpscore = item.self == 0 ? 1 : item.self,
|
|
|
hprecord = hprecords,
|
|
|
uploadHas = item.uploads.Count
|
|
|
};
|
|
@@ -858,8 +898,8 @@ namespace TEAMModelOS.SDK
|
|
|
view = view > limit ? limit : view;
|
|
|
teacherAbility.videoTime = (int)view;
|
|
|
teacherAbility.limitTime = ability.hour;
|
|
|
- teacherAbility.onlineTime = (int)(view / setting.lessonMinutes);
|
|
|
-
|
|
|
+ teacherAbility.onlineTime = setting.lessonMinutes != 0 ? (int)(view / setting.lessonMinutes) : 0;
|
|
|
+
|
|
|
}
|
|
|
if (item.otherScore.IsNotEmpty())
|
|
|
{
|
|
@@ -911,7 +951,7 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
}
|
|
|
if (currencyInt == 1)
|
|
|
- {
|
|
|
+ {
|
|
|
currency.subCount += 1;
|
|
|
currency.uploadTotal += ability.stds.FindAll(x => x.task.IsNotEmpty()).Select(y => y.task).Count();
|
|
|
currency.teacherAilities.Add(teacherAbility);
|
|
@@ -924,12 +964,12 @@ namespace TEAMModelOS.SDK
|
|
|
train.currency = currency;
|
|
|
train.currencyAll = currencyAll;
|
|
|
train.currency.videoTime = train.currency.teacherAilities.Select(x => x.videoTime).Sum();
|
|
|
- train.currencyAll.videoTime= train.currencyAll.teacherAilities.Select(x => x.videoTime).Sum();
|
|
|
+ train.currencyAll.videoTime = train.currencyAll.teacherAilities.Select(x => x.videoTime).Sum();
|
|
|
//如果总分钟数超过20学时,则直接复制20学时。
|
|
|
- var videoTime = (int)(train.currency.videoTime / setting.lessonMinutes);
|
|
|
- train.onlineTime = videoTime > setting.onlineTime ? setting.onlineTime:videoTime;
|
|
|
+ var videoTime = setting.lessonMinutes != 0 ? (int)(train.currency.videoTime / setting.lessonMinutes) : 0;
|
|
|
+ train.onlineTime = videoTime > setting.onlineTime ? setting.onlineTime : videoTime;
|
|
|
var bhg = train.currency.teacherAilities.FindAll(x => x.xzscore > 0);
|
|
|
- if (bhg.IsNotEmpty()&& bhg.Count == train.currency.subCount)
|
|
|
+ if (bhg.IsNotEmpty() && bhg.Count == train.currency.subCount)
|
|
|
{
|
|
|
///要全部合格才能获得学时。
|
|
|
train.currency.submitTime = setting.submitTime;
|
|
@@ -937,6 +977,6 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
return train;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|