Search in sources :

Example 1 with LibraryRecord

use of com.cas.sim.tis.entity.LibraryRecord in project TeachingInSimulation by ScOrPiOzzy.

the class ExamController method finish.

public void finish() {
    // 提交前更新一下当前显示试题的答案
    checkAnswer((ToggleButton) group.getSelectedToggle());
    // 计时暂停
    timeline.stop();
    // 计算得分
    float score = 0;
    for (int i = 0; i < answers.size(); i++) {
        LibraryAnswer libraryAnswer = answers.get(i);
        Question question = libraryAnswer.getQuestion();
        int type = question.getType();
        if (QuestionType.SUBJECTIVE.getType() == type) {
            continue;
        }
        ToggleButton button = (ToggleButton) group.getToggles().get(i);
        button.getStyleClass().remove("undo");
        button.getStyleClass().remove("done");
        score += libraryAnswer.getScore();
        if (AnswerState.ANSWER_STATE_RIGHT.getType() == libraryAnswer.getCorrected()) {
            button.getStyleClass().add("right");
        } else {
            button.getStyleClass().add("wrong");
        }
    }
    this.score.setText(String.valueOf(score));
    int pid = publish.getId();
    LibraryRecord record = new LibraryRecord();
    record.setCost(cost);
    record.setScore(score);
    record.setPublishId(pid);
    record.setCreator(Session.get(Session.KEY_LOGIN_ID));
    List<LibraryAnswer> libraryAnswers = new ArrayList<>(this.answers.values());
    SpringUtil.getBean(LibraryRecordAction.class).addRecord(record, libraryAnswers);
    back.setVisible(true);
    submited = true;
    group.selectToggle(group.getToggles().get(0));
}
Also used : LibraryAnswer(com.cas.sim.tis.entity.LibraryAnswer) ToggleButton(javafx.scene.control.ToggleButton) LibraryRecord(com.cas.sim.tis.entity.LibraryRecord) ArrayList(java.util.ArrayList) Question(com.cas.sim.tis.entity.Question) LibraryRecordAction(com.cas.sim.tis.action.LibraryRecordAction)

Aggregations

LibraryRecordAction (com.cas.sim.tis.action.LibraryRecordAction)1 LibraryAnswer (com.cas.sim.tis.entity.LibraryAnswer)1 LibraryRecord (com.cas.sim.tis.entity.LibraryRecord)1 Question (com.cas.sim.tis.entity.Question)1 ArrayList (java.util.ArrayList)1 ToggleButton (javafx.scene.control.ToggleButton)1