Commit 4e40b8a5 authored by liudong1993's avatar liudong1993

1

parents cd1a913b 98504ff4
using EduSpider.Model.Entity;
using System.Collections.Generic;
using VTX.FW.Config;
using VTX.FW.DB;
......@@ -15,5 +16,11 @@ namespace EduSpider.IRepository
/// <param name="Score"></param>
/// <returns></returns>
public RB_Comment GetComment(decimal Score);
/// <summary>
/// 获取系统配置评价列表
/// </summary>
/// <returns></returns>
public List<RB_Comment> GetCommentListRepository();
}
}
......@@ -33,11 +33,27 @@ namespace EduSpider.IRepository
/// <returns></returns>
public bool SetStuCommentShowTypeRepository(int ShowType, string Ids);
/// <summary>
/// 根据课程评论次数修改可见等级
/// </summary>
/// <param name="CourseId">课程编号</param>
/// <param name="Times">次数</param>
/// <param name="ShowType">可见性</param>
/// <returns></returns>
public bool SetStuCommentShowTypeByTimesRepository(int CourseId,int Times,int ShowType);
/// <summary>
/// 根据编号删除学员评论
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
public bool DeleteStuCommentRepository(string Ids);
/// <summary>
/// 获取系统生成评论次数
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Stu_Comment> GetCourseCommentTimesListRepository(CourseQuery query);
}
}
......@@ -102,11 +102,33 @@ namespace EduSpider.IServices
/// <returns></returns>
public bool SetStuCommentShowType(int ShowType, string Ids);
/// <summary>
/// 根据课程评论次数修改可见等级
/// </summary>
/// <param name="CourseId">课程编号</param>
/// <param name="Times">次数</param>
/// <param name="ShowType">可见性</param>
/// <returns></returns>
public bool SetStuCommentShowTypeByTimes(int CourseId, int Times, int ShouType);
/// <summary>
/// 根据编号删除学员评论
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
public bool RemoveStuComment(string Ids);
/// <summary>
/// 获取系统生成评论次数
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Stu_Comment> GetCourseCommentTimesList(CourseQuery query);
/// <summary>
/// 获取系统评价配置
/// </summary>
/// <returns></returns>
public List<RB_Comment> GetSysComment();
}
}
......@@ -44,5 +44,15 @@
/// 作业编号
/// </summary>
public int HomeWorkId { get; set; }
/// <summary>
/// 创建类型(1-系统创建,2-老师创建)
/// </summary>
public int CreateCommentType { get; set; }
/// <summary>
/// 评论次数
/// </summary>
public int CommentTimes { get; set; }
}
}
using EduSpider.IRepository;
using EduSpider.Model.Entity;
using EduSpider.Repository.Base;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VTX.FW.DB.Dapper;
......@@ -33,8 +34,24 @@ WHERE 1=1
{
builder.AppendFormat(@" AND A.StartNum<={0} AND {0}<=A.EndNum ", Score);
}
return base.Get<RB_Comment>(builder.ToString()).ToList().FirstOrDefault();
}
/// <summary>
/// 获取系统配置评价列表
/// </summary>
/// <returns></returns>
public List<RB_Comment> GetCommentListRepository()
{
StringBuilder builder = new();
builder.AppendFormat(@"
SELECT A.*
FROM RB_Comment AS A
WHERE 1=1
");
return base.Get<RB_Comment>(builder.ToString()).ToList();
}
}
}
......@@ -44,6 +44,10 @@ WHERE 1=1
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Stu_Comment.HomeWorkId), query.HomeWorkId);
}
if (query.CommentTimes > 0)
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Stu_Comment.Times), query.CommentTimes);
}
}
return Get<RB_Stu_Comment>(builder.ToString()).ToList();
}
......@@ -85,6 +89,19 @@ WHERE 1=1
return base.Execute(sql) > 0;
}
/// <summary>
/// 根据课程评论次数修改可见等级
/// </summary>
/// <param name="CourseId">课程编号</param>
/// <param name="Times">次数</param>
/// <param name="ShowType">可见性</param>
/// <returns></returns>
public bool SetStuCommentShowTypeByTimesRepository(int CourseId, int Times, int ShowType)
{
string sql = string.Format("UPDATE RB_Stu_Comment SET ShowType={0} WHERE CourseId={1} AND Times={2}", ShowType, CourseId, Times);
return base.Execute(sql) > 0;
}
/// <summary>
/// 根据编号删除学员评论
/// </summary>
......@@ -95,5 +112,44 @@ WHERE 1=1
string sql = string.Format("UPDATE RB_Stu_Comment SET Status=1 WHERE Id IN({0}) ", Ids);
return base.Execute(sql) > 0;
}
/// <summary>
/// 获取系统生成评论次数
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Stu_Comment> GetCourseCommentTimesListRepository(CourseQuery query)
{
StringBuilder builder = new();
builder.AppendFormat(@"
SELECT A.Times,A.CourseId,MAX(CreateTime) AS CreateTime,CreateType
FROM RB_Stu_Comment AS A
WHERE 1=1
");
builder.AppendFormat(" AND A.{0}=0 ", nameof(RB_Stu_Comment.Status));
if (query != null)
{
if (query.CourseId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Stu_Comment.CourseId), query.CourseId);
}
if (!string.IsNullOrWhiteSpace(query.StuIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Stu_Comment.StuUid), query.StuIds);
}
if (query.HomeWorkId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Stu_Comment.HomeWorkId), query.HomeWorkId);
}
if (query.CreateCommentType > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Stu_Comment.CreateType), query.CreateCommentType);
}
}
builder.AppendFormat(@" GROUP BY A.Times,A.CourseId ");
return Get<RB_Stu_Comment>(builder.ToString()).ToList();
}
}
}
......@@ -125,7 +125,7 @@ WHERE 1=1
if (homeWorkList.Count >= 5)
{
var firstList = homeWorkList.Where(qitem => qitem.RowNum <= 5).ToList();
var firstFlag= firstList.Where(qitem => qitem.HomeWorkStatus == 0).Count() > 0;
var firstFlag= firstList.Where(qitem => qitem.HomeWorkStatus == 0).Any();
//第一阶段有未提交的作业就不生成系统评价
if (!firstFlag)
{
......@@ -169,7 +169,7 @@ WHERE 1=1
if (homeWorkList.Count >= 9)
{
var secondList = homeWorkList.Where(qitem => qitem.RowNum > 5 && qitem.RowNum <= 9).ToList();
var secondFlag = secondList.Where(qitem => qitem.HomeWorkStatus == 0).Count() > 0;
var secondFlag = secondList.Where(qitem => qitem.HomeWorkStatus == 0).Any();
if (!secondFlag)
{
var secondScore = secondList.Average(qitem => qitem.Score_p) * 100;
......@@ -212,7 +212,7 @@ WHERE 1=1
if (homeWorkList.Count >= 13)
{
var thirdList = homeWorkList.Where(qitem => qitem.RowNum > 9 && qitem.RowNum <= 13).ToList();
var thirdFlag = thirdList.Where(qitem => qitem.HomeWorkStatus == 0).Count() > 0;
var thirdFlag = thirdList.Where(qitem => qitem.HomeWorkStatus == 0).Any();
if (!thirdFlag)
{
var thirdScore = thirdList.Average(qitem => qitem.Score_p) * 100;
......@@ -290,9 +290,9 @@ WHERE 1=1
/// 生成随机数
/// </summary>
/// <returns></returns>
private int CreateRandomNum()
private static int CreateRandomNum()
{
Random rnd = new Random();
Random rnd = new();
return rnd.Next(5, 20);
}
......@@ -303,9 +303,9 @@ WHERE 1=1
/// <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)
private static 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();
var tempModel = commentList.Where(qitem => qitem.CourseId == CourseId && qitem.HomeWorkId == Stu_HomeWork_Id && qitem.CreateType == 1).FirstOrDefault();
return tempModel;
}
......
This diff is collapsed.
......@@ -138,19 +138,41 @@ namespace EduSpider.WebApi.Controllers
}
/// <summary>
/// 获取课程评语列表
/// 获取课程配置评价信息
/// </summary>
/// <returns></returns>
[HttpPost]
[HttpGet]
public ApiResult GetCourseCommentList()
public ApiResult GetCourseComment()
{
var query = new Model.Query.CourseQuery()
{
CourseId = base.ReqParameters.GetInt("CourseId")
};
var list = CourseService.GetCourseCommentList(query);
return ApiResult.Success(data: list);
var courseRule = CourseService.GetCourseCommentList(query).FirstOrDefault();
object result;
if (courseRule != null)
{
result = new
{
courseRule.Id,
courseRule.Title,
courseRule.CourseId,
courseRule.CommentDetails
};
}
else
{
var sysList = CourseService.GetSysComment();
result = new
{
Id = 0,
Title = "系统默认配置",
CourseId = 0,
CommentDetails = sysList
};
}
return ApiResult.Success(data: result);
}
/// <summary>
......@@ -272,6 +294,70 @@ namespace EduSpider.WebApi.Controllers
}
[HttpPost]
[HttpGet]
/// <summary>
/// 设置学员评论可见性
/// </summary>
/// <returns></returns>
public ApiResult SetStuCommentShowTypeByTimes()
{
int CourseId = base.ReqParameters.GetInt("CourseId");
int Times = base.ReqParameters.GetInt("Times");
int ShowType = base.ReqParameters.GetInt("ShowType");
var flag = CourseService.SetStuCommentShowTypeByTimes(CourseId, Times, ShowType); ;
return flag ? ApiResult.Success() : ApiResult.Failed();
}
[HttpPost]
[HttpGet]
/// <summary>
/// 获取课程已经生成的评论统计列表
/// </summary>
/// <returns></returns>
public ApiResult GetCourseCommentTimes()
{
var query = new CourseQuery()
{
CourseId = base.ReqParameters.GetInt("CourseId"),
CreateCommentType = 1
};
List<object> result = new();
var list = CourseService.GetCourseCommentTimesList(query);
if (list != null && list.Count > 0)
{
foreach (var item in list)
{
string ShowTypeStr = "";
if (item.ShowType == 1)
{
ShowTypeStr = "全部可见";
}
else if (item.ShowType == 2)
{
ShowTypeStr = "部分可见";
}
else if (item.ShowType == 3)
{
ShowTypeStr = "不可见";
}
result.Add(new
{
item.Times,
item.CourseId,
item.CreateType,
CreateTypeStr = item.CreateType == 1 ? "系统创建" : "老师创建",
item.ShowType,
ShowTypeStr,
CreateTime = VTX.FW.Helper.ConvertHelper.FormatDate(item.CreateTime),
optionsShow = false,
});
}
}
return ApiResult.Success(data: result);
}
[HttpPost]
[HttpGet]
/// <summary>
......@@ -282,7 +368,7 @@ namespace EduSpider.WebApi.Controllers
{
var query = new CourseQuery()
{
CourseId = base.ReqParameters.GetInt("CourseId")
};
var list = CourseService.GetStuCommentList(query);
return ApiResult.Success(data: list);
......
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