AsiignmentStruct
This commit is contained in:
@@ -26,12 +26,12 @@ namespace TechHelper.Client.Exam
|
||||
Enum.TryParse<SubjectAreaEnum>(examPaper.SubjectArea, out SubjectArea);
|
||||
dto.SubjectArea = SubjectArea;
|
||||
|
||||
AssignmentStructDto examStruct = new AssignmentStructDto();
|
||||
AssignmentQuestionDto examStruct = new AssignmentQuestionDto();
|
||||
|
||||
foreach (var qg in examPaper.QuestionGroups)
|
||||
{
|
||||
examStruct.ChildrenGroups.Add(ParseMajorQuestionGroup(qg));
|
||||
examStruct.ChildrenGroups.Last().Index = (byte)(examStruct.ChildrenGroups.Count());
|
||||
examStruct.ChildrenAssignmentQuestion.Add(ParseMajorQuestionGroup(qg));
|
||||
examStruct.ChildrenAssignmentQuestion.Last().Index = (byte)(examStruct.ChildrenAssignmentQuestion.Count());
|
||||
}
|
||||
|
||||
dto.ExamStruct = examStruct;
|
||||
@@ -39,28 +39,20 @@ namespace TechHelper.Client.Exam
|
||||
return dto;
|
||||
}
|
||||
|
||||
private static AssignmentStructDto ParseMajorQuestionGroup(MajorQuestionGroup sqg)
|
||||
private static AssignmentQuestionDto ParseMajorQuestionGroup(MajorQuestionGroup sqg)
|
||||
{
|
||||
var examStruct = new AssignmentStructDto();
|
||||
|
||||
var examStruct = new AssignmentQuestionDto();
|
||||
examStruct.Title = sqg.Title;
|
||||
examStruct.Score = sqg.Score;
|
||||
if (sqg.SubQuestionGroups != null)
|
||||
{
|
||||
|
||||
examStruct.Title = sqg.Title;
|
||||
examStruct.Score = sqg.Score;
|
||||
examStruct.ChildrenGroups = new List<AssignmentStructDto>();
|
||||
|
||||
examStruct.ChildrenAssignmentQuestion = new List<AssignmentQuestionDto>();
|
||||
sqg.SubQuestionGroups?.ForEach(ssqg =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(ssqg.Descript))
|
||||
{
|
||||
examStruct.ChildrenGroups.Add(ParseMajorQuestionGroup(ssqg));
|
||||
examStruct.ChildrenGroups.Last().Index = (byte)(examStruct.ChildrenGroups.Count());
|
||||
}
|
||||
else
|
||||
{
|
||||
examStruct.AssignmentQuestions.Add(ParseGroupToAssignmentQuestion(ssqg, false));
|
||||
examStruct.AssignmentQuestions.Last().Index = (byte)(examStruct.AssignmentQuestions.Count());
|
||||
}
|
||||
examStruct.ChildrenAssignmentQuestion.Add(ParseMajorQuestionGroup(ssqg));
|
||||
examStruct.ChildrenAssignmentQuestion.Last().Index = (byte)(examStruct.ChildrenAssignmentQuestion.Count());
|
||||
|
||||
});
|
||||
|
||||
@@ -72,12 +64,8 @@ namespace TechHelper.Client.Exam
|
||||
|
||||
sqg.SubQuestions?.ForEach(sq =>
|
||||
{
|
||||
if(sq.SubQuestions.Any())
|
||||
{
|
||||
|
||||
}
|
||||
examStruct.AssignmentQuestions.Add(ParseAssignmentQuestion(sq));
|
||||
examStruct.AssignmentQuestions.Last().Index = (byte)(examStruct.AssignmentQuestions.Count());
|
||||
examStruct.ChildrenAssignmentQuestion.Add(ParseAssignmentQuestion(sq));
|
||||
examStruct.ChildrenAssignmentQuestion.Last().Index = (byte)(examStruct.ChildrenAssignmentQuestion.Count());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,47 +79,6 @@ namespace TechHelper.Client.Exam
|
||||
.Where(line => !string.IsNullOrWhiteSpace(line)).ToList();
|
||||
}
|
||||
|
||||
private static QuestionDto ParseGroupToQuestion(MajorQuestionGroup qg, bool subQ = true)
|
||||
{
|
||||
var dq = new QuestionDto();
|
||||
dq.Title = qg.Title + Environment.NewLine + qg.Descript;
|
||||
|
||||
if (subQ) dq.GroupState = QuestionGroupState.Subquestion;
|
||||
else dq.GroupState = QuestionGroupState.Group;
|
||||
|
||||
qg.SubQuestions?.ForEach(ssq =>
|
||||
{
|
||||
dq.ChildrenQuestion.Add(ParseQuestion(ssq));
|
||||
});
|
||||
|
||||
qg.SubQuestionGroups?.ForEach(sqg =>
|
||||
{
|
||||
dq.ChildrenQuestion.Add(ParseGroupToQuestion(sqg));
|
||||
});
|
||||
|
||||
return dq;
|
||||
}
|
||||
|
||||
private static AssignmentQuestionDto ParseGroupToAssignmentQuestion(MajorQuestionGroup qg, bool subQ = true)
|
||||
{
|
||||
var aq = new AssignmentQuestionDto();
|
||||
aq.Score = qg.Score;
|
||||
|
||||
qg.SubQuestions?.ForEach(ssq =>
|
||||
{
|
||||
aq.Question.ChildrenQuestion.Add(ParseQuestion(ssq));
|
||||
aq.Question.ChildrenQuestion.Last().Index = (byte)aq.Question.ChildrenQuestion.Count;
|
||||
});
|
||||
|
||||
qg.SubQuestionGroups?.ForEach(sqg =>
|
||||
{
|
||||
aq.Question.ChildrenQuestion.Add(ParseGroupToQuestion(sqg));
|
||||
aq.Question.ChildrenQuestion.Last().Index = (byte)aq.Question.ChildrenQuestion.Count;
|
||||
});
|
||||
|
||||
return aq;
|
||||
}
|
||||
|
||||
|
||||
private static AssignmentQuestionDto ParseAssignmentQuestion(PaperQuestion sq)
|
||||
{
|
||||
@@ -143,8 +90,8 @@ namespace TechHelper.Client.Exam
|
||||
sq.SubQuestions?.ForEach(ssq =>
|
||||
{
|
||||
|
||||
aq.Question.ChildrenQuestion.Add(ParseQuestion(ssq));
|
||||
aq.Question.ChildrenQuestion.Last().Index = (byte)aq.Question.ChildrenQuestion.Count;
|
||||
aq.ChildrenAssignmentQuestion.Add(ParseAssignmentQuestion(ssq));
|
||||
aq.ChildrenAssignmentQuestion.Last().Index = (byte)aq.ChildrenAssignmentQuestion.Count;
|
||||
|
||||
});
|
||||
|
||||
@@ -156,14 +103,6 @@ namespace TechHelper.Client.Exam
|
||||
var dq = new QuestionDto();
|
||||
dq.Title = sq.Stem;
|
||||
dq.Options = string.Join(Environment.NewLine, sq.Options.Select(opt => $"{opt.Label} {opt.Text}"));
|
||||
dq.Score = sq.Score;
|
||||
|
||||
|
||||
sq.SubQuestions?.ForEach(ssq =>
|
||||
{
|
||||
dq.ChildrenQuestion.Add(ParseQuestion(ssq));
|
||||
dq.ChildrenQuestion.Last().Index = (byte)dq.ChildrenQuestion.Count;
|
||||
});
|
||||
|
||||
return dq;
|
||||
}
|
||||
|
@@ -6,14 +6,14 @@ using System.Text.RegularExpressions;
|
||||
|
||||
namespace TechHelper.Client.Exam
|
||||
{
|
||||
// --- 新增错误处理相关类 ---
|
||||
|
||||
public class ParseError
|
||||
{
|
||||
public ParseErrorType Type { get; }
|
||||
public string Message { get; }
|
||||
public int? Index { get; } // 错误发生的文本索引或匹配项索引
|
||||
public string MatchedText { get; } // 如果与某个匹配项相关,记录其文本
|
||||
public Exception InnerException { get; } // 捕获到的原始异常
|
||||
public int? Index { get; }
|
||||
public string MatchedText { get; }
|
||||
public Exception InnerException { get; }
|
||||
|
||||
public ParseError(ParseErrorType type, string message, int? index = null, string matchedText = null, Exception innerException = null)
|
||||
{
|
||||
|
Reference in New Issue
Block a user