|
@@ -66,45 +66,46 @@ namespace TEAMModelOS.Controllers
|
|
|
//清除作业
|
|
|
if (!request.@params.reset)
|
|
|
{
|
|
|
- //根据作业发布对象查找到每一个具体学生生成关联关系表 HomeWorkStudent
|
|
|
- List<Target> targets = request.@params.survey.target;
|
|
|
- List<SurveyRecord> surveykStudents = new List<SurveyRecord>();
|
|
|
- foreach (Target target in targets)
|
|
|
+ //查询之前是否有 关联关系表 HomeWorkStudent 有则删除
|
|
|
+ List<SurveyRecord> surveyRecords = await azureCosmosDBV3Repository.FindByDict<SurveyRecord>(new Dictionary<string, object> { { "id", request.@params.survey.id } });
|
|
|
+ if (surveyRecords.IsNotEmpty())
|
|
|
{
|
|
|
- //查询之前是否有 关联关系表 HomeWorkStudent 有则删除
|
|
|
- List<SurveyRecord> surveyRecords = await azureCosmosDBV3Repository.FindByDict<SurveyRecord>(new Dictionary<string, object> { { "id", request.@params.survey.id } });
|
|
|
-
|
|
|
- if (surveyRecords.IsNotEmpty())
|
|
|
- {
|
|
|
- await azureCosmosDBV3Repository.DeleteAll(surveyRecords);
|
|
|
- }
|
|
|
- List<ClassStudent> classroom = await azureCosmosDBV3Repository.FindByDict<ClassStudent>(new Dictionary<string, object> { { "id", target.classroomCode } });
|
|
|
- if (classroom.IsNotEmpty() && classroom[0].code != null)
|
|
|
- {
|
|
|
- foreach (ClassStudent student in classroom)
|
|
|
- {
|
|
|
- SurveyRecord surveyStudent = new SurveyRecord();
|
|
|
- surveyStudent.id = request.@params.survey.id;
|
|
|
- surveyStudent.code = student.code;
|
|
|
- surveyStudent.classroom.code = target.classroomCode;
|
|
|
- surveyStudent.classroom.name = target.classroomName;
|
|
|
- surveykStudents.Add(surveyStudent);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (surveykStudents.IsNotEmpty())
|
|
|
- {
|
|
|
- foreach (SurveyRecord surveyRecord in surveykStudents)
|
|
|
- {
|
|
|
- List<Student> student = await azureCosmosDBV3Repository.FindById<Student>(surveyRecord.code);
|
|
|
- if (student.IsNotEmpty())
|
|
|
- {
|
|
|
- surveyRecord.name = student[0].name;
|
|
|
- surveyRecord.code = student[0].TEAMModelId;
|
|
|
- }
|
|
|
- }
|
|
|
- await azureCosmosDBV3Repository.SaveOrUpdateAll(surveykStudents);
|
|
|
+ await azureCosmosDBV3Repository.DeleteAll(surveyRecords);
|
|
|
}
|
|
|
+
|
|
|
+ ////根据作业发布对象查找到每一个具体学生生成关联关系表 HomeWorkStudent
|
|
|
+ //List<Target> targets = request.@params.survey.target;
|
|
|
+ //List<SurveyRecord> surveykStudents = new List<SurveyRecord>();
|
|
|
+ //foreach (Target target in targets)
|
|
|
+ //{
|
|
|
+
|
|
|
+ // List<ClassStudent> classroom = await azureCosmosDBV3Repository.FindByDict<ClassStudent>(new Dictionary<string, object> { { "id", target.classroomCode } });
|
|
|
+ // if (classroom.IsNotEmpty() && classroom[0].code != null)
|
|
|
+ // {
|
|
|
+ // foreach (ClassStudent student in classroom)
|
|
|
+ // {
|
|
|
+ // SurveyRecord surveyStudent = new SurveyRecord();
|
|
|
+ // surveyStudent.id = request.@params.survey.id;
|
|
|
+ // surveyStudent.code = student.code;
|
|
|
+ // surveyStudent.classroom.code = target.classroomCode;
|
|
|
+ // surveyStudent.classroom.name = target.classroomName;
|
|
|
+ // surveykStudents.Add(surveyStudent);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ //if (surveykStudents.IsNotEmpty())
|
|
|
+ //{
|
|
|
+ // foreach (SurveyRecord surveyRecord in surveykStudents)
|
|
|
+ // {
|
|
|
+ // List<Student> student = await azureCosmosDBV3Repository.FindById<Student>(surveyRecord.code);
|
|
|
+ // if (student.IsNotEmpty())
|
|
|
+ // {
|
|
|
+ // surveyRecord.name = student[0].name;
|
|
|
+ // surveyRecord.code = student[0].TEAMModelId;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // await azureCosmosDBV3Repository.SaveOrUpdateAll(surveykStudents);
|
|
|
+ //}
|
|
|
}
|
|
|
return builder.Data(homeWork).build();
|
|
|
}
|