Commit 26aebfb7 authored by 黄奎's avatar 黄奎

题库答案处理

parent f6814fb3
......@@ -770,7 +770,26 @@ namespace Edu.Module.Exam
{
var QuestionContentObj = analysisQuestion.ParsingQuestion(item.QuestionTypeKey, item.QuestionContent);
List<object> quesAnswerList = new List<object>();
if (!string.IsNullOrEmpty(item.Answer.ToString()))
if (item.QuestionTypeKey == "listening" || item.QuestionTypeKey == "reading-comprehensio")
{
try
{
var listenList = JsonHelper.DeserializeObject<List<SubAnswerItem>>(item.Answer);
if (listenList != null && listenList.Count > 0)
{
foreach (var subItem in listenList)
{
quesAnswerList.Add(subItem.SubAnswer);
}
}
}
catch (Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "GetAppQuestionCategoryListModule_listening:" + Common.Plugin.JsonHelper.Serialize(item));
}
}
if (item.QuestionTypeKey != "listening" && item.QuestionTypeKey != "reading-comprehensio" && !string.IsNullOrEmpty(item.Answer.ToString()))
{
try
{
......@@ -891,15 +910,32 @@ namespace Edu.Module.Exam
{
var QuestionContentObj = analysisQuestion.ParsingQuestion(item.QuestionTypeKey, item.QuestionContent, isNoAnswer: true);
List<object> quesAnswerList = new List<object>();
if (!string.IsNullOrEmpty(item.Answer.ToString()))
if (item.QuestionTypeKey == "listening" || item.QuestionTypeKey == "reading-comprehensio")
{
try
{
var listenList = JsonHelper.DeserializeObject<List<SubAnswerItem>>(item.Answer);
if (listenList != null && listenList.Count > 0)
{
foreach (var subItem in listenList)
{
quesAnswerList.Add(subItem.SubAnswer);
}
}
}
catch (Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "GetAppQuestionCategoryListModule_listening:" + Common.Plugin.JsonHelper.Serialize(item));
}
}
if (item.QuestionTypeKey != "listening" && item.QuestionTypeKey != "reading-comprehensio" && !string.IsNullOrEmpty(item.Answer.ToString()))
{
try
{
var qAnsList = Common.ConvertHelper.StringToFileList(item.Answer.ToString());
if (qAnsList != null && qAnsList.Count() > 0)
var tempList = Common.ConvertHelper.StringToFileList(item.Answer);
if (tempList != null && tempList.Count > 0)
{
foreach (var tItem in qAnsList)
foreach (var tItem in tempList)
{
quesAnswerList.Add(tItem);
}
......@@ -907,7 +943,7 @@ namespace Edu.Module.Exam
}
catch (Exception ex)
{
Common.Plugin.LogHelper.Write(ex, "GetAppBankDetailsPageModule_Answer:" + Common.Plugin.JsonHelper.Serialize(item));
Common.Plugin.LogHelper.Write(ex, "GetAppQuestionCategoryListModule_Answer:" + Common.Plugin.JsonHelper.Serialize(item));
}
}
var obj = new
......
......@@ -14,7 +14,7 @@ namespace Edu.Module.Question
/// <summary>
/// 字母选项数组
/// </summary>
private static readonly string [] LetterArray= new string[26] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
private static readonly string[] LetterArray = new string[26] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
/// <summary>
/// 问题解析
......@@ -25,7 +25,7 @@ namespace Edu.Module.Question
/// <param name="isOptionRandom">是否选项随机(1-随机选项)</param>
/// <param name="isEdit">是否选项随机(编辑状态)</param>
/// <returns></returns>
public object ParsingQuestion(string key, string data,bool isNoAnswer=false,int isOptionRandom=0,bool isEdit=false)
public object ParsingQuestion(string key, string data, bool isNoAnswer = false, int isOptionRandom = 0, bool isEdit = false)
{
var obj = new object();
switch (key)
......@@ -36,7 +36,7 @@ namespace Edu.Module.Question
break;
//多选题
case "multiple":
obj= GetChooseOptionList(data, isOptionRandom, isNoAnswer, isEdit: isEdit);
obj = GetChooseOptionList(data, isOptionRandom, isNoAnswer, isEdit: isEdit);
break;
//填空题
case "fill-in":
......@@ -44,7 +44,7 @@ namespace Edu.Module.Question
break;
//判断题
case "judge":
obj = GetJudgeList(data,isNoAnswer);
obj = GetJudgeList(data, isNoAnswer);
break;
//简答题
case "short-answer":
......@@ -64,7 +64,7 @@ namespace Edu.Module.Question
break;
//分录题
case "entry-problem":
obj = GetFillInList(data,isNoAnswer);
obj = GetFillInList(data, isNoAnswer);
break;
//资料题
case "data-question":
......@@ -76,11 +76,11 @@ namespace Edu.Module.Question
break;
//排序题
case "sorting-problem":
obj = GetSortingProblemList(data,isNoAnswer);
obj = GetSortingProblemList(data, isNoAnswer);
break;
//完型填空
case "cloze":
obj = GetClozeList(data,isNoAnswer);
obj = GetClozeList(data, isNoAnswer);
break;
//阅读理解
case "reading-comprehensio":
......@@ -135,7 +135,7 @@ namespace Edu.Module.Question
{
//单选题
case "single":
item.SubAnwser = GetChooseOptionList(item.SubAnwser.ToString(),0, isNoAnswer);
item.SubAnwser = GetChooseOptionList(item.SubAnwser.ToString(), 0, isNoAnswer);
break;
//多选题
case "multiple":
......@@ -172,7 +172,7 @@ namespace Edu.Module.Question
break;
//单选题(数字)
case "single-number":
obj = GetChooseOptionList(data, isOptionRandom, isNoAnswer,isSingleNum:true,isEdit:isEdit);
obj = GetChooseOptionList(data, isOptionRandom, isNoAnswer, isSingleNum: true, isEdit: isEdit);
break;
}
return obj;
......@@ -188,7 +188,6 @@ namespace Edu.Module.Question
private object GetChooseOptionList(string data, int isOptionRandom, bool isNoAnswer, bool isSingleNum = false, bool isEdit = false)
{
var obj = new object();
var singleList = Common.Plugin.JsonHelper.DeserializeObject<List<optionItem>>(data);
var newList = new List<optionItem>();
if (!isEdit)
......@@ -234,7 +233,6 @@ namespace Edu.Module.Question
{
obj = singleList;
}
return obj;
}
......@@ -362,7 +360,7 @@ namespace Edu.Module.Question
/// <returns></returns>
private object GetShortAnswer(string data, bool isNoAnswer)
{
var shortAnswerList= Common.Plugin.JsonHelper.DeserializeObject<List<fillInItem>>(data);
var shortAnswerList = Common.Plugin.JsonHelper.DeserializeObject<List<fillInItem>>(data);
if (isNoAnswer)
{
shortAnswerList.ForEach(item =>
......@@ -405,7 +403,7 @@ namespace Edu.Module.Question
/// <param name="AnalysisAnswer">解析答案</param>
/// <param name="IsRequire">是否开启验证</param>
/// <returns></returns>
public string CheckQuestion(string QuestionTypeKey,string QuestionContent,string Answer, out string AnalysisAnswer,bool IsRequire=true)
public string CheckQuestion(string QuestionTypeKey, string QuestionContent, string Answer, out string AnalysisAnswer, bool IsRequire = true)
{
AnalysisAnswer = "";
string message = "";
......@@ -446,7 +444,7 @@ namespace Edu.Module.Question
var optionItems = Common.Plugin.JsonHelper.DeserializeObject<List<optionItem>>(QuestionContent);
message = CheckChoose(optionItems);
var judgeModel = optionItems.Where(qitem => qitem.IsAnswer == true)?.FirstOrDefault();
if (judgeModel != null )
if (judgeModel != null)
{
AnalysisAnswer = string.Join(",", judgeModel?.Name);
}
......@@ -612,8 +610,8 @@ namespace Edu.Module.Question
var tempModel = rootItem.OptionList.Where(qitem => qitem.IsAnswer == true)?.FirstOrDefault();
clozeAnswerList.Add(new SubAnswerItem()
{
SubQuestionId= index.ToString(),
SubAnswer= tempModel?.Name ?? "",
SubQuestionId = index.ToString(),
SubAnswer = tempModel?.Name ?? "",
SubScore = rootItem.SubScore,
});
if (IsRequire)
......@@ -683,9 +681,9 @@ namespace Edu.Module.Question
resultList.Add(new SubAnswerItem
{
SubQuestionId = Index.ToString(),
SubQuestionKey=item.QuestionKey,
SubAnswer = singleAnwser.Where(qitem => qitem.IsAnswer == true)?.FirstOrDefault()?.Name??"",
SubScore=item.SubScore,
SubQuestionKey = item.QuestionKey,
SubAnswer = singleAnwser.Where(qitem => qitem.IsAnswer == true)?.FirstOrDefault()?.Name ?? "",
SubScore = item.SubScore,
});
if (IsRequire)
{
......@@ -723,7 +721,7 @@ namespace Edu.Module.Question
SubQuestionId = Index.ToString(),
SubQuestionKey = item.QuestionKey,
SubAnswer = string.Join(",", multipleAnwser.Where(qitem => qitem.IsAnswer == true).Select(qitem => qitem.Name)),
SubScore=item.SubScore,
SubScore = item.SubScore,
});
if (IsRequire)
{
......@@ -742,7 +740,7 @@ namespace Edu.Module.Question
SubQuestionId = Index.ToString(),
SubQuestionKey = item.QuestionKey,
SubAnswer = string.Join(",", r_fillInList.Select(qitem => Common.Plugin.StringHelper.AppHtmlFilterr(qitem.Content))),
SubScore=item.SubScore,
SubScore = item.SubScore,
});
if (IsRequire)
{
......@@ -759,8 +757,8 @@ namespace Edu.Module.Question
{
SubQuestionId = Index.ToString(),
SubQuestionKey = item.QuestionKey,
SubAnswer = judgeList.Where(qitem=>qitem.IsAnswer==true)?.FirstOrDefault()?.Name??"",
SubScore=item.SubScore,
SubAnswer = judgeList.Where(qitem => qitem.IsAnswer == true)?.FirstOrDefault()?.Name ?? "",
SubScore = item.SubScore,
});
break;
//简答题
......@@ -772,7 +770,7 @@ namespace Edu.Module.Question
SubQuestionId = Index.ToString(),
SubQuestionKey = item.QuestionKey,
SubAnswer = Common.Plugin.StringHelper.AppHtmlFilterr(shortAnswer[0].Content),
SubScore=item.SubScore,
SubScore = item.SubScore,
});
if (IsRequire)
{
......
......@@ -14,6 +14,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Edu.WebApi.Controllers.Course
{
......@@ -402,6 +403,38 @@ namespace Edu.WebApi.Controllers.Course
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 重新修改问题答案
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult RunQuestion()
{
Task.Run(() => {
var list = questionModule.GetQuestionListModule(new RB_Question_ViewModel() { Q_QuestionTypeIds = "14,16", });
if (list != null && list.Count > 0)
{
foreach (var item in list)
{
try
{
var listenList = JsonHelper.DeserializeObject<List<SubAnswerItem>>(item.Answer);
}
catch
{
string str = analysisQuestion.CheckQuestion(item.QuestionTypeKey, item.QuestionContent, item.Answer, out string newAnswer, IsRequire: false);
if (!string.IsNullOrEmpty(newAnswer))
{
item.Answer = newAnswer;
bool flag = questionModule.SetQuestionModule(item);
}
}
}
}
});
return ApiResult.Success();
}
/// <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