schema_struct.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. #pragma once
  2. #include <vector>
  3. #include <string>
  4. namespace schema{
  5. template<typename T>struct SCHEMA_RECT_FIELD{
  6. T centerx;
  7. T centery;
  8. T width;
  9. T height;
  10. };
  11. struct SCHEMA_ELEMENT_FIELD :SCHEMA_RECT_FIELD<float>{
  12. int nID;
  13. };
  14. struct SCHEMA_LOCATE_POINT :SCHEMA_ELEMENT_FIELD{//定位点
  15. };
  16. struct SCHEMA_LOCATE_AREA :SCHEMA_ELEMENT_FIELD{//区域定位点
  17. };
  18. enum SCHEMA_CROSS_SIGN_FLAG{
  19. //表示向上的边
  20. SCHEMA_CROSS_SIGN_UP = 1,
  21. //表示向下的边
  22. SCHEMA_CROSS_SIGN_DOWN = 2,
  23. //表示向左的边
  24. SCHEMA_CROSS_SIGN_LEFT = 4,
  25. //表示向右的边
  26. SCHEMA_CROSS_SIGN_RIGHT = 8,
  27. };
  28. struct SCHEMA_LOACTE_CROSS :SCHEMA_ELEMENT_FIELD{//交叉点定位
  29. //交叉点的边的标记
  30. int sign;
  31. //交叉点的旋转角度
  32. double angle;
  33. };
  34. enum DIRECTION{
  35. Horizontal,
  36. Vertical,
  37. DIR_UNKNOWN,
  38. };
  39. struct SCHEMA_CODE :SCHEMA_ELEMENT_FIELD{//条码、二维码
  40. DIRECTION bDirection;
  41. };
  42. struct SCHEMA_ITEM :SCHEMA_ELEMENT_FIELD{//填涂项
  43. //填涂项输出字符
  44. char OutChar[64];
  45. int nGroupID;
  46. int nMatrixID;
  47. int keguanti_question_locate_point_index;
  48. };
  49. enum OUT_TYPE_FLAG{
  50. OTF_SINGLE = 1,
  51. OTF_MUTIL = 1 << 1,
  52. OTF_STRICT = 1 << 3,
  53. OTF_NONSTRICT = 1 << 4,
  54. OTF_NONSTRICT_ERROR = 1 << 5,
  55. };
  56. //客观题输出类型
  57. enum OMR_OUT_TYPE{
  58. // 输出一个或*号,若解析中有0个、2个或2个以上涂点被填涂,输出*号
  59. OMR_OUT_TYPE_SINGLE_NONSTRICT_ERROR = OTF_SINGLE | OTF_NONSTRICT_ERROR,
  60. // 输出一个,若解析中有2个或2个以上涂点被填涂,则从中选出一个作为该组结果
  61. OMR_OUT_TYPE_SINGLE_NONSTRICT = OTF_SINGLE | OTF_NONSTRICT,
  62. // 输出一个,若解析中有2个或2个以上涂点被填涂,则认为用户多选,输出多选字符
  63. OMR_OUT_TYPE_SINGLE_STRICT = OTF_SINGLE | OTF_STRICT,
  64. // 输出多选字符
  65. OMR_OUT_TYPE_MUTIL_STRICT = OTF_MUTIL | OTF_STRICT,
  66. };
  67. enum QUESTION_TYPE_FLAG{
  68. QTF_DANXUANTI,
  69. //多选
  70. QTF_DUOXUANTI,
  71. //判断题
  72. QTF_PANDUANTI,
  73. //填空题
  74. QTF_ZHUGUANTI,
  75. QTF_TIANKONGTI,
  76. QTF_BIZUOTI,
  77. QTF_QUESTION_TYPE_MASK = 0xff,
  78. QTF_XUANZUOTI = 1 << 8,
  79. };
  80. enum QuestionType{
  81. //单选
  82. DANXUANTI = QTF_DANXUANTI,
  83. //多选
  84. DUOXUANTI = QTF_DUOXUANTI,
  85. //判断题
  86. PANDUANTI = QTF_PANDUANTI,
  87. //主观题
  88. ZHUGUANTI = QTF_ZHUGUANTI,
  89. //填空题
  90. TIANKONGTI = QTF_TIANKONGTI,
  91. // 必做题
  92. BIZUOTI = QTF_BIZUOTI,
  93. XUANZUO_DANXUANTI = QTF_DANXUANTI | QTF_XUANZUOTI,
  94. //多选
  95. XUANZUO_DUOXUANTI = QTF_DUOXUANTI | QTF_XUANZUOTI,
  96. //判断题
  97. XUANZUO_PANDUANTI = QTF_PANDUANTI | QTF_XUANZUOTI,
  98. //主观题
  99. XUANZUO_ZHUGUANTI = QTF_ZHUGUANTI | QTF_XUANZUOTI,
  100. //填空题
  101. XUANZUO_TIANKONGTI = QTF_TIANKONGTI | QTF_XUANZUOTI,
  102. };
  103. struct SCHEMA_QUESTION{
  104. int nID;
  105. char question_code[128];
  106. char question_code_new[128];
  107. float newqt;
  108. std::string tigan;
  109. std::string answers;
  110. std::string answerA;
  111. std::string answerB;
  112. std::string jiexi;
  113. std::string zhishidian;
  114. std::string xiaowen;
  115. std::string maxQuestionNO;
  116. int xiaofennum;
  117. char courseCode[10];
  118. float score;
  119. float halfScore;
  120. bool doubleEvl;
  121. float holdValue;
  122. QuestionType questionType;
  123. int nMarkUnit;
  124. char openOption[12];
  125. int qtLevelOne;
  126. int qtLevelTwo;
  127. int qtPostLevelOne;
  128. int qtPostLevelTwo;
  129. int showMarkTypeIndex;
  130. int postMarkTypeID;
  131. int showSubjectTypeIndex;
  132. int postSubjectTypeID;
  133. int groupid;
  134. };
  135. struct SCHEMA_GROUP :SCHEMA_ELEMENT_FIELD{//填涂组
  136. //本组涂点涂点数量
  137. int itemCount;
  138. int nMatrixID;
  139. //OMR 输出类型
  140. OMR_OUT_TYPE omr_out_type;
  141. };
  142. struct SCHEMA_CLIP :SCHEMA_ELEMENT_FIELD{//切割区域
  143. //裁切区域名称(当isfirst为真时有效)
  144. char area_name[128];
  145. int markUnit;
  146. //该区域对应的切块的第几块(从1开始)
  147. bool issplit;
  148. int markUnitPart;
  149. QuestionType question_type;
  150. int question_ids[50];
  151. int question_count;
  152. char area_name_by_questionNo[128];
  153. char area_name_by_questionNoNew[128];
  154. int xuanzutiArea;//是否为选做题作答区域 0--不是 1--是
  155. };
  156. struct KEGUANTI_LOCATEPOINT_INDEX{
  157. int indexs[4];
  158. int &operator[](int index){ return indexs[index]; }
  159. };
  160. struct SCHEMA_MATRIX :SCHEMA_ELEMENT_FIELD{
  161. int nRows;
  162. int nCols;
  163. float optionWidth;
  164. float optionHeight;
  165. DIRECTION direction;
  166. char outputchars[256];
  167. char outputcharsnew[256];
  168. };
  169. struct SCHEMA_MATRIX_KEGUANTI :SCHEMA_MATRIX{
  170. int question_ids[50];
  171. int question_count;
  172. int group_size[50];
  173. int group_count;
  174. QuestionType question_type;
  175. };
  176. struct SCHEMA_MATRIX_TIANTUKAOHAO :SCHEMA_MATRIX{
  177. };
  178. struct SCHEMA_MATRIX_QUEKAOBIAOJI :SCHEMA_MATRIX{
  179. };
  180. struct SCHEMA_MATRIX_ABJUANBIAOJI :SCHEMA_MATRIX{
  181. };
  182. struct SCHEMA_MATRIX_XUANZUOTI :SCHEMA_MATRIX{
  183. int xuantishu;
  184. int err_handler_type;
  185. };
  186. template <typename T> struct ARRAY{
  187. int offset;
  188. int count;
  189. };
  190. struct SCHEMA_PAGE{
  191. int nID;
  192. double angle;
  193. int index;
  194. int width;
  195. int height;
  196. std::vector<SCHEMA_LOCATE_POINT> locatePoints;
  197. //客观题题目定位点的索引
  198. std::vector<SCHEMA_MATRIX_KEGUANTI> keguantiMatrix;
  199. std::vector<SCHEMA_MATRIX_TIANTUKAOHAO> tiantukaohao;
  200. std::vector<SCHEMA_MATRIX_QUEKAOBIAOJI> quekaobiaoji;
  201. std::vector<SCHEMA_MATRIX_ABJUANBIAOJI> abjuanbjiaoji;
  202. std::vector<SCHEMA_MATRIX_XUANZUOTI> xuanzuoti;
  203. std::vector<SCHEMA_MATRIX> matrixs;
  204. std::vector<SCHEMA_MATRIX> matrixsTianTuKaoHao;
  205. std::vector<SCHEMA_MATRIX> matrixsKeGuanTi;
  206. std::vector<SCHEMA_MATRIX> matrixsXuanZuoTi;
  207. std::vector<SCHEMA_LOACTE_CROSS> locateCrosses;
  208. std::vector<SCHEMA_LOCATE_AREA> locateAreas;
  209. std::vector<SCHEMA_CODE> codes;
  210. std::vector<SCHEMA_CLIP> clips;
  211. std::vector<SCHEMA_CLIP> clips2;
  212. };
  213. struct SCHEMA_VERSION{
  214. unsigned short majorNum;
  215. unsigned short minorNum;
  216. char company[256];
  217. SCHEMA_VERSION(){ majorNum = 0; minorNum = 0; company[0] = 0; }
  218. SCHEMA_VERSION(unsigned short majorNum, unsigned short minorNum, const char * company){
  219. this->majorNum = majorNum;
  220. this->minorNum = minorNum;
  221. strcpy_s(this->company, company);
  222. }
  223. bool operator==(const SCHEMA_VERSION & version1){
  224. return version1.majorNum == majorNum&&version1.minorNum == minorNum;
  225. }
  226. bool operator!=(const SCHEMA_VERSION & version1){
  227. return version1.majorNum != majorNum || version1.minorNum != minorNum;
  228. }
  229. };
  230. #define SCHEMA_MAJOR_NUM 0
  231. #define SCHEMA_MINOR_NUM 11
  232. #define SCHEMA_COMPANY "知心慧学"
  233. #define CURRENT_SCHEMA_VERSTION SCHEMA_VERSION(SCHEMA_MAJOR_NUM,SCHEMA_MINOR_NUM,SCHEMA_COMPANY)
  234. enum{
  235. SCH_LOAD_SUCCESS,
  236. //格式错误
  237. SCH_LOAD_ERR_MISSINGFORMAT,
  238. //版本不正确
  239. SCH_LOAD_ERR_VERSIONCHANGE,
  240. //状态不正确
  241. SCH_LOAD_ERR_ZHUANGTAIBUZHENGQUE,
  242. };
  243. struct SCHEMA{
  244. int nNextObjID;
  245. std::vector<SCHEMA_QUESTION> questions;
  246. std::vector<SCHEMA_PAGE> pages;
  247. int state;
  248. float totalScore;
  249. DIRECTION lastKeGuanTiDirection;
  250. std::string course_code;
  251. std::string lastQuestionCourseCode;
  252. //std::string strTiMuTotal;
  253. SCHEMA(){
  254. lastKeGuanTiDirection = DIR_UNKNOWN;
  255. state = 0;
  256. totalScore = 0;
  257. nNextObjID = 10000000;
  258. }
  259. int NextObjID(){ return nNextObjID++; }
  260. };
  261. }