Commit 82602540 authored by liudong1993's avatar liudong1993

1

parent 9e75dc21
......@@ -195,7 +195,10 @@ namespace Edu.Module.Course
/// 账户仓储层
/// </summary>
private readonly RB_AccountRepository accountRepository = new RB_AccountRepository();
/// <summary>
/// 单词
/// </summary>
private readonly RB_Course_WordsRepository course_WordsRepository = new RB_Course_WordsRepository();
/// <summary>
/// 账户仓储层
......@@ -4828,6 +4831,68 @@ namespace Edu.Module.Course
}
return RList;
}
/// <summary>
/// 获取下节新词+复习词汇
/// </summary>
/// <param name="classId"></param>
/// <returns></returns>
public object GetIndexWords(int classId, int courseId, int groupId)
{
int NextCourseNo = 0, ReviewCourseNo = 0;
var planModel = class_PlanRepository.GetToDayClassPlan(classId, groupId);
if (planModel != null)
{
int zj = planModel.LessonPlanNum + 1;//这次课的章节
if (planModel.ClassDate.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
{
//查询上课时间 看这节课到底上没有上
var timeList = class_TimeRepository.GetClassTimeListRepository(new RB_Class_Time_ViewModel() { Group_Id = groupId, ClassPlanId = planModel.ClassPlanId });
string MaxTime = timeList.Max(x => x.EndTime);
if (DateTime.Now < Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + MaxTime))
{
//当日课未结束
NextCourseNo = zj;
ReviewCourseNo = zj - 1;
}
else
{
//当日课已结束
ReviewCourseNo = zj;
NextCourseNo = zj + 1;
}
}
else if (planModel.ClassDate > DateTime.Now)
{
//未开始上此课
NextCourseNo = zj;
ReviewCourseNo = zj - 1;
}
else {
//这节课已上了
ReviewCourseNo = zj;
NextCourseNo = zj + 1;
}
}
else {
//可能未开班 可能计划不存在 直接查询 第一章节的词汇
NextCourseNo = 1;
}
int NextNum = 0, ReviewNum = 0;
if (NextCourseNo > 0) {
//查询单词数量
NextNum = course_WordsRepository.GetCourseWordsNum(courseId, NextCourseNo, groupId);
}
if (ReviewCourseNo > 0)
{
ReviewNum = course_WordsRepository.GetCourseWordsNum(courseId, ReviewCourseNo, groupId);
}
return new
{
NextWord = NextNum,
ReviewWord = ReviewNum
};
}
#endregion
#region 上课反馈记录
......
......@@ -69,5 +69,18 @@ WHERE 1=1
return flag;
}
/// <summary>
/// 获取章节单词数量
/// </summary>
/// <param name="courseId"></param>
/// <param name="nextCourseNo"></param>
/// <param name="groupId"></param>
/// <returns></returns>
public int GetCourseWordsNum(int courseId, int nextCourseNo, int groupId)
{
string sql = $@"select count(0) from RB_Course_Words where Status =0 and Group_Id ={groupId} and CourseId ={courseId} and ChapterId ={nextCourseNo}";
var obj = ExecuteScalar(sql);
return obj != null ? Convert.ToInt32(obj) : 0;
}
}
}
......@@ -1191,5 +1191,21 @@ WHERE a.`Status`=0 ");
builder.AppendFormat(@" ORDER BY ClassDate DESC limit " + day);
return Get<RB_Class_Plan_ViewModel>(builder.ToString()).ToList();
}
/// <summary>
/// 获取最近的上课计划
/// </summary>
/// <param name="classId"></param>
/// <param name="groupId"></param>
/// <returns></returns>
public RB_Class_Plan_ViewModel GetToDayClassPlan(int classId, int groupId)
{
string sql = $@"SELECT a.*,(select count(0) from rb_class_plan p where p.`Status`=0 and p.Group_Id ={groupId} and p.ClassId ={classId} and p.ClassDate < a.ClassDate) as LessonPlanNum
FROM rb_class_plan as a
WHERE a.`Status`=0 and a.Group_Id ={groupId} and a.ClassId ={classId}
and a.ClassDate <='{DateTime.Now.ToString("yyyy-MM-dd")} 23:59:59'
order by a.ClassDate desc limit 1";
return Get<RB_Class_Plan_ViewModel>(sql).FirstOrDefault();
}
}
}
......@@ -58,6 +58,10 @@ namespace Edu.WebApi.Controllers.Applet
/// 学习园地处理类对象
/// </summary>
private readonly LearningGardenModule learningGardenModule = AOP.AOPHelper.CreateAOPObject<LearningGardenModule>();
/// <summary>
/// 课程单词
/// </summary>
private readonly CourseWordsModule courseWordsModule = new CourseWordsModule();
#region 小程序首页
......@@ -203,28 +207,31 @@ namespace Edu.WebApi.Controllers.Applet
var appletUserInfo = base.AppletUserInfo;
//判断学员是否退学
var studentList = studentModule.GetStudentInfo(appletUserInfo.AccountId, appletUserInfo.Group_Id);
if (studentList == null || !studentList.Any())
{
return ApiResult.Failed(message: $"很抱歉,由于你已经退学,无法继续使用本系统", new { Error = 3 });
}
//if (studentList == null || !studentList.Any())
//{
// return ApiResult.Failed(message: $"很抱歉,由于你已经退学,无法继续使用本系统", new { Error = 3 });
//}
//获取正在学习的班级 /未开班/已结班
RB_Student_ViewModel studentModel = new RB_Student_ViewModel();
studentModel = studentList.Where(x => x.ClassStatus == 2).FirstOrDefault();
if (studentModel == null || studentModel.StuId == 0)
if (studentList.Any())
{
studentModel = new RB_Student_ViewModel();
studentModel = studentList.Where(x => x.ClassStatus == 1).FirstOrDefault();
studentModel = studentList.Where(x => x.ClassStatus == 2).FirstOrDefault();
if (studentModel == null || studentModel.StuId == 0)
{
studentModel = new RB_Student_ViewModel();
studentModel = studentList.Where(x => x.ClassStatus == 3).FirstOrDefault();
studentModel = studentList.Where(x => x.ClassStatus == 1).FirstOrDefault();
if (studentModel == null || studentModel.StuId == 0)
{
studentModel = new RB_Student_ViewModel();
studentModel = studentList.Where(x => x.ClassStatus == 3).FirstOrDefault();
}
}
}
//查询下一节课(要查询正在学习中)
var ClassNext = new object();
if (studentModel.ClassStatus != 3) {
if (studentModel.ClassId > 0 && studentModel.ClassStatus != 3) {
var classTimeList = classModule.GetClassTimeByClassId(studentModel.ClassId, appletUserInfo.Group_Id);
int ClassPlanState = 1;//上课中
var tempList = classTimeList.OrderBy(x => x.NewEndPlanDateTime).Where(x => x.ClassId == studentModel.ClassId && x.NewPlanDateTime.HasValue && System.DateTime.Now >= x.NewPlanDateTime.Value && x.NewEndPlanDateTime.HasValue && System.DateTime.Now < x.NewEndPlanDateTime.Value);
......@@ -299,6 +306,18 @@ namespace Edu.WebApi.Controllers.Applet
}
//查询单词
var Words = new object();
if (studentModel.ClassId > 0)
{
Words = classModule.GetIndexWords(studentModel.ClassId, studentModel.CourseId, appletUserInfo.Group_Id);
}
else {
Words = new
{
NextWord = 0,
ReviewWord = 0
};
}
return ApiResult.Success("", new {
studentModel.GuestId,
......@@ -310,7 +329,8 @@ namespace Edu.WebApi.Controllers.Applet
studentModel.CourseId,
studentModel.CourseName,//课程
ClassNext,
LearningGardenList
LearningGardenList,
Words
});
}
......@@ -397,6 +417,7 @@ namespace Edu.WebApi.Controllers.Applet
var appletUserInfo = base.AppletUserInfo;
JObject parms = JObject.Parse(base.RequestParm.Msg.ToString());
int ClassId = parms.GetInt("ClassId", 0);//班级ID
int CourseId = parms.GetInt("CourseId", 0);//课程ID
int GuestId = parms.GetInt("GuestId", 0);//订单GuestId
if (ClassId <= 0) {
return ApiResult.ParamIsNull("请传递班级ID");
......@@ -406,7 +427,7 @@ namespace Edu.WebApi.Controllers.Applet
var Review = classModule.GetStudyCourseReview(ClassId, Day, appletUserInfo.Group_Id);
//获取考试试卷
List<Model.ViewModel.Exam.RB_Examination_Publish_ViewModel> examinationPublishList = new List<Model.ViewModel.Exam.RB_Examination_Publish_ViewModel>();
List<RB_Examination_Publish_ViewModel> examinationPublishList = new List<RB_Examination_Publish_ViewModel>();
if (GuestId > 0)
{
examinationPublishList = paperModule.GetGuestExaminationPublishPage_V2(1, 5, out long rowsCount, new RB_Examination_Publish_ViewModel { GuestId = GuestId, Group_Id = appletUserInfo.Group_Id });
......@@ -442,7 +463,20 @@ namespace Edu.WebApi.Controllers.Applet
}
//获取单词积分
//查询单词
var Words = new object();
if (ClassId > 0 && CourseId > 0)
{
Words = classModule.GetIndexWords(ClassId, CourseId, appletUserInfo.Group_Id);
}
else
{
Words = new
{
NextWord = 0,
ReviewWord = 0
};
}
return ApiResult.Success("", new
{
......@@ -463,7 +497,8 @@ namespace Edu.WebApi.Controllers.Applet
x.TotalScore,
x.ExamSecondTime,
x.MaxScore
})
}),
Words
});
}
#endregion
......
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