Commit cde00be2 authored by YangZhaoJun1's avatar YangZhaoJun1

解决bug;教师查看学生代码

parent de837402
......@@ -418,4 +418,37 @@ public class BChapterController extends PaginationController<BChapter> {
MessageConstant.MESSAGE_ALERT_ERROR,
bChapterService.queryMdFileByChapterId(businessId));
}
@ApiOperation(value="查询学生章节列表", notes="根据学生id查询学生章节列表")
@ApiImplicitParams({@ApiImplicitParam(name = "slId", value = "开课id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "lessonOrSl", value = "课程或开课;0:开课 1:课程", required = true, dataType = "varchar")})
@GetMapping(value = "/queryBChaptersByStudent")
public Result queryBChaptersByStudent(BChapter param) {
Map<String, Object> map = new HashedMap();
String userId = UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID);
param.setUserId(userId);
map.put("RoleFlag", RoleFlagEnum.STUDENT.getFlag());
map.put("scoreList", bChapterService.queryScoreListBySlIdAndStuId(param.getSlId(), userId));
map.put("chapterList", bChapterService.queryBChaptersByStudent(param));
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
map);
}
@ApiOperation(value="打分", notes="根据章节ID和学号进行打分")
@ApiImplicitParams({@ApiImplicitParam(name = "chapterId", value = "章节ID", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "slId", value = "开课id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "studentCode", value = "学号", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "score", value = "分数", required = true, dataType = "varchar"),})
@PreAuthorize("hasRole('ROLE_1002')")
@PostMapping(value = "/Mark")
public Result Mark(String chapterId,String slId,String studentCode,String score) {
return Result.builder(new PersistModel(bChapterService.Mark(chapterId,slId,studentCode,score)),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
studentCode);
}
}
......@@ -96,7 +96,8 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
*/
@Select("<script>SELECT\n" +
"\tt2.chapter_id as chapterId,\n" +
"\tt2.score\n" +
"\tt2.score,\n" +
"t2.is_complete as complete " +
"FROM\n" +
"\tb_chapter t1\n" +
"LEFT JOIN b_r_student_chapter t2 ON t1.business_id = t2.chapter_id\n" +
......@@ -250,5 +251,44 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
"from b_chapter where business_id = #{businessId} " +
" and del_flag = 0 and flag = 1 ")
String querySortByPidAndId(@Param("pid") String pid, @Param("businessId") String businessId);
@Select("<script>select *,#{userId} AS stuId from b_chapter " +
"where del_flag = 0 and flag = 1 and pid = -1 " +
"<if test=\"slId!=null and slId != ''\">\n" +
" and sl_id = #{slId}\n" +
"</if>" +
"and lesson_or_sl = #{lessonOrSl} " +
"order by sort asc</script>")
@ResultMap(value = "SupperStudentChildListResultMap" )
List<BChapter> queryBChaptersByStudent(BChapter param);
@Select("<script>select bc.*,su.business_id as userId,su.`name` as studentName,su.login_name as stuId from b_chapter bc \n" +
"LEFT JOIN b_r_student_chapter bsc on bc.business_id = bsc.chapter_id\n" +
"LEFT JOIN b_student bs on bsc.student_id = bs.business_id\n" +
"LEFT JOIN s_user su on su.login_name = bs.`code` \n" +
"where bc.business_id = #{chapterId}</script>")
@ResultMap(value = "BaseResultMap" )
List<BChapter> queryBchapterStudentById(String chapterId);
@Select("<script>SELECT brc.* 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>")
ScoreInfoDTO queryScoreByChapterId(@Param("chapterId") String chapterId, @Param("studentCode") String studentCode);
@Update("<script>update b_r_student_chapter " +
"set score = #{score} " +
"where student_id = #{studentId} " +
"and chapter_id = #{chapterId}</script>")
int remark(@Param("chapterId") String chapterId, @Param("studentId") String studentId, @Param("score") String score);
@Insert("<script>insert into b_r_student_chapter(" +
"business_id,student_id,chapter_id,is_complete,sl_id,score) " +
"values (" +
"#{businessId},#{studentId},#{chapterId},'1',#{slId},#{score})</script>")
int insertStudentScore(String businessId, String chapterId, String slId, String studentId, String score);
}
......@@ -9,4 +9,5 @@ import lombok.Data;
public class StuScoreDTO {
private String chapterId;
private String score;
private String complete;
}
......@@ -95,6 +95,18 @@ public class BChapter extends IdEntity<BChapter> {
@Transient
private String sPid;
/*学生的用户ID,查询实验是否完成时用*/
@Transient
private String userId;
@Transient
private String stuId;
@Transient
private String isComplete;
@Transient
private String studentName;
}
......
......@@ -105,4 +105,8 @@ public interface BChapterService{
int updateAutomatic(String businessId);
String queryMdFileByChapterId(String businessId);
List<BChapter> queryBChaptersByStudent(BChapter param);
int Mark(String chapterId, String slId, String studentCode, String score);
}
......@@ -20,11 +20,13 @@ import org.rcisoft.business.bsl.enums.AuditStatusEnum;
import org.rcisoft.business.bstudent.dao.BStudentRepository;
import org.rcisoft.business.bfile.dao.BFileRepository;
import org.rcisoft.business.bfile.entity.BFile;
import org.rcisoft.business.bstudent.entity.BStudent;
import org.rcisoft.common.component.Global;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.IdGen;
import org.rcisoft.core.util.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -447,4 +449,23 @@ public class BChapterServiceImpl implements BChapterService {
public String queryMdFileByChapterId(String businessId) {
return bChapterRepository.queryMdFileByChapterId(businessId);
}
@Override
public List<BChapter> queryBChaptersByStudent(BChapter param) {
return bChapterRepository.queryBChaptersByStudent(param);
}
@Override
public int Mark(String chapterId, String slId, String studentCode, String score) {
int line;
ScoreInfoDTO scoreInfoDTO = bChapterRepository.queryScoreByChapterId(chapterId,studentCode);
if(scoreInfoDTO!=null){//重新打分
line=bChapterRepository.remark(chapterId,scoreInfoDTO.getStudentId(),score);
}else {//打分
BStudent student = bStudentRepository.selectOne(new BStudent(studentCode));
line=bChapterRepository.insertStudentScore(IdGen.uuid(),chapterId,slId,student.getBusinessId(),score);
}
return line;
}
}
......@@ -142,18 +142,13 @@ public class BCodeController extends PaginationController {
@ApiImplicitParam(name = "newFilePath", value = "新文件名(修改文件名时使用该参数)", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "content", value = "内容(修改文件内容时使用该参数)", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "slId", value = "开课Id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "chapId", value = "章节Id", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "fileType", value = "1新增文件夹,2新增文件,3修改文件名,4删除文件,5修改文件内容", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "codeType", value = "1单文件,2工程", required = false, dataType = "varchar")})
@ApiImplicitParam(name = "chapId", value = "章节Id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "fileType", value = "1新增文件夹,2新增文件,3修改文件名,4删除文件,5修改文件内容", required = true, dataType = "varchar")})
@ApiOperation(value="单文件或工程各种操作", notes="单文件或工程各种操作")
@GetMapping(value = "/createOrUpdateFiles")
public Result createOrUpdateFiles(String filePath, String newFilePath, String content, String slId, String chapId, String fileType, String codeType) throws Exception{
public Result createOrUpdateFiles(String filePath, String newFilePath, String content, String slId, String chapId, String fileType) throws Exception{
String codePath = "";
if(codeType.equals("1")){
codePath = global.getCOURSE_CODE_LOCATION();
}else{
codePath = global.getCOURSE_PROJECT_LOCATION();
}
String serverPath = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
+ global.getCOURSE_LOCATION() + File.separator
+ global.getSL_LOCATION() + File.separator
......@@ -179,4 +174,17 @@ public class BCodeController extends PaginationController {
MessageConstant.MESSAGE_ALERT_ERROR,
"");
}
@ApiImplicitParams({@ApiImplicitParam(name = "slId", value = "开课Id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "chapterId", value = "章节Id", required = true, dataType = "varchar")})
@ApiOperation(value="老师查看所有学生作业", notes="老师查看所有学生作业")
@GetMapping(value = "/queryAllStudentCode")
public Result queryAllStudentCode(String slId, String chapterId){
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bCodeServiceImpl.queryAllStudentCode(slId,chapterId));
}
}
package org.rcisoft.business.bcode.controller;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
* Created by Administrator on 2018/1/16.
*/
public class testJava {
/*public static void main(String args[]) {
String fileName = "test.java";
test(fileName);
}*/
public static void exeCmd() {
BufferedReader br = null;
try {
//Runtime.getRuntime().exec("E:");
Process p = Runtime.getRuntime().exec("java E:/eduServer/test");
//Process p = Runtime.getRuntime().exec("java test");
br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = null;
StringBuilder sb = new StringBuilder();
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
System.out.println(sb.toString());
} catch (Exception e) {
e.printStackTrace();
}
finally
{
if (br != null)
{
try {
br.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
public static void main(String[] args) {
String commandStr = "java www.taobao.com";
//String commandStr = "ipconfig";
testJava.exeCmd();
}
}
......@@ -29,6 +29,8 @@ public class BCodeFile {
private String pId;
private String isFirstFile;
private String studentName;
/**
* 容器属性
*
......@@ -39,4 +41,13 @@ public class BCodeFile {
*/
private Map lxcParam;
public BCodeFile(String fileType, String content, Date lastModify, String name, String id, String pId, String isFirstFile) {
this.fileType = fileType;
this.content = content;
this.lastModify = lastModify;
this.name = name;
this.id = id;
this.pId = pId;
this.isFirstFile = isFirstFile;
}
}
......@@ -32,4 +32,6 @@ public interface BCodeService {
BCodeFile saveOwnExamFiles(String slId, String chapId, String examType, String content, String userInfoProp, String studentCode);
String exportFiles(String slId, String studentId, String type, String slCode);
List<List<BCodeFile>> queryAllStudentCode(String slId, String chapterId);
}
......@@ -118,18 +118,18 @@ public class BCodeServiceImpl implements BCodeService {
File simpleFile = new File(file);
if(!simpleFile.exists()) {
simpleFile.createNewFile();
codeFile = new BCodeFile("0", "", null, simpleFile.getName(),IdGen.uuid(), "","1",null);
codeFile = new BCodeFile("0", "", null, simpleFile.getName(),IdGen.uuid(), "","1");
codeFileList.add(codeFile);
}else{
String content = FileUtils.readFileToString(simpleFile);
///List<String> fileName = new ArrayList<>();
//fileName.add(simpleFile.getName());
codeFile = new BCodeFile("0", content,new Date(simpleFile.lastModified()), simpleFile.getName(), IdGen.uuid(),"1","",null);
codeFile = new BCodeFile("0", content,new Date(simpleFile.lastModified()), simpleFile.getName(), IdGen.uuid(),"1","");
codeFileList.add(codeFile);
}
}catch (Exception e){
log.debug(file + " is not exist");
codeFile = new BCodeFile("0", "", null, "","", "","0",null);
codeFile = new BCodeFile("0", "", null, "","", "","0");
codeFileList.add(codeFile);
}
......@@ -163,13 +163,13 @@ public class BCodeServiceImpl implements BCodeService {
BCodeFile simpleCodeFile = null;
if(!simplePath.exists()) {
simplePath.mkdirs();
simpleCodeFile = new BCodeFile("0", "", null, simplePath.getName(),IdGen.uuid(),"","0",null);
simpleCodeFile = new BCodeFile("0", "", null, simplePath.getName(),IdGen.uuid(),"","0");
codeFile.add(simpleCodeFile);
}else{
boolean isFile = true;
simpleCodeFile = new BCodeFile("0", "", null, simplePath.getName(),IdGen.uuid(),"0","",null);
codeFile.add(simpleCodeFile);
getFileList(simplePath,codeFile,simpleCodeFile,isFile);
simpleCodeFile = new BCodeFile("0", "", null, simplePath.getName(),IdGen.uuid(),"0","");
//codeFile.add(simpleCodeFile);
getFileList(simplePath,codeFile,simpleCodeFile,isFile,"");
}
/*容器是否已启动*/
byte[] results = rcRedisServiceImpl.getBytes(global.getLxcPrefix() + lxc.getUserId());
......@@ -199,7 +199,7 @@ public class BCodeServiceImpl implements BCodeService {
}catch (Exception e){
log.debug(path + " is not exist");
BCodeFile simpleCodeFile = new BCodeFile("0", "", null,"","","0", "",null);
BCodeFile simpleCodeFile = new BCodeFile("0", "", null,"","","0", "");
}
return codeFile;
......@@ -212,7 +212,7 @@ public class BCodeServiceImpl implements BCodeService {
* @param codeFile
* @throws IOException
*/
private void getFileList(File files,List<BCodeFile> codeFile,BCodeFile parentFile,boolean isFile) throws IOException {
private void getFileList(File files,List<BCodeFile> codeFile,BCodeFile parentFile,boolean isFile,String studentName) throws IOException {
BCodeFile bCodeFile = new BCodeFile();
bCodeFile.setContent("");
......@@ -221,6 +221,7 @@ public class BCodeServiceImpl implements BCodeService {
bCodeFile.setName(files.getName());
bCodeFile.setId(IdGen.uuid());
bCodeFile.setPId(parentFile.getId());
bCodeFile.setStudentName(studentName);
codeFile.add(bCodeFile);
if(files.isFile()){
if(isFile){
......@@ -234,7 +235,7 @@ public class BCodeServiceImpl implements BCodeService {
bCodeFile.setFileType("0");
File[] ffs=files.listFiles();
for (File ff : ffs) {
getFileList(ff, codeFile, bCodeFile, isFile);
getFileList(ff, codeFile, bCodeFile, isFile,studentName);
}
}
......@@ -304,11 +305,11 @@ public class BCodeServiceImpl implements BCodeService {
FileUtils.write(simpleFile,content,"UTF-8");
//List<String> fileName = new ArrayList<>();
//fileName.add(simpleFile.getName());
codeFile = new BCodeFile("0", content,new Date(simpleFile.lastModified()),simpleFile.getName(),IdGen.uuid(),"0", "",null);
codeFile = new BCodeFile("0", content,new Date(simpleFile.lastModified()),simpleFile.getName(),IdGen.uuid(),"0", "");
}catch (Exception e){
log.debug(file + "创建失败");
codeFile = new BCodeFile("0", "", null, "","","0","",null);
codeFile = new BCodeFile("0", "", null, "","","0","");
}
return codeFile;
}
......@@ -400,35 +401,7 @@ public class BCodeServiceImpl implements BCodeService {
return sl.getCode()+ "+" + sl.getLessonName() + ".zip";
}
/*private void exportFileToUser(String zipFile, HttpServletResponse response) {
InputStream bis = null;
try {
File file=new File(zipFile);
bis = new FileInputStream(zipFile);
response.reset();
response.setContentType("bin");
response.addHeader("Content-Disposition", "attachment; filename=\"" + file.getName() + "\"");
byte[] b = new byte[100];
int len;
try {
while ((len = bis.read(b)) > 0)
response.getOutputStream().write(b, 0, len);
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}catch (Exception e){
e.printStackTrace();
}finally {
if (bis != null)
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}*/
private String compressFiles(String compressPath) throws IOException {
String zipFile = "";
......@@ -451,4 +424,59 @@ public class BCodeServiceImpl implements BCodeService {
}
return zipFile;
}
@Override
public List<List<BCodeFile>> queryAllStudentCode(String slId, String chapterId){
List<List<BCodeFile>> list = new ArrayList<>();
String codePath = "";
String suffixName = "";
BCodeFile codeFile = null;
List<BCodeFile> students = new ArrayList<>();
List<BChapter> bChapters = bChapterRepository.queryBchapterStudentById(chapterId);
for(BChapter chapter : bChapters) {
if (chapter.getExperimentType().equals("1")) {//java单文件
codePath = global.getCOURSE_CODE_LOCATION();
suffixName = ".java";
} else if (chapter.getExperimentType().equals("2")) {//java工程
codePath = global.getCOURSE_PROJECT_LOCATION();
} else if (chapter.getExperimentType().equals("3")) {//html单文件
suffixName = ".html";
codePath = global.getCOURSE_CODE_LOCATION();
} else {//html工程
codePath = global.getCOURSE_PROJECT_LOCATION();
}
String path = global.getBASE_UPLOAD_SERVER_LOCATION() + File.separator
+ global.getCOURSE_LOCATION() + File.separator
+ global.getSL_LOCATION() + File.separator
+ slId + File.separator
+ chapterId + File.separator
+ codePath + File.separator
+ chapter.getUserId() + File.separator
+ chapter.getStuId()
+ suffixName;
String studentName = chapter.getStuId()+" "+chapter.getStudentName();
try {
File file = new File(path);
if (file.exists()) {
if (file.isFile()) {//单文件的处理
String content = FileUtils.readFileToString(file);
codeFile = new BCodeFile("0", content, new Date(file.lastModified()), file.getName(), IdGen.uuid(), "0", "", studentName,null);
students.add(codeFile);
list.add(students);
}else if(file.isDirectory()){//工程的处理
List<BCodeFile> codeFiles = new ArrayList<>();
BCodeFile simpleCodeFile = null;
boolean isFile = true;
simpleCodeFile = new BCodeFile("0", "", null, file.getName(),IdGen.uuid(),"0","");
getFileList(file,codeFiles,simpleCodeFile,isFile,studentName);
list.add(codeFiles);
}
}
}catch (Exception e){
}
}
return list;
}
}
......@@ -205,6 +205,7 @@ public class BTeacherServiceImpl implements BTeacherService {
bTeacher.setBusinessId(id);
BTeacher teacher = bTeacherRepository.selectOne(bTeacher);
UserUtil.setCurrentMergeOperation(bTeacher);
bTeacher.setDeleted();
sysUserMapper.deleteByCode(teacher.getCode());
int line = bTeacherRepository.logicalDelete(bTeacher);
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
......
......@@ -8,6 +8,7 @@ import org.rcisoft.core.util.IdGen;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.io.Serializable;
/**
......@@ -28,6 +29,7 @@ public abstract class IdEntity<T> extends DataEntity<T> implements Serializable
@Id
protected String businessId; // 编号
@Transient
protected String token;
......
......@@ -13,7 +13,7 @@ server:
druid:
url: jdbc:mysql://127.0.0.1:3306/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false
username: root
password: cy
password: root
initial-size: 1
min-idle: 1
max-active: 20
......@@ -104,7 +104,7 @@ global:
min_password: 6
max_password: 16
path:
base_upload_server_location: /working/resource/eduServer/
base_upload_server_location: E:\\eduServer
course_location: course
lesson_location: lesson
sl_location: sl
......@@ -127,7 +127,7 @@ global:
student_code_location: studentCode
other:
server_url: http://gwf.natapp.cc/eduServer
is_server_linux: 1
is_server_linux: 5
max_code_length: 15
code:
admin: ROLE_1001
......
......@@ -33,4 +33,33 @@
<result column="class_name" property="className"></result>
<result column="chapter_name" property="chapterName"></result>
</resultMap>
<resultMap id="SupperStudentChildListResultMap" type="org.rcisoft.business.bchapter.entity.BChapter" extends="BaseResultMap">
<association column="{studentId=stuId,paId=business_id}" property="childList" select="queryBChaptersByPidAndUserId">
</association>
</resultMap>
<select id="queryBChaptersByPidAndUserId" parameterType="java.util.Map" resultMap="SupperStudentChildListResultMap">
SELECT
bc.*,
#{studentId} AS stuId,
bf.video_url AS videoUrl,
bf.file_url AS fileUrl,
bf.ppt_url AS pptUrl,
bf.pdf_url AS pdfUrl,
IFNULL((select is_complete from b_r_student_chapter brs
LEFT JOIN b_student bs on brs.student_id = bs.business_id
LEFT JOIN s_user su on bs.`code` = su.login_name
WHERE brs.chapter_id = bc.business_id AND su.business_id = #{studentId}),0) as isComplete,
(SELECT count(*) FROM b_r_student_chapter brs WHERE brs.chapter_id = bc.business_id AND brs.score = - 1) AS studentNum
FROM
b_chapter bc
LEFT JOIN b_file bf ON bf.chapter_id = bc.business_id
WHERE
bc.del_flag = 0
AND bc.pid = #{paId}
ORDER BY
bc.sort asc
</select>
</mapper>
\ No newline at end of file
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