SwapTiXin.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. namespace QuestionSwapDoc.SwapWordModel
  7. {
  8. /// <summary>
  9. /// 题型
  10. /// </summary>
  11. public class SwapTiXin
  12. {
  13. /// <summary>
  14. /// 选项的支持的字母
  15. /// </summary>
  16. public readonly char[] XuanXianZhiMu = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K' };
  17. /// <summary>
  18. /// 判断的支持的字符
  19. /// </summary>
  20. public readonly char[] PanDuanZhiFu = new char[] { '√', '×' };
  21. /// <summary>
  22. /// 编号文本(由方法生成的编号如:一、二、三、)
  23. /// </summary>
  24. public string NumberStr { get; set; } = null;
  25. /// <summary>
  26. /// 题型
  27. /// </summary>
  28. public string TiXinStr { get; set; }
  29. /// <summary>
  30. /// 是否为选择题题型(包括单选,多选)
  31. /// </summary>
  32. public bool IsXuanZhe { get; set; } = false;
  33. /// <summary>
  34. /// 是否为判断题题型
  35. /// </summary>
  36. public bool IsPanDuan { get; set; } = false;
  37. /// <summary>
  38. /// 此题型和题型下面的题在答题卡中的表现形式
  39. /// </summary>
  40. public SwapTiXinDaTiKaType DaTiKaType { get; set; } = SwapTiXinDaTiKaType.自动;
  41. /// <summary>
  42. /// 试题集合
  43. /// </summary>
  44. public List<SwapQue> QueList { get; set; } = new List<SwapQue>();
  45. /// <summary>
  46. /// 得到答题卡(机读卡)的客观题的填涂区域
  47. /// </summary>
  48. /// <param name="isErect">是否竖着排版</param>
  49. /// <returns></returns>
  50. public List<string> GetDaTiKaJiDuKeGuanStr(bool isErect)
  51. {
  52. if (!IsXuanZhe && !IsPanDuan)
  53. return new List<string>();
  54. List<string> strR = new List<string>(QueList.Count);
  55. string jg = isErect ? "\r\n" : " ";
  56. foreach (var item in QueList)
  57. {
  58. var num = item.NumberStr.Substring(0, item.NumberStr.Length - 1);
  59. if (!isErect && num.Length == 1)
  60. num = " " + num;
  61. var nums = new List<string>() { num };
  62. var xztc = item.XuanZheTiCount <= 0 ? 4 : item.XuanZheTiCount;
  63. var xx = IsXuanZhe ? XuanXianZhiMu.Take(xztc) : PanDuanZhiFu;
  64. foreach (var item2 in xx)
  65. {
  66. if (IsPanDuan)
  67. nums.Add($"[{item2}]");
  68. else
  69. nums.Add($"[ {item2} ]");
  70. }
  71. strR.Add(string.Join(jg, nums));
  72. }
  73. return strR;
  74. }
  75. /// <summary>
  76. /// 得到答题卡(人阅卡)的客观题的填写区域
  77. /// </summary>
  78. /// <returns></returns>
  79. public List<string> GetDaTiKaRenYueKeGuanStr()
  80. {
  81. if (!IsXuanZhe && !IsPanDuan)
  82. return new List<string>();
  83. List<string> strR = new List<string>(QueList.Count);
  84. foreach (var item in QueList)
  85. {
  86. var num = item.NumberStr.Substring(0, item.NumberStr.Length - 1);
  87. if (num.Length == 1)
  88. num = " " + num;
  89. strR.Add($"{num}( )");
  90. }
  91. return strR;
  92. }
  93. /// <summary>
  94. /// 得到题型上的分的文本(仅限于下面的所有题分值一样的情况)
  95. /// </summary>
  96. /// <param name="isShow">是否显示此分(为false返回空字符串)</param>
  97. /// <returns></returns>
  98. public string GetFenStr(bool isShow = true)
  99. {
  100. if (!isShow || QueList == null || !QueList.Any() || QueList.Any(o => !o.Fen.HasValue || o.Fen <= 0))
  101. return string.Empty;
  102. var fens = QueList.Select(o => o.Fen).Distinct();
  103. if (fens.Count() > 1)
  104. return string.Empty;
  105. else
  106. {
  107. if (QueList.Count == 1)
  108. return $"(共{fens.FirstOrDefault().Value}分)";
  109. else
  110. return $"(每题{fens.FirstOrDefault().Value}分,共{QueList.Sum(o => o.Fen).Value}分)";
  111. }
  112. }
  113. }
  114. }