Commit c8e61086 authored by 黄奎's avatar 黄奎

页面修改

parent ac5e2d2d
...@@ -105,7 +105,7 @@ WHERE 1=1 ...@@ -105,7 +105,7 @@ WHERE 1=1
Score_Value = item.Score_value, Score_Value = item.Score_value,
HomeWorkStatus = item.status, HomeWorkStatus = item.status,
ThName = item.th_name, ThName = item.th_name,
Stu_HomeWork_Id=item.stu_homework_id, Stu_HomeWork_Id = item.stu_homework_id,
}); });
RowNum++; RowNum++;
} }
...@@ -113,7 +113,7 @@ WHERE 1=1 ...@@ -113,7 +113,7 @@ WHERE 1=1
//课程配置评论列表 //课程配置评论列表
var courseCommentModel = courseCommentRepository.GetCourseCommentListRepository(new CourseQuery() { QCourseIds = query.CourseId.ToString() }).FirstOrDefault(); var courseCommentModel = courseCommentRepository.GetCourseCommentListRepository(new CourseQuery() { QCourseIds = query.CourseId.ToString() }).FirstOrDefault();
//学员评论列表 //学员评论列表
var commentList= stuCommentRepository.GetStuCommentListRepository(new CourseQuery() { CourseId = query.CourseId, StuIds = query.StuIds }); var commentList = stuCommentRepository.GetStuCommentListRepository(new CourseQuery() { CourseId = query.CourseId, StuIds = query.StuIds });
ExamWorkResult firstComment = null; ExamWorkResult firstComment = null;
ExamWorkResult secondComment = null; ExamWorkResult secondComment = null;
...@@ -121,176 +121,132 @@ WHERE 1=1 ...@@ -121,176 +121,132 @@ WHERE 1=1
string info; string info;
if (homeWorkList != null && homeWorkList.Count > 0) if (homeWorkList != null && homeWorkList.Count > 0)
{ {
//第一次评价
if (homeWorkList.Count >= 5) if (homeWorkList.Count >= 5)
{ {
var firstList = homeWorkList.Where(qitem => qitem.RowNum <= 5).ToList(); var firstList = homeWorkList.Where(qitem => qitem.RowNum <= 5).ToList();
var firstScore = firstList.Average(qitem => qitem.Score_p) * 100; var firstFlag= firstList.Where(qitem => qitem.HomeWorkStatus == 0).Count() > 0;
info = ""; //第一阶段有未提交的作业就不生成系统评价
var commentModel = commentRepository.GetComment(firstScore); if (!firstFlag)
if (courseCommentModel != null && courseCommentModel.CommentDetails != null && courseCommentModel.CommentDetails.Count() > 0)
{ {
var tempModel = courseCommentModel.CommentDetails.Where(qitem => qitem.StartNum <= firstScore && firstScore < qitem.EndNum)?.FirstOrDefault(); var firstScore = firstList.Average(qitem => qitem.Score_p) * 100;
if (tempModel != null) string title = firstList.LastOrDefault().ThName + "老师的评语";
{ info = GetCommentInfo(courseCommentModel, firstScore);
info = tempModel?.Info ?? ""; var First_Stu_HomeWork_Id = firstList.LastOrDefault().Stu_HomeWork_Id;
} var tempModel = GetSystemCreateComment(commentList, query.CourseId, First_Stu_HomeWork_Id);
else
{
info = commentModel?.Info ?? "";
}
}
else
{
info = commentModel?.Info ?? "";
}
if (commentList?.Where(qitem => qitem.CourseId == qitem.CourseId && qitem.HomeWorkId == firstList.LastOrDefault().Stu_HomeWork_Id && qitem.CreateType == 1).Count() > 0)
{
var tempModel = commentList.Where(qitem => qitem.CourseId == qitem.CourseId && qitem.HomeWorkId == firstList.LastOrDefault().Stu_HomeWork_Id && qitem.CreateType == 1).FirstOrDefault();
firstComment = new ExamWorkResult() firstComment = new ExamWorkResult()
{ {
CreateTime = tempModel.CreateTime,
ResultType = 3, ResultType = 3,
Title = firstList.LastOrDefault().ThName + "老师的评语", Title = firstList.LastOrDefault().ThName + "老师的评语",
Comment = tempModel?.Info
}; };
}
else
{
firstComment = new ExamWorkResult()
{
CreateTime = firstList.LastOrDefault().CreateTime.AddMinutes(1),
ResultType = 3,
Title = firstList.LastOrDefault().ThName + "老师的评语",
Comment = info
};
stuCommentRepository.SetStuCommentRepository(new RB_Stu_Comment()
{
Id = 0,
HomeWorkId = firstList.LastOrDefault().Stu_HomeWork_Id,
StuUid = Convert.ToInt32(query.StuIds),
CourseId = query.CourseId,
Times = 1,
Info = info,
CreateType = 1,
CreateByName = firstList.LastOrDefault().ThName,
CreateTime = firstList.LastOrDefault().CreateTime.AddMinutes(1),
});
}
}
if (homeWorkList.Count >= 9)
{
var secondList = homeWorkList.Where(qitem => qitem.RowNum > 5 && qitem.RowNum <= 9).ToList();
var secondScore = secondList.Average(qitem => qitem.Score_p) * 100;
info = "";
var commentModel = commentRepository.GetComment(secondScore);
if (courseCommentModel != null && courseCommentModel.CommentDetails != null && courseCommentModel.CommentDetails.Count() > 0)
{
var tempModel = courseCommentModel.CommentDetails.Where(qitem => qitem.StartNum <= secondScore && secondScore < qitem.EndNum)?.FirstOrDefault();
if (tempModel != null) if (tempModel != null)
{ {
info = tempModel?.Info ?? ""; firstComment.CreateTime = tempModel.CreateTime;
firstComment.Comment = tempModel.Info;
} }
else else
{ {
info = commentModel?.Info ?? ""; var firstNum = CreateRandomNum();
firstComment.CreateTime = firstList.LastOrDefault().CreateTime.AddMinutes(firstNum);
firstComment.Comment = info;
//新增系统生成评价
stuCommentRepository.SetStuCommentRepository(new RB_Stu_Comment()
{
Id = 0,
HomeWorkId = First_Stu_HomeWork_Id,
StuUid = Convert.ToInt32(query.StuIds),
CourseId = query.CourseId,
Times = 1,
Info = info,
CreateType = 1,
CreateByName = firstList.LastOrDefault().ThName,
CreateTime = firstComment.CreateTime,
});
} }
} }
else }
{ //第二次评价
info = commentModel?.Info ?? ""; if (homeWorkList.Count >= 9)
} {
var secondList = homeWorkList.Where(qitem => qitem.RowNum > 5 && qitem.RowNum <= 9).ToList();
if (commentList?.Where(qitem => qitem.CourseId == qitem.CourseId && qitem.HomeWorkId == secondList.LastOrDefault().Stu_HomeWork_Id && qitem.CreateType == 1).Count() > 0) var secondFlag = secondList.Where(qitem => qitem.HomeWorkStatus == 0).Count() > 0;
{ if (!secondFlag)
var tempModel = commentList.Where(qitem => qitem.CourseId == qitem.CourseId && qitem.HomeWorkId == secondList.LastOrDefault().Stu_HomeWork_Id && qitem.CreateType == 1).FirstOrDefault();
secondComment = new ExamWorkResult()
{
CreateTime = tempModel.CreateTime,
ResultType = 3,
Title = secondList.LastOrDefault().ThName + "老师的评语",
Comment = tempModel?.Info
};
}
else
{ {
var secondScore = secondList.Average(qitem => qitem.Score_p) * 100;
info = GetCommentInfo(courseCommentModel, secondScore);
var Second_Stu_HomeWork_Id = secondList.LastOrDefault().Stu_HomeWork_Id;
var secondModel = GetSystemCreateComment(commentList, query.CourseId, Second_Stu_HomeWork_Id);
secondComment = new ExamWorkResult() secondComment = new ExamWorkResult()
{ {
CreateTime = secondList.LastOrDefault().CreateTime.AddMinutes(1),
ResultType = 3, ResultType = 3,
Title = secondList.LastOrDefault().ThName + "老师的评语", Title = secondList.LastOrDefault().ThName + "老师的评语",
Comment = info,
}; };
stuCommentRepository.SetStuCommentRepository(new RB_Stu_Comment() if (secondModel != null)
{ {
Id = 0, secondComment.CreateTime = secondModel.CreateTime;
HomeWorkId = secondList.LastOrDefault().Stu_HomeWork_Id, secondComment.Comment = secondModel.Info;
StuUid = Convert.ToInt32(query.StuIds),
CourseId = query.CourseId,
Times = 2,
Info = info,
CreateType = 1,
CreateByName = secondList.LastOrDefault().ThName,
CreateTime = secondList.LastOrDefault().CreateTime.AddMinutes(1),
});
}
}
if (homeWorkList.Count >= 13)
{
var thirdList = homeWorkList.Where(qitem => qitem.RowNum > 9&&qitem.RowNum<=13).ToList();
var thirdScore = thirdList.Average(qitem => qitem.Score_p) * 100;
info = "";
var commentModel = commentRepository.GetComment(thirdScore);
if (courseCommentModel != null && courseCommentModel.CommentDetails != null && courseCommentModel.CommentDetails.Count() > 0)
{
var tempModel = courseCommentModel.CommentDetails.Where(qitem => qitem.StartNum <= thirdScore && thirdScore < qitem.EndNum)?.FirstOrDefault();
if (tempModel != null)
{
info = tempModel?.Info ?? "";
} }
else else
{ {
info = commentModel?.Info ?? ""; var secondNum = CreateRandomNum();
secondComment.CreateTime = secondList.LastOrDefault().CreateTime.AddMinutes(secondNum);
secondComment.Comment = info;
stuCommentRepository.SetStuCommentRepository(new RB_Stu_Comment()
{
Id = 0,
HomeWorkId = Second_Stu_HomeWork_Id,
StuUid = Convert.ToInt32(query.StuIds),
CourseId = query.CourseId,
Times = 2,
Info = info,
CreateType = 1,
CreateByName = secondList.LastOrDefault().ThName,
CreateTime = secondComment.CreateTime,
});
} }
} }
else }
{ //第三次评价
info = commentModel?.Info ?? ""; if (homeWorkList.Count >= 13)
} {
var thirdList = homeWorkList.Where(qitem => qitem.RowNum > 9 && qitem.RowNum <= 13).ToList();
if (commentList?.Where(qitem => qitem.CourseId == qitem.CourseId && qitem.HomeWorkId == thirdList.LastOrDefault().Stu_HomeWork_Id && qitem.CreateType == 1).Count() > 0) var thirdFlag = thirdList.Where(qitem => qitem.HomeWorkStatus == 0).Count() > 0;
if (!thirdFlag)
{ {
var tempModel = commentList.Where(qitem => qitem.CourseId == qitem.CourseId && qitem.HomeWorkId == thirdList.LastOrDefault().Stu_HomeWork_Id && qitem.CreateType == 1).FirstOrDefault(); var thirdScore = thirdList.Average(qitem => qitem.Score_p) * 100;
info = GetCommentInfo(courseCommentModel, thirdScore);
var Third_Stu_HomeWork_Id = thirdList.LastOrDefault().Stu_HomeWork_Id;
var thirdModel = GetSystemCreateComment(commentList, query.CourseId, Third_Stu_HomeWork_Id);
thirdComment = new ExamWorkResult() thirdComment = new ExamWorkResult()
{ {
CreateTime = tempModel.CreateTime,
ResultType = 3, ResultType = 3,
Title = thirdList.LastOrDefault().ThName + "老师的评语", Title = thirdList.LastOrDefault().ThName + "老师的评语",
Comment = tempModel?.Info
}; };
} if (thirdModel != null)
else
{
thirdComment = new ExamWorkResult()
{ {
CreateTime = thirdList.LastOrDefault().CreateTime.AddMinutes(1), thirdComment.CreateTime = thirdModel.CreateTime;
ResultType = 3, thirdComment.Comment = thirdModel.Info;
Title = thirdList.LastOrDefault().ThName + "老师的评语", }
Comment = info, else
};
stuCommentRepository.SetStuCommentRepository(new RB_Stu_Comment()
{ {
Id = 0, var thirdNum = CreateRandomNum();
HomeWorkId = thirdList.LastOrDefault().Stu_HomeWork_Id, thirdComment.CreateTime = thirdList.LastOrDefault().CreateTime.AddMinutes(thirdNum);
StuUid = Convert.ToInt32(query.StuIds), thirdComment.Comment = info;
CourseId = query.CourseId, stuCommentRepository.SetStuCommentRepository(new RB_Stu_Comment()
Times = 3, {
Info = info, Id = 0,
CreateType = 1, HomeWorkId = Third_Stu_HomeWork_Id,
CreateByName = thirdList.LastOrDefault().ThName, StuUid = Convert.ToInt32(query.StuIds),
CreateTime = thirdList.LastOrDefault().CreateTime.AddMinutes(1), CourseId = query.CourseId,
}); Times = 3,
Info = info,
CreateType = 1,
CreateByName = thirdList.LastOrDefault().ThName,
CreateTime = thirdComment.CreateTime,
});
}
} }
} }
} }
...@@ -329,5 +285,57 @@ WHERE 1=1 ...@@ -329,5 +285,57 @@ WHERE 1=1
} }
return list; return list;
} }
/// <summary>
/// 生成随机数
/// </summary>
/// <returns></returns>
private int CreateRandomNum()
{
Random rnd = new Random();
return rnd.Next(5, 20);
}
/// <summary>
/// 获取系统生成的评论
/// </summary>
/// <param name="commentList"></param>
/// <param name="CourseId"></param>
/// <param name="Stu_HomeWork_Id"></param>
/// <returns></returns>
private RB_Stu_Comment GetSystemCreateComment(List<RB_Stu_Comment> commentList,int CourseId,int Stu_HomeWork_Id)
{
var tempModel = commentList.Where(qitem => qitem.CourseId == qitem.CourseId && qitem.HomeWorkId == Stu_HomeWork_Id && qitem.CreateType == 1).FirstOrDefault();
return tempModel;
}
/// <summary>
/// 获取课程评论或自定义评论
/// </summary>
/// <param name="courseCommentModel">课程评价配置</param>
/// <param name="Score">平均分数</param>
/// <returns></returns>
private string GetCommentInfo(RB_Course_Comment_Extend courseCommentModel, decimal Score)
{
string info = "";
var commentModel = commentRepository.GetComment(Score);
if (courseCommentModel != null && courseCommentModel.CommentDetails != null && courseCommentModel.CommentDetails.Count() > 0)
{
var tempModel = courseCommentModel.CommentDetails.Where(qitem => qitem.StartNum <= Score && Score < qitem.EndNum)?.FirstOrDefault();
if (tempModel != null)
{
info = tempModel?.Info ?? "";
}
else
{
info = commentModel?.Info ?? "";
}
}
else
{
info = commentModel?.Info ?? "";
}
return info;
}
} }
} }
...@@ -138,7 +138,7 @@ namespace EduSpider.Services ...@@ -138,7 +138,7 @@ namespace EduSpider.Services
if (dataList != null && dataList.Count > 0) if (dataList != null && dataList.Count > 0)
{ {
dataList = dataList.OrderBy(qitem => qitem.CreateTime).ToList(); dataList = dataList.OrderByDescending(qitem => qitem.CreateTime).ToList();
var firstModel = dataList.FirstOrDefault(); var firstModel = dataList.FirstOrDefault();
foreach (var item in dataList) foreach (var item in dataList)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment