DividePartitionConfig.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using Newtonsoft.Json;
  2. using System.Collections.Generic;
  3. namespace DaJiaoYan.Models
  4. {
  5. /// <summary>
  6. /// 划分模版
  7. /// </summary>
  8. public class DividePartitionConfig
  9. {
  10. [JsonProperty(PropertyName = "test_name")]
  11. public string Name { get; set; }
  12. [JsonProperty(PropertyName = "subject_id")]
  13. public int SubjectId { get; set; }
  14. // TODO 需要服务端返回模版所属考试id
  15. public int ExamId { get; set; }
  16. public int TestId { get; set; }
  17. [JsonProperty(PropertyName = "test_correct_type")]
  18. public Enumerates.TestCorrectType TestCorrectType { get; set; }
  19. /// <summary>
  20. /// 是否自动分配老师阅卷;
  21. /// true自动分配
  22. /// </summary>
  23. [JsonProperty(PropertyName = "auto_assign_teacher_marking")]
  24. public bool AutoAssignTeacherMarking { get; set; }
  25. [JsonProperty(PropertyName = "answer_sheet")]
  26. public TestAnswerSheet[] AnswerSheets { get; set; }
  27. [JsonProperty(PropertyName = "template_info")]
  28. public TestTemplate Template { get; set; }
  29. [JsonProperty(PropertyName = "data")]
  30. public List<PartitionConfig> Partitions { get; set; }
  31. /// <summary>
  32. /// 客观题数量
  33. /// </summary>
  34. //public int ObjectiveQuestCount { get; set; }
  35. public void SetObjectivePaintThreshold(PartitionConfig p, Dictionary<string, double> baseThreshold, int weights)
  36. {
  37. if (p.Config.OptionRects != null)
  38. {
  39. // 设置客观题填涂阈值
  40. foreach (var op in p.Config.OptionRects)
  41. {
  42. //op.PaintThreshold = baseThreshold[op.Option.ToUpper()] + weights / 100.0;
  43. op.PaintThreshold = 0.01 + weights / 100.0;
  44. if (op.PaintThreshold > 0.9)
  45. {
  46. op.PaintThreshold = 0.9;
  47. }
  48. }
  49. }
  50. }
  51. /// <summary>
  52. /// 识别前预处理
  53. /// </summary>
  54. /// <param name="baseThreshold"></param>
  55. /// <param name="weights"></param>
  56. public void Init(Dictionary<string, double> baseThreshold = null, int weights = 0)
  57. {
  58. //Dictionary<string, int> objectives = new Dictionary<string, int>();
  59. Partitions.ForEach(p =>
  60. {
  61. //if (p.Config.CorrectType == Enumerates.QuestionType.Objective)
  62. //{
  63. // if (Template.ParsedVersion == TestTemplate.TemplateVersion.V2)
  64. // {
  65. // ObjectiveQuestCount += p.Config.RectDivides.Keys.Count;
  66. // }
  67. // else
  68. // {
  69. // p.Config.OptionRects.ForEach(op =>
  70. // {
  71. // if( !objectives.ContainsKey(op.Key) )
  72. // {
  73. // objectives[op.Key] = 0;
  74. // }
  75. // });
  76. // }
  77. //}
  78. SetObjectivePaintThreshold(p, baseThreshold, weights);
  79. });
  80. //ObjectiveQuestCount += objectives.Keys.Count;
  81. }
  82. }
  83. }