Commit 7252a0a3 authored by YangZhaoJun1's avatar YangZhaoJun1

智评分数代码优化

parent 9368ace7
......@@ -225,7 +225,7 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiImplicitParam(name = "slId", value = "开课ID", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "chapterId", value = "章节id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "filePath", value = "文件路径", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "studentId", value = "学生学号", required = true, dataType = "varchar")})
@ApiImplicitParam(name = "studentCode", value = "学生学号", required = true, dataType = "varchar")})
@PreAuthorize("hasRole('ROLE_1003')")
@PostMapping(value = "/complete")
public Result complete(ScoreInfoDTO scoreInfoDTO) {
......@@ -239,110 +239,6 @@ public class BChapterController extends PaginationController<BChapter> {
}
private Callable<Result> timeOutCallBack(){
Callable<Result> callback = (()-> {
log.info("请求超时");
Result result = new Result();
result.setMessage("请求超时");
return result;
});
return callback;
}
@ApiOperation(value="关闭che", notes="根据端口关闭che")
@ApiImplicitParam(name = "port", value = "che启动的端口", required = true, dataType = "varchar")
@PostMapping(value = "/cheStopWithoutAuth" )
public WebAsyncTask<Result> cheStop(String port) throws Exception {
Result result = new Result();
log.info("主线程开始");
Callable<Result> data = (() -> {
log.info("副线程开始");
/*action.cheStop(port);
result.setCode(ResultCode.SUCCESS.code);
result.setMessage(ResultServiceEnums.SUCCESS.getMessage());
result.setData(null);*/
log.info("副线程结束");
return result;
});
WebAsyncTask<Result> webAsyncTask = new WebAsyncTask<>(300000, data);
webAsyncTask.onTimeout(timeOutCallBack());
log.info("主线程结束");
return webAsyncTask;
}
@ApiOperation(value="提交代码", notes="提交代码")
@ApiImplicitParams({@ApiImplicitParam(name = "port", value = "端口", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "slCode", value = "课程编号", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "stuCode", value = "学生学号", required = false, dataType = "varchar")})
@PostMapping(value = "/pushCode")
public Result pushCode(String port,
String slCode,
String stuCode) {
/*try {
action.pushCode(
global.getGIT_LAB_PROJECT_PREFIX() + slCode,
port,
global.getGIT_LAB_STU_PREFIX() + stuCode
);*/
return Result.builder(new PersistModel(1),
ResultServiceEnums.SUCCESS.getMessage(),
MessageConstant.MESSAGE_ALERT_ERROR,
null);
/*} catch (Exception e) {
throw new ServiceException(ResultServiceEnums.PUSH_ERROR);
}*/
}
@ApiOperation(value="检出分支", notes="检出分支")
@ApiImplicitParams({@ApiImplicitParam(name = "port", value = "端口", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "slCode", value = "课程编号", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "stuCode", value = "学生学号", required = false, dataType = "varchar")})
@PostMapping(value = "/checkoutCode")
public Result checkoutCode(String port,
String slCode,
String stuCode) throws IOException, InterruptedException {
/*action.checkoutBranch(
global.getGIT_LAB_PROJECT_PREFIX() + slCode,
port,
global.getGIT_LAB_STU_PREFIX() + stuCode);*/
return Result.builder(new PersistModel(1),
ResultServiceEnums.SUCCESS.getMessage(),
MessageConstant.MESSAGE_ALERT_ERROR,
null);
}
@PostMapping(value = "/testCountDown")
public String testCountDown() throws Exception {
return getPort();
}
@ApiOperation(value="刷新che启动时间", notes="根据端口刷新che启动时间")
@ApiImplicitParam(name = "port", value = "che启动的端口", required = true, dataType = "varchar")
@PostMapping(value = "/refreshChe")
public Result refreshChe(String port) {
/*CountDown countDown = CountDown.portMap.get(port);
if (countDown.getMidTime() > 300)
throw new ServiceException(ResultServiceEnums.TEST_NOT_OVER);
countDown.setMidTime(Integer.parseInt(global.getCHE_START_TIME()));
return Result.builder(new PersistModel(1),ResultServiceEnums.SUCCESS.getMessage(),countDown.getEndTime().getTime());*/
return Result.builder(new PersistModel(1),
ResultServiceEnums.SUCCESS.getMessage(),
MessageConstant.MESSAGE_ALERT_ERROR,
new Date().getTime());
}
private String getPort() throws Exception {
Random random = new Random();
Integer port = 8000 + random.nextInt(1000);
/*while (CountDown.portMap.containsKey(port))
port = 8000 + random.nextInt(1000);*/
return port.toString();
}
@ApiOperation(value="更改章节状态", notes="根据章节ID更改章节状态")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar"),
......
......@@ -271,7 +271,7 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
List<BChapter> queryBchapterStudentById(String chapterId);
@Select("<script>SELECT brc.* from b_r_student_chapter brc\n" +
@Select("<script>SELECT brc.student_id as studentId from b_r_student_chapter brc\n" +
"LEFT JOIN b_student bs ON brc.student_id = bs.business_id\n" +
"where bs.`code` = #{studentCode}\n" +
"AND brc.chapter_id = #{chapterId}</script>")
......
......@@ -11,6 +11,7 @@ public class ScoreInfoDTO extends IdEntity<ScoreInfoDTO> {
Integer score;
String chapterId;
String studentId;
String studentCode;
String isComplete;
String slId;
String filePath;
......
......@@ -206,8 +206,19 @@ public class BChapterServiceImpl implements BChapterService {
BChapter bChapter = bChapterRepository.selectOne(new BChapter(scoreInfoDTO.getChapterId()));
if(bChapter.getAutomatic().equals("1")){//智评
String codeType = global.getCOURSE_CODE_LOCATION();
if(bChapter.getExperimentType().equals("2")||bChapter.getExperimentType().equals("4")){
codeType = global.getCOURSE_PROJECT_LOCATION();
}
String filePath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
+ global.getCOURSE_LOCATION() + File.separator
+ global.getSL_LOCATION() + File.separator
+ scoreInfoDTO.getSlId() + File.separator
+ scoreInfoDTO.getChapterId() + File.separator
+ codeType + File.separator
+ scoreInfoDTO.getStudentId() + File.separator;
//获取智评分数
int score = IntellEvaluation.IntellEvaluation(scoreInfoDTO.getFilePath(),bChapter.getExperimentType());
int score = IntellEvaluation.IntellEvaluation(filePath,scoreInfoDTO.getStudentCode(),bChapter.getExperimentType());
scoreInfoDTO.setScore(score);
}
......
......@@ -25,27 +25,42 @@ import java.io.File;
*/
public class IntellEvaluation {
public static int IntellEvaluation(String filePath, String experimentType) throws Exception{
public static int IntellEvaluation(String filePath, String studentCode, String experimentType) throws Exception{
int score = 0;
String content = "";
File file = new File(filePath);
if(!file.exists()){
throw new ServiceException(ResultServiceEnums.PASSWORD_ERROR);
}
if(experimentType.equals("1")){
//java单文件
File file = new File(filePath+studentCode+".java");
if(!file.exists()){
throw new ServiceException(ResultServiceEnums.PASSWORD_ERROR);
}
content = FileUtils.readFileToString(file);
score = getJavaSingleScore(content);
}else if(experimentType.equals("2")){
//java工程
File file = new File(filePath+studentCode);
score = getJavaProjectScore(file);
}else if(experimentType.equals("3")){
//html单文件
File file = new File(filePath+studentCode+".html");
if(!file.exists()){
throw new ServiceException(ResultServiceEnums.PASSWORD_ERROR);
}
content = FileUtils.readFileToString(file);
score = getHtmlSingleScore(content);
}else if(experimentType.equals("4")){
//html工程
File file = new File(filePath+studentCode);
score = getHtmlProjectScore(file);
}
return score;
}
......@@ -71,6 +86,9 @@ public class IntellEvaluation {
//java工程评分
private static int getJavaProjectScore(File file) throws Exception{
if(!file.exists()){
throw new ServiceException(ResultServiceEnums.PASSWORD_ERROR);
}
File[] dirFiles = file.listFiles();
int score = 0;
int javaFileNum = 0;//java文件个数
......@@ -118,6 +136,9 @@ public class IntellEvaluation {
//html工程评分
private static int getHtmlProjectScore(File file) throws Exception{
if(!file.exists()){
throw new ServiceException(ResultServiceEnums.PASSWORD_ERROR);
}
File[] dirFiles = file.listFiles();
int score = 0;
int htmlFileNum = 0;//java文件个数
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment