Commit 502dfe7e authored by 黄奎's avatar 黄奎

题库查询

parent a20d9c92
......@@ -58,5 +58,10 @@ namespace Edu.Model.ViewModel.Question
/// </summary>
public object AnswerObj { get; set; }
/// <summary>
/// 知识点名称
/// </summary>
public string PointName { get; set; }
}
}
\ No newline at end of file
......@@ -54,7 +54,7 @@ WHERE 1=1
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.*,IFNULL(B.`Name` ,'') AS QuestionTypeName
FROM RB_Question AS A LEFT JOIN RB_Question_Type B ON A.QuestionTypeId=B.QId
FROM RB_Question AS A LEFT JOIN RB_Question_Type B ON A.QuestionTypeId=B.QId
WHERE 1=1 ");
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Question_ViewModel.Status), (int)DateStateEnum.Normal);
if (query == null)
......@@ -72,6 +72,19 @@ WHERE 1=1 ");
builder.AppendFormat(" AND A.{0} LIKE @Title ", nameof(RB_Question_ViewModel.Title));
parameters.Add("Title", "%" + query.Title.Trim() + "%");
}
if (!string.IsNullOrEmpty(query.PointName))
{
builder.Append(@" AND A.Knowledge<>'' AND EXISTS (SELECT 1 FROM rb_question_point WHERE PointId IN(A.Knowledge) AND A.CourseId=CourseId AND PointName LIKE @PointName ) ");
parameters.Add("PointName", "%" + query.PointName.Trim() + "%");
}
if (!string.IsNullOrEmpty(query.QQuestionTypeStr))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Question_ViewModel.QuestionTypeId), query.QQuestionTypeStr);
}
if (!string.IsNullOrEmpty(query.QDifficultyType))
{
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Question_ViewModel.DifficultyType), query.QDifficultyType);
}
builder.AppendFormat(" ORDER BY A.{0} DESC ", nameof(RB_Question_ViewModel.QuestionId));
return GetPage<RB_Question_ViewModel>(pageIndex, pageSize, out rowsCount, builder.ToString(), parameters).ToList();
}
......
......@@ -48,9 +48,34 @@ namespace Edu.WebApi.Controllers.Course
var query = new RB_Question_ViewModel()
{
CourseId=base.ParmJObj.GetInt("CourseId"),
Title=base.ParmJObj.GetStringValue("Title"),
CourseId = base.ParmJObj.GetInt("CourseId"),
Title = base.ParmJObj.GetStringValue("Title"),
PointName = base.ParmJObj.GetStringValue("PointName"),
};
try
{
var DifficultyTypeList = Common.Plugin.JsonHelper.DeserializeObject<List<int>>(base.ParmJObj.GetStringValue("DifficultyType"));
if (DifficultyTypeList != null && DifficultyTypeList.Count > 0 && !DifficultyTypeList.Contains(0))
{
query.QDifficultyType = string.Join(",", DifficultyTypeList);
}
}
catch
{
}
try
{
var QuestionTypeIdList = Common.Plugin.JsonHelper.DeserializeObject<List<int>>(base.ParmJObj.GetStringValue("QuestionTypeId"));
if (QuestionTypeIdList != null && QuestionTypeIdList.Count > 0)
{
query.QQuestionTypeStr = string.Join(",", QuestionTypeIdList);
}
}
catch
{
}
var list = questionModule.GetQuestionPageListModule(pageModel.PageIndex, pageModel.PageSize, out long rowsCount, query);
List<object> resultList = new List<object>();
foreach (var item in list)
......
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