mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-06 09:26:48 +08:00
Merge branch 'zcwy0912-llf' into 104-master
This commit is contained in:
@@ -166,118 +166,231 @@ public class ExamQuestionApi extends ApiBaseController {
|
|||||||
return badRequest("请上传正确的试题文件");
|
return badRequest("请上传正确的试题文件");
|
||||||
}
|
}
|
||||||
//获取表头
|
//获取表头
|
||||||
Row row = sheetAt.getRow(2);
|
Row row ;
|
||||||
//从第二行开始获取数据
|
//从第二行开始获取数据
|
||||||
List<ExamQuestion> examQuestions1 = new ArrayList<>();
|
List<ExamQuestion> examQuestions1 = new ArrayList<>();
|
||||||
QuestionDto questionDto = new QuestionDto();
|
QuestionDto questionDto = new QuestionDto();
|
||||||
|
if(sheetAt.getRow(1).getCell(0).getStringCellValue().equals("标题(*)")){
|
||||||
|
row = sheetAt.getRow(1);
|
||||||
|
for (int i = 2;i<sheetAt.getPhysicalNumberOfRows();i++) {
|
||||||
|
//获取每一行
|
||||||
|
|
||||||
for (int i=3;i<sheetAt.getPhysicalNumberOfRows();i++) {
|
Row row1 = sheetAt.getRow(i);
|
||||||
//获取每一行
|
if(row1==null || row1.getCell(0)==null){
|
||||||
|
break;
|
||||||
Row row1 = sheetAt.getRow(i);
|
}
|
||||||
if(row1==null || row1.getCell(0)==null){
|
if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){
|
ExamQuestion examQuestion = new ExamQuestion();
|
||||||
break;
|
examQuestion.setTitle(row1.getCell(0).getStringCellValue());
|
||||||
}
|
if(row1.getCell(1).getStringCellValue().equals("单选题")){
|
||||||
ExamQuestion examQuestion = new ExamQuestion();
|
examQuestion.setType(1);
|
||||||
examQuestion.setTitle(row1.getCell(0).getStringCellValue());
|
}
|
||||||
if(row1.getCell(1).getStringCellValue().equals("单选题")){
|
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
||||||
examQuestion.setType(1);
|
examQuestion.setType(2);
|
||||||
}
|
}
|
||||||
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
|
||||||
examQuestion.setType(2);
|
if(row1.getCell(3).getStringCellValue().equals("中")){
|
||||||
}
|
examQuestion.setDifficulty(2f);
|
||||||
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
|
}
|
||||||
if(row1.getCell(3).getStringCellValue().equals("中")){
|
if(row1.getCell(3).getStringCellValue().equals("难")){
|
||||||
examQuestion.setDifficulty(2f);
|
examQuestion.setDifficulty(3f);
|
||||||
}
|
}
|
||||||
if(row1.getCell(3).getStringCellValue().equals("难")){
|
if(row1.getCell(3).getStringCellValue().equals("低")){
|
||||||
examQuestion.setDifficulty(3f);
|
examQuestion.setDifficulty(1f);
|
||||||
}
|
}
|
||||||
if(row1.getCell(3).getStringCellValue().equals("低")){
|
Cell cell = row1.getCell(4);
|
||||||
examQuestion.setDifficulty(1f);
|
cell.setCellType(CellType.STRING);
|
||||||
}
|
|
||||||
Cell cell = row1.getCell(4);
|
|
||||||
cell.setCellType(CellType.STRING);
|
|
||||||
|
|
||||||
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue()));
|
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue()));
|
||||||
|
|
||||||
//单选
|
//单选
|
||||||
if (!cell.getStringCellValue().contains(",")){
|
if (!cell.getStringCellValue().contains(",")){
|
||||||
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
||||||
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||||
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||||
cell1.setCellType(CellType.STRING);
|
cell1.setCellType(CellType.STRING);
|
||||||
examQuestion.setAnalysis(cell1.getStringCellValue());
|
examQuestion.setAnalysis(cell1.getStringCellValue());
|
||||||
|
|
||||||
List<ExamOption> examOptions = new ArrayList<>();
|
List<ExamOption> examOptions = new ArrayList<>();
|
||||||
for (int j=7;j<=13;j++) {
|
for (int j=7;j<=13;j++) {
|
||||||
|
|
||||||
if(row1.getCell(j)!=null) {
|
if(row1.getCell(j)!=null) {
|
||||||
ExamOption examOption = new ExamOption();
|
ExamOption examOption = new ExamOption();
|
||||||
// 截取表头
|
// 截取表头
|
||||||
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
|
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
|
||||||
if (row1.getCell(6).getStringCellValue().contains(substring)) {
|
if (row1.getCell(6).getStringCellValue().contains(substring)) {
|
||||||
|
|
||||||
examOption.setIsAnswer(true);
|
examOption.setIsAnswer(true);
|
||||||
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||||
} else {
|
} else {
|
||||||
examOption.setIsAnswer(false);
|
examOption.setIsAnswer(false);
|
||||||
}
|
}
|
||||||
if (examOption.getIsAnswer()) {
|
if (examOption.getIsAnswer()) {
|
||||||
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
examOption.setOptions(row.getCell(j).getStringCellValue());
|
examOption.setOptions(row.getCell(j).getStringCellValue());
|
||||||
|
|
||||||
Cell cell2 = row1.getCell(j);
|
Cell cell2 = row1.getCell(j);
|
||||||
cell2.setCellType(CellType.STRING);
|
cell2.setCellType(CellType.STRING);
|
||||||
examOption.setContent(cell2.getStringCellValue());
|
examOption.setContent(cell2.getStringCellValue());
|
||||||
|
|
||||||
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
|
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
|
||||||
examOptions.add(examOption);
|
examOptions.add(examOption);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
examQuestion.setOptionList(examOptions);
|
examQuestion.setOptionList(examOptions);
|
||||||
examQuestions1.add(examQuestion);
|
examQuestions1.add(examQuestion);
|
||||||
}
|
}
|
||||||
//多选 多选的默认分存的是最大分
|
//多选 多选的默认分存的是最大分
|
||||||
else{
|
else{
|
||||||
String stringCellValue = row1.getCell(4).getStringCellValue();
|
String stringCellValue = row1.getCell(4).getStringCellValue();
|
||||||
String[] strings = stringCellValue.split(",");
|
String[] strings = stringCellValue.split(",");
|
||||||
// String[] strings = new String[stringCellValue.length()];
|
// String[] strings = new String[stringCellValue.length()];
|
||||||
String max=strings[0];
|
String max=strings[0];
|
||||||
for (int j=0;j<strings.length;j++) {
|
for (int j=0;j<strings.length;j++) {
|
||||||
if(Float.valueOf(max)<Float.valueOf(strings[j])){
|
if(Float.valueOf(max)<Float.valueOf(strings[j])){
|
||||||
max=strings[j];
|
max=strings[j];
|
||||||
}
|
|
||||||
}
|
|
||||||
examQuestion.setDefaultScore(Float.valueOf(max));
|
|
||||||
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
|
||||||
cell1.setCellType(CellType.STRING);
|
|
||||||
examQuestion.setAnalysis(cell1.getStringCellValue());
|
|
||||||
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
|
||||||
List<ExamOption> examOptions = new ArrayList<>();
|
|
||||||
//A
|
|
||||||
for (int j=7;j<=13;j++){
|
|
||||||
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
|
|
||||||
ExamOption examOption=new ExamOption();
|
|
||||||
examOption.setOptions(row.getCell(j).getStringCellValue());
|
|
||||||
examOption.setContent(row1.getCell(j).getStringCellValue());
|
|
||||||
examOption.setIsAnswer(true);
|
|
||||||
examOption.setScore(Float.valueOf(strings[j-7]));
|
|
||||||
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
|
|
||||||
examOptions.add(examOption);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
examQuestion.setDefaultScore(Float.valueOf(max));
|
||||||
|
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||||
|
cell1.setCellType(CellType.STRING);
|
||||||
|
examQuestion.setAnalysis(cell1.getStringCellValue());
|
||||||
|
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
||||||
|
List<ExamOption> examOptions = new ArrayList<>();
|
||||||
|
//A
|
||||||
|
for (int j=7;j<=13;j++){
|
||||||
|
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
|
||||||
|
ExamOption examOption=new ExamOption();
|
||||||
|
examOption.setOptions(row.getCell(j).getStringCellValue());
|
||||||
|
examOption.setContent(row1.getCell(j).getStringCellValue());
|
||||||
|
examOption.setIsAnswer(true);
|
||||||
|
examOption.setScore(Float.valueOf(strings[j-7]));
|
||||||
|
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
|
||||||
|
examOptions.add(examOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
examQuestion.setOptionList(examOptions);
|
||||||
|
examQuestions1.add(examQuestion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
row = sheetAt.getRow(2);
|
||||||
|
for (int i = 3;i<sheetAt.getPhysicalNumberOfRows();i++) {
|
||||||
|
//获取每一行
|
||||||
|
|
||||||
|
Row row1 = sheetAt.getRow(i);
|
||||||
|
if(row1==null || row1.getCell(0)==null){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ExamQuestion examQuestion = new ExamQuestion();
|
||||||
|
examQuestion.setTitle(row1.getCell(0).getStringCellValue());
|
||||||
|
if(row1.getCell(1).getStringCellValue().equals("单选题")){
|
||||||
|
examQuestion.setType(1);
|
||||||
|
}
|
||||||
|
if(row1.getCell(1).getStringCellValue().equals("多选题")){
|
||||||
|
examQuestion.setType(2);
|
||||||
|
}
|
||||||
|
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
|
||||||
|
if(row1.getCell(3).getStringCellValue().equals("中")){
|
||||||
|
examQuestion.setDifficulty(2f);
|
||||||
|
}
|
||||||
|
if(row1.getCell(3).getStringCellValue().equals("难")){
|
||||||
|
examQuestion.setDifficulty(3f);
|
||||||
|
}
|
||||||
|
if(row1.getCell(3).getStringCellValue().equals("低")){
|
||||||
|
examQuestion.setDifficulty(1f);
|
||||||
|
}
|
||||||
|
Cell cell = row1.getCell(4);
|
||||||
|
cell.setCellType(CellType.STRING);
|
||||||
|
|
||||||
|
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue()));
|
||||||
|
|
||||||
|
//单选
|
||||||
|
if (!cell.getStringCellValue().contains(",")){
|
||||||
|
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
||||||
|
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||||
|
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||||
|
cell1.setCellType(CellType.STRING);
|
||||||
|
examQuestion.setAnalysis(cell1.getStringCellValue());
|
||||||
|
|
||||||
|
List<ExamOption> examOptions = new ArrayList<>();
|
||||||
|
for (int j=7;j<=13;j++) {
|
||||||
|
|
||||||
|
if(row1.getCell(j)!=null) {
|
||||||
|
ExamOption examOption = new ExamOption();
|
||||||
|
// 截取表头
|
||||||
|
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
|
||||||
|
if (row1.getCell(6).getStringCellValue().contains(substring)) {
|
||||||
|
|
||||||
|
examOption.setIsAnswer(true);
|
||||||
|
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||||
|
} else {
|
||||||
|
examOption.setIsAnswer(false);
|
||||||
|
}
|
||||||
|
if (examOption.getIsAnswer()) {
|
||||||
|
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
examOption.setOptions(row.getCell(j).getStringCellValue());
|
||||||
|
|
||||||
|
Cell cell2 = row1.getCell(j);
|
||||||
|
cell2.setCellType(CellType.STRING);
|
||||||
|
examOption.setContent(cell2.getStringCellValue());
|
||||||
|
|
||||||
|
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
|
||||||
|
examOptions.add(examOption);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
examQuestion.setOptionList(examOptions);
|
||||||
|
examQuestions1.add(examQuestion);
|
||||||
|
}
|
||||||
|
//多选 多选的默认分存的是最大分
|
||||||
|
else{
|
||||||
|
String stringCellValue = row1.getCell(4).getStringCellValue();
|
||||||
|
String[] strings = stringCellValue.split(",");
|
||||||
|
// String[] strings = new String[stringCellValue.length()];
|
||||||
|
String max=strings[0];
|
||||||
|
for (int j=0;j<strings.length;j++) {
|
||||||
|
if(Float.valueOf(max)<Float.valueOf(strings[j])){
|
||||||
|
max=strings[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
examQuestion.setDefaultScore(Float.valueOf(max));
|
||||||
|
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
|
||||||
|
cell1.setCellType(CellType.STRING);
|
||||||
|
examQuestion.setAnalysis(cell1.getStringCellValue());
|
||||||
|
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
|
||||||
|
List<ExamOption> examOptions = new ArrayList<>();
|
||||||
|
//A
|
||||||
|
for (int j=7;j<=13;j++){
|
||||||
|
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
|
||||||
|
ExamOption examOption=new ExamOption();
|
||||||
|
examOption.setOptions(row.getCell(j).getStringCellValue());
|
||||||
|
examOption.setContent(row1.getCell(j).getStringCellValue());
|
||||||
|
examOption.setIsAnswer(true);
|
||||||
|
examOption.setScore(Float.valueOf(strings[j-7]));
|
||||||
|
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
|
||||||
|
examOptions.add(examOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
examQuestion.setOptionList(examOptions);
|
||||||
|
examQuestions1.add(examQuestion);
|
||||||
}
|
}
|
||||||
examQuestion.setOptionList(examOptions);
|
|
||||||
examQuestions1.add(examQuestion);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//判断题 只存在试题表中
|
//判断题 只存在试题表中
|
||||||
|
|||||||
Reference in New Issue
Block a user