Commit a43b8308 authored by 黄奎's avatar 黄奎

页面修改

parent 381765f3
...@@ -19,5 +19,10 @@ namespace Edu.Model.ViewModel.Course ...@@ -19,5 +19,10 @@ namespace Edu.Model.ViewModel.Course
/// 章节编号 /// 章节编号
/// </summary> /// </summary>
public string QChapterIds { get; set; } public string QChapterIds { get; set; }
/// <summary>
/// 小于等于当前章节
/// </summary>
public int LessThanOrEqualChapterId { get; set; }
} }
} }
...@@ -57,6 +57,11 @@ namespace Edu.Module.Exam ...@@ -57,6 +57,11 @@ namespace Edu.Module.Exam
QChapterIds = ChapterId + "," + NextChapterId QChapterIds = ChapterId + "," + NextChapterId
}); });
var totalList = course_WordsRepository.GetCourseWordsListRepository(new RB_Course_Words_Extend()
{
CourseId = CourseId,
LessThanOrEqualChapterId = ChapterId,
})?.OrderBy(qitem => Guid.NewGuid())?.ToList();
var reviewList = list?.Where(qitem => qitem.ChapterId == ChapterId)?.OrderBy(qitem => Guid.NewGuid())?.ToList(); var reviewList = list?.Where(qitem => qitem.ChapterId == ChapterId)?.OrderBy(qitem => Guid.NewGuid())?.ToList();
var prepList = list?.Where(qitem => qitem.ChapterId == NextChapterId)?.OrderBy(qitem => Guid.NewGuid())?.ToList(); var prepList = list?.Where(qitem => qitem.ChapterId == NextChapterId)?.OrderBy(qitem => Guid.NewGuid())?.ToList();
List<object> reviewGroupList = new List<object>(); List<object> reviewGroupList = new List<object>();
...@@ -66,32 +71,34 @@ namespace Edu.Module.Exam ...@@ -66,32 +71,34 @@ namespace Edu.Module.Exam
{ {
for (var i = 0; i < reviewList.Count; i++) for (var i = 0; i < reviewList.Count; i++)
{ {
var titleRandomNum= Common.ConvertHelper.CreateRandomNum(); var titleRandomNum = Common.ConvertHelper.CreateRandomNum();
var tempWords = reviewList[i]; var tempWords = reviewList[i];
//选择题
if (titleRandomNum % 2 == 0) reviewGroupList.Add(CreateSingleModule(tempWords,totalList));
{ ////选择题
var tempList = reviewList.Where(qitem => qitem.Id != tempWords.Id)?.Take(3)?.ToList(); //if (titleRandomNum % 2 == 0)
if (tempList != null && tempList.Count > 2) //{
{ //
reviewGroupList.Add(CreateSingleModule(tempWords, tempList)); // if (tempList != null && tempList.Count > 2)
} // {
else // reviewGroupList.Add(CreateSingleModule(tempWords, tempList));
{ // }
if (!string.IsNullOrEmpty(tempWords.ChineseMean) || !string.IsNullOrEmpty(tempWords.WordWrite)) // else
{ // {
reviewGroupList.Add(CreateFillInModule(tempWords)); // if (!string.IsNullOrEmpty(tempWords.ChineseMean) || !string.IsNullOrEmpty(tempWords.WordWrite))
} // {
} // reviewGroupList.Add(CreateFillInModule(tempWords));
} // }
//填空题 // }
else //}
{ ////填空题
if (!string.IsNullOrEmpty(tempWords.ChineseMean) || !string.IsNullOrEmpty(tempWords.WordWrite)) //else
{ //{
reviewGroupList.Add(CreateFillInModule(tempWords)); // if (!string.IsNullOrEmpty(tempWords.ChineseMean) || !string.IsNullOrEmpty(tempWords.WordWrite))
} // {
} // reviewGroupList.Add(CreateFillInModule(tempWords));
// }
//}
} }
} }
...@@ -124,7 +131,7 @@ namespace Edu.Module.Exam ...@@ -124,7 +131,7 @@ namespace Edu.Module.Exam
} }
else else
{ {
title = string.Format("根据中文意思【{0}】,填写单词.", item.ChineseMean); title = string.Format("根据中文意思【{0}】,填写单词.", item.ChineseMean);
} }
} }
...@@ -132,7 +139,7 @@ namespace Edu.Module.Exam ...@@ -132,7 +139,7 @@ namespace Edu.Module.Exam
{ {
if (!string.IsNullOrEmpty(item.ChineseMean)) if (!string.IsNullOrEmpty(item.ChineseMean))
{ {
title = string.Format("根据中文意思【{0}】,填写单词.", item.ChineseMean); title = string.Format("根据中文意思【{0}】,填写单词.", item.ChineseMean);
} }
else else
...@@ -140,8 +147,8 @@ namespace Edu.Module.Exam ...@@ -140,8 +147,8 @@ namespace Edu.Module.Exam
title = string.Format("根据日语书写【{0}】,填写单词.", item.WordWrite); title = string.Format("根据日语书写【{0}】,填写单词.", item.WordWrite);
} }
} }
var fillinObj= new var fillinObj = new
{ {
QuestionTypeName = "填空题", QuestionTypeName = "填空题",
QuestionTypeId = 3, QuestionTypeId = 3,
...@@ -155,7 +162,7 @@ namespace Edu.Module.Exam ...@@ -155,7 +162,7 @@ namespace Edu.Module.Exam
item.WordWrite, item.WordWrite,
item.ChineseMean, item.ChineseMean,
item.FileUrl, item.FileUrl,
IsTrue=0, IsTrue = 0,
}; };
return fillinObj; return fillinObj;
} }
...@@ -164,33 +171,17 @@ namespace Edu.Module.Exam ...@@ -164,33 +171,17 @@ namespace Edu.Module.Exam
/// 创建单选题 /// 创建单选题
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public object CreateSingleModule(RB_Course_Words_Extend item,List<RB_Course_Words_Extend> chooseList) public object CreateSingleModule(RB_Course_Words_Extend item, List<RB_Course_Words_Extend> totalList)
{ {
string title = "我是问题"; string title = "我是问题";
int randNum = Common.ConvertHelper.CreateRandomNum(); int randNum = Common.ConvertHelper.CreateRandomNum();
List<optionItem> options = new List<optionItem>(); List<optionItem> options = new List<optionItem>();
var tempList = totalList?.OrderBy(qitem => Guid.NewGuid())?.ToList();
switch (randNum) switch (randNum)
{ {
//根据单词选择中文意思 //根据单词选择中文意思
case 0: case 0:
title = string.Format("请选择【{0}】单词的正确中文意思.", item.WordContent); title = CreateDefaultQuestion(item, tempList, options);
options.Add(new optionItem()
{
Content = item.ChineseMean,
IsAnswer = true,
Name = "",
ShowName = ""
});
foreach (var cItem in chooseList)
{
options.Add(new optionItem()
{
Content = cItem.ChineseMean,
IsAnswer = false,
Name = "",
ShowName = "",
});
}
break; break;
//根据中文意思选择单词 //根据中文意思选择单词
case 1: case 1:
...@@ -202,62 +193,82 @@ namespace Edu.Module.Exam ...@@ -202,62 +193,82 @@ namespace Edu.Module.Exam
Name = "", Name = "",
ShowName = "" ShowName = ""
}); });
foreach (var cItem in chooseList) for (var i = 0; i < 3; i++)
{ {
var cItem = tempList[i];
options.Add(new optionItem() options.Add(new optionItem()
{ {
Content = cItem.WordContent, Content = !string.IsNullOrEmpty(cItem.WordContent) ? cItem.WordContent : (totalList?.FirstOrDefault(qitem => !string.IsNullOrEmpty(qitem.WordContent))?.WordContent ?? ""),
IsAnswer = false, IsAnswer = false,
Name = "", Name = "",
ShowName = "", ShowName = "",
}); });
} }
break; break;
//根据日语书写选择中文意思 //根据日语书写选择中文意思
case 2: case 2:
title = item.WordWrite; if (!string.IsNullOrEmpty(item.WordWrite) && !string.IsNullOrEmpty(item.WordContent))
title = string.Format("请选择【{0}】所对应的单词.", item.WordWrite);
options.Add(new optionItem()
{
Content = item.WordContent,
IsAnswer = true,
Name = "",
ShowName = ""
});
foreach (var cItem in chooseList)
{ {
title = string.Format("请选择【{0}】所对应的单词.", item.WordWrite);
options.Add(new optionItem() options.Add(new optionItem()
{ {
Content = cItem.WordContent, Content = item.WordContent,
IsAnswer = false, IsAnswer = true,
Name = "", Name = "",
ShowName = "", ShowName = ""
}); });
for (var i = 0; i < 3; i++)
{
var cItem = tempList[i];
options.Add(new optionItem()
{
Content = !string.IsNullOrEmpty(cItem.WordContent) ? cItem.WordContent : (totalList?.FirstOrDefault(qitem => !string.IsNullOrEmpty(qitem.WordContent))?.WordContent ?? ""),
IsAnswer = false,
Name = "",
ShowName = "",
});
}
}
else
{
title = CreateDefaultQuestion(item, totalList, options);
} }
break; break;
//根据中文意思选日语书写 //根据中文意思选日语书写
case 3: case 3:
title = string.Format("请选择【{0}】所对应日语书写.", item.ChineseMean); if (!string.IsNullOrEmpty(item.WordWrite)&&!string.IsNullOrEmpty(item.ChineseMean))
options.Add(new optionItem()
{
Content = item.WordWrite,
IsAnswer = true,
Name = "",
ShowName = ""
});
foreach (var cItem in chooseList)
{ {
title = string.Format("请选择【{0}】所对应日语书写.", item.ChineseMean);
options.Add(new optionItem() options.Add(new optionItem()
{ {
Content = cItem.WordWrite, Content = item.WordWrite,
IsAnswer = false, IsAnswer = true,
Name = "", Name = "",
ShowName = "", ShowName = ""
}); });
for (var i = 0; i < 3; i++)
{
var cItem = tempList[i];
options.Add(new optionItem()
{
Content = !string.IsNullOrEmpty(cItem.WordWrite) ? cItem.WordWrite : (totalList?.FirstOrDefault(qitem => !string.IsNullOrEmpty(qitem.WordWrite))?.WordWrite ?? ""),
IsAnswer = false,
Name = "",
ShowName = "",
});
}
}
else
{
title = CreateDefaultQuestion(item, totalList, options);
} }
break; break;
} }
options = options?.OrderBy(qitem => Guid.NewGuid())?.ToList(); options = options?.OrderBy(qitem => Guid.NewGuid())?.ToList();
string Answer = ""; string Answer = "";
for (var j = 1; j <= options.Count; j++) for (var j = 1; j <= options.Count; j++)
{ {
...@@ -288,6 +299,30 @@ namespace Edu.Module.Exam ...@@ -288,6 +299,30 @@ namespace Edu.Module.Exam
return singleObj; return singleObj;
} }
public string CreateDefaultQuestion(RB_Course_Words_Extend item, List<RB_Course_Words_Extend> totalList, List<optionItem> options)
{
string title = string.Format("请选择【{0}】单词的正确中文意思.", item.WordContent);
options.Add(new optionItem()
{
Content = item.ChineseMean,
IsAnswer = true,
Name = "",
ShowName = ""
});
for (var i = 0; i < 3; i++)
{
var cItem = totalList[i];
options.Add(new optionItem()
{
Content = !string.IsNullOrEmpty(cItem.ChineseMean) ? cItem.ChineseMean : (totalList?.FirstOrDefault(qitem => !string.IsNullOrEmpty(qitem.ChineseMean))?.ChineseMean ?? ""),
IsAnswer = false,
Name = "",
ShowName = "",
});
}
return title;
}
/// <summary> /// <summary>
/// 单词学习或复习 /// 单词学习或复习
/// </summary> /// </summary>
...@@ -295,18 +330,18 @@ namespace Edu.Module.Exam ...@@ -295,18 +330,18 @@ namespace Edu.Module.Exam
/// <param name="ChapterId">当前章节编号</param> /// <param name="ChapterId">当前章节编号</param>
/// <param name="ReviewChapterId">复习章节编号</param> /// <param name="ReviewChapterId">复习章节编号</param>
/// <returns></returns> /// <returns></returns>
public object GetStudyCourseWords(int CourseId, int ChapterId, int ReviewChapterId,int Stu_Account_Id) public object GetStudyCourseWords(int CourseId, int ChapterId, int ReviewChapterId, int Stu_Account_Id)
{ {
List<object> list = new List<object>(); List<object> list = new List<object>();
List<object> reviewList = new List<object>(); List<object> reviewList = new List<object>();
var dataList = course_WordsRepository.GetCourseWordsListRepository(new RB_Course_Words_Extend() var dataList = course_WordsRepository.GetCourseWordsListRepository(new RB_Course_Words_Extend()
{ {
CourseId = CourseId, CourseId = CourseId,
QChapterIds = ChapterId+","+ ReviewChapterId QChapterIds = ChapterId + "," + ReviewChapterId
}); });
if (dataList != null && dataList.Count > 0) if (dataList != null && dataList.Count > 0)
{ {
foreach (var item in dataList.Where(qitem=>qitem.ChapterId==ChapterId)) foreach (var item in dataList.Where(qitem => qitem.ChapterId == ChapterId))
{ {
list.Add(new list.Add(new
{ {
...@@ -376,7 +411,7 @@ namespace Edu.Module.Exam ...@@ -376,7 +411,7 @@ namespace Edu.Module.Exam
var wordsList = course_WordsRepository.GetCourseWordsListRepository(new RB_Course_Words_Extend() var wordsList = course_WordsRepository.GetCourseWordsListRepository(new RB_Course_Words_Extend()
{ {
CourseId = model.CourseId, CourseId = model.CourseId,
QChapterIds = model.ChapterId+","+model.ReviewCourseChapterId QChapterIds = model.ChapterId + "," + model.ReviewCourseChapterId
}); });
//当前章节单词总数 //当前章节单词总数
var currentChapterCount = wordsList?.Where(qitem => qitem.ChapterId == model.ChapterId)?.Count() ?? 0; var currentChapterCount = wordsList?.Where(qitem => qitem.ChapterId == model.ChapterId)?.Count() ?? 0;
...@@ -402,7 +437,7 @@ namespace Edu.Module.Exam ...@@ -402,7 +437,7 @@ namespace Edu.Module.Exam
else else
{ {
fileds.Add(nameof(RB_StuWords_Prep_Extend.ReviewNum), model.ReviewNum); fileds.Add(nameof(RB_StuWords_Prep_Extend.ReviewNum), model.ReviewNum);
model.StudyNum =oldModel.PrepNum+ model.ReviewNum; model.StudyNum = oldModel.PrepNum + model.ReviewNum;
} }
fileds.Add(nameof(RB_StuWords_Prep_Extend.StudyNum), model.StudyNum); fileds.Add(nameof(RB_StuWords_Prep_Extend.StudyNum), model.StudyNum);
model.Score = GetScoreModule(model.PrepNum, currentChapterCount); model.Score = GetScoreModule(model.PrepNum, currentChapterCount);
...@@ -438,7 +473,7 @@ namespace Edu.Module.Exam ...@@ -438,7 +473,7 @@ namespace Edu.Module.Exam
int score = 0; int score = 0;
if (TotalNum > 0) if (TotalNum > 0)
{ {
var progress= Convert.ToDecimal(StartNum) / Convert.ToDecimal(TotalNum) * 100; var progress = Convert.ToDecimal(StartNum) / Convert.ToDecimal(TotalNum) * 100;
if (progress > 0 && progress <= 33) if (progress > 0 && progress <= 33)
{ {
score = 1; score = 1;
......
...@@ -86,6 +86,10 @@ WHERE 1=1 ...@@ -86,6 +86,10 @@ WHERE 1=1
{ {
builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Course_Words_Extend.ChapterId), query.QChapterIds); builder.AppendFormat(" AND A.{0} IN({1}) ", nameof(RB_Course_Words_Extend.ChapterId), query.QChapterIds);
} }
if (query.LessThanOrEqualChapterId > 0)
{
builder.AppendFormat(" AND A.{0}<={1} ", nameof(RB_Course_Words_Extend.ChapterId), query.LessThanOrEqualChapterId);
}
} }
return Get<RB_Course_Words_Extend>(builder.ToString()).ToList(); return Get<RB_Course_Words_Extend>(builder.ToString()).ToList();
} }
......
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