|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
|
using Microsoft.IdentityModel.Tokens; |
|
|
|
|
using MongoDB.Driver.Linq; |
|
|
|
|
using NPOI.HSSF.UserModel; |
|
|
|
|
using NPOI.SS.UserModel; |
|
|
|
@ -1538,13 +1539,39 @@ WHERE A.Id = '{id}'"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var details = await Db.Queryable<Ghre_StudyRecordDetail>() |
|
|
|
|
.Where(x => x.StudyRecordId == id) |
|
|
|
|
.GroupBy(x => new { x.CourseWareAttachmentId, x.CourseWareId }) |
|
|
|
|
.Select(x => new |
|
|
|
|
{ |
|
|
|
|
x.CourseWareAttachmentId, |
|
|
|
|
x.CourseWareId, |
|
|
|
|
StudyDuration = SqlFunc.AggregateSumNoNull(x.StudyDuration) |
|
|
|
|
}) |
|
|
|
|
.ToListAsync(); |
|
|
|
|
|
|
|
|
|
for (int j = 0; j < course.CourseWareList.Count; j++) |
|
|
|
|
{ |
|
|
|
|
var attachments = await Db.Queryable<Ghre_CourseWareAttachment>().Where(x => x.CourseWareId == course.CourseWareList[j].Id).ToListAsync(); |
|
|
|
|
course.CourseWareList[j].Attachments = attachments.Where(x => x.AttachFileExtension != "http").OrderBy(x => x.SortNo).ToList(); |
|
|
|
|
|
|
|
|
|
var attachmentDtos = attachments.Where(x => x.AttachFileExtension != "http").OrderBy(x => x.SortNo).ToList(); |
|
|
|
|
|
|
|
|
|
course.CourseWareList[j].Attachments = Mapper.Map(attachmentDtos).ToANew<List<Ghre_CourseWareAttachmentDto>>(); |
|
|
|
|
if (course.CourseWareList[j].Attachments != null && course.CourseWareList[j].Attachments.Any()) |
|
|
|
|
course.CourseWareList[j].Attachments.ForEach(x => x.RelativePath = "/Advanced" + x.RelativePath); |
|
|
|
|
|
|
|
|
|
course.CourseWareList[j].Attachments.ForEach(x => |
|
|
|
|
{ |
|
|
|
|
x.HasLearnDuration = details.FirstOrDefault(o => o.CourseWareAttachmentId == x.Id)?.StudyDuration ?? 0; |
|
|
|
|
if (x.HasLearnDuration != 0 && x.LearnDuration != 0) |
|
|
|
|
{ |
|
|
|
|
x.HasLearnPercent = (x.HasLearnDuration / x.LearnDuration) * 100; |
|
|
|
|
if (x.HasLearnPercent > 100) |
|
|
|
|
x.HasLearnPercent = 100; |
|
|
|
|
x.HasLearnPercent = x.HasLearnPercent.RemoveZero().ObjToDecimal(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
course.CourseWareList[j].Links = attachments |
|
|
|
|
.Where(x => x.AttachFileExtension == "http") |
|
|
|
|
.OrderBy(x => x.SortNo) |
|
|
|
@ -1553,7 +1580,20 @@ WHERE A.Id = '{id}'"; |
|
|
|
|
Id = x.Id, |
|
|
|
|
LinkName = x.AttachmentName, |
|
|
|
|
LinkAddress = x.RelativePath, |
|
|
|
|
LearnDuration = x.LearnDuration |
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
course.CourseWareList[j].Links.ForEach(x => |
|
|
|
|
{ |
|
|
|
|
x.HasLearnDuration = details.FirstOrDefault(o => o.CourseWareAttachmentId == x.Id)?.StudyDuration ?? 0; |
|
|
|
|
if (x.HasLearnDuration != 0 && x.LearnDuration != 0) |
|
|
|
|
{ |
|
|
|
|
x.HasLearnPercent = (x.HasLearnDuration / x.LearnDuration) * 100; |
|
|
|
|
if (x.HasLearnPercent > 100) |
|
|
|
|
x.HasLearnPercent = 100; |
|
|
|
|
x.HasLearnPercent = x.HasLearnPercent.RemoveZero().ObjToDecimal(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (course.CourseBeginTime != null && course.CourseEndTime != null) |
|
|
|
|