|
@@ -16,9 +16,9 @@ using TEAMModelOS.SDK.Helper.Common.StringHelper;
|
|
using TEAMModelOS.SDK.Helper.Security.ShaHash;
|
|
using TEAMModelOS.SDK.Helper.Security.ShaHash;
|
|
using TEAMModelOS.Service.Model.PowerPoint;
|
|
using TEAMModelOS.Service.Model.PowerPoint;
|
|
using TEAMModelOS.Service.Models.Core;
|
|
using TEAMModelOS.Service.Models.Core;
|
|
-using TEAMModelOS.Service.Models.Evaluation.Models;
|
|
|
|
-using TEAMModelOS.Service.Services.Evaluation.Interfaces;
|
|
|
|
-namespace TEAMModelOS.Service.Services.Evaluation.Implements
|
|
|
|
|
|
+using TEAMModelOS.Service.Models.Exam.Models;
|
|
|
|
+using TEAMModelOS.Service.Services.Exam.Interfaces;
|
|
|
|
+namespace TEAMModelOS.Service.Services.Exam.Implements
|
|
{
|
|
{
|
|
public class HtmlAnalyzeService : IHtmlAnalyzeService
|
|
public class HtmlAnalyzeService : IHtmlAnalyzeService
|
|
{
|
|
{
|
|
@@ -36,7 +36,7 @@ namespace TEAMModelOS.Service.Services.Evaluation.Implements
|
|
{ "Single", "【单选题】|【结束】" }, { "Multiple", "【多选题】|【结束】" },
|
|
{ "Single", "【单选题】|【结束】" }, { "Multiple", "【多选题】|【结束】" },
|
|
{ "Judge", "【判断题】|【结束】" }, { "Complete", "【填空题】|【结束】" },
|
|
{ "Judge", "【判断题】|【结束】" }, { "Complete", "【填空题】|【结束】" },
|
|
{ "Subjective", "【问答题】|【结束】" } , { "Compose", "【综合题】|【完结】" }};
|
|
{ "Subjective", "【问答题】|【结束】" } , { "Compose", "【综合题】|【完结】" }};
|
|
- public List<ItemInfo> AnalyzeWordAsync(string html, string Lang)
|
|
|
|
|
|
+ public List<ExamItem> AnalyzeWordAsync(string html, string Lang)
|
|
{
|
|
{
|
|
//去除class 以及span标签"
|
|
//去除class 以及span标签"
|
|
string classpattern = "class=\"([^\"]*)\"";
|
|
string classpattern = "class=\"([^\"]*)\"";
|
|
@@ -45,33 +45,33 @@ namespace TEAMModelOS.Service.Services.Evaluation.Implements
|
|
html = Regex.Replace(html, pattern, "");
|
|
html = Regex.Replace(html, pattern, "");
|
|
html = html.Replace("\t", " ").Replace("<span>", "").Replace("</span>", "").Replace("dir=\"ltr\"", "");
|
|
html = html.Replace("\t", " ").Replace("<span>", "").Replace("</span>", "").Replace("dir=\"ltr\"", "");
|
|
Dictionary<string, List<string>> TestInType = ConvertTest(html);
|
|
Dictionary<string, List<string>> TestInType = ConvertTest(html);
|
|
- List<ItemInfo> tests = new List<ItemInfo>();
|
|
|
|
|
|
+ List<ExamItem> tests = new List<ExamItem>();
|
|
foreach (string key in TestInType.Keys)
|
|
foreach (string key in TestInType.Keys)
|
|
{
|
|
{
|
|
switch (key)
|
|
switch (key)
|
|
{
|
|
{
|
|
case "Single":
|
|
case "Single":
|
|
- List<ItemInfo> exercisesSingle = SingleConvert(key, TestInType[key]);
|
|
|
|
|
|
+ List<ExamItem> exercisesSingle = SingleConvert(key, TestInType[key]);
|
|
exercisesSingle.ForEach(x => { x.pShaCode = x.shaCode; });
|
|
exercisesSingle.ForEach(x => { x.pShaCode = x.shaCode; });
|
|
tests.AddRange(exercisesSingle); break;
|
|
tests.AddRange(exercisesSingle); break;
|
|
case "Multiple":
|
|
case "Multiple":
|
|
- List<ItemInfo> exercisesMultiple = MultipleConvert(key, TestInType[key]);
|
|
|
|
|
|
+ List<ExamItem> exercisesMultiple = MultipleConvert(key, TestInType[key]);
|
|
exercisesMultiple.ForEach(x => { x.pShaCode = x.shaCode; });
|
|
exercisesMultiple.ForEach(x => { x.pShaCode = x.shaCode; });
|
|
tests.AddRange(exercisesMultiple); break;
|
|
tests.AddRange(exercisesMultiple); break;
|
|
case "Judge":
|
|
case "Judge":
|
|
- List<ItemInfo> exercisesJudge = JudgeConvert(key, TestInType[key]);
|
|
|
|
|
|
+ List<ExamItem> exercisesJudge = JudgeConvert(key, TestInType[key]);
|
|
exercisesJudge.ForEach(x => { x.pShaCode = x.shaCode; });
|
|
exercisesJudge.ForEach(x => { x.pShaCode = x.shaCode; });
|
|
tests.AddRange(exercisesJudge); break;
|
|
tests.AddRange(exercisesJudge); break;
|
|
case "Complete":
|
|
case "Complete":
|
|
- List<ItemInfo> exercisesComplete = CompleteConvert(key, TestInType[key]);
|
|
|
|
|
|
+ List<ExamItem> exercisesComplete = CompleteConvert(key, TestInType[key]);
|
|
exercisesComplete.ForEach(x => { x.pShaCode = x.shaCode; });
|
|
exercisesComplete.ForEach(x => { x.pShaCode = x.shaCode; });
|
|
tests.AddRange(exercisesComplete); break;
|
|
tests.AddRange(exercisesComplete); break;
|
|
case "Subjective":
|
|
case "Subjective":
|
|
- List<ItemInfo> exercisesSubjective = SubjectiveConvert(key, TestInType[key]);
|
|
|
|
|
|
+ List<ExamItem> exercisesSubjective = SubjectiveConvert(key, TestInType[key]);
|
|
exercisesSubjective.ForEach(x => { x.pShaCode = x.shaCode; });
|
|
exercisesSubjective.ForEach(x => { x.pShaCode = x.shaCode; });
|
|
tests.AddRange(exercisesSubjective); break;
|
|
tests.AddRange(exercisesSubjective); break;
|
|
case "Compose":
|
|
case "Compose":
|
|
- List<ItemInfo> exercisesCompose = ComposeConvert(key, TestInType[key], Lang);
|
|
|
|
|
|
+ List<ExamItem> exercisesCompose = ComposeConvert(key, TestInType[key], Lang);
|
|
exercisesCompose.ForEach(x => { x.pShaCode = x.shaCode; });
|
|
exercisesCompose.ForEach(x => { x.pShaCode = x.shaCode; });
|
|
tests.AddRange(exercisesCompose);
|
|
tests.AddRange(exercisesCompose);
|
|
break;
|
|
break;
|
|
@@ -81,36 +81,36 @@ namespace TEAMModelOS.Service.Services.Evaluation.Implements
|
|
return tests;
|
|
return tests;
|
|
}
|
|
}
|
|
|
|
|
|
- private List<ItemInfo> SingleConvert(string TypeKey, List<string> list)
|
|
|
|
|
|
+ private List<ExamItem> SingleConvert(string TypeKey, List<string> list)
|
|
{
|
|
{
|
|
- List<ItemInfo> testInfos = OptionProcess(TypeKey, list);
|
|
|
|
|
|
+ List<ExamItem> testInfos = OptionProcess(TypeKey, list);
|
|
return testInfos;
|
|
return testInfos;
|
|
}
|
|
}
|
|
|
|
|
|
- private List<ItemInfo> MultipleConvert(string TypeKey, List<string> list)
|
|
|
|
|
|
+ private List<ExamItem> MultipleConvert(string TypeKey, List<string> list)
|
|
{
|
|
{
|
|
- List<ItemInfo> testInfos = OptionProcess(TypeKey, list);
|
|
|
|
|
|
+ List<ExamItem> testInfos = OptionProcess(TypeKey, list);
|
|
return testInfos;
|
|
return testInfos;
|
|
}
|
|
}
|
|
|
|
|
|
- private List<ItemInfo> JudgeConvert(string TypeKey, List<string> list)
|
|
|
|
|
|
+ private List<ExamItem> JudgeConvert(string TypeKey, List<string> list)
|
|
{
|
|
{
|
|
- List<ItemInfo> testInfos = OptionProcess(TypeKey, list);
|
|
|
|
|
|
+ List<ExamItem> testInfos = OptionProcess(TypeKey, list);
|
|
return testInfos;
|
|
return testInfos;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private List<ItemInfo> CompleteConvert(string TypeKey, List<string> list)
|
|
|
|
|
|
+ private List<ExamItem> CompleteConvert(string TypeKey, List<string> list)
|
|
{
|
|
{
|
|
- List<ItemInfo> testInfos = CompleteProcess(TypeKey, list);
|
|
|
|
|
|
+ List<ExamItem> testInfos = CompleteProcess(TypeKey, list);
|
|
return testInfos;
|
|
return testInfos;
|
|
}
|
|
}
|
|
- private List<ItemInfo> CompleteProcess(string TypeKey, List<string> tests)
|
|
|
|
|
|
+ private List<ExamItem> CompleteProcess(string TypeKey, List<string> tests)
|
|
{
|
|
{
|
|
//List<string> tests = ConvertTest(testHtml);
|
|
//List<string> tests = ConvertTest(testHtml);
|
|
- List<ItemInfo> testInfos = ConvertTestInfo(tests, TypeKey);
|
|
|
|
|
|
+ List<ExamItem> testInfos = ConvertTestInfo(tests, TypeKey);
|
|
HtmlDocument doc = new HtmlDocument();
|
|
HtmlDocument doc = new HtmlDocument();
|
|
- foreach (ItemInfo testInfo in testInfos)
|
|
|
|
|
|
+ foreach (ExamItem testInfo in testInfos)
|
|
{
|
|
{
|
|
List<string> ans = new List<string>();
|
|
List<string> ans = new List<string>();
|
|
testInfo.question = testInfo.question.Replace(AnalysisTag, "").Replace(SummaryTag, "").Replace(AnswerTag, "");
|
|
testInfo.question = testInfo.question.Replace(AnalysisTag, "").Replace(SummaryTag, "").Replace(AnswerTag, "");
|
|
@@ -156,11 +156,11 @@ namespace TEAMModelOS.Service.Services.Evaluation.Implements
|
|
return testInfos;
|
|
return testInfos;
|
|
}
|
|
}
|
|
|
|
|
|
- private List<ItemInfo> OptionProcess(string typeKey, List<string> list)
|
|
|
|
|
|
+ private List<ExamItem> OptionProcess(string typeKey, List<string> list)
|
|
{
|
|
{
|
|
string[] optionsKeys = Options.Select(s => s.ToString()).ToArray();
|
|
string[] optionsKeys = Options.Select(s => s.ToString()).ToArray();
|
|
- List<ItemInfo> testInfos = ConvertTestInfo(list, typeKey);
|
|
|
|
- foreach (ItemInfo testInfo in testInfos)
|
|
|
|
|
|
+ List<ExamItem> testInfos = ConvertTestInfo(list, typeKey);
|
|
|
|
+ foreach (ExamItem testInfo in testInfos)
|
|
{
|
|
{
|
|
string optsRgex = optionsKeys[0] + "(\\.|\\.|\\、|\\:|\\:)([\\s\\S]*?)" + AnswerTag;
|
|
string optsRgex = optionsKeys[0] + "(\\.|\\.|\\、|\\:|\\:)([\\s\\S]*?)" + AnswerTag;
|
|
string optsHtml = Regex.Match(testInfo.question, optsRgex).Value;
|
|
string optsHtml = Regex.Match(testInfo.question, optsRgex).Value;
|
|
@@ -222,12 +222,12 @@ namespace TEAMModelOS.Service.Services.Evaluation.Implements
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private List<ItemInfo> SubjectiveConvert(string TypeKey, List<string> tests)
|
|
|
|
|
|
+ private List<ExamItem> SubjectiveConvert(string TypeKey, List<string> tests)
|
|
{
|
|
{
|
|
// List<string> tests = ConvertTest(testHtml);
|
|
// List<string> tests = ConvertTest(testHtml);
|
|
- List<ItemInfo> testInfos = ConvertTestInfo(tests, TypeKey);
|
|
|
|
|
|
+ List<ExamItem> testInfos = ConvertTestInfo(tests, TypeKey);
|
|
|
|
|
|
- foreach (ItemInfo testInfo in testInfos)
|
|
|
|
|
|
+ foreach (ExamItem testInfo in testInfos)
|
|
{
|
|
{
|
|
testInfo.question = testInfo.question.Replace(AnalysisTag, "").Replace(SummaryTag, "").Replace(AnswerTag, "");
|
|
testInfo.question = testInfo.question.Replace(AnalysisTag, "").Replace(SummaryTag, "").Replace(AnswerTag, "");
|
|
testInfo.question = HtmlHelper.DoUselessTag(testInfo.question);
|
|
testInfo.question = HtmlHelper.DoUselessTag(testInfo.question);
|
|
@@ -244,19 +244,19 @@ namespace TEAMModelOS.Service.Services.Evaluation.Implements
|
|
return testInfos;
|
|
return testInfos;
|
|
}
|
|
}
|
|
|
|
|
|
- private List<ItemInfo> ComposeConvert(string TypeKey, List<string> list, string Lang)
|
|
|
|
|
|
+ private List<ExamItem> ComposeConvert(string TypeKey, List<string> list, string Lang)
|
|
{
|
|
{
|
|
- List<ItemInfo> exerciseDtos = new List<ItemInfo>();
|
|
|
|
|
|
+ List<ExamItem> exerciseDtos = new List<ExamItem>();
|
|
foreach (string html in list)
|
|
foreach (string html in list)
|
|
{
|
|
{
|
|
- ItemInfo exercise = new ItemInfo() { type = TypeKey };
|
|
|
|
|
|
+ ExamItem exercise = new ExamItem() { type = TypeKey };
|
|
string RegexStr = ComposeStart + "([\\s\\S]*?)" + ComposeEnd;
|
|
string RegexStr = ComposeStart + "([\\s\\S]*?)" + ComposeEnd;
|
|
Match mt = Regex.Match(html, RegexStr);
|
|
Match mt = Regex.Match(html, RegexStr);
|
|
exercise.question = HtmlHelper.DoUselessTag(mt.Value.Replace(ComposeStart, "").Replace(ComposeEnd, ""));
|
|
exercise.question = HtmlHelper.DoUselessTag(mt.Value.Replace(ComposeStart, "").Replace(ComposeEnd, ""));
|
|
string testinfo = Regex.Replace(html, RegexStr, "").Replace(ComposeTag, CompleteStart);
|
|
string testinfo = Regex.Replace(html, RegexStr, "").Replace(ComposeTag, CompleteStart);
|
|
//获取综合题的材料加每个小题的sha1Code
|
|
//获取综合题的材料加每个小题的sha1Code
|
|
string testQs = HtmlHelper.DoTextImg(exercise.question);
|
|
string testQs = HtmlHelper.DoTextImg(exercise.question);
|
|
- List<ItemInfo> dtos = AnalyzeWordAsync(testinfo, Lang);
|
|
|
|
|
|
+ List<ExamItem> dtos = AnalyzeWordAsync(testinfo, Lang);
|
|
if (dtos.IsNotEmpty())
|
|
if (dtos.IsNotEmpty())
|
|
{
|
|
{
|
|
dtos.ForEach(x => { testQs = testQs + x.shaCode; });
|
|
dtos.ForEach(x => { testQs = testQs + x.shaCode; });
|
|
@@ -268,15 +268,15 @@ namespace TEAMModelOS.Service.Services.Evaluation.Implements
|
|
}
|
|
}
|
|
return exerciseDtos;
|
|
return exerciseDtos;
|
|
}
|
|
}
|
|
- public static List<ItemInfo> ConvertTestInfo(List<string> tests, string TypeKey)
|
|
|
|
|
|
+ public static List<ExamItem> ConvertTestInfo(List<string> tests, string TypeKey)
|
|
{
|
|
{
|
|
- List<ItemInfo> testInfos = new List<ItemInfo>();
|
|
|
|
|
|
+ List<ExamItem> testInfos = new List<ExamItem>();
|
|
foreach (string html in tests)
|
|
foreach (string html in tests)
|
|
{
|
|
{
|
|
Dictionary<string, string> regex = new Dictionary<string, string>();
|
|
Dictionary<string, string> regex = new Dictionary<string, string>();
|
|
Dictionary<string, string> question = new Dictionary<string, string> { { "Summary", TestType[TypeKey].Split("|")[0] + "|" + AnswerTag }, { "Answer", AnswerTag + "|" + AnalysisTag }, { "Analysis", AnalysisTag + "|" + EndedTag } };
|
|
Dictionary<string, string> question = new Dictionary<string, string> { { "Summary", TestType[TypeKey].Split("|")[0] + "|" + AnswerTag }, { "Answer", AnswerTag + "|" + AnalysisTag }, { "Analysis", AnalysisTag + "|" + EndedTag } };
|
|
Dictionary<string, string> compquestion = new Dictionary<string, string> { { "Summary", TestType[TypeKey].Split("|")[0] + "|" + AnalysisTag }, { "Analysis", AnalysisTag + "|" + EndedTag } };
|
|
Dictionary<string, string> compquestion = new Dictionary<string, string> { { "Summary", TestType[TypeKey].Split("|")[0] + "|" + AnalysisTag }, { "Analysis", AnalysisTag + "|" + EndedTag } };
|
|
- ItemInfo test = new ItemInfo();
|
|
|
|
|
|
+ ExamItem test = new ExamItem();
|
|
test.type = TypeKey;
|
|
test.type = TypeKey;
|
|
List<string> keys = new List<string>();
|
|
List<string> keys = new List<string>();
|
|
if (TypeKey.Equals("Complete"))
|
|
if (TypeKey.Equals("Complete"))
|