Search in sources :

Example 11 with Question

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

Example 12 with Question

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;
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PageInfo(com.github.pagehelper.PageInfo) Question(com.cas.sim.tis.entity.Question) Criteria(tk.mybatis.mapper.entity.Example.Criteria)

Example 13 with Question

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

Example 14 with Question

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

Example 15 with Question

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;
}
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