Search in sources :

Example 16 with Question

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);
}
Also used : QuestionAction(com.cas.sim.tis.action.QuestionAction) Question(com.cas.sim.tis.entity.Question)

Example 17 with Question

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;
}
Also used : Question(com.cas.sim.tis.entity.Question)

Example 18 with Question

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);
}
Also used : QuestionAction(com.cas.sim.tis.action.QuestionAction) Question(com.cas.sim.tis.entity.Question)

Example 19 with Question

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;
}
Also used : Question(com.cas.sim.tis.entity.Question)

Example 20 with Question

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;
}
Also used : Question(com.cas.sim.tis.entity.Question)

Aggregations

Question (com.cas.sim.tis.entity.Question)20 QuestionAction (com.cas.sim.tis.action.QuestionAction)7 ArrayList (java.util.ArrayList)4 LibraryAnswer (com.cas.sim.tis.entity.LibraryAnswer)3 ToggleButton (javafx.scene.control.ToggleButton)2 LibraryAnswerAction (com.cas.sim.tis.action.LibraryAnswerAction)1 LibraryRecordAction (com.cas.sim.tis.action.LibraryRecordAction)1 Library (com.cas.sim.tis.entity.Library)1 LibraryRecord (com.cas.sim.tis.entity.LibraryRecord)1 LibraryService (com.cas.sim.tis.services.LibraryService)1 PageInfo (com.github.pagehelper.PageInfo)1 File (java.io.File)1 IOException (java.io.IOException)1 KeyFrame (javafx.animation.KeyFrame)1 Timeline (javafx.animation.Timeline)1 ActionEvent (javafx.event.ActionEvent)1 FXML (javafx.fxml.FXML)1 Node (javafx.scene.Node)1 PieChart (javafx.scene.chart.PieChart)1 Data (javafx.scene.chart.PieChart.Data)1