|
@@ -19,6 +19,7 @@ using TEAMModelOS.SDK;
|
|
|
using TEAMModelOS.SDK.DI;
|
|
|
using TEAMModelOS.SDK.Extension;
|
|
|
using TEAMModelOS.SDK.Models;
|
|
|
+using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
|
|
|
|
|
|
namespace HTEX.Lib.ETL.Lesson
|
|
|
{
|
|
@@ -31,7 +32,7 @@ namespace HTEX.Lib.ETL.Lesson
|
|
|
/// <param name="azureStorage"></param>
|
|
|
/// <param name="lessonLocal"></param>
|
|
|
/// <returns></returns>
|
|
|
- public static async Task DoStudentLessonData(List<string> objectiveTypes, AzureStorageFactory azureStorage, LessonLocal? lessonLocal)
|
|
|
+ public static async Task DoStudentLessonData(List<string> objectiveTypes, AzureStorageFactory azureStorage, LessonLocal lessonLocal,DingDing _dingDing)
|
|
|
{
|
|
|
List<StudentLessonData> studentLessonDatas = lessonLocal.studentLessonDatas.ToJsonString().ToObject<List<StudentLessonData>>();
|
|
|
studentLessonDatas = LessonETLService.GetBaseInfo(lessonLocal.lessonBase!, studentLessonDatas, lessonLocal?.lessonRecord?.id);
|
|
@@ -42,11 +43,32 @@ namespace HTEX.Lib.ETL.Lesson
|
|
|
studentLessonDatas = LessonETLService.GetTaskData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.taskDatas, studentLessonDatas, lessonLocal.lessonRecord.id);
|
|
|
var pickupData = LessonETLService.GetPickupData(lessonLocal.lessonBase!, lessonLocal. timeLineData!, studentLessonDatas, lessonLocal.lessonRecord.id);
|
|
|
studentLessonDatas= pickupData.studentLessonDatas;
|
|
|
+
|
|
|
+ LessonDataAnalysisCluster lessonDataAnalysis = null ;
|
|
|
string owner = lessonLocal.lessonRecord.scope.Equals("school") ? lessonLocal.lessonRecord.school : lessonLocal.lessonRecord.tmdid;
|
|
|
- if (!azureStorage.GetBlobContainerClient(owner).GetBlobClient($"records/{lessonLocal.lessonRecord.id}/student-analysis.json").Exists())
|
|
|
+ try
|
|
|
{
|
|
|
- await azureStorage.GetBlobContainerClient(owner).UploadFileByContainer(studentLessonDatas.ToJsonString(), "records", $"{lessonLocal.lessonRecord.id}/student-analysis.json");
|
|
|
+ bool exists= await azureStorage.GetBlobContainerClient("0-public").GetBlobClient($"/lesson/analysis/analysis.json").ExistsAsync();
|
|
|
+ if (exists)
|
|
|
+ {
|
|
|
+ BlobDownloadResult blobDownload = await azureStorage.GetBlobContainerClient("0-public").GetBlobClient($"/lesson/analysis/analysis.json").DownloadContentAsync();
|
|
|
+ lessonDataAnalysis = blobDownload.Content.ToObjectFromJson<LessonDataAnalysisCluster>();
|
|
|
+ var lessonItems = LessonETLService.ProcessStudentDataV2(studentLessonDatas, lessonDataAnalysis);
|
|
|
+ XmlDocument xmlDocument = new XmlDocument();
|
|
|
+ var runtimePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
|
|
+ xmlDocument.Load($"{runtimePath}\\summary.xml");
|
|
|
+ await LessonETLService.ExportToExcelAzureBlob(lessonItems,azureStorage, owner,$"{lessonLocal.lessonRecord.id}/student-analysis.xlsx", xmlDocument);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ if (!ex.Message.Contains("The specified blob does not exist"))
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},lesson/analysis/analysis.json转换异常,{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ }
|
|
|
}
|
|
|
+ await azureStorage.GetBlobContainerClient(owner).UploadFileByContainer(studentLessonDatas.ToJsonString(), "records", $"{lessonLocal.lessonRecord.id}/student-analysis.json");
|
|
|
+
|
|
|
}
|
|
|
public static void GenAnalysisData(string pathAnalysis, long newest, List<TechCount> techCounts)
|
|
|
{
|
|
@@ -1710,6 +1732,12 @@ namespace HTEX.Lib.ETL.Lesson
|
|
|
//排名 = (积分 - 最低积分) / (最高积分 - 最低积分) * (最大排名 - 最小排名) + 最小排名
|
|
|
return x==0 ? 0 : max-min!=0 ? (x - min)*1.0 / (max - min) * (maxRank - minRank) + minRank : (x)*1.0 / (max) * (maxRank - minRank) + minRank;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 处理学生课中数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="studentLessonDatas"></param>
|
|
|
+ /// <param name="lessonDataAnalysis"></param>
|
|
|
+ /// <returns></returns>
|
|
|
public static List<StudentLessonItem> ProcessStudentDataV2(List<StudentLessonData> studentLessonDatas, LessonDataAnalysisCluster lessonDataAnalysis)
|
|
|
{
|
|
|
|
|
@@ -1725,6 +1753,9 @@ namespace HTEX.Lib.ETL.Lesson
|
|
|
foreach (var studentLessonData in studentLessonDatas)
|
|
|
{
|
|
|
StudentLessonItem lessonItem = new StudentLessonItem() { studentId= studentLessonData.id! };
|
|
|
+ if (studentLessonData.id.Equals("1529649295")) {
|
|
|
+ int s1 = 1;
|
|
|
+ }
|
|
|
double u = 0.0;
|
|
|
if (studentLessonData.attend==1)
|
|
|
{
|
|
@@ -1735,7 +1766,7 @@ namespace HTEX.Lib.ETL.Lesson
|
|
|
//本节课教师手动给学生的个人计分
|
|
|
var s = studentLessonData.pscore;
|
|
|
//个人计分指数
|
|
|
- double c = GetPersent(lessonDataAnalysis.pscore, s).persent/100;// s*1.0/max_q;
|
|
|
+ double c = GetPersent(lessonDataAnalysis.pscore, s).persent;// s*1.0/max_q;
|
|
|
{
|
|
|
//互动相关的计分
|
|
|
//课例互动次数
|
|
@@ -1795,9 +1826,42 @@ namespace HTEX.Lib.ETL.Lesson
|
|
|
//c+a= 个人计分指数+ 个人互动成效指数
|
|
|
//互动成效
|
|
|
var f1 = Math.Round(190*1.0/(1+Math.Exp(-(a*m)))-95, 4);
|
|
|
- //如果有互动计分,则互动成效指数取0.8 0.2
|
|
|
- f1=f1*0.8+d*0.2+c*0.4;
|
|
|
- if (f1>95) { f1=95; }
|
|
|
+ if (f1==0)
|
|
|
+ {
|
|
|
+ if (d>0 && c==0)
|
|
|
+ {
|
|
|
+ f1=d*0.6;
|
|
|
+ }
|
|
|
+ else if (d==0 && c>0)
|
|
|
+ {
|
|
|
+ f1=c*0.6;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ f1=(d*0.6+c*0.6)/2;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //如果有互动计分,则互动成效指数取0.8 0.2
|
|
|
+ var dy = (95-f1)/95/2;
|
|
|
+ if (dy>0.2)
|
|
|
+ {
|
|
|
+ dy=0.2;
|
|
|
+ }
|
|
|
+ if (dy<0.1) {
|
|
|
+ dy=0.1;
|
|
|
+ }
|
|
|
+
|
|
|
+ f1=f1*(dy>0.1? 1-dy : 1-dy*2)+d*dy+c*dy;
|
|
|
+
|
|
|
+ }
|
|
|
+ if (f1>95)
|
|
|
+ {
|
|
|
+ f1=95;
|
|
|
+ }
|
|
|
+
|
|
|
//var f1 = Math.Round(a*m);
|
|
|
lessonItem.hd_cx=f1;
|
|
|
|
|
@@ -1914,7 +1978,17 @@ namespace HTEX.Lib.ETL.Lesson
|
|
|
groupType+=1;
|
|
|
lessonItem.xz_sc=groupTasks.Count();
|
|
|
}
|
|
|
- var fxGrp = (pickRate+coworkRate+gscoreRate+groupTask)/groupType;
|
|
|
+ double fxGrp = 0;
|
|
|
+ if (groupType>0) {
|
|
|
+ fxGrp = (pickRate+coworkRate+gscoreRate+groupTask)/groupType; }
|
|
|
+ if (groupType==2 &&(pickRate>0 && gscoreRate>0) )
|
|
|
+ {
|
|
|
+ fxGrp = (pickRate*0.8+coworkRate+gscoreRate*0.8+groupTask)/groupType;
|
|
|
+ }
|
|
|
+ if (groupType==1)
|
|
|
+ {
|
|
|
+ fxGrp=(pickRate+coworkRate+gscoreRate+groupTask)*0.8/groupType;
|
|
|
+ }
|
|
|
lessonItem.hz_nl=fxGrp;
|
|
|
}
|
|
|
{
|
|
@@ -2047,8 +2121,10 @@ namespace HTEX.Lib.ETL.Lesson
|
|
|
{
|
|
|
avg_cx+=1;
|
|
|
}
|
|
|
- xx_cx+=lessonItem.hd_cx * 1.0/avg_cx+ lessonItem.pc_df* 1.0/avg_cx+ lessonItem.rw_cx* 1.0/avg_cx+ lessonItem.pj_nl* 1.0/avg_cx+ lessonItem.xz_cx* 1.0/avg_cx+ lessonItem.hz_nl* 1.0/avg_cx;
|
|
|
-
|
|
|
+ if (avg_cx>0)
|
|
|
+ {
|
|
|
+ xx_cx+=lessonItem.hd_cx * 1.0/avg_cx+ lessonItem.pc_df* 1.0/avg_cx+ lessonItem.rw_cx* 1.0/avg_cx+ lessonItem.pj_nl* 1.0/avg_cx+ lessonItem.xz_cx* 1.0/avg_cx+ lessonItem.hz_nl* 1.0/avg_cx;
|
|
|
+ }
|
|
|
if (lessonItem.xz_cy>0)
|
|
|
{
|
|
|
avg_cy+=1;
|
|
@@ -2073,10 +2149,18 @@ namespace HTEX.Lib.ETL.Lesson
|
|
|
{
|
|
|
avg_cy+=1;
|
|
|
}
|
|
|
- xx_cy+=lessonItem.hd_cy * 1.0/avg_cy+ lessonItem.pc_zd* 1.0/avg_cy+ lessonItem.rw_cy* 1.0/avg_cy+ lessonItem.pj_nl* 1.0/avg_cy+ lessonItem.xz_cy* 1.0/avg_cy+ lessonItem.hz_nl* 1.0/avg_cy;
|
|
|
+ if (avg_cy>0)
|
|
|
+ {
|
|
|
+ xx_cy+=lessonItem.hd_cy * 1.0/avg_cy+ lessonItem.pc_zd* 1.0/avg_cy+ lessonItem.rw_cy* 1.0/avg_cy+ lessonItem.pj_nl* 1.0/avg_cy+ lessonItem.xz_cy* 1.0/avg_cy+ lessonItem.hz_nl* 1.0/avg_cy;
|
|
|
+ }
|
|
|
lessonItem.xx_cx=xx_cx;
|
|
|
lessonItem.xx_cy=xx_cy;
|
|
|
lessonItems.Add(lessonItem);
|
|
|
+ studentLessonData.achieve= lessonItem.xx_cx;
|
|
|
+ studentLessonData.attitude= lessonItem.xx_cy;
|
|
|
+ studentLessonData.appraise= lessonItem.pj_nl;
|
|
|
+ studentLessonData.cowork= lessonItem.xz_cx;
|
|
|
+ studentLessonData.cooperation=lessonItem.hz_nl;
|
|
|
}
|
|
|
return lessonItems;
|
|
|
}
|
|
@@ -2117,12 +2201,61 @@ namespace HTEX.Lib.ETL.Lesson
|
|
|
return datas;
|
|
|
}
|
|
|
/// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="items"></param>
|
|
|
+ /// <param name="filePath"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static async Task ExportToExcelAzureBlob(List<StudentLessonItem> items, AzureStorageFactory azureStorage,string owner , string path , XmlDocument xmlDocument)
|
|
|
+ {
|
|
|
+ ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial;
|
|
|
+ using (var memoryStream = new MemoryStream())
|
|
|
+ {
|
|
|
+ using (ExcelPackage package = new ExcelPackage())
|
|
|
+ {
|
|
|
+ ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("学生课中数据");
|
|
|
+
|
|
|
+ // 获取类的属性
|
|
|
+ PropertyInfo[] properties = typeof(StudentLessonItem).GetProperties();
|
|
|
+
|
|
|
+ // 添加表头
|
|
|
+ int currentRow = 1;
|
|
|
+ for (int i = 0; i < properties.Length; i++)
|
|
|
+ {
|
|
|
+
|
|
|
+ string summary = Regex.Replace(GetPropertySummary(properties[i], xmlDocument), @"\s+", "");
|
|
|
+ worksheet.Cells[currentRow, i + 1].Value = summary;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 填充数据
|
|
|
+ currentRow = 2;
|
|
|
+ foreach (var item in items)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < properties.Length; i++)
|
|
|
+ {
|
|
|
+ worksheet.Cells[currentRow, i + 1].Value = properties[i].GetValue(item);
|
|
|
+ }
|
|
|
+ currentRow++;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置表格样式
|
|
|
+ worksheet.Cells[worksheet.Dimension.Address].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Left;
|
|
|
+ worksheet.Cells[worksheet.Dimension.Address].Style.VerticalAlignment = OfficeOpenXml.Style.ExcelVerticalAlignment.Top;
|
|
|
+
|
|
|
+ // 保存到文件流
|
|
|
+ await package.SaveAsAsync(memoryStream);
|
|
|
+ memoryStream.Position=0;
|
|
|
+ }
|
|
|
+ await azureStorage.GetBlobContainerClient(owner).UploadFileByContainer(memoryStream, "records", path);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
/// 导出Excel
|
|
|
/// </summary>
|
|
|
/// <param name="items"></param>
|
|
|
/// <param name="filePath"></param>
|
|
|
/// <returns></returns>
|
|
|
- public static async Task ExportToExcel(List<StudentLessonItem> items, string filePath, XmlDocument xmlDocument)
|
|
|
+ public static async Task ExportToExcelLocal(List<StudentLessonItem> items, string filePath, XmlDocument xmlDocument)
|
|
|
{
|
|
|
ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial;
|
|
|
using (ExcelPackage package = new ExcelPackage())
|