|
@@ -5,8 +5,11 @@ using Newtonsoft.Json.Linq;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
+using System.Threading.Tasks;
|
|
|
using TEAMModelOS.Helper.Common.FileHelper;
|
|
|
+using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
|
|
|
using TEAMModelOS.SDK.Extension.DataResult.JsonRpcResponse;
|
|
|
+using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
|
|
|
using TEAMModelOS.SDK.Helper.Common.DateTimeHelper;
|
|
|
using TEAMModelOS.SDK.Helper.Common.JsonHelper;
|
|
|
using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
|
|
@@ -75,7 +78,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
int Stus = 0;
|
|
|
ExamResult simple = new ExamResult();
|
|
|
ExamAnswer examAnswer = new ExamAnswer();
|
|
|
-
|
|
|
+
|
|
|
List<Student> students = new List<Student>();
|
|
|
List<Classroom> classrooms = new List<Classroom>();
|
|
|
//List<ExamAnswer> examAnswers = new List<ExamAnswer>();
|
|
@@ -93,12 +96,12 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
Itempoint.ForEach(p =>
|
|
|
{
|
|
|
string pt = p.point;
|
|
|
- string OpenTracing = p+"";
|
|
|
+ string OpenTracing = p + "";
|
|
|
JObject jArray = JObject.Parse(OpenTracing);
|
|
|
string queryOptions = "$.options[*]";
|
|
|
List<dynamic> itemOption = context.SelectNodes(jArray,
|
|
|
queryOptions).Select(node => node.Value).ToList();
|
|
|
- List<CodeValue> codeValues = new List<CodeValue> ();
|
|
|
+ List<CodeValue> codeValues = new List<CodeValue>();
|
|
|
itemOption.ToList<dynamic>().ForEach(i =>
|
|
|
{
|
|
|
CodeValue code = new CodeValue
|
|
@@ -137,16 +140,18 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
paper.item = items;
|
|
|
paper.subjectCode = "Subject_Math";
|
|
|
//基本信息
|
|
|
- info.ForEach(e => {
|
|
|
+ info.ForEach(e =>
|
|
|
+ {
|
|
|
simple.name = e.test_name;
|
|
|
simple.time = e.test_date;
|
|
|
paper.name = e.test_name;
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
|
|
|
School sc = null;
|
|
|
ExamInfo examInfo = null;
|
|
|
- SchoolInfo.ForEach(s => {
|
|
|
+ SchoolInfo.ForEach(s =>
|
|
|
+ {
|
|
|
string count = s.stucount;
|
|
|
string st = s.ex_time;
|
|
|
string ed = s.ex_endtime;
|
|
@@ -169,9 +174,10 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
name = s.ex_name,
|
|
|
type = s.ex_type,
|
|
|
startTime = time,
|
|
|
- endTime = edtime,
|
|
|
+ endTime = edtime,
|
|
|
stuCount = int.Parse(count),
|
|
|
- conditions = new Condition {
|
|
|
+ conditions = new Condition
|
|
|
+ {
|
|
|
period = "c3e1e95a-561e-fabf-cce3-3a564782e443",
|
|
|
grade = s.grade_name,
|
|
|
semester = s.semester,
|
|
@@ -206,8 +212,8 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
Dictionary<string, int[]> map = new Dictionary<string, int[]>();
|
|
|
int[] Range = new int[2];
|
|
|
//处理学生作答数据
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
for (int j = 0; j < 22; j++)
|
|
|
{
|
|
|
Student stus = new Student
|
|
@@ -225,7 +231,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
//学生ID集合
|
|
|
List<dynamic> studentIds = context.SelectNodes(jArray,
|
|
|
queryStu).Select(node => node.Value).ToList();
|
|
|
- List<double> point = new List<double>();
|
|
|
+ List<double> point = new List<double>();
|
|
|
if (answers.Count == 0)
|
|
|
{
|
|
|
StuIds.Add("0");
|
|
@@ -241,15 +247,17 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
//id = System.Guid.NewGuid().ToString();
|
|
|
stus.id = id.Trim();
|
|
|
stus.name = s.name;
|
|
|
- stus.studentId = id.Trim();
|
|
|
+ stus.studentId = id.Trim();
|
|
|
string sno = s.seatno;
|
|
|
if (sno.Equals(""))
|
|
|
{
|
|
|
stus.seatNo = 0;
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
stus.seatNo = int.Parse(sno);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//stus.classroom = classInfoOfStudent;
|
|
|
StuIds.Add(id.Trim());
|
|
|
});
|
|
@@ -263,7 +271,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
if (ans.Equals(""))
|
|
|
{
|
|
|
ansContent = "无";
|
|
|
- }
|
|
|
+ }
|
|
|
ans.Add(ansContent);
|
|
|
point.Add(double.Parse(pt.Trim()));
|
|
|
});
|
|
@@ -309,9 +317,9 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
{ "students",students},
|
|
|
{ "paperInfo",paper},
|
|
|
{ "examResult",simple},
|
|
|
- { "examAnswer",examAnswer}
|
|
|
+ { "examAnswer",examAnswer}
|
|
|
};
|
|
|
- azureBlobDB.UploadFileByContainer("analysis",keyValues.ToJson(),"exam",sc.schoolCode+examInfo.id+paper.subjectCode+".json");
|
|
|
+ azureBlobDB.UploadFileByContainer("analysis", keyValues.ToJson(), "exam", sc.schoolCode + examInfo.id + paper.subjectCode + ".json");
|
|
|
//_examInfoService.SaveToCosmos(simple);
|
|
|
//_cosmosrepository.Save(sc);
|
|
|
/*_cosmosrepository.Save(simple);
|
|
@@ -326,7 +334,114 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
//return builder.build();
|
|
|
}
|
|
|
|
|
|
+ [HttpGet("SaveExamToBlob")]
|
|
|
+ public async Task<BaseJosnRPCResponse> SendExam(JosnRPCRequest<Dictionary<string, object>> request)
|
|
|
+ {
|
|
|
+ JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
+ Student student = null;
|
|
|
+ List<Student> AnalysisStudents = new List<Student>();
|
|
|
+ ExamInfo examInfo = null;
|
|
|
+ ExamResult result = null;
|
|
|
+ if (request.@params.TryGetValue("id", out object id) && request.@params.TryGetValue("pk", out object pk))
|
|
|
+ {
|
|
|
+ examInfo = await _cosmosrepository.FindByIdPk<ExamInfo>(id.ToString(), pk.ToString());
|
|
|
+ //获取发布对象
|
|
|
+ if (request.@params.TryGetValue("schoolCode", out object schoolCode))
|
|
|
+ {
|
|
|
+ List<string> targetCode = examInfo.target;
|
|
|
+ List<ClassStudent> classroomStudents = await _cosmosrepository.FindByDict<ClassStudent>(new Dictionary<string, object> { { "id", targetCode } });
|
|
|
+ List<Student> students = await _cosmosrepository.FindByDict<Student>(
|
|
|
+ new Dictionary<string, object>() { { "classroomCode", targetCode }, { "code", schoolCode } },
|
|
|
+ new List<string> { "id", "name", "code", "seatNo", "studentId", "classroomCode" });
|
|
|
+ List<dynamic> stus = new List<dynamic>();
|
|
|
+ List<ClassStudent> newClassStudents = new List<ClassStudent>();
|
|
|
+ ///新增的学生
|
|
|
+ if (students.IsNotEmpty())
|
|
|
+ {
|
|
|
+ students.ForEach(x =>
|
|
|
+ {
|
|
|
+ if (!classroomStudents.Select(m => m.code).Contains(x.studentId))
|
|
|
+ {
|
|
|
+ newClassStudents.Add(new ClassStudent() { id = x.classroomCode, code = x.studentId });
|
|
|
+ }
|
|
|
+ var stu = new { x.id, x.name, x.code, x.seatNo, x.studentId, x.classroomCode };
|
|
|
+ stus.Add(stu);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ ///反射已存在的id信息
|
|
|
+ if (classroomStudents.IsNotEmpty())
|
|
|
+ {
|
|
|
+ ///处理冗余的id查询
|
|
|
+ List<string> ids = new List<string>();
|
|
|
+ classroomStudents.ForEach(x =>
|
|
|
+ {
|
|
|
+ if (!students.Select(m => m.studentId).Contains(x.code))
|
|
|
+ {
|
|
|
+ ids.Add(x.code);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ var sts = await _cosmosrepository.FindByDict<Student>(new Dictionary<string, object>() { { "studentId", ids.ToArray() } });
|
|
|
+ if (sts.IsNotEmpty())
|
|
|
+ {
|
|
|
+ sts.ForEach(x =>
|
|
|
+ {
|
|
|
+ var stu = new { x.id, x.name, x.code, x.seatNo, x.studentId, x.classroomCode };
|
|
|
+ stus.Add(stu);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //保存新增学生
|
|
|
+ if (newClassStudents.IsNotEmpty())
|
|
|
+ {
|
|
|
+ classroomStudents.AddRange(await _cosmosrepository.SaveOrUpdateAll(newClassStudents));
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理学生信息以便学情使用
|
|
|
+ int n = 1;
|
|
|
+ stus.ForEach(s => {
|
|
|
+ student = new Student
|
|
|
+ {
|
|
|
+ id = s[0],
|
|
|
+ name = s[1],
|
|
|
+ studentId = s[4],
|
|
|
+ seatNo = n,
|
|
|
+ classroomCode = s[5]
|
|
|
|
|
|
+ };
|
|
|
+ n++;
|
|
|
+ AnalysisStudents.Add(student);
|
|
|
+ });
|
|
|
+ //依次处理班级信息
|
|
|
+ targetCode.ForEach(c =>
|
|
|
+ {
|
|
|
+ int count = 0;
|
|
|
+ AnalysisStudents.ForEach(s => {
|
|
|
+ if (c.Equals(s.classroomCode))
|
|
|
+ {
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
+ });
|
|
|
+ result = new ExamResult
|
|
|
+ {
|
|
|
+ code = examInfo.id,
|
|
|
+ name = examInfo.name,
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ //return builder.Data(classroomStudents).Extend(new Dictionary<string, object> { { "students", stus }, { "count", stus.Count } }).build();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return builder.build();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return builder.build();
|
|
|
+ }
|
|
|
+ return builder.Data("").build();
|
|
|
+ }
|
|
|
}
|
|
|
}
|