|
|
@ -1,4 +1,5 @@ |
|
|
|
using NPOI.SS.UserModel; |
|
|
|
using NPOI.SS.UserModel; |
|
|
|
|
|
|
|
using System.Net; |
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
namespace Tiobon.Core.Services; |
|
|
@ -1408,6 +1409,57 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins |
|
|
|
|
|
|
|
|
|
|
|
var data = DbAccess.QueryList<CourseAndScene>(sql1); |
|
|
|
var data = DbAccess.QueryList<CourseAndScene>(sql1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < data.Count; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
data[i].RequiredCount = await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
|
|
|
.Where(x => (x.CourseSceneId == data[i].Id || x.CourseId == data[i].Id) && x.OpenClassId == null && x.CourseType.Contains("Required")) |
|
|
|
|
|
|
|
.CountAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data[i].ElectiveCount = await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
|
|
|
.Where(x => (x.CourseSceneId == data[i].Id || x.CourseId == data[i].Id) && x.OpenClassId == null && x.CourseType.Contains("Elective")) |
|
|
|
|
|
|
|
.CountAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data[i].OpenClassCount = await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
|
|
|
.Where(x => (x.CourseSceneId == data[i].Id || x.CourseId == data[i].Id) && x.OpenClassId != null) |
|
|
|
|
|
|
|
.CountAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data[i].CompleteCount = await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
|
|
|
.Where(x => (x.CourseSceneId == data[i].Id || x.CourseId == data[i].Id) && x.CompleteStatus == DIC_STUDY_RECORD_STUDY_COMPLETE_STATUS.FINISHED) |
|
|
|
|
|
|
|
.CountAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var studyRecordIds = await Db.Queryable<Ghre_StudyRecord>() |
|
|
|
|
|
|
|
.Where(x => x.CourseSceneId == data[i].Id || x.CourseId == data[i].Id) |
|
|
|
|
|
|
|
.Select(x => x.Id) |
|
|
|
|
|
|
|
.ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data[i].TotalStudyDuration = await Db.Queryable<Ghre_StudyRecordDetail>() |
|
|
|
|
|
|
|
.Where(x => x.StudyRecordId != null && studyRecordIds.Contains(x.StudyRecordId.Value)) |
|
|
|
|
|
|
|
.SumAsync(x => x.StudyDuration); |
|
|
|
|
|
|
|
data[i].TotalStudyDuration = data[i].TotalStudyDuration ?? 0; |
|
|
|
|
|
|
|
if (data[i].TotalStudyDuration > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var avgStudyDuration = data[i].TotalStudyDuration / (studyRecordIds.Count); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data[i].AvgStudyDuration = avgStudyDuration.TrimDecimalString(2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data[i].AvgScore = await Db.Queryable<Ghre_ExamRecord>() |
|
|
|
|
|
|
|
.Where(x => x.StudyRecordId != null && studyRecordIds.Contains(x.StudyRecordId.Value)) |
|
|
|
|
|
|
|
.AvgAsync(x => x.Score); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data[i].AvgScore = data[i].AvgScore ?? 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var examCount = await Db.Queryable<Ghre_ExamRecord>() |
|
|
|
|
|
|
|
.Where(x => x.StudyRecordId != null && studyRecordIds.Contains(x.StudyRecordId.Value)) |
|
|
|
|
|
|
|
.CountAsync(); |
|
|
|
|
|
|
|
var passCount = await Db.Queryable<Ghre_ExamRecord>() |
|
|
|
|
|
|
|
.Where(x => x.StudyRecordId != null && studyRecordIds.Contains(x.StudyRecordId.Value) && x.IsPass == true) |
|
|
|
|
|
|
|
.CountAsync(); |
|
|
|
|
|
|
|
if (passCount > 0 && examCount > 0) |
|
|
|
|
|
|
|
data[i].PassPercent = passCount / examCount; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
totalCount = await Db.Ado.GetIntAsync("SELECT COUNT(0) from Ghre_CourseScene_V A WHERE 1=1"); |
|
|
|
totalCount = await Db.Ado.GetIntAsync("SELECT COUNT(0) from Ghre_CourseScene_V A WHERE 1=1"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1615,6 +1667,7 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < questionErrorRankings.Count; i++) |
|
|
|
for (int i = 0; i < questionErrorRankings.Count; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
questionErrorRankings[i].QuestionContent = WebUtility.HtmlDecode(questionErrorRankings[i].QuestionContent); |
|
|
|
questionErrorRankings[i].TotalCount = recordDetails.Where(x => x.QuestionId == questionErrorRankings[i].Id).Count(); |
|
|
|
questionErrorRankings[i].TotalCount = recordDetails.Where(x => x.QuestionId == questionErrorRankings[i].Id).Count(); |
|
|
|
questionErrorRankings[i].ErrorCount = recordDetails.Where(x => x.QuestionId == questionErrorRankings[i].Id && x.IsCorrect != true).Count(); |
|
|
|
questionErrorRankings[i].ErrorCount = recordDetails.Where(x => x.QuestionId == questionErrorRankings[i].Id && x.IsCorrect != true).Count(); |
|
|
|
|
|
|
|
|
|
|
|