|
@@ -8,7 +8,9 @@ import cn.com.qmth.examcloud.core.oe.admin.api.ExamRecordQuestionsCloudService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.bean.SubjectiveAnswerBean;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.bean.SubjectiveAnswerBean;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.GetSubjectiveAnswerReq;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.request.GetSubjectiveAnswerReq;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.GetSubjectiveAnswerResp;
|
|
import cn.com.qmth.examcloud.core.oe.admin.api.response.GetSubjectiveAnswerResp;
|
|
|
|
+import cn.com.qmth.examcloud.web.config.SystemConfig;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
@@ -37,6 +39,9 @@ public class CloudMarkingController {
|
|
@Autowired
|
|
@Autowired
|
|
ExamRecordQuestionsCloudService examRecordQuestionsCloudService;
|
|
ExamRecordQuestionsCloudService examRecordQuestionsCloudService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ SystemConfig systemConfig;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 生成主观题答案
|
|
* 生成主观题答案
|
|
*/
|
|
*/
|
|
@@ -47,75 +52,20 @@ public class CloudMarkingController {
|
|
}
|
|
}
|
|
|
|
|
|
//答案临时存放目录
|
|
//答案临时存放目录
|
|
- final String tempAnswerDir = "tempAnswer";
|
|
|
|
- //答案临时压缩目录
|
|
|
|
- final String tempAnswerZipDir = "tempAnswerZip";
|
|
|
|
-
|
|
|
|
- /*//清空临时目录中的文件
|
|
|
|
- File t1 = new File(tempAnswerDir);
|
|
|
|
- for (File f : t1.listFiles()) {
|
|
|
|
- FileUtils.deleteQuietly(f);
|
|
|
|
- }
|
|
|
|
- File t2 = new File(tempAnswerZipDir);
|
|
|
|
- for (File f : t2.listFiles()) {
|
|
|
|
- FileUtils.deleteQuietly(f);
|
|
|
|
- }*/
|
|
|
|
|
|
+ final String tempAnswerDir = systemConfig.getTempDataDir() + "/tempAnswer";
|
|
|
|
|
|
Long startId = 0L;
|
|
Long startId = 0L;
|
|
-
|
|
|
|
- /*String json1 = "{\n" +
|
|
|
|
- " \"cost\": 6317,\n" +
|
|
|
|
- " \"nextExamRecordDataId\": 80703,\n" +
|
|
|
|
- " \"subjectiveAnswerList\": [{\n" +
|
|
|
|
- " \"examId\": 198,\n" +
|
|
|
|
- " \"courseCode\": \"6000459\",\n" +
|
|
|
|
- " \"examStudentId\": 1837550,\n" +
|
|
|
|
- " \"examRecordDataId\": 80507,\n" +
|
|
|
|
- " \"mainNumber\": 5,\n" +
|
|
|
|
- " \"questionId\": \"5c45384def8fce45257834d8\",\n" +
|
|
|
|
- " \"order\": 19,\n" +
|
|
|
|
- " \"studentAnswer\": \"https://ecs-test-static.qmth.com.cn/oe-answer-file/1837550/80507/19/1837550_80507_19_1558433562519.jpg|https://ecs-test-static.qmth.com.cn/oe-answer-file/1837550/80507/19/1837550_80507_19_1558433889599.png\",\n" +
|
|
|
|
- " \"answerType\": \"SINGLE_AUDIO\",\n" +
|
|
|
|
- " \"realAnswerType\": \"audio\"\n" +
|
|
|
|
- " }, {\n" +
|
|
|
|
- " \"examId\": 198,\n" +
|
|
|
|
- " \"courseCode\": \"6000459\",\n" +
|
|
|
|
- " \"examStudentId\": 1837550,\n" +
|
|
|
|
- " \"examRecordDataId\": 80507,\n" +
|
|
|
|
- " \"mainNumber\": 5,\n" +
|
|
|
|
- " \"questionId\": \"5c45384def8fce45257834d9\",\n" +
|
|
|
|
- " \"order\": 20,\n" +
|
|
|
|
- " \"studentAnswer\": null,\n" +
|
|
|
|
- " \"answerType\": \"SINGLE_AUDIO\",\n" +
|
|
|
|
- " \"realAnswerType\": \"audio\"\n" +
|
|
|
|
- " }, {\n" +
|
|
|
|
- " \"examId\": 198,\n" +
|
|
|
|
- " \"courseCode\": \"6000459\",\n" +
|
|
|
|
- " \"examStudentId\": 1837550,\n" +
|
|
|
|
- " \"examRecordDataId\": 80507,\n" +
|
|
|
|
- " \"mainNumber\": 6,\n" +
|
|
|
|
- " \"questionId\": \"5c45384def8fce45257834da\",\n" +
|
|
|
|
- " \"order\": 23,\n" +
|
|
|
|
- " \"studentAnswer\": null,\n" +
|
|
|
|
- " \"answerType\": null,\n" +
|
|
|
|
- " \"realAnswerType\": \"text\"\n" +
|
|
|
|
- " }]\n" +
|
|
|
|
- "}";*/
|
|
|
|
-
|
|
|
|
while (true) {
|
|
while (true) {
|
|
GetSubjectiveAnswerReq req = new GetSubjectiveAnswerReq();
|
|
GetSubjectiveAnswerReq req = new GetSubjectiveAnswerReq();
|
|
req.setExamId(examId);
|
|
req.setExamId(examId);
|
|
req.setStartExamRecordId(startId);
|
|
req.setStartExamRecordId(startId);
|
|
|
|
|
|
-
|
|
|
|
GetSubjectiveAnswerResp resp = examRecordQuestionsCloudService.getSubjectiveAnswerList(req);
|
|
GetSubjectiveAnswerResp resp = examRecordQuestionsCloudService.getSubjectiveAnswerList(req);
|
|
-
|
|
|
|
- /*GetSubjectiveAnswerResp resp = JsonUtil.fromJson(json1, GetSubjectiveAnswerResp.class);*/
|
|
|
|
|
|
+// GetSubjectiveAnswerResp resp = JsonUtil.fromJson(testJson(), GetSubjectiveAnswerResp.class);
|
|
if (resp.getNextExamRecordDataId().equals(startId)) {
|
|
if (resp.getNextExamRecordDataId().equals(startId)) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
List<SubjectiveAnswerBean> subjectiveAnswerList = resp.getSubjectiveAnswerList();
|
|
List<SubjectiveAnswerBean> subjectiveAnswerList = resp.getSubjectiveAnswerList();
|
|
|
|
|
|
List<Long> examStudentIdList = subjectiveAnswerList.stream().
|
|
List<Long> examStudentIdList = subjectiveAnswerList.stream().
|
|
@@ -158,7 +108,6 @@ public class CloudMarkingController {
|
|
answerMap.put("body", bodyMap);
|
|
answerMap.put("body", bodyMap);
|
|
|
|
|
|
answerMapList.add(answerMap);
|
|
answerMapList.add(answerMap);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//将考生结果保存至临时文件
|
|
//将考生结果保存至临时文件
|
|
@@ -166,11 +115,10 @@ public class CloudMarkingController {
|
|
String filePath = tempAnswerDir + "/" + examId + "-" + courseCode + "-" + examStudentId + ".json";
|
|
String filePath = tempAnswerDir + "/" + examId + "-" + courseCode + "-" + examStudentId + ".json";
|
|
IOUtil.toFile(json.getBytes(Charset.forName("UTF-8")), filePath);
|
|
IOUtil.toFile(json.getBytes(Charset.forName("UTF-8")), filePath);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
startId = resp.getNextExamRecordDataId();
|
|
startId = resp.getNextExamRecordDataId();
|
|
}
|
|
}
|
|
- String zipPath = tempAnswerZipDir + "/" + examId + "-" + System.currentTimeMillis() + ".zip";
|
|
|
|
|
|
+
|
|
|
|
+ String zipPath = tempAnswerDir + "/" + examId + "-" + System.currentTimeMillis() + ".zip";
|
|
File zipFile = new File(zipPath);
|
|
File zipFile = new File(zipPath);
|
|
ZipUtil.zip(new File(tempAnswerDir), zipFile);
|
|
ZipUtil.zip(new File(tempAnswerDir), zipFile);
|
|
|
|
|
|
@@ -181,6 +129,60 @@ public class CloudMarkingController {
|
|
header("Content-Disposition", "attachment; filename=" + downLoadFileName).
|
|
header("Content-Disposition", "attachment; filename=" + downLoadFileName).
|
|
contentType(MediaType.APPLICATION_OCTET_STREAM).body(bytes);
|
|
contentType(MediaType.APPLICATION_OCTET_STREAM).body(bytes);
|
|
|
|
|
|
|
|
+ clearTempAnswerFile(tempAnswerDir);
|
|
return responseEntity;
|
|
return responseEntity;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 清空临时目录中的文件
|
|
|
|
+ *
|
|
|
|
+ * @param tempAnswerDir
|
|
|
|
+ */
|
|
|
|
+ private void clearTempAnswerFile(String tempAnswerDir) {
|
|
|
|
+ File t1 = new File(tempAnswerDir);
|
|
|
|
+ for (File f : t1.listFiles()) {
|
|
|
|
+ FileUtils.deleteQuietly(f);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String testJson() {
|
|
|
|
+ return "{\n" +
|
|
|
|
+ " \"cost\": 6317,\n" +
|
|
|
|
+ " \"nextExamRecordDataId\": 80703,\n" +
|
|
|
|
+ " \"subjectiveAnswerList\": [{\n" +
|
|
|
|
+ " \"examId\": 198,\n" +
|
|
|
|
+ " \"courseCode\": \"6000459\",\n" +
|
|
|
|
+ " \"examStudentId\": 1837550,\n" +
|
|
|
|
+ " \"examRecordDataId\": 80507,\n" +
|
|
|
|
+ " \"mainNumber\": 5,\n" +
|
|
|
|
+ " \"questionId\": \"5c45384def8fce45257834d8\",\n" +
|
|
|
|
+ " \"order\": 19,\n" +
|
|
|
|
+ " \"studentAnswer\": \"https://ecs-test-static.qmth.com.cn/oe-answer-file/1837550/80507/19/1837550_80507_19_1558433562519.jpg|https://ecs-test-static.qmth.com.cn/oe-answer-file/1837550/80507/19/1837550_80507_19_1558433889599.png\",\n" +
|
|
|
|
+ " \"answerType\": \"SINGLE_AUDIO\",\n" +
|
|
|
|
+ " \"realAnswerType\": \"audio\"\n" +
|
|
|
|
+ " }, {\n" +
|
|
|
|
+ " \"examId\": 198,\n" +
|
|
|
|
+ " \"courseCode\": \"6000459\",\n" +
|
|
|
|
+ " \"examStudentId\": 1837550,\n" +
|
|
|
|
+ " \"examRecordDataId\": 80507,\n" +
|
|
|
|
+ " \"mainNumber\": 5,\n" +
|
|
|
|
+ " \"questionId\": \"5c45384def8fce45257834d9\",\n" +
|
|
|
|
+ " \"order\": 20,\n" +
|
|
|
|
+ " \"studentAnswer\": null,\n" +
|
|
|
|
+ " \"answerType\": \"SINGLE_AUDIO\",\n" +
|
|
|
|
+ " \"realAnswerType\": \"audio\"\n" +
|
|
|
|
+ " }, {\n" +
|
|
|
|
+ " \"examId\": 198,\n" +
|
|
|
|
+ " \"courseCode\": \"6000459\",\n" +
|
|
|
|
+ " \"examStudentId\": 1837550,\n" +
|
|
|
|
+ " \"examRecordDataId\": 80507,\n" +
|
|
|
|
+ " \"mainNumber\": 6,\n" +
|
|
|
|
+ " \"questionId\": \"5c45384def8fce45257834da\",\n" +
|
|
|
|
+ " \"order\": 23,\n" +
|
|
|
|
+ " \"studentAnswer\": null,\n" +
|
|
|
|
+ " \"answerType\": null,\n" +
|
|
|
|
+ " \"realAnswerType\": \"text\"\n" +
|
|
|
|
+ " }]\n" +
|
|
|
|
+ "}";
|
|
|
|
+ }
|
|
}
|
|
}
|