use of com.cas.sim.tis.entity.Question in project TeachingInSimulation by ScOrPiOzzy.
the class PreviewQuestionPaper method exportChoice.
private void exportChoice(Map<String, Object[][]> datas) {
List<Question> questions = SpringUtil.getBean(QuestionAction.class).findQuestionsByLibraryAndQuestionType(rid, QuestionType.CHOICE.getType());
Object[][] data = new Object[questions.size() + 1][4];
for (int i = 0; i < questions.size(); i++) {
Question question = questions.get(i);
data[i + 1][0] = question.getTitle();
data[i + 1][1] = question.getOptions().replaceAll("\\|", "\r\n");
data[i + 1][2] = question.getReference();
data[i + 1][3] = question.getAnalysis();
}
datas.put(QuestionType.CHOICE.getSheetName(), data);
}
use of com.cas.sim.tis.entity.Question in project TeachingInSimulation by ScOrPiOzzy.
the class PreviewQuestionPaper 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"));
AlertUtil.showAlert(AlertType.WARNING, 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);
AlertUtil.showAlert(AlertType.WARNING, 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"));
AlertUtil.showAlert(AlertType.WARNING, 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);
AlertUtil.showAlert(AlertType.WARNING, 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"));
AlertUtil.showAlert(AlertType.WARNING, 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"));
AlertUtil.showAlert(AlertType.WARNING, 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);
AlertUtil.showAlert(AlertType.WARNING, 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(QuestionType.JUDGMENT.getType());
question.setCreator(Session.get(Session.KEY_LOGIN_ID));
questions.add(question);
}
return true;
}
use of com.cas.sim.tis.entity.Question in project TeachingInSimulation by ScOrPiOzzy.
the class PreviewQuestionPaper method exportSubjective.
private void exportSubjective(Map<String, Object[][]> datas) {
List<Question> questions = SpringUtil.getBean(QuestionAction.class).findQuestionsByLibraryAndQuestionType(rid, QuestionType.SUBJECTIVE.getType());
Object[][] data = new Object[questions.size() + 1][2];
for (int i = 0; i < questions.size(); i++) {
Question question = questions.get(i);
data[i + 1][0] = question.getTitle();
data[i + 1][1] = question.getAnalysis();
}
datas.put(QuestionType.SUBJECTIVE.getSheetName(), data);
}
use of com.cas.sim.tis.entity.Question in project TeachingInSimulation by ScOrPiOzzy.
the class PreviewQuestionPaper method loadChoice.
private boolean loadChoice(File source, List<Question> questions) {
Object[][] result = ExcelUtil.readExcelSheet(source.getAbsolutePath(), QuestionType.CHOICE.getSheetName(), 5);
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"));
AlertUtil.showAlert(AlertType.WARNING, 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);
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("excel.import.error", i + 1, 1, reason));
return false;
}
Object optionsObj = result[i][1];
if (Util.isEmpty(optionsObj)) {
String reason = MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("question.option"));
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("excel.import.error", i + 1, 2, reason));
return false;
}
String options = String.valueOf(optionsObj).replace("\r\n", "|").replace("\n", "|").trim();
if (options.length() > 250) {
String reason = MsgUtil.getMessage("alert.warning.over.length", MsgUtil.getMessage("question.option"), 250);
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("excel.import.error", i + 1, 2, reason));
return false;
}
Object referenceObj = result[i][2];
if (Util.isEmpty(referenceObj)) {
String reason = MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("question.reference"));
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("excel.import.error", i + 1, 3, 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);
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("excel.import.error", i + 1, 3, reason));
return false;
}
Object pointObj = result[i][3];
if (Util.isEmpty(pointObj)) {
String reason = MsgUtil.getMessage("alert.warning.cant.null", MsgUtil.getMessage("question.point"));
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("excel.import.error", i + 1, 4, 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"));
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("excel.import.error", i + 1, 4, reason));
return false;
}
Object analysisObj = result[i][4];
String analysis = String.valueOf(analysisObj).trim();
if (analysis.length() > 250) {
String reason = MsgUtil.getMessage("alert.warning.over.length", MsgUtil.getMessage("question.analysis"), 250);
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("excel.import.error", i + 1, 5, reason));
return false;
}
Question question = new Question();
question.setRelateId(rid);
question.setTitle(title);
question.setOptions(options);
question.setAnalysis(analysis);
question.setPoint(Float.parseFloat(point));
question.setReference(reference);
question.setType(QuestionType.CHOICE.getType());
question.setCreator(Session.get(Session.KEY_LOGIN_ID));
questions.add(question);
}
return true;
}
use of com.cas.sim.tis.entity.Question in project TeachingInSimulation by ScOrPiOzzy.
the class PreviewQuestionPaper method loadSubjective.
private boolean loadSubjective(File source, List<Question> questions) {
Object[][] result = ExcelUtil.readExcelSheet(source.getAbsolutePath(), QuestionType.SUBJECTIVE.getSheetName(), 2);
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"));
AlertUtil.showAlert(AlertType.WARNING, 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);
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("excel.import.error", i + 1, 1, reason));
return false;
}
Object analysisObj = result[i][1];
String analysis = String.valueOf(analysisObj).trim();
if (analysis.length() > 250) {
String reason = MsgUtil.getMessage("alert.warning.over.length", MsgUtil.getMessage("question.analysis"), 250);
AlertUtil.showAlert(AlertType.WARNING, MsgUtil.getMessage("excel.import.error", i + 1, 2, reason));
return false;
}
Question question = new Question();
question.setRelateId(rid);
question.setTitle(title);
question.setAnalysis(analysis);
question.setType(QuestionType.SUBJECTIVE.getType());
question.setCreator(Session.get(Session.KEY_LOGIN_ID));
questions.add(question);
}
return true;
}
Aggregations