Commit 58db7150 authored by 黄奎's avatar 黄奎

页面修改

parent 8a800efb
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend; using EduSpider.Model.Extend;
using EduSpider.Model.Query;
using System.Collections.Generic; using System.Collections.Generic;
using VTX.FW.Config; using VTX.FW.Config;
using VTX.FW.DB; using VTX.FW.DB;
...@@ -11,17 +12,11 @@ namespace EduSpider.IRepository ...@@ -11,17 +12,11 @@ namespace EduSpider.IRepository
/// </summary> /// </summary>
public interface ICommentRepository : IDBRepository<RB_Comment>, IDependency public interface ICommentRepository : IDBRepository<RB_Comment>, IDependency
{ {
/// <summary>
/// 新增修改默认配置
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetCommentRepository(RB_Comment_Extend model);
/// <summary> /// <summary>
/// 获取系统配置评价列表 /// 获取系统配置评价列表
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public RB_Comment_Extend GetCommentListRepository(string KeyWords,int CommentTimes); public List<RB_Comment_Extend> GetCommentListRepository(CourseQuery query);
} }
} }
...@@ -24,7 +24,7 @@ namespace EduSpider.IRepository ...@@ -24,7 +24,7 @@ namespace EduSpider.IRepository
/// </summary> /// </summary>
/// <param name="list"></param> /// <param name="list"></param>
/// <returns></returns> /// <returns></returns>
public bool BatchSetStuCommentRepository(List<RB_Stu_Comment> list); public bool BatchSetStuCommentRepository(List<RB_Stu_Comment> list, StuCommentType commentType );
/// <summary> /// <summary>
......
...@@ -19,6 +19,14 @@ namespace EduSpider.IRepository ...@@ -19,6 +19,14 @@ namespace EduSpider.IRepository
/// <returns></returns> /// <returns></returns>
public bool BatchSetStuHomeWorkRepository(List<RB_Stu_HomeWork> homeWorks); public bool BatchSetStuHomeWorkRepository(List<RB_Stu_HomeWork> homeWorks);
/// <summary>
/// 获取家庭作业列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Stu_HomeWork_Extend> GetStuHomeWorkDetailsListRepository(CourseQuery query);
/// <summary> /// <summary>
/// 创建课程作业评论 /// 创建课程作业评论
/// </summary> /// </summary>
...@@ -31,12 +39,5 @@ namespace EduSpider.IRepository ...@@ -31,12 +39,5 @@ namespace EduSpider.IRepository
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<ExamWorkResult> GetStuHomeWorkListRepository(CourseQuery query); public List<ExamWorkResult> GetStuHomeWorkListRepository(CourseQuery query);
/// <summary>
/// 获取家庭作业列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Stu_HomeWork_Extend> GetStuHomeWorkDetailsListRepository(CourseQuery query);
} }
} }
\ No newline at end of file
...@@ -92,7 +92,7 @@ namespace EduSpider.IServices ...@@ -92,7 +92,7 @@ namespace EduSpider.IServices
/// </summary> /// </summary>
/// <param name="list"></param> /// <param name="list"></param>
/// <returns></returns> /// <returns></returns>
public bool BatchSetStuComment(List<RB_Stu_Comment> list); public bool BatchSetStuComment(List<RB_Stu_Comment> list, StuCommentType commentType);
/// <summary> /// <summary>
/// 获取学员评价列表 /// 获取学员评价列表
...@@ -136,7 +136,7 @@ namespace EduSpider.IServices ...@@ -136,7 +136,7 @@ namespace EduSpider.IServices
/// 获取系统评价配置 /// 获取系统评价配置
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public RB_Comment_Extend GetSysComment(string KeyWords,int CommentTimes); public List<RB_Comment_Extend> GetSysComment(CourseQuery query);
/// <summary> /// <summary>
/// 创建课程作业评论 /// 创建课程作业评论
......
...@@ -75,4 +75,6 @@ namespace EduSpider.Model.Entity ...@@ -75,4 +75,6 @@ namespace EduSpider.Model.Entity
/// </summary> /// </summary>
public int Status { get; set; } public int Status { get; set; }
} }
} }
...@@ -45,6 +45,16 @@ ...@@ -45,6 +45,16 @@
/// </summary> /// </summary>
public int HomeWorkId { get; set; } public int HomeWorkId { get; set; }
/// <summary>
/// 开始作业编号
/// </summary>
public int StartHomeWorkId { get; set; }
/// <summary>
/// 结束作业编号
/// </summary>
public int EndHomeWorkId { get; set; }
/// <summary> /// <summary>
/// 创建类型(1-系统创建,2-老师创建) /// 创建类型(1-系统创建,2-老师创建)
/// </summary> /// </summary>
...@@ -54,5 +64,10 @@ ...@@ -54,5 +64,10 @@
/// 评论次数 /// 评论次数
/// </summary> /// </summary>
public int CommentTimes { get; set; } public int CommentTimes { get; set; }
/// <summary>
/// 默认评价编号
/// </summary>
public int DefaultCommentId { get; set; }
} }
} }
using EduSpider.IRepository; using EduSpider.IRepository;
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend; using EduSpider.Model.Extend;
using EduSpider.Model.Query;
using EduSpider.Repository.Base; using EduSpider.Repository.Base;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -18,46 +19,14 @@ namespace EduSpider.Repository ...@@ -18,46 +19,14 @@ namespace EduSpider.Repository
/// <summary> /// <summary>
/// 默认评论详情接口 /// 默认评论详情接口
/// </summary> /// </summary>
ICommentDetailsRepository commentDetailsRepository = new CommentDetailsRepository(); CommentDetailsRepository commentDetailsRepository = new CommentDetailsRepository();
/// <summary>
/// 新增修改默认配置
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetCommentRepository(RB_Comment_Extend model)
{
bool flag = false;
if (model.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Comment_Extend.KeyWords),model.KeyWords.Trim() }
};
flag = base.UpdateOne(fileds, new WhereHelper(nameof(RB_Comment_Extend.Id), model.Id));
}
else
{
var newId = base.Insert(model);
model.Id = newId;
flag = newId > 0;
}
if (model.Details != null && model.Details.Count > 0)
{
foreach (var item in model.Details)
{
item.CommentId = model.Id;
}
commentDetailsRepository.BatchSetCommentDetailsRepository(model.Details);
}
return flag;
}
/// <summary> /// <summary>
/// 获取系统配置评价列表 /// 获取系统配置评价列表
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public RB_Comment_Extend GetCommentListRepository(string KeyWords,int CommentTimes) public List<RB_Comment_Extend> GetCommentListRepository(CourseQuery query)
{ {
DynamicParameters parameters = new DynamicParameters(); DynamicParameters parameters = new DynamicParameters();
StringBuilder builder = new(); StringBuilder builder = new();
...@@ -66,45 +35,53 @@ SELECT A.* ...@@ -66,45 +35,53 @@ SELECT A.*
FROM RB_Comment AS A FROM RB_Comment AS A
WHERE 1=1 WHERE 1=1
"); ");
if (!string.IsNullOrEmpty(KeyWords)) if (!string.IsNullOrEmpty(query.KeyWords))
{ {
if (KeyWords.Contains("高")) if (query.KeyWords.Contains("高"))
{ {
builder.AppendFormat(" AND A.{0} LIKE @KeyWords1 ",nameof(RB_Comment_Extend.KeyWords)); builder.AppendFormat(" AND A.{0} LIKE @KeyWords1 ",nameof(RB_Comment_Extend.KeyWords));
parameters.Add("KeyWords1", "%高%"); parameters.Add("KeyWords1", "%高%");
} }
if (KeyWords.Contains("初")) if (query.KeyWords.Contains("初"))
{ {
builder.AppendFormat(" AND A.{0} LIKE @KeyWords2 ", nameof(RB_Comment_Extend.KeyWords)); builder.AppendFormat(" AND A.{0} LIKE @KeyWords2 ", nameof(RB_Comment_Extend.KeyWords));
parameters.Add("KeyWords2", "%初%"); parameters.Add("KeyWords2", "%初%");
} }
if (KeyWords.Contains("化学")) if (query.KeyWords.Contains("化学"))
{ {
builder.AppendFormat(" AND A.{0} LIKE @KeyWords3 ", nameof(RB_Comment_Extend.KeyWords)); builder.AppendFormat(" AND A.{0} LIKE @KeyWords3 ", nameof(RB_Comment_Extend.KeyWords));
parameters.Add("KeyWords3", "%化学%"); parameters.Add("KeyWords3", "%化学%");
} }
if (KeyWords.Contains("数学")) if (query.KeyWords.Contains("数学"))
{ {
builder.AppendFormat(" AND A.{0} LIKE @KeyWords4 ",nameof(RB_Comment_Extend.KeyWords)); builder.AppendFormat(" AND A.{0} LIKE @KeyWords4 ",nameof(RB_Comment_Extend.KeyWords));
parameters.Add("KeyWords4", "%数学%"); parameters.Add("KeyWords4", "%数学%");
} }
} }
if (CommentTimes > 0) if (query.CommentTimes > 0)
{ {
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Comment_Extend.Times), CommentTimes); builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Comment_Extend.Times), query.CommentTimes);
} }
var model = base.Get<RB_Comment_Extend>(builder.ToString(),parameters).ToList().FirstOrDefault(); if (query.DefaultCommentId > 0)
if (model != null && model.Id>0)
{ {
string Ids = model.Id.ToString(); builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Comment_Extend.Id), query.DefaultCommentId);
}
var list = base.Get<RB_Comment_Extend>(builder.ToString(),parameters).ToList();
if (list != null && list.Count>0)
{
string Ids = string.Join(",", list.Select(qitem => qitem.Id));
List<RB_Comment_Details> subList = new List<RB_Comment_Details>(); List<RB_Comment_Details> subList = new List<RB_Comment_Details>();
if (!string.IsNullOrEmpty(Ids)) if (!string.IsNullOrEmpty(Ids))
{ {
subList = commentDetailsRepository.GetCommentDetailsListRepository(Ids); subList = commentDetailsRepository.GetCommentDetailsListRepository(Ids);
} }
model.Details = subList?.Where(qitem => qitem.CommentId == model.Id)?.OrderBy(qitem => qitem.StartNum)?.ToList(); foreach (var item in list)
{
item.Details = subList?.Where(qitem => qitem.CommentId == item.Id)?.OrderBy(qitem => qitem.StartNum)?.ToList();
}
} }
return model; return list;
} }
} }
} }
...@@ -17,6 +17,8 @@ namespace EduSpider.Repository ...@@ -17,6 +17,8 @@ namespace EduSpider.Repository
/// </summary> /// </summary>
public class StuCommentRepository : BaseRepository<RB_Stu_Comment>, IStuCommentRepository public class StuCommentRepository : BaseRepository<RB_Stu_Comment>, IStuCommentRepository
{ {
/// <summary> /// <summary>
/// 获取学员评语列表 /// 获取学员评语列表
/// </summary> /// </summary>
...@@ -45,6 +47,14 @@ WHERE 1=1 ...@@ -45,6 +47,14 @@ WHERE 1=1
{ {
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Stu_Comment.HomeWorkId), query.HomeWorkId); builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Stu_Comment.HomeWorkId), query.HomeWorkId);
} }
if (query.StartHomeWorkId > 0)
{
builder.AppendFormat(" AND A.{0}>={1} ", nameof(RB_Stu_Comment.HomeWorkId), query.StartHomeWorkId);
}
if (query.EndHomeWorkId > 0)
{
builder.AppendFormat(" AND A.{0}<={1} ", nameof(RB_Stu_Comment.HomeWorkId), query.EndHomeWorkId);
}
if (query.CommentTimes > 0) if (query.CommentTimes > 0)
{ {
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Stu_Comment.Times), query.CommentTimes); builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Stu_Comment.Times), query.CommentTimes);
...@@ -83,10 +93,99 @@ WHERE 1=1 ...@@ -83,10 +93,99 @@ WHERE 1=1
/// </summary> /// </summary>
/// <param name="list"></param> /// <param name="list"></param>
/// <returns></returns> /// <returns></returns>
public bool BatchSetStuCommentRepository(List<RB_Stu_Comment> list) public bool BatchSetStuCommentRepository(List<RB_Stu_Comment> list, StuCommentType commentType)
{ {
bool flag = false; bool flag = false;
// 以前批量添加接口 // 以前批量添加接口
if (commentType != null)
{
if (commentType.CommentType == 2)
{
flag = AddTemplateStuComment(list, commentType.IsDefault, commentType.CommentId);
}
else
{
flag = AddDefaultStuComment(list);
}
}
else
{
flag = AddDefaultStuComment(list);
}
return flag;
}
/// <summary>
/// 根据模板生成评价
/// </summary>
/// <param name="list"></param>
/// <param name="IsDefault"></param>
/// <param name="CommentId"></param>
/// <returns></returns>
private bool AddTemplateStuComment(List<RB_Stu_Comment> list, int IsDefault, int CommentId)
{
bool flag = false;
if (list != null && list.Count > 0)
{
var homeworkList =new StuHomeWorkRepository().GetStuHomeWorkDetailsListRepository(new CourseQuery()
{
CourseId = list[0].CourseId,
StartHomeWorkId = list[0].StartHomeWorkId,
EndHomeWorkId = list[0].HomeWorkId
});
var courseComment = new RB_Course_Comment_Extend();
var defaultComment = new RB_Comment_Extend();
if (IsDefault == 1)
{
defaultComment =new CommentRepository().GetCommentListRepository(new CourseQuery() { DefaultCommentId = CommentId }).FirstOrDefault();
}
else
{
courseComment =new CourseCommentRepository().GetCourseCommentListRepository(new CourseQuery() { CourseId = list[0].CourseId }).Where(qitem => qitem.Id == CommentId).FirstOrDefault();
}
foreach (var item in list)
{
var tempList = homeworkList.Where(qitem => qitem.student_uid == item.StuUid).ToList();
item.CreateTime = tempList.LastOrDefault().add_time.AddSeconds(1);
var Score = tempList.Sum(qitem => qitem.score_p) * 100;
string info = "";
if (IsDefault == 1)
{
if (defaultComment != null && defaultComment.Details != null && defaultComment.Details.Count > 0)
{
var tempModel = defaultComment.Details.Where(qitem => qitem.StartNum <= Score && Score < qitem.EndNum)?.FirstOrDefault();
if (tempModel != null)
{
info = tempModel?.Info ?? "";
}
}
}
else
{
if (courseComment != null && courseComment.CommentDetails != null && courseComment.CommentDetails.Count > 0)
{
var tempModel = courseComment.CommentDetails.Where(qitem => qitem.StartNum <= Score && Score < qitem.EndNum)?.FirstOrDefault();
if (tempModel != null)
{
info = tempModel?.Info ?? "";
}
}
}
item.Info = info;
flag = base.Insert(item) > 0;
}
}
return flag;
}
/// <summary>
/// 自定义添加评价
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
private bool AddDefaultStuComment(List<RB_Stu_Comment> list)
{
bool flag = false;
foreach (var item in list) foreach (var item in list)
{ {
var defaultModel = GetStuCommentListRepository(new CourseQuery() var defaultModel = GetStuCommentListRepository(new CourseQuery()
...@@ -94,7 +193,7 @@ WHERE 1=1 ...@@ -94,7 +193,7 @@ WHERE 1=1
CourseId = item.CourseId, CourseId = item.CourseId,
CommentTimes = item.Times, CommentTimes = item.Times,
StuIds = item.StuUid.ToString(), StuIds = item.StuUid.ToString(),
HomeWorkId=item.HomeWorkId, HomeWorkId = item.HomeWorkId,
}).FirstOrDefault(); }).FirstOrDefault();
item.CreateTime = defaultModel.CreateTime.AddSeconds(1); item.CreateTime = defaultModel.CreateTime.AddSeconds(1);
item.HomeWorkId = defaultModel.HomeWorkId; item.HomeWorkId = defaultModel.HomeWorkId;
...@@ -103,6 +202,8 @@ WHERE 1=1 ...@@ -103,6 +202,8 @@ WHERE 1=1
return flag; return flag;
} }
/// <summary> /// <summary>
/// 修改学员评论状态 /// 修改学员评论状态
/// </summary> /// </summary>
......
...@@ -15,20 +15,7 @@ namespace EduSpider.Repository ...@@ -15,20 +15,7 @@ namespace EduSpider.Repository
/// </summary> /// </summary>
public class StuHomeWorkRepository : BaseRepository<RB_Stu_HomeWork>, IStuHomeWorkRepository public class StuHomeWorkRepository : BaseRepository<RB_Stu_HomeWork>, IStuHomeWorkRepository
{ {
/// <summary>
/// 评语配置仓储层对象
/// </summary>
private readonly ICommentRepository commentRepository = new CommentRepository();
/// <summary>
/// 学员评论仓储层对象
/// </summary>
private readonly StuCommentRepository stuCommentRepository = new();
/// <summary>
/// 课程评价配置仓储对象
/// </summary>
private readonly CourseCommentRepository courseCommentRepository = new();
/// <summary> /// <summary>
/// 批量添加学生家庭作业 /// 批量添加学生家庭作业
...@@ -74,6 +61,14 @@ WHERE 1=1 ...@@ -74,6 +61,14 @@ WHERE 1=1
{ {
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Stu_HomeWork_Extend.homework_id), query.HomeWorkId); builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Stu_HomeWork_Extend.homework_id), query.HomeWorkId);
} }
if (query.StartHomeWorkId > 0)
{
builder.AppendFormat(" AND A.{0}>={1} ", nameof(RB_Stu_HomeWork_Extend.homework_id), query.StartHomeWorkId);
}
if (query.EndHomeWorkId > 0)
{
builder.AppendFormat(" AND A.{0}<={1} ", nameof(RB_Stu_HomeWork_Extend.homework_id), query.EndHomeWorkId);
}
} }
var dataList = Get<RB_Stu_HomeWork_Extend>(builder.ToString()).ToList(); var dataList = Get<RB_Stu_HomeWork_Extend>(builder.ToString()).ToList();
return dataList; return dataList;
...@@ -96,13 +91,13 @@ WHERE 1=1 ...@@ -96,13 +91,13 @@ WHERE 1=1
{ {
var stuList = dataList.Where(qitem => qitem.course_id == cItem.course_id).GroupBy(qitem => new { qitem.student_uid }).Select(qitem => new{ qitem.Key.student_uid}); var stuList = dataList.Where(qitem => qitem.course_id == cItem.course_id).GroupBy(qitem => new { qitem.student_uid }).Select(qitem => new{ qitem.Key.student_uid});
//课程配置评论列表 //课程配置评论列表
var courseCommentList = courseCommentRepository.GetCourseCommentListRepository(new CourseQuery() { QCourseIds = cItem.course_id.ToString() }); var courseCommentList =new CourseCommentRepository().GetCourseCommentListRepository(new CourseQuery() { QCourseIds = cItem.course_id.ToString() });
foreach (var sItem in stuList) foreach (var sItem in stuList)
{ {
List<ExamWorkResult> homeWorkList = new(); List<ExamWorkResult> homeWorkList = new();
//学员评论列表 //学员评论列表
var commentList = stuCommentRepository.GetStuCommentListRepository(new CourseQuery() { CourseId = cItem.course_id, StuIds = sItem.student_uid.ToString() }); var commentList = new StuCommentRepository().GetStuCommentListRepository(new CourseQuery() { CourseId = cItem.course_id, StuIds = sItem.student_uid.ToString() });
var tempDataList = dataList.Where(qitem => qitem.course_id == cItem.course_id && qitem.student_uid == sItem.student_uid).ToList(); var tempDataList = dataList.Where(qitem => qitem.course_id == cItem.course_id && qitem.student_uid == sItem.student_uid).ToList();
if (tempDataList != null && tempDataList.Count > 0) if (tempDataList != null && tempDataList.Count > 0)
{ {
...@@ -141,6 +136,8 @@ WHERE 1=1 ...@@ -141,6 +136,8 @@ WHERE 1=1
var firstScore = firstList.Average(qitem => qitem.Score_p) * 100; var firstScore = firstList.Average(qitem => qitem.Score_p) * 100;
string title = firstList.LastOrDefault().ThName + "老师的评语"; string title = firstList.LastOrDefault().ThName + "老师的评语";
info = GetCommentInfo(courseCommentList,cItem.CourseName,1, firstScore); info = GetCommentInfo(courseCommentList,cItem.CourseName,1, firstScore);
if (!string.IsNullOrEmpty(info))
{
var First_Stu_HomeWork_Id = firstList.LastOrDefault().Stu_HomeWork_Id; var First_Stu_HomeWork_Id = firstList.LastOrDefault().Stu_HomeWork_Id;
var tempModel = GetSystemCreateComment(commentList, cItem.course_id, First_Stu_HomeWork_Id); var tempModel = GetSystemCreateComment(commentList, cItem.course_id, First_Stu_HomeWork_Id);
var firstNum = CreateRandomNum(); var firstNum = CreateRandomNum();
...@@ -158,10 +155,10 @@ WHERE 1=1 ...@@ -158,10 +155,10 @@ WHERE 1=1
if (tempModel == null || (tempModel != null && tempModel.Id <= 0)) if (tempModel == null || (tempModel != null && tempModel.Id <= 0))
{ {
//新增系统生成评价 //新增系统生成评价
stuCommentRepository.SetStuCommentRepository(new RB_Stu_Comment() new StuCommentRepository().SetStuCommentRepository(new RB_Stu_Comment()
{ {
Id = 0, Id = 0,
StartHomeWorkId= firstList.FirstOrDefault().Stu_HomeWork_Id, StartHomeWorkId = firstList.FirstOrDefault().Stu_HomeWork_Id,
HomeWorkId = First_Stu_HomeWork_Id, HomeWorkId = First_Stu_HomeWork_Id,
StuUid = Convert.ToInt32(sItem.student_uid), StuUid = Convert.ToInt32(sItem.student_uid),
CourseId = cItem.course_id, CourseId = cItem.course_id,
...@@ -175,6 +172,7 @@ WHERE 1=1 ...@@ -175,6 +172,7 @@ WHERE 1=1
} }
} }
} }
}
//第二次评价 //第二次评价
if (homeWorkList.Count >= 9) if (homeWorkList.Count >= 9)
{ {
...@@ -185,6 +183,8 @@ WHERE 1=1 ...@@ -185,6 +183,8 @@ WHERE 1=1
{ {
var secondScore = secondList.Average(qitem => qitem.Score_p) * 100; var secondScore = secondList.Average(qitem => qitem.Score_p) * 100;
info = GetCommentInfo(courseCommentList, cItem.CourseName, 2, secondScore); info = GetCommentInfo(courseCommentList, cItem.CourseName, 2, secondScore);
if (!string.IsNullOrEmpty(info))
{
var Second_Stu_HomeWork_Id = secondList.LastOrDefault().Stu_HomeWork_Id; var Second_Stu_HomeWork_Id = secondList.LastOrDefault().Stu_HomeWork_Id;
var secondModel = GetSystemCreateComment(commentList, cItem.course_id, Second_Stu_HomeWork_Id); var secondModel = GetSystemCreateComment(commentList, cItem.course_id, Second_Stu_HomeWork_Id);
var secondNum = CreateRandomNum(); var secondNum = CreateRandomNum();
...@@ -202,10 +202,10 @@ WHERE 1=1 ...@@ -202,10 +202,10 @@ WHERE 1=1
if (secondModel == null || (secondModel != null && secondModel.Id <= 0)) if (secondModel == null || (secondModel != null && secondModel.Id <= 0))
{ {
stuCommentRepository.SetStuCommentRepository(new RB_Stu_Comment() new StuCommentRepository().SetStuCommentRepository(new RB_Stu_Comment()
{ {
Id = 0, Id = 0,
StartHomeWorkId= secondList.FirstOrDefault().Stu_HomeWork_Id, StartHomeWorkId = secondList.FirstOrDefault().Stu_HomeWork_Id,
HomeWorkId = Second_Stu_HomeWork_Id, HomeWorkId = Second_Stu_HomeWork_Id,
StuUid = Convert.ToInt32(sItem.student_uid), StuUid = Convert.ToInt32(sItem.student_uid),
CourseId = cItem.course_id, CourseId = cItem.course_id,
...@@ -219,6 +219,7 @@ WHERE 1=1 ...@@ -219,6 +219,7 @@ WHERE 1=1
} }
} }
} }
}
//第三次评价 //第三次评价
if (homeWorkList.Count >= 13) if (homeWorkList.Count >= 13)
{ {
...@@ -229,6 +230,8 @@ WHERE 1=1 ...@@ -229,6 +230,8 @@ WHERE 1=1
{ {
var thirdScore = thirdList.Average(qitem => qitem.Score_p) * 100; var thirdScore = thirdList.Average(qitem => qitem.Score_p) * 100;
info = GetCommentInfo(courseCommentList, cItem.CourseName, 3, thirdScore); info = GetCommentInfo(courseCommentList, cItem.CourseName, 3, thirdScore);
if (!string.IsNullOrEmpty(info))
{
var Third_Stu_HomeWork_Id = thirdList.LastOrDefault().Stu_HomeWork_Id; var Third_Stu_HomeWork_Id = thirdList.LastOrDefault().Stu_HomeWork_Id;
var thirdModel = GetSystemCreateComment(commentList, cItem.course_id, Third_Stu_HomeWork_Id); var thirdModel = GetSystemCreateComment(commentList, cItem.course_id, Third_Stu_HomeWork_Id);
var thirdNum = CreateRandomNum(); var thirdNum = CreateRandomNum();
...@@ -245,7 +248,7 @@ WHERE 1=1 ...@@ -245,7 +248,7 @@ WHERE 1=1
} }
if (thirdModel == null || (thirdModel != null && thirdModel.Id <= 0)) if (thirdModel == null || (thirdModel != null && thirdModel.Id <= 0))
{ {
stuCommentRepository.SetStuCommentRepository(new RB_Stu_Comment() new StuCommentRepository().SetStuCommentRepository(new RB_Stu_Comment()
{ {
Id = 0, Id = 0,
StartHomeWorkId = thirdList.FirstOrDefault().Stu_HomeWork_Id, StartHomeWorkId = thirdList.FirstOrDefault().Stu_HomeWork_Id,
...@@ -266,20 +269,9 @@ WHERE 1=1 ...@@ -266,20 +269,9 @@ WHERE 1=1
} }
} }
} }
return list;
} }
/// <summary> return list;
/// 生成随机秒数
/// </summary>
/// <returns></returns>
private static int CreateRandomSecondNum(DateTime startTime,DateTime endTime)
{
double seconds = (endTime - startTime).TotalSeconds;
Random rnd = new();
var newSeconds = rnd.Next(0, Convert.ToInt32(seconds));
return newSeconds;
} }
/// <summary> /// <summary>
...@@ -315,7 +307,7 @@ WHERE 1=1 ...@@ -315,7 +307,7 @@ WHERE 1=1
} }
//学员评论列表 //学员评论列表
var commentList = stuCommentRepository.GetStuCommentListRepository(new CourseQuery() { CourseId = query.CourseId, StuIds = query.StuIds }); var commentList =new StuCommentRepository().GetStuCommentListRepository(new CourseQuery() { CourseId = query.CourseId, StuIds = query.StuIds });
ExamWorkResult firstComment = null; ExamWorkResult firstComment = null;
ExamWorkResult secondComment = null; ExamWorkResult secondComment = null;
...@@ -414,6 +406,18 @@ WHERE 1=1 ...@@ -414,6 +406,18 @@ WHERE 1=1
return list; return list;
} }
/// <summary>
/// 生成随机秒数
/// </summary>
/// <returns></returns>
private static int CreateRandomSecondNum(DateTime startTime, DateTime endTime)
{
double seconds = (endTime - startTime).TotalSeconds;
Random rnd = new();
var newSeconds = rnd.Next(0, Convert.ToInt32(seconds));
return newSeconds;
}
/// <summary> /// <summary>
/// 生成随机数 /// 生成随机数
/// </summary> /// </summary>
...@@ -458,7 +462,7 @@ WHERE 1=1 ...@@ -458,7 +462,7 @@ WHERE 1=1
} }
if (string.IsNullOrEmpty(info)) if (string.IsNullOrEmpty(info))
{ {
var commentModel = commentRepository.GetCommentListRepository(keyWords, Times); var commentModel =new CommentRepository().GetCommentListRepository(new CourseQuery() { KeyWords=keyWords,CommentTimes=Times}).FirstOrDefault();
if (commentModel != null && commentModel.Details != null && commentModel.Details.Count > 0) if (commentModel != null && commentModel.Details != null && commentModel.Details.Count > 0)
{ {
var tempModel = commentModel.Details.Where(qitem => qitem.StartNum <= Score && Score < qitem.EndNum)?.FirstOrDefault(); var tempModel = commentModel.Details.Where(qitem => qitem.StartNum <= Score && Score < qitem.EndNum)?.FirstOrDefault();
......
...@@ -382,9 +382,9 @@ namespace EduSpider.Services ...@@ -382,9 +382,9 @@ namespace EduSpider.Services
/// </summary> /// </summary>
/// <param name="list"></param> /// <param name="list"></param>
/// <returns></returns> /// <returns></returns>
public bool BatchSetStuComment(List<RB_Stu_Comment> list) public bool BatchSetStuComment(List<RB_Stu_Comment> list, StuCommentType commentType)
{ {
return StuCommentRepository.BatchSetStuCommentRepository(list); return StuCommentRepository.BatchSetStuCommentRepository(list,commentType);
} }
/// <summary> /// <summary>
...@@ -472,9 +472,9 @@ namespace EduSpider.Services ...@@ -472,9 +472,9 @@ namespace EduSpider.Services
/// 获取系统评价配置 /// 获取系统评价配置
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public RB_Comment_Extend GetSysComment(string KeyWords, int CommentTimes) public List<RB_Comment_Extend> GetSysComment(CourseQuery query)
{ {
var model = CommentRepository.GetCommentListRepository(KeyWords, CommentTimes); var model = CommentRepository.GetCommentListRepository(query);
return model; return model;
} }
......
...@@ -166,7 +166,7 @@ namespace EduSpider.WebApi.Controllers ...@@ -166,7 +166,7 @@ namespace EduSpider.WebApi.Controllers
} }
else else
{ {
var sysModel = CourseService.GetSysComment(query.CourseName,query.CommentTimes); var sysModel = CourseService.GetSysComment(new CourseQuery() { KeyWords= query.CourseName ,CommentTimes= query.CommentTimes }).FirstOrDefault();
if (sysModel != null) if (sysModel != null)
{ {
result = new result = new
...@@ -205,52 +205,57 @@ namespace EduSpider.WebApi.Controllers ...@@ -205,52 +205,57 @@ namespace EduSpider.WebApi.Controllers
{ {
CourseId = base.ReqParameters.GetInt("CourseId"), CourseId = base.ReqParameters.GetInt("CourseId"),
CourseName = base.ReqParameters.GetString("CourseName"), CourseName = base.ReqParameters.GetString("CourseName"),
}; };
var courseRuleList = CourseService.GetCourseCommentList(query); var courseRuleList = CourseService.GetCourseCommentList(query);
object result = new object(); List<object> result = new List<object>();
if (courseRuleList != null) if (courseRuleList != null && courseRuleList.Count > 0)
{ {
result = new foreach (var item in courseRuleList)
{ {
result.Add(new
query.CourseId, {
query.CourseName, IsDefault = 0,
item.Id,
CommentDetails = courseRuleList, item.Times,
}; CommentDetails = item.CommentDetails.Select(qitem => new
{
qitem.DetailId,
qitem.CourseCommentId,
qitem.StartNum,
qitem.EndNum,
qitem.Info,
}),
});
}
} }
else else
{ {
var sysModel = CourseService.GetSysComment(query.CourseName, query.CommentTimes); var sysCommentList = CourseService.GetSysComment(new CourseQuery() { KeyWords = query.CourseName, CommentTimes = query.CommentTimes });
if (sysModel != null) if (sysCommentList != null && sysCommentList.Count > 0)
{
result = new
{ {
Id = 0, foreach (var item in sysCommentList)
Title = "系统默认配置",
query.CourseId,
Times = query.CommentTimes,
CommentDetails = sysModel.Details,
};
}
else
{ {
result = new result.Add(new
{ {
Id = 0, IsDefault = 1,
Title = "系统默认配置", item.Id,
query.CourseId, item.Times,
Times = query.CommentTimes, CommentDetails = item.Details.Select(qitem => new
CommentDetails = new List<RB_Comment_Details>() {
}; DetailId = 0,
CourseCommentId = 0,
qitem.StartNum,
qitem.EndNum,
qitem.Info,
}),
});
}
} }
} }
return ApiResult.Success(data: result); return ApiResult.Success(data: result);
} }
/// <summary> /// <summary>
/// 新增可以课程评语 /// 新增可以课程评语
/// </summary> /// </summary>
...@@ -336,6 +341,12 @@ namespace EduSpider.WebApi.Controllers ...@@ -336,6 +341,12 @@ namespace EduSpider.WebApi.Controllers
public ApiResult BatchSetStuComment() public ApiResult BatchSetStuComment()
{ {
var stuListStr = base.ReqParameters.GetString("ChooseStuList"); var stuListStr = base.ReqParameters.GetString("ChooseStuList");
StuCommentType commentType = new StuCommentType()
{
CommentId = base.ReqParameters.GetInt("CommentId"),
CommentType = base.ReqParameters.GetInt("CommentType"),
IsDefault = base.ReqParameters.GetInt("IsDefault")
};
List<RB_Stu_Comment> list = new(); List<RB_Stu_Comment> list = new();
if (!string.IsNullOrWhiteSpace(stuListStr)) if (!string.IsNullOrWhiteSpace(stuListStr))
{ {
...@@ -365,7 +376,7 @@ namespace EduSpider.WebApi.Controllers ...@@ -365,7 +376,7 @@ namespace EduSpider.WebApi.Controllers
} }
} }
} }
var flag = CourseService.BatchSetStuComment(list); var flag = CourseService.BatchSetStuComment(list, commentType);
return flag ? ApiResult.Success() : ApiResult.Failed(); return flag ? ApiResult.Success() : ApiResult.Failed();
} }
......
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