kaoshixing.txt 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. 1.api接口说明
  2. 考试星api接口采用jwt规范。Json web token (JWT), 是为了在网络应用环境间传递声明而执行的一种基于JSON的开放标准((RFC 7519)。JWT调用示例代码
  3. 2.api参数配置
  4. appId : 客户唯一标识符,由考试星提供,例如:14343。
  5. appKey : 用于加密jwt,由考试星提供,例如:xf5ha3h67h4Ger34wh35p345h4。
  6. 获取方式:【管理员后台:系统设置->更多设置->开发者信息管理】
  7. 3.api统一接口地址
  8. 地址: https://api.kaoshixing.com/api/company/data/:appId/?jwt=:jwtInfo
  9. **jwtInfo:**jwt_info是用户根据jwt规范,用app_key将过期时间、action_id加密,生成的加密字符串
  10. 4.生成加密jwtInfo(java示例)
  11. (1).安装依赖
  12. <dependency>
  13. <groupId>io.jsonwebtoken</groupId>
  14. <artifactId>jjwt</artifactId>
  15. <version>0.7.0</version>
  16. (2).生成加密字符串
  17. 生成jwtInfo加密字符串
  18. import io.jsonwebtoken.Jwts;
  19. String appKey = “xf5ha3h67h4Ger34wh35p345h4”
  20. String jwtInfo = Jwts.builder()
  21. .claim("exp", System. currentTimeMillis() + 1000*10)
  22. .claim("action_id", "201")
  23. .signWith(SignatureAlgorithm.HS256,app_key.getBytes("UTF-8")).compact();
  24. (3).加密参数解释
  25. appKey:加密的私钥,由考试星提供。
  26. exp:过期时间。
  27. action_id:表示请求的数据类型(注意是下划线)。
  28. 5.action_id参数解释
  29. 不同的action_id代表不同的请求行为,目前开放的请求行为如下:
  30. 请求行为编码 行为解释
  31. 601 考试信息列表
  32. 602 考生分数列表
  33. 603 试卷试题列表
  34. 604 考生答案列表
  35. 605 在线学习内容表
  36. 606 在线学习时长
  37. 609 学员列表
  38. 702 获取考试和考试结果
  39. 6.当前开放的请求接口
  40. (1)考试信息列表接口:
  41. 请求地址:https://api.kaoshixing.com/api/company/data/:appId/?jwt=:jwtInfo
  42. 请求方法:post
  43. 请求参数:
  44. 参数编号 参数名称 参数值示例 参数描述
  45. 1 page 3 页码,每页10个
  46. 2 examStartTime 2021-12-27 00:00:00 String类型,筛选出考试开始时间大于等于examStartTime的考试,非必传项
  47. 3 examEndTime 2021-12-27 00:00:00 String类型,筛选出考试结束时间小于等于examEndTime的考试,非必传项
  48. 4 createTime 2021-12-27 00:00:00 String类型,筛选出考试创建时间大于等于createTime的考试,非必传项
  49. 5 examIds 1179422,1171758 String类型,筛选出考试id为examIds的几场考试,非必传项
  50. 返回结果:
  51. 参数名称 参数描述 类型 备注
  52. examInfold 考试ID String,下同
  53. examName 考试名称
  54. examTotalScore 考试总分
  55. passMark 及格分
  56. examTime 答题时长
  57. examStartTime 考试开始时间
  58. examEndTime 考试结束时间
  59. examineeNums 应考人数
  60. maxScore 最高分
  61. avgScore 平均分
  62. minScore 最低分
  63. testNums 试题数
  64. userExamedCount 已考人数
  65. userCommitCount 已交卷人数
  66. examLink 考试链接
  67. examCreatTime 创建考试时间
  68. examClass 考试分类
  69. createUserId 创建人账号
  70. createUserName 创建人姓名
  71. (2)考生分数列表接口:
  72. 请求地址:https://api.kaoshixing.com/api/company/data/:appId/?jwt=:jwtInfo
  73. 请求方法:post
  74. 请求参数:
  75. 返回结果:
  76. 参数名称 参数描述 参数类型 备注
  77. userId 考生账号 String
  78. userName 考生姓名 String
  79. depName 部门名称 String
  80. position 职位 String
  81. ansTime 答题时长 String
  82. startTime 开始时间 String
  83. commitTime 交卷时间 String
  84. score 成绩 String
  85. rank 排名 String
  86. isPass 是否通过 String
  87. result 考试情况 String,取值枚举:
  88. 及格,不及格,漏考
  89. isForce 是否强制交卷 Integer,取值枚举
  90. 0--否
  91. 2--是(切屏防作弊 )
  92. 3--是(x秒无操作自动交卷 )
  93. 4--是(闯关失败 )
  94. 6--是(管理员强制交卷)
  95. 7--是(人脸识别失败次数超限)
  96. - 未参与学员
  97. note 备注 String
  98. field1 自定义字段1 String
  99. field2 自定义字段2 String
  100. field3 自定义字段3 String
  101. field4 自定义字段4 String
  102. field5 自定义字段5 String
  103. (3)试卷试题列表接口:
  104. 请求地址:https://api.kaoshixing.com/api/company/data/:appId/?jwt=:jwtInfo
  105. 请求方法:post
  106. 请求参数:
  107. 返回结果:
  108. (4)考生答案列表接口:
  109. 请求地址:https://api.kaoshixing.com/api/company/data/:appId/?jwt=:jwtInfo
  110. 请求方法:post
  111. 请求参数:
  112. 参数名称 参数描述 类型 备注
  113. examInfoId 考试id int 119511
  114. 返回结果:
  115. 参数名称 参数描述 类型 备注
  116. userId 账号 String
  117. ansAndScore 考生答案和得分 JsonString
  118. (5)在线学习内容列表接口:
  119. 请求地址:https://api.kaoshixing.com/api/company/data/:appId/?jwt=:jwtInfo
  120. 请求方法:post
  121. 请求参数:
  122. 返回结果:
  123. 参数名称 参数描述 类型 备注
  124. courseID 课程ID string
  125. courseName 课程名称 string
  126. courseCreateTime 课程创建时间 string
  127. courseUpdateTime 课程最后一次修改时间 string
  128. courseTime 学习课程所需最短时间 int 单位秒
  129. courseStuNum 应参与该课程的人数 int
  130. courseClassify 课程分类 string
  131. createUserId 创建人账号 string
  132. createUserName 创建人姓名 string
  133. (6)在线学习时长列表接口:
  134. 请求地址:https://api.kaoshixing.com/api/company/data/:appId/?jwt=:jwtInfo
  135. 请求方法:post
  136. 请求参数:
  137. 返回结果:
  138. 参数名称 参数描述 类型 备注
  139. userId 账号 String
  140. studyTime 学习时长 String
  141. finishStatus 完成进度 String
  142. courseTime 学习课程所需最短时间 int 单位 秒
  143. (7)获取考生可见考试和考试结果整合列表
  144. 请求地址:https://api.kaoshixing.com/api/company/data/:appId/?jwt=:jwtInfo
  145. 请求方法:post
  146. 请求参数:
  147. 参数编号 参数名称 参数值示例 参数描述
  148. 1 user_id 123456 学员账号
  149. 2 page 2 页码,每页500个
  150. 返回结果:
  151. 参数名称 参数描述 类型 备注
  152. examInfoId 考试id int
  153. examStyleName 考试类型 String
  154. examName 考试名称 String
  155. examStartTime 考试开始时间 String
  156. examEndTime 考试结束时间 String
  157. examTimeRestrict 是否限制每题时长 String
  158. examTime 考试时长(分钟) int
  159. examResultsId 考试结果id int
  160. results 分数 double
  161. isPass 是否通过 int
  162. examLink 考试链接 String
  163. inquireLink 查询结果链接 String
  164. practiceMode 是否联系模式 int
  165. status 考试状态 String
  166. examing:答题中、checked:已批改可查看、
  167. checking:批改中不可查看、new:未作答、
  168. notReleased:暂不公布不可查看
  169. (8)获取学员列表
  170. 请求地址:https://api.kaoshixing.com/api/company/data/:appId/?jwt=:jwtInfo
  171. 请求方法:post
  172. 请求参数:
  173. 参数名称 参数值示例 参数描述
  174. page 1 页面id
  175. 返回结果
  176. 参数名称 参数描述 类型 备注
  177. page 页码 int 每页20条
  178. userId 用户账号 string
  179. surname 姓名 string
  180. departmentName 部门,从根目录往下,例如“部门分类/部门” string
  181. userPoint 积分 int
  182. lastLoginTime 最近登录时间 string
  183. isBindWechatDesc 是否绑定微信 string
  184. 1代表已绑定,0代表未绑定
  185. userLableNames 学员标签,标签间以逗号隔开 string 仅在学员标签功能开启时生效,功能关闭时返回null
  186. status 状态 string
  187. 0正常,1禁用,2临时账号
  188. permission 权限 int
  189. 0代表考试星;1代表会否;2代表全部都有;3代表全部没有
  190. creater 创建人 int 创建账号的用户id
  191. createTime 创建时间 string
  192. phone 手机 string 未设置时返回null
  193. email 证件号 string 未设置时返回null
  194. position 职位 string 未设置时返回null
  195. identityCard 证件号 string 未设置时返回null
  196. notice 备注 string 未设置时返回null
  197. field1 字段1 string 未设置时返回null
  198. field2 字段2 string 未设置时返回null
  199. field3 字段3 string 未设置时返回null
  200. field4 字段4 string 未设置时返回null
  201. field5 字段5 string 未设置时返回null
  202. identityImg 证件照url string 未设置时返回null
  203. 1.api接口说明
  204. api接口采用jwt规范。Json web token (JWT), 是为了在网络应用环境间传递声明而执行的一种基于JSON的开放标准((RFC 7519).该token被设计为紧凑且安全的,特别适用于分布式站点的单点登录(SSO)场景。JWT调用示例代码
  205. 2.api参数配置
  206. appId : 客户唯一标识符,由考试星提供,例如:14343。
  207. appKey : 用于加密/解密jwt,由考试星提供,例如:xf5ha3h67h4Ger34wh35p345h4。
  208. 获取方式:【管理员后台:系统设置->更多设置->开发者信息管理】
  209. 3.考试星提供api统一接口地址
  210. 地址: https://api.kaoshixing.com/api/company/data/:appId?jwt=:jwtInfo
  211. 请求方式:post
  212. jwtInfo:jwt_info是根据jwt规范,用appKey将过期时间、action_id加密,生成的加密字符串
  213. 4.客户提供api统一接口地址
  214. 地址(仅作示例):https://www.example.com/api/company/data/:appId?jwt=:jwtInfo
  215. 请求方式:post
  216. jwtInfo:jwt_info是根据jwt规范,用appKey将过期时间、action_id加密,生成的加密字符串
  217. 5.生成加密jwtInfo和解密(java示例)
  218. (1).安装依赖
  219. <dependency>
  220. <groupId>io.jsonwebtoken</groupId>
  221. <artifactId>jjwt</artifactId>
  222. <version>0.7.0</version>
  223. </dependency>
  224. (2).生成加密字符串
  225. import io.jsonwebtoken.Jwts;
  226. String appKey = “xf5ha3h67h4Ger34wh35p345h4”
  227. String jwtInfo = Jwts.builder()
  228. .claim("exp", System. currentTimeMillis() + 1000*10)
  229. .claim("action_id", "201")
  230. .signWith(SignatureAlgorithm.HS256,appKey.getBytes("UTF-8")).compact();
  231. (3).加密参数解释
  232. appKey:加密的私钥,由考试星提供。
  233. exp:过期时间。
  234. action_id:请求行为类型。
  235. (4).解密方法示例
  236. import io.jsonwebtoken.Claims;
  237. import io.jsonwebtoken.ExpiredJwtException;
  238. import io.jsonwebtoken.Jwts;
  239. public Boolean decodeJwt(String jwtInfo, String appKey) {
  240. try {
  241. Claims claims;
  242. claims = Jwts.parser().setSigningKey(appKey.getBytes("UTF-8")).parseClaimsJws(jwtInfo).getBody();
  243. String actionId = null == claims.get("action_id") || "".equals(claims.get("action_id")) ? ""
  244. : claims.get("action_id").toString();
  245. /**
  246. * 处理action_id
  247. */
  248. } catch (ExpiredJwtException e) {
  249. LOGGER.info("decodeJwt解密失败!");
  250. return false;
  251. } catch (Exception e) {
  252. LOGGER.info("decodeJwt解密失败!");
  253. return false;
  254. }
  255. return true;
  256. }
  257. 6.action_id参数解释
  258. action_id调用方请求行为类型10000客户查询考生考试结果信息10001考试星回传考生考试结果信息。
  259. 7.查询考生考试结果信息
  260. action_id = 10000
  261. 请求地址:https://api.kaoshixing.com/api/company/data/:appId?jwt=:jwtInfo
  262. 请求方式:POST
  263. 请求参数:
  264. 参数名称 是否必填 类型 参数描述
  265. userId 是 String 考生唯一标识
  266. examId 否 int 考试id
  267. commitTimeStart 否 String 起始交卷时间
  268. commitTimeEnd 否 String 最晚交卷时间
  269. page 是 int 页数,每页5条数据
  270. 参数示例:
  271. {
  272. "userId":"zhangsan",
  273. "examId":47167,
  274. "commitTimeStart":"2021-06-01 08:00:00",
  275. "commitTimeEnd":"2021-06-30 20:00:00",
  276. "page":1
  277. }
  278. 正常返回:
  279. {
  280. "success":true,
  281. "code":10000,
  282. "desc":"成功",
  283. "englishDesc":"Success",
  284. "bizContent":{
  285. "total":2,
  286. "current":1,
  287. "rowCount":5,
  288. "rows":[
  289. {
  290. "userId":"zhangsan",
  291. "examId":47167,
  292. "examName":"期末考试",
  293. "examStartTime":"2021-06-02 14:18:00",
  294. "examEndTime":"2021-06-30 14:18:00",
  295. "examTime":60,
  296. "startTime":"2021-06-03 11:44:37",
  297. "commitTime":"2021-06-03 11:44:44",
  298. "score":"0.0",
  299. "isPass":0,
  300. "times":2,
  301. "examResultsId":40561249,
  302. "examStyleName":"考试分类",
  303. "examStyleId":20046
  304. },
  305. {
  306. "userId":"zhangsan",
  307. "examId":47167,
  308. "examName":"期末考试",
  309. "examStartTime":"2021-06-02 14:18:00",
  310. "examEndTime":"2021-06-30 14:18:00",
  311. "examTime":60,
  312. "startTime":"2021-06-02 14:19:17",
  313. "commitTime":null,
  314. "score":"0.0",
  315. "isPass":0,
  316. "times":1,
  317. "examResultsId":40561220,
  318. "examStyleName":"考试分类",
  319. "examStyleId":20046
  320. }
  321. ]
  322. }
  323. }
  324. 参数说明:
  325. 参数 类型 参数描述
  326. userId
  327. String 客户内部考生id
  328. examId
  329. int 考试id
  330. examName
  331. String 考试名称
  332. examStartTime
  333. String 考试开始时间
  334. examEndTime
  335. String 考试结束时间
  336. examTime
  337. int 考试时长(分钟)
  338. startTime
  339. String 考生开考时间
  340. commitTime
  341. String 考生交卷时间
  342. score
  343. double 考试分数
  344. isPass
  345. int 是否及格(1及格,0不及格)
  346. times
  347. int 考试次数
  348. examResultsId
  349. int 考试结果id
  350. examStyleName
  351. String 考试分类名称
  352. examStyleId
  353. int 考试分类id
  354. 错误返回:
  355. {
  356. "success":false,
  357. "code":31014,
  358. "desc":"用户不存在",
  359. "englishDesc":"user not existed",
  360. "bizContent":null
  361. }
  362. 8.同步考生的考试结果(客户提供)
  363. action_id = 10001
  364. 时序图:
  365. 请求地址(仅作示例):https://www.example.com/api/company/data/:appId?jwt=:jwtInfo
  366. 请求方式:POST
  367. 请求参数:
  368. 参数编号 参数名称 类型 参数描述
  369. 1 jwt String 包含action_id的加密字符串
  370. 2 params JSONObject 包含考生的考试信息
  371. 参数示例:
  372. {
  373. "jwt":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo1LCJleHAiOjE0OTc5NTMxODguNjg0MTIxLCJhY3Rpb25faWQiOiIyMDEifQ.I3j56t_tVMX1GgH62dy-rIktqFRienFZTJ7VKgc6lPs",
  374. "params":{
  375. "commitTime":"2018-10-30 20:00:00",
  376. "examEndTime":"2018-10-31 18:00:00",
  377. "examId":15960,
  378. "examName":"测试考试",
  379. "examStartTime":"2018-10-30 18:00:00",
  380. "examTime":60,
  381. "isPass":1,
  382. "score":100,
  383. "startTime":"2018-10-30 19:00:00",
  384. "times":1,
  385. "userId":"779821sfsf"
  386. }
  387. }
  388. 参数说明:
  389. 参数 类型 说明
  390. userId String 客户内部考生id
  391. examId int 考试id
  392. examName String 考试名称
  393. examStartTime String 考试开始时间
  394. examEndTime String 考试结束时间
  395. examTime int 考试时长(分钟)
  396. startTime String 考生开考时间
  397. commitTime String 考生交卷时间
  398. score double 考试分数
  399. isPass int 是否及格
  400. times int 考试次数
  401. examResultsId int 考试结果id
  402. examStyleName String 考试分类名
  403. examStyleId int 考试分类id
  404. userName String 考生姓名
  405. field1 String 自定义属性1
  406. field2 String 自定义属性2
  407. field3 String 自定义属性3
  408. field4 String 自定义属性4
  409. field5 String 自定义属性5
  410. identityCard
  411. String 证件号
  412. phone
  413. String 手机号
  414. email String 邮箱
  415. position
  416. String 职位
  417. 返回数据:
  418. {
  419. "success":true,
  420. "code":10000,
  421. "desc":"成功",
  422. "bizContent":null
  423. }