Commit 169ace6c authored by 黄奎's avatar 黄奎

页面修改

parent 499151f8
using EduSpider.Model.Entity;
using VTX.FW.Config;
using VTX.FW.DB;
namespace EduSpider.IRepository
{
/// <summary>
/// 评语仓储层接口
/// </summary>
public interface ICommentRepository : IDBRepository<RB_Comment>, IDependency
{
/// <summary>
/// 根据查询条件获取评语
/// </summary>
/// <param name="Score"></param>
/// <returns></returns>
public RB_Comment GetComment(decimal Score);
}
}
......@@ -25,6 +25,6 @@ namespace EduSpider.IRepository
/// 获取学生作业列表
/// </summary>
/// <returns></returns>
public List<RB_Stu_HomeWork_Extend> GetStuHomeWorkListRepository(CourseQuery query);
public List<ExamWorkResult> GetStuHomeWorkListRepository(CourseQuery query);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VTX.FW.Attr;
namespace EduSpider.Model.Entity
{
/// <summary>
/// 评语配置
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Comment
{
/// <summary>
/// 评语
/// </summary>
public int Id { get; set; }
/// <summary>
/// 开始值
/// </summary>
public decimal StartNum { get; set; }
/// <summary>
/// 结束值
/// </summary>
public decimal EndNum { get; set; }
/// <summary>
/// 评语
/// </summary>
public string Info { get; set; }
}
}
......@@ -11,6 +11,11 @@ namespace EduSpider.Model.Extend
/// </summary>
public class ExamWorkResult
{
/// <summary>
/// 行号
/// </summary>
public int RowNum { get; set; }
/// <summary>
/// 创建时间
/// </summary>
......@@ -21,6 +26,29 @@ namespace EduSpider.Model.Extend
/// </summary>
public int ResultType { get; set; }
/// <summary>
/// 类型(1-作业,2-考试,3-评语)
/// </summary>
public string ResultTypeStr
{
get
{
string str = "";
switch (this.ResultType)
{
case 1:str = "作业"; break;
case 2: str = "考试"; break;
case 3: str = "评语"; break;
}
return str;
}
}
/// <summary>
/// 阶段评语
/// </summary>
public string Comment { get; set; }
/// <summary>
/// 标题
/// </summary>
......
using EduSpider.IRepository;
using EduSpider.Model.Entity;
using EduSpider.Repository.Base;
using System.Linq;
using System.Text;
using VTX.FW.DB.Dapper;
namespace EduSpider.Repository
{
/// <summary>
/// 课程仓储层
/// </summary>
public class CommentRepository : BaseRepository<RB_Comment>, ICommentRepository
{
/// <summary>
/// 获取评语
/// </summary>
/// <param name="Score"></param>
/// <returns></returns>
public RB_Comment GetComment(decimal Score)
{
StringBuilder builder = new();
builder.AppendFormat(@"
SELECT A.*
FROM RB_Comment AS A
WHERE 1=1
");
builder.AppendFormat(@" AND A.StartNum<{0} AND {0}<=A.EndNum ", Score);
return base.Get<RB_Comment>(builder.ToString()).ToList().FirstOrDefault();
}
}
}
......@@ -14,6 +14,11 @@ namespace EduSpider.Repository
/// </summary>
public class StuHomeWorkRepository : BaseRepository<RB_Stu_HomeWork>, IStuHomeWorkRepository
{
/// <summary>
/// 评语配置仓储层对象
/// </summary>
private readonly CommentRepository commentRepository = new CommentRepository();
/// <summary>
/// 批量添加学生家庭作业
/// </summary>
......@@ -30,11 +35,12 @@ namespace EduSpider.Repository
/// 获取学生作业列表
/// </summary>
/// <returns></returns>
public List<RB_Stu_HomeWork_Extend> GetStuHomeWorkListRepository(CourseQuery query)
public List<ExamWorkResult> GetStuHomeWorkListRepository(CourseQuery query)
{
List<ExamWorkResult> list = new List<ExamWorkResult>();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*,B.homework_title,B.score_type,B.score_value,C.courseName
SELECT A.*,B.homework_title,B.score_value,C.courseName
FROM RB_Stu_HomeWork AS A LEFT JOIN rb_homework AS B ON A.homework_id=B.homework_id
LEFT JOIN rb_course AS C ON A.course_id=C.courseId
WHERE 1=1
......@@ -54,7 +60,95 @@ WHERE 1=1
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Stu_HomeWork_Extend.student_uid), query.StuIds);
}
}
return Get<RB_Stu_HomeWork_Extend>(builder.ToString()).ToList();
var dataList = Get<RB_Stu_HomeWork_Extend>(builder.ToString()).ToList();
List<ExamWorkResult> homeWorkList = new List<ExamWorkResult>();
if (dataList != null && dataList.Count > 0)
{
int RowNum = 1;
foreach (var item in dataList)
{
homeWorkList.Add(new ExamWorkResult()
{
RowNum= RowNum,
CreateTime = item.add_time,
ResultType = 1,
Title = item.homework_title,
Score = item.score,
Score_p = item.score_p,
ScoreType = item.score_type,
Score_Value = item.score_value,
HomeWorkStatus = item.status,
});
RowNum++;
}
}
ExamWorkResult firstComment = null;
ExamWorkResult secondComment = null;
ExamWorkResult thirdComment = null;
if (homeWorkList != null && homeWorkList.Count > 0)
{
if (homeWorkList.Count >= 5)
{
var firstList = homeWorkList.Where(qitem => qitem.RowNum <= 5).ToList();
var score = firstList.Average(qitem => qitem.Score_p) * 100;
var commentModel = commentRepository.GetComment(score);
firstComment = new ExamWorkResult()
{
CreateTime = firstList.LastOrDefault().CreateTime.AddMinutes(1),
ResultType = 3,
Title = "第一阶段评语",
Comment = commentModel?.Info
};
}
if (homeWorkList.Count >= 9)
{
var secondList = homeWorkList.Where(qitem => qitem.RowNum > 5 && qitem.RowNum <= 9).ToList();
var score = secondList.Average(qitem => qitem.Score_p) * 100;
var commentModel = commentRepository.GetComment(score);
secondComment = new ExamWorkResult()
{
CreateTime = secondList.LastOrDefault().CreateTime.AddMinutes(1),
ResultType = 3,
Title = "第二阶段评语",
Comment = commentModel?.Info
};
}
if (homeWorkList.Count >= 13)
{
var thirdList = homeWorkList.Where(qitem => qitem.RowNum > 9).ToList();
var score = thirdList.Average(qitem => qitem.Score_p) * 100;
var commentModel = commentRepository.GetComment(score);
thirdComment = new ExamWorkResult()
{
CreateTime = thirdList.LastOrDefault().CreateTime.AddMinutes(1),
ResultType = 3,
Title = "第三阶段评语",
Comment = commentModel?.Info
};
}
}
for (var i = 0; i < homeWorkList.Count; i++)
{
var item = homeWorkList[i];
list.Add(item);
if (i == 4 && firstComment != null)
{
list.Add(firstComment);
}
if (i == 8 && secondComment != null)
{
list.Add(secondComment);
}
if (i == 12 && thirdComment != null)
{
list.Add(thirdComment);
}
}
return list;
}
}
}
......@@ -31,6 +31,12 @@ namespace EduSpider.Services
[Autowired]
public IStuHomeWorkRepository StuHomeWorkRepository { get; set; }
/// <summary>
/// 评语仓储层接口
/// </summary>
[Autowired]
public ICommentRepository CommentRepository { get; set; }
/// <summary>
/// 获取学员课程列表
......@@ -55,21 +61,7 @@ namespace EduSpider.Services
var homeWorkList = StuHomeWorkRepository.GetStuHomeWorkListRepository(query);
if (homeWorkList != null && homeWorkList.Count > 0)
{
foreach (var item in homeWorkList)
{
ExamWorkResult model = new ExamWorkResult()
{
CreateTime = item.add_time,
ResultType = 1,
Title = item.homework_title,
Score = item.score,
Score_p = item.score_p,
ScoreType = item.score_type,
Score_Value = item.score_value,
HomeWorkStatus = item.status,
};
dataList.Add(model);
}
dataList.AddRange(homeWorkList);
}
if (dataList != null && dataList.Count > 0)
{
......@@ -78,6 +70,7 @@ namespace EduSpider.Services
list.Add(new
{
item.ResultType,
item.ResultTypeStr,
item.Title,
CreateTime = VTX.FW.Helper.ConvertHelper.FormatTime(item.CreateTime),
item.Score,
......@@ -87,6 +80,7 @@ namespace EduSpider.Services
item.Score_Value,
item.HomeWorkStatus,
item.HomeWorkStatusStr,
item.Comment,
});
}
}
......
......@@ -30,7 +30,7 @@ namespace EduSpider.WebApi.Controllers
{
var query = new Model.Query.CourseQuery() { StuIds = "1976394" };
var list = CourseService.GetStuCourseList(query);
query.StuIds = "14137510";
query.StuIds = "23067080";
var homeworkExamList = CourseService.GetStuWorkAndExamList(query);
return ApiResult.Success(data: homeworkExamList, message: "成功!");
}
......

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32210.238
# Visual Studio Version 16
VisualStudioVersion = 16.0.31729.503
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EduSpider.Model", "EduSpider.Model\EduSpider.Model.csproj", "{58B2199B-FE72-4F48-972D-F7FE32A28A0F}"
EndProject
......@@ -63,6 +63,10 @@ Global
{DAC5E8C6-98DF-4B33-9E2C-452DDE54A5FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DAC5E8C6-98DF-4B33-9E2C-452DDE54A5FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DAC5E8C6-98DF-4B33-9E2C-452DDE54A5FA}.Release|Any CPU.Build.0 = Release|Any CPU
{6D059BFB-A071-4856-A35D-38EB893FED74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D059BFB-A071-4856-A35D-38EB893FED74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D059BFB-A071-4856-A35D-38EB893FED74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D059BFB-A071-4856-A35D-38EB893FED74}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
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