Commit 8a5750d4 authored by liudong1993's avatar liudong1993
parents f0bf5e71 499151f8
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using EduSpider.Model.Query; using EduSpider.Model.Query;
using System.Collections.Generic; using System.Collections.Generic;
using VTX.FW.Config; using VTX.FW.Config;
...@@ -24,7 +25,7 @@ namespace EduSpider.Repository ...@@ -24,7 +25,7 @@ namespace EduSpider.Repository
/// </summary> /// </summary>
/// <param name="courseQuery"></param> /// <param name="courseQuery"></param>
/// <returns></returns> /// <returns></returns>
public List<RB_Course_Student> GetCourseStudentListRepository(CourseQuery query); public List<RB_Course_Student_Extend> GetCourseStudentListRepository(CourseQuery query);
} }
} }
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using VTX.FW.Config; using VTX.FW.Config;
using VTX.FW.DB; using VTX.FW.DB;
using System.Text;
using System.Linq;
using EduSpider.Model.Query;
using EduSpider.Model.Extend;
namespace EduSpider.IRepository namespace EduSpider.IRepository
{ {
...@@ -16,5 +20,11 @@ namespace EduSpider.IRepository ...@@ -16,5 +20,11 @@ namespace EduSpider.IRepository
/// <param name="homeWorks"></param> /// <param name="homeWorks"></param>
/// <returns></returns> /// <returns></returns>
public bool BatchSetStuHomeWorkRepository(List<RB_Stu_HomeWork> homeWorks); public bool BatchSetStuHomeWorkRepository(List<RB_Stu_HomeWork> homeWorks);
/// <summary>
/// 获取学生作业列表
/// </summary>
/// <returns></returns>
public List<RB_Stu_HomeWork_Extend> GetStuHomeWorkListRepository(CourseQuery query);
} }
} }
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using EduSpider.Model.Query; using EduSpider.Model.Query;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -15,20 +16,17 @@ namespace EduSpider.IServices ...@@ -15,20 +16,17 @@ namespace EduSpider.IServices
public interface ICourseService : IDependency public interface ICourseService : IDependency
{ {
/// <summary> /// <summary>
/// 获取课程分页列表 /// 获取学员课程列表
/// </summary> /// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param> /// <param name="query"></param>
/// <returns></returns> /// <returns></returns>
public List<RB_Course> GetCoursePage(int pageIndex, int pageSize, out long rowsCount, CourseQuery query); public List<RB_Course_Student_Extend> GetStuCourseList(CourseQuery query);
/// <summary> /// <summary>
/// 获取课程列表 /// 获取学员考试和家庭作业列表
/// </summary> /// </summary>
/// <param name="query"></param> /// <param name="query"></param>
/// <returns></returns> /// <returns></returns>
public List<RB_Course> GetCourseList(CourseQuery query); public List<object> GetStuWorkAndExamList(CourseQuery query);
} }
} }
...@@ -71,7 +71,7 @@ namespace EduSpider.Model.Entity ...@@ -71,7 +71,7 @@ namespace EduSpider.Model.Entity
public int? is_reform { get; set; } public int? is_reform { get; set; }
/// <summary> /// <summary>
/// is_revised /// 是否补交(1-正常,2-补交)
/// </summary> /// </summary>
public int is_revised { get; set; } public int is_revised { get; set; }
...@@ -126,9 +126,9 @@ namespace EduSpider.Model.Entity ...@@ -126,9 +126,9 @@ namespace EduSpider.Model.Entity
public DateTime show_time { get; set; } public DateTime show_time { get; set; }
/// <summary> /// <summary>
/// status /// 作业状态(0-未提交,1-已提交,2-已批阅)
/// </summary> /// </summary>
public string status { get; set; } public int status { get; set; }
/// <summary> /// <summary>
/// 学生作业分享Key /// 学生作业分享Key
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EduSpider.Model.Extend
{
/// <summary>
/// 学员作业和考试结果
/// </summary>
public class ExamWorkResult
{
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 类型(1-作业,2-考试,3-评语)
/// </summary>
public int ResultType { get; set; }
/// <summary>
/// 标题
/// </summary>
public string Title { get; set; }
/// <summary>
/// 评分机制(5-自定义,4-不评分,3-等第制,2-十分制,1-百分制)
/// </summary>
public int ScoreType { get; set; }
/// <summary>
/// 分数(ScoreType=5时使用)
/// </summary>
public decimal Score_Value { get; set; }
/// <summary>
/// 评分方式字符串
/// </summary>
public string ScoreTypeStr
{
get
{
string str = "";
switch (this.ScoreType)
{
case 1: str = "百分制"; break;
case 2: str = "十分制"; break;
case 3: str = "等第制"; break;
case 4: str = "不评分"; break;
case 5: str = "自定义"; break;
}
return str;
}
}
/// <summary>
/// 得分
/// </summary>
public decimal Score { get; set; }
/// <summary>
/// 得分率
/// </summary>
public decimal Score_p { get; set; }
/// <summary>
/// 作业状态状态
/// </summary>
public int HomeWorkStatus { get; set; }
/// <summary>
/// 作业状态字符串
/// </summary>
public string HomeWorkStatusStr
{
get
{
string str = "";
switch (this.HomeWorkStatus)
{
case 0: str = "未交作业"; break;
case 1: str = "未批阅"; break;
case 2: str = "已批阅"; break;
}
return str;
}
}
}
}
using EduSpider.Model.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EduSpider.Model.Extend
{
/// <summary>
/// 课程学员关联表扩展实体类
/// </summary>
public class RB_Course_Student_Extend : RB_Course_Student
{
/// <summary>
/// 课程名称
/// </summary>
public string courseName { get; set; }
/// <summary>
/// 教师编号
/// </summary>
public int teacherId { get; set; }
/// <summary>
/// 教师名称
/// </summary>
public string teacherName { get; set; }
/// <summary>
/// 教师头像
/// </summary>
public string teacherLogo { get; set;}
/// <summary>
/// 课程图片
/// </summary>
public string courseWare { get; set; }
/// <summary>
/// 封面图
/// </summary>
public string CoverImg { get; set; }
/// <summary>
/// 课程状态
/// </summary>
public int courseStatus { get; set; }
/// <summary>
/// 完成次数
/// </summary>
public int completeNum { get; set; }
/// <summary>
/// 总次数
/// </summary>
public int totalClassNum { get; set; }
}
}
using EduSpider.Model.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EduSpider.Model.Extend
{
/// <summary>
/// 学员作业扩展实体类
/// </summary>
public class RB_Stu_HomeWork_Extend : RB_Stu_HomeWork
{
/// <summary>
/// 作业名称
/// </summary>
public string homework_title { get; set; }
/// <summary>
/// 课程名称
/// </summary>
public string courseName { get; set; }
/// <summary>
/// 自定义分数
/// </summary>
public decimal score_value { get; set; }
}
}
...@@ -17,11 +17,25 @@ namespace EduSpider.Model.Query ...@@ -17,11 +17,25 @@ namespace EduSpider.Model.Query
/// </summary> /// </summary>
public int courseId { get; set; } public int courseId { get; set; }
/// <summary>
/// 课程编号【多个】
/// </summary>
public string QCourseIds { get; set; }
/// <summary> /// <summary>
/// 课程名称 /// 课程名称
/// </summary> /// </summary>
public string courseName { get; set; } public string courseName { get; set; }
/// <summary>
/// 学员编号
/// </summary>
public string StuIds { get; set; }
/// <summary>
/// 教师编号
/// </summary>
public string TeacherIds { get; set; }
} }
} }
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using EduSpider.Model.Query; using EduSpider.Model.Query;
using EduSpider.Repository.Base; using EduSpider.Repository.Base;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -30,13 +31,13 @@ namespace EduSpider.Repository ...@@ -30,13 +31,13 @@ namespace EduSpider.Repository
/// </summary> /// </summary>
/// <param name="courseQuery"></param> /// <param name="courseQuery"></param>
/// <returns></returns> /// <returns></returns>
public List<RB_Course_Student> GetCourseStudentListRepository(CourseQuery query) public List<RB_Course_Student_Extend> GetCourseStudentListRepository(CourseQuery query)
{ {
var parameters = new DynamicParameters(); var parameters = new DynamicParameters();
StringBuilder builder = new(); StringBuilder builder = new();
builder.AppendFormat(@" builder.AppendFormat(@"
SELECT A.* SELECT A.*,B.courseName,B.teacherId,B.teacherName,B.teacherLogo,B.courseWare,B.CoverImg,B.courseStatus,B.completeNum,B.totalClassNum
FROM RB_Course_Student AS A FROM RB_Course_Student AS A INNER JOIN RB_Course AS B ON A.courseId=B.courseId
WHERE 1=1 WHERE 1=1
"); ");
if (query != null) if (query != null)
...@@ -46,8 +47,13 @@ WHERE 1=1 ...@@ -46,8 +47,13 @@ WHERE 1=1
{ {
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Course_Student.courseId), query.courseId); builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Course_Student.courseId), query.courseId);
} }
if (!string.IsNullOrWhiteSpace(query.StuIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Course_Student.uid), query.StuIds);
}
} }
return base.Get<RB_Course_Student>(builder.ToString(), parameters).ToList(); builder.AppendFormat(" ORDER BY A.courseId DESC ");
return base.Get<RB_Course_Student_Extend>(builder.ToString(), parameters).ToList();
} }
} }
} }
using EduSpider.IRepository; using EduSpider.IRepository;
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
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.Text;
namespace EduSpider.Repository namespace EduSpider.Repository
{ {
...@@ -21,5 +25,36 @@ namespace EduSpider.Repository ...@@ -21,5 +25,36 @@ namespace EduSpider.Repository
flag = base.BatchInsert(homeWorks, isReplace: true); flag = base.BatchInsert(homeWorks, isReplace: true);
return flag; return flag;
} }
/// <summary>
/// 获取学生作业列表
/// </summary>
/// <returns></returns>
public List<RB_Stu_HomeWork_Extend> GetStuHomeWorkListRepository(CourseQuery query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*,B.homework_title,B.score_type,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
");
if (query != null)
{
if (query.courseId > 0)
{
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Stu_HomeWork_Extend.course_id), query.courseId);
}
if (!string.IsNullOrWhiteSpace(query.QCourseIds))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Stu_HomeWork_Extend.course_id), query.QCourseIds);
}
if (!string.IsNullOrEmpty(query.StuIds))
{
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();
}
} }
} }
 
using EduSpider.IRepository;
using EduSpider.IServices; using EduSpider.IServices;
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using EduSpider.Model.Query; using EduSpider.Model.Query;
using EduSpider.Repository; using EduSpider.Repository;
using System; using System;
...@@ -18,32 +20,77 @@ namespace EduSpider.Services ...@@ -18,32 +20,77 @@ namespace EduSpider.Services
public class CourseService : ICourseService public class CourseService : ICourseService
{ {
/// <summary> /// <summary>
/// 课程仓储接口 /// 学员课程仓储接口
/// </summary> /// </summary>
[Autowired] [Autowired]
public ICourseRepository CourseRepository { get; set; } public ICourseStudentRepository CourseStudentRepository { get; set; }
/// <summary> /// <summary>
/// 获取课程列表 /// 学员家庭作业仓储接口
/// </summary>
[Autowired]
public IStuHomeWorkRepository StuHomeWorkRepository { get; set; }
/// <summary>
/// 获取学员课程列表
/// </summary> /// </summary>
/// <param name="query"></param> /// <param name="query"></param>
/// <returns></returns> /// <returns></returns>
public List<RB_Course> GetCourseList(CourseQuery query) public List<RB_Course_Student_Extend> GetStuCourseList(CourseQuery query)
{ {
return CourseRepository.GetCourseListRepository(query); var list = CourseStudentRepository.GetCourseStudentListRepository(query);
return list;
} }
/// <summary> /// <summary>
/// 获取课程分页列表 /// 获取学员考试和家庭作业列表
/// </summary> /// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param> /// <param name="query"></param>
/// <returns></returns> /// <returns></returns>
public List<RB_Course> GetCoursePage(int pageIndex, int pageSize, out long rowsCount, CourseQuery query) public List<object> GetStuWorkAndExamList(CourseQuery query)
{ {
return CourseRepository.GetCoursePageRepository(pageIndex, pageSize, out rowsCount, query); List<object> list = new List<object>();
List<ExamWorkResult> dataList = new List<ExamWorkResult>();
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);
}
}
if (dataList != null && dataList.Count > 0)
{
foreach (var item in dataList)
{
list.Add(new
{
item.ResultType,
item.Title,
CreateTime = VTX.FW.Helper.ConvertHelper.FormatTime(item.CreateTime),
item.Score,
item.Score_p,
item.ScoreType,
item.ScoreTypeStr,
item.Score_Value,
item.HomeWorkStatus,
item.HomeWorkStatusStr,
});
}
}
return list;
} }
} }
} }
...@@ -28,8 +28,11 @@ namespace EduSpider.WebApi.Controllers ...@@ -28,8 +28,11 @@ namespace EduSpider.WebApi.Controllers
public ApiResult GetCoursePage() public ApiResult GetCoursePage()
{ {
var list = CourseService.GetCoursePage(1, 1000, out _, new Model.Query.CourseQuery()); var query = new Model.Query.CourseQuery() { StuIds = "1976394" };
return ApiResult.Success(data: list, message: "成功!"); var list = CourseService.GetStuCourseList(query);
query.StuIds = "14137510";
var homeworkExamList = CourseService.GetStuWorkAndExamList(query);
return ApiResult.Success(data: homeworkExamList, message: "成功!");
} }
} }
} }
...@@ -228,7 +228,7 @@ namespace EduSpider.Spiders.ClassInRule ...@@ -228,7 +228,7 @@ namespace EduSpider.Spiders.ClassInRule
score_p = lastObj.GetDecimal("score_p"), score_p = lastObj.GetDecimal("score_p"),
score_type = lastObj.GetInt("score_type"), score_type = lastObj.GetInt("score_type"),
show_time = ConvertHelper.UnixToDateTime(lastObj.GetInt("show_time")), show_time = ConvertHelper.UnixToDateTime(lastObj.GetInt("show_time")),
status = lastObj.GetString("status"), status = lastObj.GetInt("status"),
stu_homework_share_key= lastObj.GetString("stu_homework_share_key"), stu_homework_share_key= lastObj.GetString("stu_homework_share_key"),
student_account = lastObj.GetString("student_account"), student_account = lastObj.GetString("student_account"),
student_name = lastObj.GetString("student_name"), student_name = lastObj.GetString("student_name"),
......
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