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