|
@@ -7,6 +7,8 @@
|
|
|
|
|
|
package cn.com.qmth.examcloud.app.controller.v1;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.app.model.Result;
|
|
|
+import cn.com.qmth.examcloud.app.service.NetExamService;
|
|
|
import cn.com.qmth.examcloud.app.service.QuestionPoolService;
|
|
|
import cn.com.qmth.examcloud.app.service.UpYunService;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -15,9 +17,11 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
/**
|
|
|
* 离线考试相关接口
|
|
@@ -30,10 +34,50 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
public class OfflineExamController {
|
|
|
private static Logger log = LoggerFactory.getLogger(OfflineExamController.class);
|
|
|
@Autowired
|
|
|
+ private NetExamService netExamService;
|
|
|
+ @Autowired
|
|
|
private QuestionPoolService questionPoolService;
|
|
|
@Autowired
|
|
|
private UpYunService upYunService;
|
|
|
|
|
|
+ @ResponseBody
|
|
|
+ @ApiOperation(value = "获取当前用户参加的离线课程列表接口")
|
|
|
+ @RequestMapping(value = "/course/list", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
+ public Result getOfflineExamCourseList(@RequestHeader String key, @RequestHeader String token) throws Exception {
|
|
|
+ return netExamService.getOfflineExamCourseList(key, token);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ResponseBody
|
|
|
+ @ApiOperation(value = "离线考试的抽取考题接口")
|
|
|
+ @RequestMapping(value = "/record/start", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
+ public Result startOfflineExamRecord(@RequestHeader String key, @RequestHeader String token, @RequestParam String examStudentId) throws Exception {
|
|
|
+ return netExamService.startOfflineExamRecord(key, token, examStudentId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ResponseBody
|
|
|
+ @ApiOperation(value = "上传作答文件接口")
|
|
|
+ @RequestMapping(value = "/paper/answer/upload", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
+ public Result uploadPaperAnswer(@RequestHeader String key, @RequestHeader String token, @RequestParam String examRecordId,
|
|
|
+ @RequestParam(required = false) String md5, HttpServletRequest request) throws Exception {
|
|
|
+ MultipartFile multipart = null;
|
|
|
+ try {
|
|
|
+ multipart = ((MultipartHttpServletRequest) request).getFile("file");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ }
|
|
|
+ if (multipart == null) {
|
|
|
+ return new Result().error("请选择要上传文件!");
|
|
|
+ }
|
|
|
+ return netExamService.uploadPaperAnswer(key, token, examRecordId, multipart.getBytes(), multipart.getOriginalFilename(), md5);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ResponseBody
|
|
|
+ @ApiOperation(value = "获取某份试卷的详细信息接口")
|
|
|
+ @RequestMapping(value = "/paper/detail", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
+ public Result getPaperDetail(@RequestHeader String key, @RequestHeader String token, @RequestParam String paperId) throws Exception {
|
|
|
+ return questionPoolService.getPaperDetail(key, token, paperId);
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "下载考题接口")
|
|
|
@RequestMapping(value = "/paper/download", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
public String downloadPaper(@RequestParam String paperId, @RequestParam String orgName) throws Exception {
|