Commit bc97ecac authored by liudong1993's avatar liudong1993

1

parent 97826a2a
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -14,6 +15,6 @@ namespace EduSpider.Repository ...@@ -14,6 +15,6 @@ namespace EduSpider.Repository
/// </summary> /// </summary>
public interface IExamRepository : IDBRepository<RB_Exam>, IDependency public interface IExamRepository : IDBRepository<RB_Exam>, IDependency
{ {
List<RB_Exam_Extend> GetExamPageList(int pageIndex, int pageSize, out long count, RB_Exam_Extend demodel);
} }
} }
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -14,6 +15,6 @@ namespace EduSpider.Repository ...@@ -14,6 +15,6 @@ namespace EduSpider.Repository
/// </summary> /// </summary>
public interface IExam_QuestionsRepository : IDBRepository<RB_Exam_Questions>, IDependency public interface IExam_QuestionsRepository : IDBRepository<RB_Exam_Questions>, IDependency
{ {
List<RB_Exam_Questions_Extend> GetList(RB_Exam_Questions_Extend rB_Exam_Questions_Extend);
} }
} }
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -14,6 +15,6 @@ namespace EduSpider.Repository ...@@ -14,6 +15,6 @@ namespace EduSpider.Repository
/// </summary> /// </summary>
public interface IExam_ScoreRepository : IDBRepository<RB_Exam_Score>, IDependency public interface IExam_ScoreRepository : IDBRepository<RB_Exam_Score>, IDependency
{ {
List<RB_Exam_Score_Extend> GetList(RB_Exam_Score_Extend rB_Exam_Score_Extend);
} }
} }
using System; using EduSpider.Model.Extend;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
...@@ -13,5 +14,7 @@ namespace EduSpider.IServices ...@@ -13,5 +14,7 @@ namespace EduSpider.IServices
public interface IExamService : IDependency public interface IExamService : IDependency
{ {
string ImportExcelForStuExamScore(string path_server,int courseId, string examName, int userId); string ImportExcelForStuExamScore(string path_server,int courseId, string examName, int userId);
List<RB_Exam_Extend> GetExamPageList(int pageIndex, int pageSize, out long count, RB_Exam_Extend demodel);
object GetExamStuScoreInfo(int examId, int stuId);
} }
} }
...@@ -9,6 +9,14 @@ namespace EduSpider.Model.Extend ...@@ -9,6 +9,14 @@ namespace EduSpider.Model.Extend
/// </summary> /// </summary>
public class RB_Exam_Extend : RB_Exam public class RB_Exam_Extend : RB_Exam
{ {
/// <summary>
/// 学生数量
/// </summary>
public int StuNum { get; set; }
/// <summary>
/// 总分数
/// </summary>
public decimal TScore { get; set; }
} }
} }
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using System; using System;
using System.Collections.Generic;
using VTX.FW.Attr; using VTX.FW.Attr;
namespace EduSpider.Model.Extend namespace EduSpider.Model.Extend
...@@ -9,6 +10,45 @@ namespace EduSpider.Model.Extend ...@@ -9,6 +10,45 @@ namespace EduSpider.Model.Extend
/// </summary> /// </summary>
public class RB_Exam_Score_Extend : RB_Exam_Score public class RB_Exam_Score_Extend : RB_Exam_Score
{ {
public List<ExamQScoreModel> ScoreList { get; set; }
} }
/// <summary>
/// 学生单项分数
/// </summary>
public class ExamQScoreModel {
/// <summary>
/// 题号
/// </summary>
public int Sort { get; set; }
/// <summary>
/// 得分
/// </summary>
public decimal Score { get; set; }
/// <summary>
/// 平均得分
/// </summary>
public decimal AvgScore { get; set; }
/// <summary>
/// 难度
/// </summary>
public string Difficulty { get; set; }
/// <summary>
/// 知识点
/// </summary>
public string KnowledgePoint { get; set; }
/// <summary>
/// 归属模块
/// </summary>
public string Module { get; set; }
/// <summary>
/// 题目分数
/// </summary>
public decimal QScore { get; set; }
}
} }
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using EduSpider.Repository.Base; using EduSpider.Repository.Base;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using VTX.FW.DB.Dapper;
namespace EduSpider.Repository namespace EduSpider.Repository
{ {
...@@ -13,6 +15,37 @@ namespace EduSpider.Repository ...@@ -13,6 +15,37 @@ namespace EduSpider.Repository
/// </summary> /// </summary>
public class ExamRepository : BaseRepository<RB_Exam>, IExamRepository public class ExamRepository : BaseRepository<RB_Exam>, IExamRepository
{ {
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Exam_Extend> GetExamPageList(int pageIndex, int pageSize, out long count, RB_Exam_Extend demodel)
{
var parameters = new DynamicParameters();
string where = " 1=1 and e.Status =0";
if (demodel.CourseId > 0)
{
where += $@" and e.{nameof(RB_Exam_Extend.CourseId)} ={demodel.CourseId}";
}
if (!string.IsNullOrEmpty(demodel.ExamName)) {
where += $@" and e.{nameof(RB_Exam_Extend.ExamName)} like @ExamName";
parameters.Add("ExamName", "%" + demodel.ExamName.Trim() + "%");
}
if (demodel.CreateBy > 0)
{
where += $@" and e.{nameof(RB_Exam_Extend.CreateBy)} ={demodel.CreateBy}";
}
string sql = $@"select e.*,es.StuNum,es.TScore FROM rb_exam e
LEFT JOIN (
SELECT e.ExamId,COUNT(0) as StuNum,SUM(e.TScore) as TScore FROM rb_exam_score e GROUP BY e.ExamId
) es on e.ExamId = es.ExamId
where {where} order by e.EcamId desc";
return GetPage<RB_Exam_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
} }
} }
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using EduSpider.Repository.Base; using EduSpider.Repository.Base;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -13,6 +14,20 @@ namespace EduSpider.Repository ...@@ -13,6 +14,20 @@ namespace EduSpider.Repository
/// </summary> /// </summary>
public class Exam_QuestionsRepository : BaseRepository<RB_Exam_Questions>, IExam_QuestionsRepository public class Exam_QuestionsRepository : BaseRepository<RB_Exam_Questions>, IExam_QuestionsRepository
{ {
/// <summary>
/// 获取列表
/// </summary>
/// <param name="rB_Exam_Questions_Extend"></param>
/// <returns></returns>
public List<RB_Exam_Questions_Extend> GetList(RB_Exam_Questions_Extend dmodel)
{
string where = " 1=1";
if (dmodel.ExamId > 0)
{
where += $" and {nameof(RB_Exam_Questions_Extend.ExamId)} ={dmodel.ExamId}";
}
string sql = $"select * from RB_Exam_Questions where {where}";
return Get<RB_Exam_Questions_Extend>(sql).ToList();
}
} }
} }
using EduSpider.Model.Entity; using EduSpider.Model.Entity;
using EduSpider.Model.Extend;
using EduSpider.Repository.Base; using EduSpider.Repository.Base;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -13,6 +14,19 @@ namespace EduSpider.Repository ...@@ -13,6 +14,19 @@ namespace EduSpider.Repository
/// </summary> /// </summary>
public class Exam_ScoreRepository : BaseRepository<RB_Exam_Score>, IExam_ScoreRepository public class Exam_ScoreRepository : BaseRepository<RB_Exam_Score>, IExam_ScoreRepository
{ {
public List<RB_Exam_Score_Extend> GetList(RB_Exam_Score_Extend dmodel)
{
string where = " 1=1";
if (dmodel.ExamId > 0)
{
where += $" and {nameof(RB_Exam_Score_Extend.ExamId)} ={dmodel.ExamId}";
}
if (dmodel.StuId > 0)
{
where += $" and {nameof(RB_Exam_Score_Extend.StuId)} ={dmodel.StuId}";
}
string sql = $"select * from RB_Exam_Score where {where}";
return Get<RB_Exam_Score_Extend>(sql).ToList();
}
} }
} }
 
using EduSpider.IRepository; using EduSpider.IRepository;
using EduSpider.IServices; using EduSpider.IServices;
using EduSpider.Model.Extend;
using EduSpider.Repository; using EduSpider.Repository;
using EduSpider.Utility.Data; using EduSpider.Utility.Data;
using System; using System;
...@@ -44,6 +45,89 @@ namespace EduSpider.Services ...@@ -44,6 +45,89 @@ namespace EduSpider.Services
[Autowired] [Autowired]
private IStudentRepository studentRepository { get; set; } private IStudentRepository studentRepository { get; set; }
/// <summary>
/// 获取考试分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Exam_Extend> GetExamPageList(int pageIndex, int pageSize, out long count, RB_Exam_Extend demodel)
{
return examRepository.GetExamPageList(pageIndex, pageSize, out count, demodel);
}
/// <summary>
/// 获取学生考试详情
/// </summary>
/// <param name="examId"></param>
/// <param name="stuId"></param>
/// <returns></returns>
public object GetExamStuScoreInfo(int examId, int stuId)
{
var stuModel = studentRepository.GetEntity(stuId);
if (stuModel == null) { return ""; }
var examModel = examRepository.GetEntity(examId);
if (examModel == null) { return ""; }
//考试题目
var qlist = exam_QuestionsRepository.GetList(new RB_Exam_Questions_Extend() { ExamId = examId });
//考试成绩
var sExamModel = exam_ScoreRepository.GetList(new RB_Exam_Score_Extend() { ExamId = examId, StuId = stuId }).FirstOrDefault();
if (sExamModel != null) {
sExamModel.ScoreList = JsonHelper.Deserialize<List<ExamQScoreModel>>(sExamModel.Content);
foreach (var qitem in sExamModel.ScoreList) {
qitem.Difficulty = qlist.Where(x => x.Sort == qitem.Sort).FirstOrDefault()?.Difficulty ?? "";
qitem.KnowledgePoint = qlist.Where(x => x.Sort == qitem.Sort).FirstOrDefault()?.KnowledgePoint ?? "";
qitem.Module = qlist.Where(x => x.Sort == qitem.Sort).FirstOrDefault()?.Module ?? "";
qitem.QScore = qlist.Where(x => x.Sort == qitem.Sort).FirstOrDefault()?.Score ?? 0;
}
}
//开始组装数据
return new
{
StuId = stuModel.StudId,
StuName = stuModel.StudentName,
ExamName = examModel.ExamName,
sExamModel?.TScore,
sExamModel?.Rank,
sExamModel?.RankRate,
ScoreRate = Math.Round((sExamModel?.TScore ?? 0) / qlist.Sum(x => x.Score), 2, MidpointRounding.AwayFromZero),
ScoreList = sExamModel?.ScoreList.Select(x => new
{
x.Sort,
x.Difficulty,
x.KnowledgePoint,
x.QScore,
x.Score,
ScoreRate = Math.Round(x.Score / x.QScore, 2, MidpointRounding.AwayFromZero),
x.AvgScore,
AvgScoreRate = Math.Round(x.AvgScore / x.QScore, 2, MidpointRounding.AwayFromZero),
}),
ModuleList = sExamModel?.ScoreList.GroupBy(x => new { x.Module }).Select(x => new
{
x.Key.Module,
Score = x.Sum(y => y.QScore),
ScoreRate = Math.Round(x.Sum(y => y.Score) / x.Sum(y => y.QScore), 2, MidpointRounding.AwayFromZero),
AvgScoreRate = Math.Round(x.Sum(y => y.AvgScore) / x.Sum(y => y.QScore), 2, MidpointRounding.AwayFromZero),
}),
DifficultyList = sExamModel?.ScoreList.GroupBy(x => new { x.Difficulty }).Select(x => new
{
x.Key.Difficulty,
Count = x.Count(),
Score = x.Sum(x => x.QScore)
}),
DifficultyRateList = sExamModel?.ScoreList.GroupBy(x => new { x.Difficulty }).Select(x => new
{
x.Key.Difficulty,
ScoreRate = Math.Round(x.Sum(y => y.Score) / x.Sum(y => y.QScore), 2, MidpointRounding.AwayFromZero),
AvgScoreRate = Math.Round(x.Sum(y => y.AvgScore) / x.Sum(y => y.QScore), 2, MidpointRounding.AwayFromZero),
})
};
}
/// <summary> /// <summary>
/// 导入考试成绩 /// 导入考试成绩
......
using Microsoft.AspNetCore.Cors; using EduSpider.Cache.User;
using EduSpider.Model.Cache;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System; using System;
using VTX.FW.Helper; using VTX.FW.Helper;
...@@ -30,5 +32,16 @@ namespace EduSpider.WebApi.Controllers.Base ...@@ -30,5 +32,16 @@ namespace EduSpider.WebApi.Controllers.Base
return UserId; return UserId;
} }
} }
/// <summary>
/// 获取登录信息
/// </summary>
public UserInfo UserInfo
{
get
{
return UserReidsCache.GetUserLoginInfo(this.BaseUserId);
}
}
} }
} }
using EduSpider.IServices;
using EduSpider.Model.Extend;
using EduSpider.WebApi.Controllers.Base;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using VTX.FW.Api;
using VTX.FW.Attr;
using VTX.FW.Helper;
namespace EduSpider.WebApi.Controllers
{
/// <summary>
/// 考试控制器
/// </summary>
public class ExamController : BaseController
{
/// <summary>
/// 考试
/// </summary>
[Autowired]
public IExamService examService { get; set; }
/// <summary>
/// 获取考试分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetExamPageList()
{
ResultPageModel pmodel = JsonHelper.Deserialize<ResultPageModel>(RequestParm.Msg.ToString());
RB_Exam_Extend demodel = JsonHelper.Deserialize<RB_Exam_Extend>(RequestParm.Msg.ToString());
var list = examService.GetExamPageList(pmodel.PageIndex, pmodel.PageSize, out long count, demodel);
pmodel.RowsCount = count;
pmodel.PageData = list.Select(x => new
{
x.ExamId,
x.ExamName,
x.StuNum,
x.TScore,
AvgScore = x.StuNum > 0 ? Math.Round(x.TScore / x.StuNum, 2, MidpointRounding.AwayFromZero) : 0,
CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH:mm")
});
return ApiResult.Success("", pmodel);
}
/// <summary>
/// 获取学生考试明细
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetExamStuScoreInfo() {
int ExamId = ReqParameters.GetInt("ExamId");//考试ID
int StuId = ReqParameters.GetInt("StuId");//学生id
if (ExamId <= 0 || StuId <= 0) {
return ApiResult.ParamIsNull();
}
var robj = examService.GetExamStuScoreInfo(ExamId, StuId);
return ApiResult.Success("", robj);
}
}
}
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