Commit 080d989f authored by 黄奎's avatar 黄奎

页面修改

parent 9874320c
...@@ -73,6 +73,37 @@ namespace Edu.Model.ViewModel.Question ...@@ -73,6 +73,37 @@ namespace Edu.Model.ViewModel.Question
public List<optionItem> OptionList { get; set; } public List<optionItem> OptionList { get; set; }
} }
/// <summary>
/// 完型填空、阅读理解、听力答案
/// </summary>
public class SubAnswerItem
{
/// <summary>
/// 小题编号
/// </summary>
public string SubQuestionId { get; set; }
/// <summary>
/// 小题问题类型
/// </summary>
public string SubQuestionKey { get; set; }
/// <summary>
/// 小题答案
/// </summary>
public string SubAnswer { get; set; }
/// <summary>
/// 小题分数
/// </summary>
public decimal SubScore { get; set; }
/// <summary>
/// 学生小题得分
/// </summary>
public decimal StudentScore { get; set; }
}
/// <summary> /// <summary>
/// 填空题、简答题 /// 填空题、简答题
/// </summary> /// </summary>
......
...@@ -1267,6 +1267,7 @@ namespace Edu.Module.Exam ...@@ -1267,6 +1267,7 @@ namespace Edu.Module.Exam
QuestionContentObj = analysisQuestion.ParsingQuestion(questionModel.QuestionTypeKey, sItem.StudentContent, isEdit: true); QuestionContentObj = analysisQuestion.ParsingQuestion(questionModel.QuestionTypeKey, sItem.StudentContent, isEdit: true);
} }
List<object> answerList = new List<object>(); List<object> answerList = new List<object>();
List<object> quesAnswerList = new List<object>();
//填空题、分录题、资料题 //填空题、分录题、资料题
if (questionModel.QuestionTypeKey == "fill-in" || questionModel.QuestionTypeKey == "entry-problem" || questionModel.QuestionTypeKey == "data-question") if (questionModel.QuestionTypeKey == "fill-in" || questionModel.QuestionTypeKey == "entry-problem" || questionModel.QuestionTypeKey == "data-question")
{ {
...@@ -1282,7 +1283,20 @@ namespace Edu.Module.Exam ...@@ -1282,7 +1283,20 @@ namespace Edu.Module.Exam
//完型填空 //完型填空
else if (questionModel.QuestionTypeKey == "cloze") else if (questionModel.QuestionTypeKey == "cloze")
{ {
var tempList = sItem.StundetAnswer.Split(','); if (!string.IsNullOrEmpty(questionModel.Answer.ToString()))
{
var qAnsList = Common.Plugin.JsonHelper.DeserializeObject<List<SubAnswerItem>>(questionModel.Answer.ToString());
if (qAnsList != null && qAnsList.Count() > 0)
{
foreach (var tItem in qAnsList)
{
quesAnswerList.Add(tItem);
}
}
}
if (!string.IsNullOrEmpty(sItem.StundetAnswer.ToString()))
{
var tempList = JsonHelper.DeserializeObject<List<SubAnswerItem>>(sItem.StundetAnswer.ToString());
if (tempList != null && tempList.Count() > 0) if (tempList != null && tempList.Count() > 0)
{ {
foreach (var tItem in tempList) foreach (var tItem in tempList)
...@@ -1291,15 +1305,29 @@ namespace Edu.Module.Exam ...@@ -1291,15 +1305,29 @@ namespace Edu.Module.Exam
} }
} }
} }
}
else if (questionModel.QuestionTypeKey == "reading-comprehensio" || questionModel.QuestionTypeKey == "listening") else if (questionModel.QuestionTypeKey == "reading-comprehensio" || questionModel.QuestionTypeKey == "listening")
{ {
var qList = JsonHelper.DeserializeObject<List<matchingItem>>(sItem.StundetAnswer.ToString()); if (!string.IsNullOrEmpty(questionModel.Answer.ToString()))
{
var qAnsList = Common.Plugin.JsonHelper.DeserializeObject<List<SubAnswerItem>>(questionModel.Answer.ToString());
if (qAnsList != null && qAnsList.Count() > 0)
{
foreach (var tItem in qAnsList)
{
quesAnswerList.Add(tItem);
}
}
}
if (!string.IsNullOrEmpty(sItem.StundetAnswer.ToString()))
{
var qList = JsonHelper.DeserializeObject<List<SubAnswerItem>>(sItem.StundetAnswer.ToString());
foreach (var mItem in qList) foreach (var mItem in qList)
{ {
answerList.Add(new { mItem.Name, mItem.Content }); answerList.Add(mItem);
}
} }
} }
var qObj = new var qObj = new
{ {
PaperDetailsId = sItem.DetailsId,//试卷问题编号 PaperDetailsId = sItem.DetailsId,//试卷问题编号
...@@ -1314,6 +1342,7 @@ namespace Edu.Module.Exam ...@@ -1314,6 +1342,7 @@ namespace Edu.Module.Exam
questionModel.Score, questionModel.Score,
Answer = isShowAnswer ? questionModel.Answer : sItem.StundetAnswer, Answer = isShowAnswer ? questionModel.Answer : sItem.StundetAnswer,
sItem.StundetAnswer, sItem.StundetAnswer,
QuestionAnswerList= quesAnswerList,
AnswerList = isShowAnswer ? answerList : new List<object>(), AnswerList = isShowAnswer ? answerList : new List<object>(),
questionModel.AnswerParse, questionModel.AnswerParse,
sItem.StudentScore, sItem.StudentScore,
...@@ -1430,7 +1459,7 @@ namespace Edu.Module.Exam ...@@ -1430,7 +1459,7 @@ namespace Edu.Module.Exam
{ {
foreach (var item in list) foreach (var item in list)
{ {
analysisQuestion.CheckQuestion(item.QuestionTypeKey, item.QuestionContent, item.Answer, out string newAnswer); analysisQuestion.CheckQuestion(item.QuestionTypeKey, item.QuestionContent, item.Answer, out string newAnswer,IsRequire:false);
RB_Examination_StudentDetails_ViewModel model = new RB_Examination_StudentDetails_ViewModel() RB_Examination_StudentDetails_ViewModel model = new RB_Examination_StudentDetails_ViewModel()
{ {
Id = item.StundetDetailsId, Id = item.StundetDetailsId,
......
using Edu.Model.ViewModel.Exam; using Edu.Model.ViewModel.Exam;
using Edu.Model.ViewModel.Question;
using Edu.Repository.Exam; using Edu.Repository.Exam;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -114,11 +115,56 @@ namespace Edu.Module.Exam ...@@ -114,11 +115,56 @@ namespace Edu.Module.Exam
break; break;
//完型填空 //完型填空
case "cloze": case "cloze":
var cloze_AnswerList= Common.Plugin.JsonHelper.DeserializeObject<List<SubAnswerItem>>(sItem.Answer.ToString());
var cloze_Stu_AnswerList= Common.Plugin.JsonHelper.DeserializeObject<List<SubAnswerItem>>(answerModel.StundetAnswer.ToString());
decimal clozeScore = 0;
if (cloze_AnswerList != null && cloze_Stu_AnswerList != null
&& cloze_AnswerList.Count > 0 && cloze_Stu_AnswerList.Count > 0
&& cloze_AnswerList.Count == cloze_Stu_AnswerList.Count)
{
for (var i = 0; i < cloze_AnswerList.Count; i++)
{
if (cloze_AnswerList[i].SubAnswer == cloze_Stu_AnswerList[i].SubAnswer)
{
clozeScore += cloze_AnswerList[i].SubScore;
cloze_Stu_AnswerList[i].StudentScore = cloze_AnswerList[i].SubScore;
}
}
}
answerList.Add(new RB_Examination_StudentDetails_ViewModel()
{
Id = answerModel.Id,
StudentScore = clozeScore,
StundetAnswer=Common.Plugin.JsonHelper.Serialize(cloze_Stu_AnswerList)
});
break; break;
//阅读理解 //阅读理解
case "reading-comprehensio": case "reading-comprehensio":
var reading_AnswerList = Common.Plugin.JsonHelper.DeserializeObject<List<SubAnswerItem>>(sItem.Answer.ToString());
var reading_Stu_AnswerList = Common.Plugin.JsonHelper.DeserializeObject<List<SubAnswerItem>>(answerModel.StundetAnswer.ToString());
decimal readingScore = 0;
if (reading_AnswerList != null && reading_Stu_AnswerList != null
&& reading_AnswerList.Count > 0 && reading_Stu_AnswerList.Count > 0
&& reading_AnswerList.Count == reading_Stu_AnswerList.Count)
{
for (var i = 0; i < reading_AnswerList.Count; i++)
{
if (reading_AnswerList[i].SubQuestionKey != "fill-in" && reading_AnswerList[i].SubQuestionKey != "short-answer")
{
if (reading_AnswerList[i].SubAnswer == reading_Stu_AnswerList[i].SubAnswer)
{
readingScore += reading_AnswerList[i].SubScore;
reading_Stu_AnswerList[i].StudentScore = reading_AnswerList[i].SubScore;
}
}
}
}
answerList.Add(new RB_Examination_StudentDetails_ViewModel()
{
Id = answerModel.Id,
StudentScore = readingScore,
StundetAnswer = Common.Plugin.JsonHelper.Serialize(reading_Stu_AnswerList)
});
break; break;
//口语题 //口语题
case "spoken": case "spoken":
...@@ -126,7 +172,31 @@ namespace Edu.Module.Exam ...@@ -126,7 +172,31 @@ namespace Edu.Module.Exam
break; break;
//听力题 //听力题
case "listening": case "listening":
var listening_AnswerList = Common.Plugin.JsonHelper.DeserializeObject<List<SubAnswerItem>>(sItem.Answer.ToString());
var listening_Stu_AnswerList = Common.Plugin.JsonHelper.DeserializeObject<List<SubAnswerItem>>(answerModel.StundetAnswer.ToString());
decimal listeningScore = 0;
if (listening_AnswerList != null && listening_Stu_AnswerList != null
&& listening_AnswerList.Count > 0 && listening_Stu_AnswerList.Count > 0
&& listening_AnswerList.Count == listening_Stu_AnswerList.Count)
{
for (var i = 0; i < listening_AnswerList.Count; i++)
{
if (listening_AnswerList[i].SubQuestionKey != "fill-in"&& listening_AnswerList[i].SubQuestionKey != "short-answer")
{
if (listening_AnswerList[i].SubAnswer == listening_Stu_AnswerList[i].SubAnswer)
{
listeningScore += listening_AnswerList[i].SubScore;
listening_Stu_AnswerList[i].StudentScore = listening_AnswerList[i].SubScore;
}
}
}
}
answerList.Add(new RB_Examination_StudentDetails_ViewModel()
{
Id = answerModel.Id,
StudentScore = listeningScore,
StundetAnswer = Common.Plugin.JsonHelper.Serialize(listening_Stu_AnswerList)
});
break; break;
//公用选项题 //公用选项题
case "sharing-choose": case "sharing-choose":
...@@ -157,6 +227,10 @@ namespace Edu.Module.Exam ...@@ -157,6 +227,10 @@ namespace Edu.Module.Exam
{nameof(RB_Examination_StudentDetails_ViewModel.StudentScore),item.StudentScore }, {nameof(RB_Examination_StudentDetails_ViewModel.StudentScore),item.StudentScore },
{nameof(RB_Examination_StudentDetails_ViewModel.IsMarking),1 }, {nameof(RB_Examination_StudentDetails_ViewModel.IsMarking),1 },
}; };
if (!string.IsNullOrEmpty(item.StundetAnswer))
{
fileds.Add(nameof(RB_Examination_StudentDetails_ViewModel.StundetAnswer), item.StundetAnswer);
}
examination_StudentDetailsRepository.Update(fileds, new WhereHelper(nameof(RB_Examination_StudentDetails_ViewModel.Id), item.Id)); examination_StudentDetailsRepository.Update(fileds, new WhereHelper(nameof(RB_Examination_StudentDetails_ViewModel.Id), item.Id));
} }
} }
......
...@@ -402,8 +402,9 @@ namespace Edu.Module.Question ...@@ -402,8 +402,9 @@ namespace Edu.Module.Question
/// <param name="QuestionTypeKey">问题内容</param> /// <param name="QuestionTypeKey">问题内容</param>
/// <param name="Answer">问题答案</param> /// <param name="Answer">问题答案</param>
/// <param name="AnalysisAnswer">解析答案</param> /// <param name="AnalysisAnswer">解析答案</param>
/// <param name="IsRequire">是否开启验证</param>
/// <returns></returns> /// <returns></returns>
public string CheckQuestion(string QuestionTypeKey,string QuestionContent,string Answer, out string AnalysisAnswer) public string CheckQuestion(string QuestionTypeKey,string QuestionContent,string Answer, out string AnalysisAnswer,bool IsRequire=true)
{ {
AnalysisAnswer = ""; AnalysisAnswer = "";
string message = ""; string message = "";
...@@ -592,11 +593,18 @@ namespace Edu.Module.Question ...@@ -592,11 +593,18 @@ namespace Edu.Module.Question
if (clozeList != null && clozeList.Count > 0) if (clozeList != null && clozeList.Count > 0)
{ {
int index = 1; int index = 1;
string clozeAnswer = ""; List<SubAnswerItem> clozeAnswerList = new List<SubAnswerItem>();
foreach (var rootItem in clozeList) foreach (var rootItem in clozeList)
{ {
var tempModel = rootItem.OptionList.Where(qitem => qitem.IsAnswer == true)?.FirstOrDefault(); var tempModel = rootItem.OptionList.Where(qitem => qitem.IsAnswer == true)?.FirstOrDefault();
clozeAnswer += "," + tempModel?.Name ?? ""; clozeAnswerList.Add(new SubAnswerItem()
{
SubQuestionId= index.ToString(),
SubAnswer= tempModel?.Name ?? "",
SubScore = rootItem.SubScore,
});
if (IsRequire)
{
if (rootItem.OptionList.Where(qitem => string.IsNullOrEmpty(qitem.Content)).Count() > 0) if (rootItem.OptionList.Where(qitem => string.IsNullOrEmpty(qitem.Content)).Count() > 0)
{ {
message = string.Format("第{0}小题选项内容不能为空!", index); message = string.Format("第{0}小题选项内容不能为空!", index);
...@@ -607,9 +615,10 @@ namespace Edu.Module.Question ...@@ -607,9 +615,10 @@ namespace Edu.Module.Question
message = string.Format("请设置第{0}小题选项的正确答案!", index); message = string.Format("请设置第{0}小题选项的正确答案!", index);
return message; return message;
} }
}
index++; index++;
} }
AnalysisAnswer = clozeAnswer.TrimStart(','); AnalysisAnswer = Common.Plugin.JsonHelper.Serialize(clozeAnswerList);
} }
else else
{ {
...@@ -643,7 +652,7 @@ namespace Edu.Module.Question ...@@ -643,7 +652,7 @@ namespace Edu.Module.Question
var readingList = Common.Plugin.JsonHelper.DeserializeObject<List<readingComprehensioItem>>(QuestionContent); var readingList = Common.Plugin.JsonHelper.DeserializeObject<List<readingComprehensioItem>>(QuestionContent);
if (readingList != null && readingList.Count > 0) if (readingList != null && readingList.Count > 0)
{ {
List<matchingItem> resultList = new List<matchingItem>(); List<SubAnswerItem> resultList = new List<SubAnswerItem>();
int Index = 1; int Index = 1;
foreach (var item in readingList) foreach (var item in readingList)
{ {
...@@ -658,67 +667,88 @@ namespace Edu.Module.Question ...@@ -658,67 +667,88 @@ namespace Edu.Module.Question
case "single": case "single":
var singleAnwser = Common.Plugin.JsonHelper.DeserializeObject<List<optionItem>>(item.SubAnwser.ToString()); var singleAnwser = Common.Plugin.JsonHelper.DeserializeObject<List<optionItem>>(item.SubAnwser.ToString());
string singleMessage = CheckChoose(singleAnwser); string singleMessage = CheckChoose(singleAnwser);
resultList.Add(new matchingItem resultList.Add(new SubAnswerItem
{ {
Name = Index.ToString(), SubQuestionId = Index.ToString(),
Content = singleAnwser.Where(qitem => qitem.IsAnswer == true)?.FirstOrDefault()?.Name??"" SubQuestionKey=item.QuestionKey,
SubAnswer = singleAnwser.Where(qitem => qitem.IsAnswer == true)?.FirstOrDefault()?.Name??"",
SubScore=item.SubScore,
}); });
if (IsRequire)
{
if (!string.IsNullOrEmpty(singleMessage)) if (!string.IsNullOrEmpty(singleMessage))
{ {
return singleMessage; return singleMessage;
} }
}
break; break;
//多选题 //多选题
case "multiple": case "multiple":
var multipleAnwser = Common.Plugin.JsonHelper.DeserializeObject<List<optionItem>>(item.SubAnwser.ToString()); var multipleAnwser = Common.Plugin.JsonHelper.DeserializeObject<List<optionItem>>(item.SubAnwser.ToString());
string multipleMessage = CheckChoose(multipleAnwser); string multipleMessage = CheckChoose(multipleAnwser);
resultList.Add(new matchingItem resultList.Add(new SubAnswerItem
{ {
Name = Index.ToString(), SubQuestionId = Index.ToString(),
Content = string.Join(",", multipleAnwser.Where(qitem => qitem.IsAnswer == true).Select(qitem => qitem.Name)) SubQuestionKey = item.QuestionKey,
SubAnswer = string.Join(",", multipleAnwser.Where(qitem => qitem.IsAnswer == true).Select(qitem => qitem.Name)),
SubScore=item.SubScore,
}); });
if (IsRequire)
{
if (!string.IsNullOrEmpty(multipleMessage)) if (!string.IsNullOrEmpty(multipleMessage))
{ {
return multipleMessage; return multipleMessage;
} }
}
break; break;
//填空题 //填空题
case "fill-in": case "fill-in":
var r_fillInList = Common.Plugin.JsonHelper.DeserializeObject<List<fillInItem>>(item.SubAnwser.ToString()); var r_fillInList = Common.Plugin.JsonHelper.DeserializeObject<List<fillInItem>>(item.SubAnwser.ToString());
string r_fillMessage = CheckFillIn(r_fillInList); string r_fillMessage = CheckFillIn(r_fillInList);
resultList.Add(new matchingItem resultList.Add(new SubAnswerItem
{ {
Name = Index.ToString(), SubQuestionId = Index.ToString(),
Content = string.Join(",", r_fillInList.Select(qitem => Common.Plugin.StringHelper.AppHtmlFilterr(qitem.Content))) SubQuestionKey = item.QuestionKey,
SubAnswer = string.Join(",", r_fillInList.Select(qitem => Common.Plugin.StringHelper.AppHtmlFilterr(qitem.Content))),
SubScore=item.SubScore,
}); });
if (IsRequire)
{
if (!string.IsNullOrEmpty(r_fillMessage)) if (!string.IsNullOrEmpty(r_fillMessage))
{ {
return r_fillMessage; return r_fillMessage;
} }
}
break; break;
//判断题 //判断题
case "judge": case "judge":
var judgeList = Common.Plugin.JsonHelper.DeserializeObject<List<optionItem>>(item.SubAnwser.ToString()); var judgeList = Common.Plugin.JsonHelper.DeserializeObject<List<optionItem>>(item.SubAnwser.ToString());
resultList.Add(new matchingItem resultList.Add(new SubAnswerItem
{ {
Name = Index.ToString(), SubQuestionId = Index.ToString(),
Content = judgeList.Where(qitem=>qitem.IsAnswer==true)?.FirstOrDefault()?.Name??"" SubQuestionKey = item.QuestionKey,
SubAnswer = judgeList.Where(qitem=>qitem.IsAnswer==true)?.FirstOrDefault()?.Name??"",
SubScore=item.SubScore,
}); });
break; break;
//简答题 //简答题
case "short-answer": case "short-answer":
var shortAnswer = Common.Plugin.JsonHelper.DeserializeObject<List<fillInItem>>(item.SubAnwser.ToString()); var shortAnswer = Common.Plugin.JsonHelper.DeserializeObject<List<fillInItem>>(item.SubAnwser.ToString());
string r_shortMessage = CheckShortAnswer(shortAnswer[0].Content); string r_shortMessage = CheckShortAnswer(shortAnswer[0].Content);
resultList.Add(new matchingItem resultList.Add(new SubAnswerItem
{ {
Name = Index.ToString(), SubQuestionId = Index.ToString(),
Content = Common.Plugin.StringHelper.AppHtmlFilterr(shortAnswer[0].Content) SubQuestionKey = item.QuestionKey,
SubAnswer = Common.Plugin.StringHelper.AppHtmlFilterr(shortAnswer[0].Content),
SubScore=item.SubScore,
}); });
if (IsRequire)
{
if (!string.IsNullOrEmpty(r_shortMessage)) if (!string.IsNullOrEmpty(r_shortMessage))
{ {
return r_shortMessage; return r_shortMessage;
} }
}
break; break;
} }
......
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