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

题库答案处理

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