|
@@ -488,45 +488,95 @@ namespace TEAMModelOS.SDK
|
|
|
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()) {
|
|
|
+ workidSubmits.Add(item.id);
|
|
|
+ }
|
|
|
homeworkRecords.Add(item);
|
|
|
}
|
|
|
//标记已经有需要提交作业的线下研修活动。则需要检查至少有一次的作业提交记录。否则不能获得学时。
|
|
|
haswork = true;
|
|
|
}
|
|
|
+ //如果交了至少一份作业
|
|
|
+ //一份作业都没有交
|
|
|
|
|
|
- List<OfflineRecord> offlines = new List<OfflineRecord>();
|
|
|
+ //标记是否计算所有学时。
|
|
|
+ bool getAll= false;
|
|
|
+ if (haswork)
|
|
|
+ {
|
|
|
+ //如果有作业就需要检查是否至少交了一份作业。 如果交了一份,并且通过了,则可以计算全部。具体查看mark qweorrty
|
|
|
+ getAll = false;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //如果没有作业,则计算全部学时。
|
|
|
+ getAll= true;
|
|
|
+ }
|
|
|
activities.ForEach(item => {
|
|
|
- Study study = studies.Find(y => y.id.Equals(item.id));
|
|
|
+ Study study = studies.Find(y => y.id.Equals(item.id) && !string.IsNullOrEmpty(y.workId));
|
|
|
if (study != null) {
|
|
|
+ StudyRecord studyRecord = studyRecords.Find(y => y.id.Equals(item.id));
|
|
|
+ if (studyRecord!=null && studyRecord.status > 0) {
|
|
|
+ //mark qweorrty
|
|
|
+ var submit = workidSubmits.Find(y => y.Equals(study.workId));
|
|
|
+ if (submit != null) {
|
|
|
+ getAll = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<OfflineRecord> offlines = new List<OfflineRecord>();
|
|
|
+
|
|
|
+ activities.ForEach(item =>
|
|
|
+ {
|
|
|
+ Study study = studies.Find(y => y.id.Equals(item.id));
|
|
|
+ if (study != null)
|
|
|
+ {
|
|
|
StudyRecord studyRecord = studyRecords.Find(y => y.id.Equals(item.id));
|
|
|
OfflineRecord record = new OfflineRecord
|
|
|
{
|
|
|
id = item.id,
|
|
|
name = item.name,
|
|
|
done = item.taskStatus,
|
|
|
- owner = item.owner
|
|
|
+ owner = item.owner,
|
|
|
+ sethour=study.hour
|
|
|
};
|
|
|
- record.sethour = study.hour;
|
|
|
- if (!string.IsNullOrEmpty(study.workId))
|
|
|
- {
|
|
|
+ bool workOk = false;
|
|
|
+ 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;
|
|
|
- //有作业的必须检查有没有提交作业,只有提交作业通过才能统计获得学时。
|
|
|
if (null != attachment)
|
|
|
{
|
|
|
record.url = attachment.url;
|
|
|
record.upload = 1;
|
|
|
record.hash = attachment.hash;
|
|
|
record.size = attachment.size;
|
|
|
- if (null != studyRecord)
|
|
|
+ workOk = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (studyRecord != null) {
|
|
|
+ if (getAll)
|
|
|
+ {
|
|
|
+ record.hour = studyRecord.status == 1 ? study.hour : 0;
|
|
|
+ record.score = studyRecord.status;
|
|
|
+ if (record.score >= 0)
|
|
|
+ {
|
|
|
+ record.done = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ record.score = -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (workOk && !string.IsNullOrEmpty(study.workId))
|
|
|
{
|
|
|
- //通过获得学时
|
|
|
record.hour = studyRecord.status == 1 ? study.hour : 0;
|
|
|
record.score = studyRecord.status;
|
|
|
if (record.score >= 0)
|
|
@@ -538,52 +588,53 @@ namespace TEAMModelOS.SDK
|
|
|
record.score = -1;
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //没有作业的 可以直接统计通过获得学时
|
|
|
- if (null != studyRecord)
|
|
|
- {
|
|
|
- //通过获得学时
|
|
|
- record.hour = studyRecord.status == 1 ? study.hour : 0;
|
|
|
- record.score = studyRecord.status;
|
|
|
- if (record.score >= 0)
|
|
|
+ else if (!workOk && !string.IsNullOrEmpty(study.workId))
|
|
|
{
|
|
|
- record.done = 1;
|
|
|
+ //没有交任何作业,即使通过,也不会获得学时。
|
|
|
+ record.hour = 0;
|
|
|
+ record.score = studyRecord.status;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- record.score = -1;
|
|
|
+ else {
|
|
|
+ record.hour = studyRecord.status == 1 ? study.hour : 0;
|
|
|
+ record.score = studyRecord.status;
|
|
|
+ if (record.score >= 0)
|
|
|
+ {
|
|
|
+ record.done = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ record.score = -1;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
offlines.Add(record);
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
//标记已经有需要提交作业的线下研修活动。则需要检查至少有一次的作业提交记录。否则不能获得学时。
|
|
|
- int sum = 0;
|
|
|
- if (haswork)
|
|
|
+ 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);
|
|
|
+ // if (workd != null && workd.Count() > 0) {
|
|
|
+ // sum = offlines.Select(x => x.hour).Sum();
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // sum = offlines.Select(x => x.hour).Sum();
|
|
|
+ //}
|
|
|
+ //有作业,且没有交任何作业。
|
|
|
+ if (workidSubmits.IsEmpty() && haswork)
|
|
|
{
|
|
|
- var workd= homeworkRecords.Where(z=>z.content.IsNotEmpty()).SelectMany(x => x.content).Where(y => y.prime);
|
|
|
- if (workd != null && workd.Count() > 0) {
|
|
|
- sum = offlines.Select(x => x.hour).Sum();
|
|
|
- }
|
|
|
+ train.offlineTime = 0;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- sum = offlines.Select(x => x.hour).Sum();
|
|
|
+ else {
|
|
|
+ train.offlineTime = sum > setting.offlineTime ? setting.offlineTime : sum;
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
- train.offlineTime =sum >setting.offlineTime?setting.offlineTime: sum;
|
|
|
- train.offlineRecords= offlines;
|
|
|
+ train.offlineRecords = offlines;
|
|
|
return train;
|
|
|
}
|
|
|
/// <summary>
|