|
@@ -35,12 +35,12 @@ namespace TEAMModelOS.Controllers.Learn
|
|
/// <param name="request"></param>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
[HttpPost("RevokeHomeWork")]
|
|
[HttpPost("RevokeHomeWork")]
|
|
- public async Task<BaseJosnRPCResponse> RevokeHomeWork(JosnRPCRequest<string> homeWorkId)
|
|
|
|
|
|
+ public async Task<BaseJosnRPCResponse> RevokeHomeWork(JosnRPCRequest<string> homeWorkId)
|
|
{
|
|
{
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
List<HomeWork> homeWorks = await _cosmos.FindByDict<HomeWork>(new Dictionary<string, object> { { "id", homeWorkId.@params } });
|
|
List<HomeWork> homeWorks = await _cosmos.FindByDict<HomeWork>(new Dictionary<string, object> { { "id", homeWorkId.@params } });
|
|
|
|
|
|
- foreach (HomeWork homeWork in homeWorks)
|
|
|
|
|
|
+ foreach (HomeWork homeWork in homeWorks)
|
|
{
|
|
{
|
|
homeWork.state = 100;
|
|
homeWork.state = 100;
|
|
}
|
|
}
|
|
@@ -82,7 +82,7 @@ namespace TEAMModelOS.Controllers.Learn
|
|
if (!request.@params.reset)
|
|
if (!request.@params.reset)
|
|
{
|
|
{
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
//根据作业发布对象查找到每一个具体学生生成关联关系表 HomeWorkStudent
|
|
//根据作业发布对象查找到每一个具体学生生成关联关系表 HomeWorkStudent
|
|
List<Target> targets = request.@params.homeWork.target;
|
|
List<Target> targets = request.@params.homeWork.target;
|
|
List<ClassroomStudent> Classrooms = new List<ClassroomStudent>();
|
|
List<ClassroomStudent> Classrooms = new List<ClassroomStudent>();
|
|
@@ -91,9 +91,9 @@ namespace TEAMModelOS.Controllers.Learn
|
|
{
|
|
{
|
|
//查询之前是否有 关联关系表 HomeWorkStudent 有则删除
|
|
//查询之前是否有 关联关系表 HomeWorkStudent 有则删除
|
|
List<HomeWorkStudent> homeWorks = await _cosmos.FindByDict<HomeWorkStudent>(new Dictionary<string, object> { { "homeWorkId", request.@params.homeWork.id } });
|
|
List<HomeWorkStudent> homeWorks = await _cosmos.FindByDict<HomeWorkStudent>(new Dictionary<string, object> { { "homeWorkId", request.@params.homeWork.id } });
|
|
- if (homeWorks.IsNotEmpty())
|
|
|
|
|
|
+ if (homeWorks.IsNotEmpty())
|
|
{
|
|
{
|
|
- await _cosmos.DeleteAll(homeWorks);
|
|
|
|
|
|
+ await _cosmos.DeleteAll(homeWorks);
|
|
}
|
|
}
|
|
|
|
|
|
List<ClassroomStudent> classroom = await _cosmos.FindByDict<ClassroomStudent>(new Dictionary<string, object> { { "id", target.classroomCode }, { "scopeCode", target.scopeCode } });
|
|
List<ClassroomStudent> classroom = await _cosmos.FindByDict<ClassroomStudent>(new Dictionary<string, object> { { "id", target.classroomCode }, { "scopeCode", target.scopeCode } });
|
|
@@ -140,7 +140,7 @@ namespace TEAMModelOS.Controllers.Learn
|
|
/// <param name="request"></param>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
[HttpPost("SaveorUpdataWorkStudents")]
|
|
[HttpPost("SaveorUpdataWorkStudents")]
|
|
- public async Task<BaseJosnRPCResponse> SaveorUpdataWorkStudents(JosnRPCRequest<List<HomeWorkStudent>> request)
|
|
|
|
|
|
+ public async Task<BaseJosnRPCResponse> SaveorUpdataWorkStudents(JosnRPCRequest<List<HomeWorkStudent>> request)
|
|
{
|
|
{
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
await _cosmos.SaveOrUpdateAll<HomeWorkStudent>(request.@params);
|
|
await _cosmos.SaveOrUpdateAll<HomeWorkStudent>(request.@params);
|
|
@@ -153,7 +153,8 @@ namespace TEAMModelOS.Controllers.Learn
|
|
/// <param name="request"></param>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
[HttpPost("FindHomeWork")]
|
|
[HttpPost("FindHomeWork")]
|
|
- public async Task<BaseJosnRPCResponse> FindHomeWork(JosnRPCRequest<Dictionary<string,object>> request) {
|
|
|
|
|
|
+ public async Task<BaseJosnRPCResponse> FindHomeWork(JosnRPCRequest<Dictionary<string, object>> request)
|
|
|
|
+ {
|
|
|
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
List<HomeWork> data = new List<HomeWork>();
|
|
List<HomeWork> data = new List<HomeWork>();
|
|
@@ -199,10 +200,10 @@ namespace TEAMModelOS.Controllers.Learn
|
|
/// <param name="request"></param>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
[HttpPost("FindClassroom")]
|
|
[HttpPost("FindClassroom")]
|
|
- public async Task<BaseJosnRPCResponse> FindClassroom(JosnRPCRequest<string> request)
|
|
|
|
|
|
+ public async Task<BaseJosnRPCResponse> FindClassroom(JosnRPCRequest<string> request)
|
|
{
|
|
{
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
- List<Course> courses = await _cosmos.FindByDict<Course>(dict:new Dictionary<string, object> { { "assistTeacher[*]", request.@params },{ "scopeCode.|", request.@params } }, propertys: new List<string> { "classroom" });
|
|
|
|
|
|
+ List<Course> courses = await _cosmos.FindByDict<Course>(dict: new Dictionary<string, object> { { "assistTeacher[*]", request.@params }, { "scopeCode.|", request.@params } }, propertys: new List<string> { "classroom" });
|
|
//List<Course> courses2 = await _cosmos.FindByDict<Course>(dict:new Dictionary<string, object> { { "scopeCode", request.@params } }, propertys: new List<string> { "classroom" });
|
|
//List<Course> courses2 = await _cosmos.FindByDict<Course>(dict:new Dictionary<string, object> { { "scopeCode", request.@params } }, propertys: new List<string> { "classroom" });
|
|
//List<Course> courses = new List<Course>();
|
|
//List<Course> courses = new List<Course>();
|
|
//courses.AddRange(courses1);
|
|
//courses.AddRange(courses1);
|
|
@@ -223,45 +224,78 @@ namespace TEAMModelOS.Controllers.Learn
|
|
builder.Data(classroom1);
|
|
builder.Data(classroom1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else {
|
|
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
|
|
throw new BizException("没有找到该老师协同课程", ResponseCode.NOT_FOUND);
|
|
throw new BizException("没有找到该老师协同课程", ResponseCode.NOT_FOUND);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
return builder.build();
|
|
return builder.build();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// 作业打分
|
|
|
|
|
|
+ /// 教师作业打分评论
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- [HttpPost("Scoring")]
|
|
|
|
- public async Task<BaseJosnRPCResponse> HomeWorkScoring(JosnRPCRequest<HomeWorkScoringDto> request)
|
|
|
|
|
|
+ [HttpPost("TeacherScoring")]
|
|
|
|
+ public async Task<BaseJosnRPCResponse> TeacherScoring(JosnRPCRequest<HomeWorkScoringDto> request)
|
|
{
|
|
{
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
List<HomeWorkStudent> homeWorkStudents = await _cosmos.FindByDict<HomeWorkStudent>(new Dictionary<string, object> { { "id", request.@params.id }, { "homeWorkId", request.@params.homeWorkId } });
|
|
List<HomeWorkStudent> homeWorkStudents = await _cosmos.FindByDict<HomeWorkStudent>(new Dictionary<string, object> { { "id", request.@params.id }, { "homeWorkId", request.@params.homeWorkId } });
|
|
HomeWorkStudent data = new HomeWorkStudent();
|
|
HomeWorkStudent data = new HomeWorkStudent();
|
|
- if (homeWorkStudents.IsNotEmpty()) {
|
|
|
|
|
|
+ if (homeWorkStudents.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ if (!double.IsNegative(request.@params.score)) homeWorkStudents[0].score = request.@params.score;
|
|
|
|
+ HomeWorkComment homeWorkComment = new HomeWorkComment
|
|
|
|
+ {
|
|
|
|
+ comment = request.@params.comments,
|
|
|
|
+ createTime = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(),
|
|
|
|
+ TEAMModelId = request.@params.TEAMModelId
|
|
|
|
+ };
|
|
|
|
|
|
- homeWorkStudents[0].score = request.@params.score;
|
|
|
|
- data = await _cosmos.Update(homeWorkStudents[0]);
|
|
|
|
|
|
+ homeWorkStudents[0].teacherComments = homeWorkComment;
|
|
|
|
+ data = await _cosmos.SaveOrUpdate(homeWorkStudents[0]);
|
|
}
|
|
}
|
|
- return builder.Data(data).build() ;
|
|
|
|
|
|
+ return builder.Data(data).build();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ ///// <summary>
|
|
|
|
+ ///// 学生作业打分评论
|
|
|
|
+ ///// </summary>
|
|
|
|
+ ///// <param name="request"></param>
|
|
|
|
+ ///// <returns></returns>
|
|
|
|
+ //[HttpPost("StudentScoring")]
|
|
|
|
+ //public async Task<BaseJosnRPCResponse> StudentScoring(JosnRPCRequest<HomeWorkCommentDto> request)
|
|
|
|
+ //{
|
|
|
|
+ // JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
|
+ // List<HomeWorkStudent> homeWorkStudents = await _cosmos.FindByDict<HomeWorkStudent>(new Dictionary<string, object> { { "id", request.@params.id }, { "homeWorkId", request.@params.homeWorkId } });
|
|
|
|
+ // HomeWorkStudent data = new HomeWorkStudent();
|
|
|
|
+ // if (homeWorkStudents.IsNotEmpty())
|
|
|
|
+ // {
|
|
|
|
+ // StudentComment homeWorkComment = new StudentComment
|
|
|
|
+ // {
|
|
|
|
+ // comment = request.@params.comment,
|
|
|
|
+ // createTime = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(),
|
|
|
|
+ // TEAMModelId = request.@params.fromId
|
|
|
|
+ // };
|
|
|
|
+ // if (!double.IsNegative(request.@params.score)) homeWorkComment.score = request.@params.score;
|
|
|
|
+ // homeWorkStudents[0].studentComments.Add(homeWorkComment);
|
|
|
|
+ // data = await _cosmos.SaveOrUpdate(homeWorkStudents[0]);
|
|
|
|
+ // }
|
|
|
|
+ // return builder.Data(data).build();
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 作业评论
|
|
/// 作业评论
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- [HttpPost("Comment")]
|
|
|
|
- public async Task<BaseJosnRPCResponse> HomeWorkComment(JosnRPCRequest<HomeWorkCommentDto> request)
|
|
|
|
|
|
+ [HttpPost("StudentScoring")]
|
|
|
|
+ public async Task<BaseJosnRPCResponse> StudentScoring(JosnRPCRequest<HomeWorkCommentDto> request)
|
|
{
|
|
{
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
List<HomeWorkStudent> homeWorkStudents = await _cosmos.FindByDict<HomeWorkStudent>(new Dictionary<string, object> { { "id", request.@params.id }, { "homeWorkId", request.@params.homeWorkId } });
|
|
List<HomeWorkStudent> homeWorkStudents = await _cosmos.FindByDict<HomeWorkStudent>(new Dictionary<string, object> { { "id", request.@params.id }, { "homeWorkId", request.@params.homeWorkId } });
|
|
@@ -271,20 +305,23 @@ namespace TEAMModelOS.Controllers.Learn
|
|
if (string.IsNullOrEmpty(request.@params.commentid))
|
|
if (string.IsNullOrEmpty(request.@params.commentid))
|
|
{
|
|
{
|
|
//评论
|
|
//评论
|
|
- HomeWorkComment comment = new HomeWorkComment();
|
|
|
|
- comment.commentid = Guid.NewGuid().ToString();
|
|
|
|
- comment.fromId = request.@params.fromId;
|
|
|
|
- comment.toId = request.@params.toId;
|
|
|
|
- comment.identity = request.@params.identity;
|
|
|
|
- comment.comment = request.@params.comment;
|
|
|
|
- comment.createTime = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds();
|
|
|
|
- homeWorkStudents[0].comments.Add(comment);
|
|
|
|
|
|
+ StudentComment homeWorkComment = new StudentComment
|
|
|
|
+ {
|
|
|
|
+ commentid = Guid.NewGuid().ToString(),
|
|
|
|
+ comment = request.@params.comment,
|
|
|
|
+ createTime = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(),
|
|
|
|
+ fromId = request.@params.fromId
|
|
|
|
+ };
|
|
|
|
+ if (!double.IsNegative(request.@params.score)) homeWorkComment.score = request.@params.score;
|
|
|
|
+ homeWorkStudents[0].studentComments.Add(homeWorkComment);
|
|
}
|
|
}
|
|
- else
|
|
|
|
|
|
+ else
|
|
{
|
|
{
|
|
//回复评论
|
|
//回复评论
|
|
- foreach (HomeWorkComment comment in homeWorkStudents[0].comments ) {
|
|
|
|
- if (comment.commentid == request.@params.commentid) {
|
|
|
|
|
|
+ foreach (StudentComment comment in homeWorkStudents[0].studentComments)
|
|
|
|
+ {
|
|
|
|
+ if (comment.commentid == request.@params.commentid)
|
|
|
|
+ {
|
|
Reply reply = new Reply();
|
|
Reply reply = new Reply();
|
|
reply.fromId = request.@params.fromId;
|
|
reply.fromId = request.@params.fromId;
|
|
reply.toId = request.@params.toId;
|
|
reply.toId = request.@params.toId;
|
|
@@ -302,5 +339,121 @@ namespace TEAMModelOS.Controllers.Learn
|
|
return builder.Data(data).build();
|
|
return builder.Data(data).build();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 保存教师评语快捷回复
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="request"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("SaveOrUpdateTeacherComments")]
|
|
|
|
+ public async Task<BaseJosnRPCResponse> SaveOrUpdateTeacherComments(JosnRPCRequest<TeacherCommentsDto> request)
|
|
|
|
+ {
|
|
|
|
+ JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
|
+ List<TeacherComments> teacherComments1 = await _cosmos.FindByDict<TeacherComments>(new Dictionary<string, object> { { "TEAMModelId", request.@params.TEAMModelId } });
|
|
|
|
+ if (teacherComments1.IsEmpty()) {
|
|
|
|
+ teacherComments1 = new List<TeacherComments>();
|
|
|
|
+ TeacherComments teacher = new TeacherComments();
|
|
|
|
+ teacher.id = Guid.NewGuid().ToString();
|
|
|
|
+ teacher.TEAMModelId = request.@params.TEAMModelId;
|
|
|
|
+ teacherComments1.Add(teacher);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ foreach (TeacherComments item in teacherComments1) {
|
|
|
|
+ TeacherComments.Comment comment = new TeacherComments.Comment();
|
|
|
|
+ comment.comment = request.@params.comment;
|
|
|
|
+ //comment.createTime = new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds();
|
|
|
|
+ comment.id = CreateRandomCode(6);
|
|
|
|
+ item.comment.Add(comment);
|
|
|
|
+ }
|
|
|
|
+ List<TeacherComments> teacherComments = await _cosmos.SaveOrUpdateAll(teacherComments1);
|
|
|
|
+ if (teacherComments.IsNotEmpty()) builder.Data(teacherComments);
|
|
|
|
+
|
|
|
|
+ return builder.build();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 查询教师评语罐头
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="request"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("FindTeacherComments")]
|
|
|
|
+ public async Task<BaseJosnRPCResponse> FindTeacherComments(JosnRPCRequest<Dictionary<string, object>> request)
|
|
|
|
+ {
|
|
|
|
+ // request.@params.TryAdd("PartitionKey", request.lang);
|
|
|
|
+ JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
|
+ List<TeacherComments> data = new List<TeacherComments>();
|
|
|
|
+ if (request.@params.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ data = await _cosmos.FindByDict<TeacherComments>(request.@params);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ throw new BizException("参数异常", ResponseCode.PARAMS_ERROR);
|
|
|
|
+ }
|
|
|
|
+ return builder.Data(data.OrderBy(m => m.comment.OrderBy(c => c.order))).Extend(new Dictionary<string, object> { { "count", data.Count } }).build();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [HttpPost("DeleteTeacherComments")]
|
|
|
|
+ public async Task<BaseJosnRPCResponse> DeleteTeacherComments(JosnRPCRequest<Dictionary<string, object>> request)
|
|
|
|
+ {
|
|
|
|
+ // request.@params.TryAdd("PartitionKey", request.lang);
|
|
|
|
+ JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
|
+ List<TeacherComments> data = new List<TeacherComments>();
|
|
|
|
+ if (request.@params.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ request.@params.TryGetValue("TEAMModelId", out object TEAMModelId);
|
|
|
|
+ request.@params.TryGetValue("id", out object id);
|
|
|
|
+ data = await _cosmos.FindByDict<TeacherComments>(new Dictionary<string, object> { { "TEAMModelId", TEAMModelId.ToString() } });
|
|
|
|
+ foreach (TeacherComments teacherComments in data) {
|
|
|
|
+ List<TeacherComments.Comment> comment = new List<TeacherComments.Comment>();
|
|
|
|
+ comment.AddRange(teacherComments.comment);
|
|
|
|
+
|
|
|
|
+ comment.ForEach(x =>
|
|
|
|
+ {
|
|
|
|
+ if (x.id.Equals(id + "")) {
|
|
|
|
+ teacherComments.comment.Remove(x);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ data = await _cosmos.SaveOrUpdateAll<TeacherComments>(data);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ throw new BizException("参数异常", ResponseCode.PARAMS_ERROR);
|
|
|
|
+ }
|
|
|
|
+ return builder.Data(data).build();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 生成随机数
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="codeCount"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public string CreateRandomCode(int codeCount) //生成随机数
|
|
|
|
+ {
|
|
|
|
+ string allChar = "1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,P,Q,R,S,T,U,V,W,X,Y,Z";//没有0O
|
|
|
|
+ string[] allCharArray = allChar.Split(',');
|
|
|
|
+ string randomCode = "";
|
|
|
|
+ int temp = -1;
|
|
|
|
+ Random rand = new Random();
|
|
|
|
+ for (int i = 0; i < codeCount; i++)
|
|
|
|
+ {
|
|
|
|
+ if (temp != -1)
|
|
|
|
+ {
|
|
|
|
+ rand = new Random(i * temp * ((int)DateTime.Now.Ticks));
|
|
|
|
+ }
|
|
|
|
+ int t = rand.Next(34);
|
|
|
|
+ if (temp != -1 && temp == t)
|
|
|
|
+ {
|
|
|
|
+ return CreateRandomCode(codeCount);
|
|
|
|
+ }
|
|
|
|
+ temp = t;
|
|
|
|
+ randomCode += allCharArray[t];
|
|
|
|
+ }
|
|
|
|
+ return randomCode;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|