Commit 86fd01de authored by 黄奎's avatar 黄奎

问题统计修改

parent 418d46b8
......@@ -111,5 +111,10 @@ namespace Edu.Model.ViewModel.Question
/// 是否返回所有字段
/// </summary>
public int IsShowAllQuestion { get; set; }
/// <summary>
/// 问题数量
/// </summary>
public int QuestionCount { get; set; }
}
}
\ No newline at end of file
......@@ -146,7 +146,7 @@ namespace Edu.Module.Question
public List<object> GetQuestionCategoryListModule(RB_Question_ViewModel query)
{
List<object> list = new List<object>();
var dataList = GetQuestionListModule(query);
var dataList = questionRepository.GetQuestionStaticsListRepository(query);
if (dataList != null && dataList.Count > 0)
{
var questionTypeList = GetQuestionTypeListModule(new RB_Question_Type_ViewModel());
......@@ -158,12 +158,11 @@ namespace Edu.Module.Question
{
var qType = questionTypeList?.Where(qitem => qitem.QId == item.QuestionTypeId)?.FirstOrDefault();
var diffTypeList = dataList.Where(qitem => qitem.QuestionTypeId == item.QuestionTypeId)
.GroupBy(qitem => new { qitem.DifficultyType })
.Select(qitem => new
{
DifficultyType = qitem.Key.DifficultyType,
DifficultyTypeName = qitem.Key.DifficultyType.ToName(),
DifficultyTypeCount = qitem.Count(),
DifficultyType = qitem.DifficultyType,
DifficultyTypeName = qitem.DifficultyType.ToName(),
DifficultyTypeCount = qitem.QuestionCount,
ChooseNum = 0
});
var obj = new
......@@ -175,7 +174,7 @@ namespace Edu.Module.Question
QuestionDesc = "",
ChooseType = 1,
ChooseNum = 0,
QuestionTypeNum = dataList.Where(qitem => qitem.QuestionTypeId == item.QuestionTypeId).Count(),
QuestionTypeNum = dataList.Where(qitem => qitem.QuestionTypeId == item.QuestionTypeId).Sum(qitem=>qitem.QuestionCount),
ChooseList = diffTypeList,
};
list.Add(obj);
......
......@@ -48,6 +48,42 @@ WHERE 1=1
}
}
/// <summary>
/// 问题统计
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Question_ViewModel> GetQuestionStaticsListRepository(RB_Question_ViewModel query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT QuestionTypeId,DifficultyType,Count(QuestionId) AS QuestionCount
FROM RB_Question
WHERE 1=1
");
if (query == null)
{
return new List<RB_Question_ViewModel>();
}
else
{
if (!string.IsNullOrEmpty(query.QBankIds))
{
builder.AppendFormat(" AND {0} IN({1}) ", nameof(RB_Question_ViewModel.BankId), query.QBankIds);
}
if (query.CourseId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Question_ViewModel.CourseId), query.CourseId);
}
if (!string.IsNullOrEmpty(query.Q_QuestionTypeIds))
{
builder.AppendFormat(" AND {0} IN({1}) ", nameof(RB_Question_ViewModel.QuestionTypeId), query.Q_QuestionTypeIds);
}
builder.AppendFormat(" GROUP BY QuestionTypeId,DifficultyType ");
return Get<RB_Question_ViewModel>(builder.ToString()).ToList();
}
}
/// <summary>
/// 获取问题分页列表
/// </summary>
......
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