Commit 98c1e4b0 authored by liudong1993's avatar liudong1993

Merge branch 'master' of http://gitlab.oytour.com/Kui2/education

parents 9a6a9e70 a91c5ee9
...@@ -25,7 +25,7 @@ namespace Edu.Model.Entity.Exam ...@@ -25,7 +25,7 @@ namespace Edu.Model.Entity.Exam
/// <summary> /// <summary>
/// 问题编号 /// 问题编号
/// </summary> /// </summary>
public int? QuestionId { get; set; } public int QuestionId { get; set; }
/// <summary> /// <summary>
/// 问题名称(题干) /// 问题名称(题干)
......
...@@ -968,15 +968,7 @@ namespace Edu.Module.Exam ...@@ -968,15 +968,7 @@ namespace Edu.Module.Exam
return result; return result;
} }
/// <summary>
/// 判断是否存在学生练习
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool ExistsStudentPracticeModule(RB_Student_Practice_Extend model)
{
return false;
}
/// <summary> /// <summary>
/// 新增修改学员练习 /// 新增修改学员练习
...@@ -1010,6 +1002,19 @@ namespace Edu.Module.Exam ...@@ -1010,6 +1002,19 @@ namespace Edu.Module.Exam
return flag; return flag;
} }
/// <summary>
/// 学员开始测试
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetStudentStartExamModule(RB_Student_Exam_Extend model)
{
model.Times = student_ExamRepository.GetStudentExamTimesRepository(model);
var newId = student_ExamRepository.Insert(model);
model.Id = newId;
return newId > 0;
}
/// <summary> /// <summary>
/// 新增修改学员考试练习 /// 新增修改学员考试练习
/// </summary> /// </summary>
...@@ -1022,7 +1027,7 @@ namespace Edu.Module.Exam ...@@ -1022,7 +1027,7 @@ namespace Edu.Module.Exam
{ {
Dictionary<string, object> fileds = new Dictionary<string, object>() Dictionary<string, object> fileds = new Dictionary<string, object>()
{ {
{ nameof(RB_Student_Exam_Extend.EndTime),model.EndTime}
}; };
flag = student_ExamRepository.Update(fileds, new WhereHelper(nameof(RB_Student_Exam_Extend.Id), model.Id)); flag = student_ExamRepository.Update(fileds, new WhereHelper(nameof(RB_Student_Exam_Extend.Id), model.Id));
} }
......
...@@ -85,5 +85,42 @@ WHERE 1=1 ...@@ -85,5 +85,42 @@ WHERE 1=1
} }
return Get<RB_Student_Exam_Extend>(builder.ToString()).ToList(); return Get<RB_Student_Exam_Extend>(builder.ToString()).ToList();
} }
/// <summary>
/// 计算学员的考试次数
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public int GetStudentExamTimesRepository(RB_Student_Exam_Extend query)
{
int result = 0;
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@" SELECT COUNT(1) FROM RB_Student_Exam AS A WHERE 1=1 ");
if (query != null)
{
if (query.GroupId > 0)
{
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Student_Exam_Extend.GroupId), query.GroupId);
}
if (query.StudentId > 0)
{
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Student_Exam_Extend.StudentId), query.StudentId);
}
if (query.BankId > 0)
{
builder.AppendFormat(@" AND A.{0}={1} ", nameof(RB_Student_Exam_Extend.BankId), query.BankId);
}
if (!string.IsNullOrEmpty(query.QBankIds))
{
builder.AppendFormat(@" AND A.{0} IN({1}) ", nameof(RB_Student_Exam_Extend.BankId), query.QBankIds);
}
}
var obj = base.ExecuteScalar(builder.ToString());
if (obj != null)
{
Int32.TryParse(obj.ToString(), out result);
}
return result + 1;
}
} }
} }
...@@ -1127,6 +1127,27 @@ namespace Edu.WebApi.Controllers.Exam ...@@ -1127,6 +1127,27 @@ namespace Edu.WebApi.Controllers.Exam
return flag ? ApiResult.Success() : ApiResult.Failed(); return flag ? ApiResult.Success() : ApiResult.Failed();
} }
/// <summary>
/// 学员开始考试
/// </summary>
/// <returns></returns>
[HttpPost]
[AllowRepeat]
public ApiResult SetStudentStartExam()
{
var model = new RB_Student_Exam_Extend()
{
Id = base.ParmJObj.GetInt("Id"),
BankId = base.ParmJObj.GetInt("BankId"),
StudentId = base.ParmJObj.GetInt("StudentId"),
StartTime = base.ParmJObj.GetDateTime("StartTime"),
CreateTime = DateTime.Now,
GroupId = base.ParmJObj.GetInt("GroupId")
};
bool flag = courseExamModule.SetStudentStartExamModule(model);
return flag ? ApiResult.Success(data: model) : ApiResult.Failed();
}
/// <summary> /// <summary>
/// 新增修改学员考试 /// 新增修改学员考试
/// </summary> /// </summary>
...@@ -1147,6 +1168,34 @@ namespace Edu.WebApi.Controllers.Exam ...@@ -1147,6 +1168,34 @@ namespace Edu.WebApi.Controllers.Exam
CreateTime=DateTime.Now, CreateTime=DateTime.Now,
GroupId=base.ParmJObj.GetInt("GroupId") GroupId=base.ParmJObj.GetInt("GroupId")
}; };
model.ExamDetailsList = new List<RB_Student_ExamDetails_Extend>();
string examDetailsList = base.ParmJObj.GetStringValue("ExamDetailsList");
if (!string.IsNullOrEmpty(examDetailsList))
{
JArray jarray = JArray.Parse(examDetailsList);
if (jarray != null && jarray.Count > 0)
{
foreach (var jItem in jarray)
{
JObject sObj = JObject.Parse(jItem.ToString());
var sModel = new RB_Student_ExamDetails_Extend()
{
DetailId = sObj.GetInt("DetailId"),
ExamId = sObj.GetInt("ExamId"),
QuestionId=sObj.GetInt("QuestionId"),
Title=sObj.GetStringValue("Title"),
QuestionContent=sObj.GetStringValue("QuestionContent"),
QuestionTypeId=sObj.GetInt("QuestionTypeId"),
QuestionTypeKey=sObj.GetStringValue("QuestionTypeKey"),
Answer=sObj.GetStringValue("Answer"),
AnswerParse=sObj.GetStringValue("AnswerParse"),
IsAnswer=sObj.GetInt("IsAnswer"),
IsWrong=sObj.GetInt("IsWrong"),
};
model.ExamDetailsList.Add(sModel);
}
}
}
bool flag = courseExamModule.SetStudentExamModule(model); bool flag = courseExamModule.SetStudentExamModule(model);
return flag ? ApiResult.Success() : ApiResult.Failed(); return flag ? ApiResult.Success() : ApiResult.Failed();
} }
......
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