using Newtonsoft.Json; using System.Collections.Generic; namespace DaJiaoYan.Models { /// /// 划分模版 /// public class DividePartitionConfig { [JsonProperty(PropertyName = "test_name")] public string Name { get; set; } [JsonProperty(PropertyName = "subject_id")] public int SubjectId { get; set; } // TODO 需要服务端返回模版所属考试id public int ExamId { get; set; } public int TestId { get; set; } [JsonProperty(PropertyName = "test_correct_type")] public Enumerates.TestCorrectType TestCorrectType { get; set; } /// /// 是否自动分配老师阅卷; /// true自动分配 /// [JsonProperty(PropertyName = "auto_assign_teacher_marking")] public bool AutoAssignTeacherMarking { get; set; } [JsonProperty(PropertyName = "answer_sheet")] public TestAnswerSheet[] AnswerSheets { get; set; } [JsonProperty(PropertyName = "template_info")] public TestTemplate Template { get; set; } [JsonProperty(PropertyName = "data")] public List Partitions { get; set; } /// /// 客观题数量 /// //public int ObjectiveQuestCount { get; set; } public void SetObjectivePaintThreshold(PartitionConfig p, Dictionary baseThreshold, int weights) { if (p.Config.OptionRects != null) { // 设置客观题填涂阈值 foreach (var op in p.Config.OptionRects) { //op.PaintThreshold = baseThreshold[op.Option.ToUpper()] + weights / 100.0; op.PaintThreshold = 0.01 + weights / 100.0; if (op.PaintThreshold > 0.9) { op.PaintThreshold = 0.9; } } } } /// /// 识别前预处理 /// /// /// public void Init(Dictionary baseThreshold = null, int weights = 0) { //Dictionary objectives = new Dictionary(); Partitions.ForEach(p => { //if (p.Config.CorrectType == Enumerates.QuestionType.Objective) //{ // if (Template.ParsedVersion == TestTemplate.TemplateVersion.V2) // { // ObjectiveQuestCount += p.Config.RectDivides.Keys.Count; // } // else // { // p.Config.OptionRects.ForEach(op => // { // if( !objectives.ContainsKey(op.Key) ) // { // objectives[op.Key] = 0; // } // }); // } //} SetObjectivePaintThreshold(p, baseThreshold, weights); }); //ObjectiveQuestCount += objectives.Keys.Count; } } }