use of com.cas.sim.tis.entity.Question in project TeachingInSimulation by ScOrPiOzzy.
the class PreviewQuestionPaper method exportJudgment.
private void exportJudgment(Map<String, Object[][]> datas) {
List<Question> questions = SpringUtil.getBean(QuestionAction.class).findQuestionsByLibraryAndQuestionType(rid, QuestionType.JUDGMENT.getType());
Object[][] data = new Object[questions.size() + 1][3];
for (int i = 0; i < questions.size(); i++) {
Question question = questions.get(i);
data[i + 1][0] = question.getTitle();
data[i + 1][1] = question.getReference();
data[i + 1][2] = question.getAnalysis();
}
datas.put(QuestionType.JUDGMENT.getSheetName(), data);
}
use of com.cas.sim.tis.entity.Question in project TeachingInSimulation by ScOrPiOzzy.
the class QuestionServiceImpl method findQuestionsByLibrary.
@Override
public PageInfo<Question> findQuestionsByLibrary(int pageIndex, int pageSize, int rid) {
Condition condition = new Condition(Question.class);
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("relateId", rid);
PageHelper.startPage(pageIndex, pageSize);
List<Question> result = findByCondition(condition);
PageInfo<Question> page = new PageInfo<>(result);
LOG.info("成功查找到{}条资源,当前页码{},每页{}条资源,共{}页", result.size(), pageIndex, pageSize, page.getPages());
return page;
}
use of com.cas.sim.tis.entity.Question in project TeachingInSimulation by ScOrPiOzzy.
the class TeacherQuestionPaper method loadQuestions.
private void loadQuestions() {
this.paper.getChildren().clear();
boolean mostWrong = false;
Toggle toggle = order.getSelectedToggle();
if (toggle != null) {
mostWrong = Boolean.valueOf((String) order.getSelectedToggle().getUserData());
}
List<Question> questions = SpringUtil.getBean(QuestionAction.class).findQuestionsByPublish(pid, mostWrong);
for (int i = 0; i < questions.size(); i++) {
int index = i + 1;
Question question = questions.get(i);
PreviewQuestionItem item = new PreviewQuestionItem(index, QuestionType.getQuestionType(question.getType()), question, true);
item.setOnMouseClicked(e -> {
selectQuestion(question, item);
});
paper.getChildren().add(item);
if (i == 0) {
selectQuestion(question, item);
}
}
}
use of com.cas.sim.tis.entity.Question in project TeachingInSimulation by ScOrPiOzzy.
the class LibraryImportTest method importExcel.
private void importExcel(File source) {
String name = FileUtil.getFileName(source.getAbsolutePath());
Library library = new Library();
library.setName(name);
library.setNum(0);
library.setTime(100);
library.setType(0);
library.setCreator(1);
LibraryService libraryService = (LibraryService) libraryServiceFactory.getObject();
libraryService.save(library);
List<Library> librarys = libraryService.findAll();
library = librarys.get(librarys.size() - 1);
rid = library.getId();
List<Question> questions = new ArrayList<>();
if (!loadChoice(source, questions) || !loadJudgment(source, questions) || !loadBlank(source, questions) || !loadSubjective(source, questions)) {
return;
}
try {
SpringUtil.getBean(QuestionAction.class).addQuestions(rid, questions);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.cas.sim.tis.entity.Question in project TeachingInSimulation by ScOrPiOzzy.
the class LibraryImportTest method loadJudgment.
private boolean loadJudgment(File source, List<Question> questions) {
Object[][] result = ExcelUtil.readExcelSheet(source.getAbsolutePath(), QuestionType.JUDGMENT.getSheetName(), 4);
for (int i = 2; i < result.length; i++) {
Object descObj = result[i][0];
if (Util.isEmpty(descObj)) {
String reason = MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("question.stem"));
System.out.println(MsgUtil.getMessage("excel.import.error", i + 1, 1, reason));
return false;
}
String title = String.valueOf(descObj).replaceAll("\\(", "(").replaceAll("\\)", ")").trim();
if (title.length() > 250) {
String reason = MsgUtil.getMessage("alert.warning.over.length", MsgUtil.getMessage("question.stem"), 250);
System.out.println(MsgUtil.getMessage("excel.import.error", i + 1, 1, reason));
return false;
}
Object referenceObj = result[i][1];
if (Util.isEmpty(referenceObj)) {
String reason = MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("question.reference"));
System.out.println(MsgUtil.getMessage("excel.import.error", i + 1, 2, reason));
return false;
}
String reference = String.valueOf(referenceObj).trim();
if (reference.length() > 10) {
String reason = MsgUtil.getMessage("alert.warning.over.length", MsgUtil.getMessage("question.reference"), 10);
System.out.println(MsgUtil.getMessage("excel.import.error", i + 1, 2, reason));
return false;
}
Object pointObj = result[i][2];
if (Util.isEmpty(pointObj)) {
String reason = MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("question.point"));
System.out.println(MsgUtil.getMessage("excel.import.error", i + 1, 3, reason));
return false;
}
String point = String.valueOf(pointObj).trim();
if (!Util.isNumeric(point)) {
String reason = MsgUtil.getMessage("alert.warning.not.number", MsgUtil.getMessage("question.point"));
System.out.println(MsgUtil.getMessage("excel.import.error", i + 1, 3, reason));
return false;
}
Object analysisObj = result[i][3];
String analysis = String.valueOf(analysisObj).trim();
if (analysis.length() > 250) {
String reason = MsgUtil.getMessage("alert.warning.over.length", MsgUtil.getMessage("question.analysis"), 250);
System.out.println(MsgUtil.getMessage("excel.import.error", i + 1, 4, reason));
return false;
}
Question question = new Question();
question.setRelateId(rid);
question.setTitle(title);
question.setAnalysis(analysis);
question.setPoint(Float.parseFloat(point));
question.setReference(reference);
question.setType(1);
question.setCreator(1);
questions.add(question);
}
return true;
}
Aggregations