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

单词测试算法修改

parent 3cb85c96
......@@ -74,30 +74,30 @@ namespace Edu.Module.Exam
var titleRandomNum = Common.ConvertHelper.CreateRandomNum();
var tempWords = reviewList[i];
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 (count > 2)
{
reviewGroupList.Add(CreateSingleModule(tempWords, totalList));
}
else
{
if (!string.IsNullOrEmpty(tempWords.ChineseMean) || !string.IsNullOrEmpty(tempWords.WordWrite))
{
reviewGroupList.Add(CreateFillInModule(tempWords));
}
}
}
//填空题
else
{
if (!string.IsNullOrEmpty(tempWords.ChineseMean) || !string.IsNullOrEmpty(tempWords.WordWrite))
{
reviewGroupList.Add(CreateFillInModule(tempWords));
}
}
//if (titleRandomNum % 2 == 0)
//{
// if (count > 2)
// {
// reviewGroupList.Add(CreateSingleModule(tempWords, totalList));
// }
// else
// {
// if (!string.IsNullOrEmpty(tempWords.ChineseMean) || !string.IsNullOrEmpty(tempWords.WordWrite))
// {
// reviewGroupList.Add(CreateFillInModule(tempWords));
// }
// }
//}
////填空题
//else
//{
// if (!string.IsNullOrEmpty(tempWords.ChineseMean) || !string.IsNullOrEmpty(tempWords.WordWrite))
// {
// reviewGroupList.Add(CreateFillInModule(tempWords));
// }
//}
}
}
......@@ -195,17 +195,24 @@ namespace Edu.Module.Exam
for (var i = 0; i < 3; 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()
{
Content = !string.IsNullOrEmpty(cItem.WordContent)
? cItem.WordContent
: (totalList?.FirstOrDefault(qitem => qitem.Id != item.Id &&!string.IsNullOrEmpty(qitem.WordContent))?.WordContent ?? ""),
Content = Content,
IsAnswer = false,
Name = "",
ShowName = "",
});
}
break;
//根据日语书写选择中文意思
case 2:
......@@ -222,11 +229,18 @@ namespace Edu.Module.Exam
for (var i = 0; i < 3; 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()
{
Content = !string.IsNullOrEmpty(cItem.WordContent)
? cItem.WordContent :
(totalList?.FirstOrDefault(qitem => qitem.Id != item.Id&&!string.IsNullOrEmpty(qitem.WordContent))?.WordContent ?? ""),
Content = Content,
IsAnswer = false,
Name = "",
ShowName = "",
......@@ -253,11 +267,21 @@ namespace Edu.Module.Exam
for (var i = 0; i < 3; 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()
{
Content = !string.IsNullOrEmpty(cItem.WordWrite)
? cItem.WordWrite
:(totalList?.FirstOrDefault(qitem => qitem.Id != item.Id &&!string.IsNullOrEmpty(qitem.WordWrite))?.WordWrite ?? ""),
Content = Content,
IsAnswer = false,
Name = "",
ShowName = "",
......@@ -271,9 +295,7 @@ namespace Edu.Module.Exam
break;
}
options = options?.OrderBy(qitem => Guid.NewGuid())?.ToList();
string Answer = "";
for (var j = 1; j <= options.Count; j++)
{
......@@ -304,6 +326,18 @@ namespace Edu.Module.Exam
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>
......@@ -324,10 +358,21 @@ namespace Edu.Module.Exam
for (var i = 0; i < 3; 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()
{
Content = !string.IsNullOrEmpty(cItem.ChineseMean) ? cItem.ChineseMean :
(totalList?.FirstOrDefault(qitem =>qitem.Id!=item.Id && !string.IsNullOrEmpty(qitem.ChineseMean))?.ChineseMean ?? ""),
Content = Content,
IsAnswer = false,
Name = "",
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