Commit 1a7b8519 authored by 黄奎's avatar 黄奎

单词测试算法修改

parent 3cb85c96
...@@ -74,30 +74,30 @@ namespace Edu.Module.Exam ...@@ -74,30 +74,30 @@ namespace Edu.Module.Exam
var titleRandomNum = Common.ConvertHelper.CreateRandomNum(); var titleRandomNum = Common.ConvertHelper.CreateRandomNum();
var tempWords = reviewList[i]; var tempWords = reviewList[i];
var count = totalList?.Where(qitem => qitem.Id != tempWords.Id)?.Count()??0; var count = totalList?.Where(qitem => qitem.Id != tempWords.Id)?.Count()??0;
// reviewGroupList.Add(CreateSingleModule(tempWords,totalList)); reviewGroupList.Add(CreateSingleModule(tempWords,totalList));
//选择题 //选择题
if (titleRandomNum % 2 == 0) //if (titleRandomNum % 2 == 0)
{ //{
if (count > 2) // if (count > 2)
{ // {
reviewGroupList.Add(CreateSingleModule(tempWords, totalList)); // reviewGroupList.Add(CreateSingleModule(tempWords, totalList));
} // }
else // else
{ // {
if (!string.IsNullOrEmpty(tempWords.ChineseMean) || !string.IsNullOrEmpty(tempWords.WordWrite)) // if (!string.IsNullOrEmpty(tempWords.ChineseMean) || !string.IsNullOrEmpty(tempWords.WordWrite))
{ // {
reviewGroupList.Add(CreateFillInModule(tempWords)); // reviewGroupList.Add(CreateFillInModule(tempWords));
} // }
} // }
} //}
//填空题 ////填空题
else //else
{ //{
if (!string.IsNullOrEmpty(tempWords.ChineseMean) || !string.IsNullOrEmpty(tempWords.WordWrite)) // if (!string.IsNullOrEmpty(tempWords.ChineseMean) || !string.IsNullOrEmpty(tempWords.WordWrite))
{ // {
reviewGroupList.Add(CreateFillInModule(tempWords)); // reviewGroupList.Add(CreateFillInModule(tempWords));
} // }
} //}
} }
} }
...@@ -195,17 +195,24 @@ namespace Edu.Module.Exam ...@@ -195,17 +195,24 @@ namespace Edu.Module.Exam
for (var i = 0; i < 3; i++) for (var i = 0; i < 3; i++)
{ {
var cItem = tempList[i]; var cItem = tempList[i];
string Content = cItem.WordContent;
if (string.IsNullOrEmpty(Content))
{
var cTempList = totalList?.Where(qitem => qitem.Id != cItem.Id && qitem.Id != item.Id && !string.IsNullOrEmpty(qitem.WordContent))?.OrderBy(qitem => Guid.NewGuid());
Content = cTempList?.FirstOrDefault()?.WordContent ?? "";
}
if (options.Where(qitem => qitem.Content.Equals(Content)).Count() > 0)
{
Content += GetRandWords(i);
}
options.Add(new optionItem() options.Add(new optionItem()
{ {
Content = !string.IsNullOrEmpty(cItem.WordContent) Content = Content,
? cItem.WordContent
: (totalList?.FirstOrDefault(qitem => qitem.Id != item.Id &&!string.IsNullOrEmpty(qitem.WordContent))?.WordContent ?? ""),
IsAnswer = false, IsAnswer = false,
Name = "", Name = "",
ShowName = "", ShowName = "",
}); });
} }
break; break;
//根据日语书写选择中文意思 //根据日语书写选择中文意思
case 2: case 2:
...@@ -222,11 +229,18 @@ namespace Edu.Module.Exam ...@@ -222,11 +229,18 @@ namespace Edu.Module.Exam
for (var i = 0; i < 3; i++) for (var i = 0; i < 3; i++)
{ {
var cItem = tempList[i]; var cItem = tempList[i];
string Content = cItem.WordContent;
if (string.IsNullOrEmpty(Content))
{
Content = (totalList?.OrderBy(qitem => Guid.NewGuid())?.FirstOrDefault(qitem => qitem.Id != cItem.Id && qitem.Id != item.Id && !string.IsNullOrEmpty(qitem.WordContent))?.WordContent ?? "");
}
if (options.Where(qitem => qitem.Content.Equals(Content)).Count() > 0)
{
Content += GetRandWords(i);
}
options.Add(new optionItem() options.Add(new optionItem()
{ {
Content = !string.IsNullOrEmpty(cItem.WordContent) Content = Content,
? cItem.WordContent :
(totalList?.FirstOrDefault(qitem => qitem.Id != item.Id&&!string.IsNullOrEmpty(qitem.WordContent))?.WordContent ?? ""),
IsAnswer = false, IsAnswer = false,
Name = "", Name = "",
ShowName = "", ShowName = "",
...@@ -253,11 +267,21 @@ namespace Edu.Module.Exam ...@@ -253,11 +267,21 @@ namespace Edu.Module.Exam
for (var i = 0; i < 3; i++) for (var i = 0; i < 3; i++)
{ {
var cItem = tempList[i]; var cItem = tempList[i];
string Content = cItem.WordWrite;
if (string.IsNullOrEmpty(Content))
{
Content = totalList
?.OrderBy(qitem => Guid.NewGuid())
?.FirstOrDefault(qitem =>qitem.Id != cItem.Id && qitem.Id != item.Id && !string.IsNullOrEmpty(qitem.WordWrite))
?.WordWrite ?? "";
}
if (options.Where(qitem => qitem.Content.Equals(Content)).Count() > 0)
{
Content += GetRandWords(i);
}
options.Add(new optionItem() options.Add(new optionItem()
{ {
Content = !string.IsNullOrEmpty(cItem.WordWrite) Content = Content,
? cItem.WordWrite
:(totalList?.FirstOrDefault(qitem => qitem.Id != item.Id &&!string.IsNullOrEmpty(qitem.WordWrite))?.WordWrite ?? ""),
IsAnswer = false, IsAnswer = false,
Name = "", Name = "",
ShowName = "", ShowName = "",
...@@ -270,10 +294,8 @@ namespace Edu.Module.Exam ...@@ -270,10 +294,8 @@ namespace Edu.Module.Exam
} }
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++)
{ {
...@@ -304,6 +326,18 @@ namespace Edu.Module.Exam ...@@ -304,6 +326,18 @@ namespace Edu.Module.Exam
return singleObj; return singleObj;
} }
/// <summary>
/// 获取随机假名
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public string GetRandWords(int index)
{
var array = new string[4] { "ん", "ー", "ム", "い" };
return array[index];
}
/// <summary> /// <summary>
/// 生成默认的选择题 /// 生成默认的选择题
/// </summary> /// </summary>
...@@ -324,10 +358,21 @@ namespace Edu.Module.Exam ...@@ -324,10 +358,21 @@ namespace Edu.Module.Exam
for (var i = 0; i < 3; i++) for (var i = 0; i < 3; i++)
{ {
var cItem = totalList[i]; var cItem = totalList[i];
string Content = cItem.ChineseMean;
if (string.IsNullOrEmpty(Content))
{
Content = totalList
?.OrderBy(qitem => Guid.NewGuid())
?.FirstOrDefault(qitem => qitem.Id != cItem.Id && qitem.Id != item.Id && !string.IsNullOrEmpty(qitem.ChineseMean))
?.ChineseMean ?? "";
}
if (options.Where(qitem => qitem.Content.Equals(Content)).Count() > 0)
{
Content += GetRandWords(i);
}
options.Add(new optionItem() options.Add(new optionItem()
{ {
Content = !string.IsNullOrEmpty(cItem.ChineseMean) ? cItem.ChineseMean : Content = Content,
(totalList?.FirstOrDefault(qitem =>qitem.Id!=item.Id && !string.IsNullOrEmpty(qitem.ChineseMean))?.ChineseMean ?? ""),
IsAnswer = false, IsAnswer = false,
Name = "", Name = "",
ShowName = "", ShowName = "",
......
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