use of com.cas.sim.tis.entity.LibraryPublish in project TeachingInSimulation by ScOrPiOzzy.
the class LibraryPublishAction method publishLibraryToClass.
/**
* 教师发布考核
* @param rid 题库编号
* @param cid 班级编号
* @return
*/
public Integer publishLibraryToClass(Integer rid, Integer cid) {
LibraryPublish publish = new LibraryPublish();
publish.setLibraryId(rid);
publish.setClassId(cid);
publish.setCreator(Session.get(Session.KEY_LOGIN_ID));
publish.setType(LibraryPublishType.EXAM.getType());
return getService().publishLibraryToClass(publish);
}
use of com.cas.sim.tis.entity.LibraryPublish in project TeachingInSimulation by ScOrPiOzzy.
the class StudentQuestionPaper method initialize.
/**
* 界面初始化
*/
private void initialize() {
this.title.setTitle(type.getDetailTitle());
LibraryPublish publish = SpringUtil.getBean(LibraryPublishAction.class).findPublishById(pid);
this.libName.setText(publish.getLibrary().getName());
filter.selectedToggleProperty().addListener((b, o, n) -> {
loadQuestions();
});
loadQuestions();
}
use of com.cas.sim.tis.entity.LibraryPublish in project TeachingInSimulation by ScOrPiOzzy.
the class TeacherQuestionPaper method initialize.
/**
* 界面初始化
*/
private void initialize() {
LibraryPublish publish = SpringUtil.getBean(LibraryPublishAction.class).findPublishById(pid);
this.libName.setText(publish.getLibrary().getName());
chart.setOnMouseMoved(e -> {
tip.setTranslateX(e.getX());
tip.setTranslateY(e.getY());
});
order.selectedToggleProperty().addListener((observe, oldVal, newVal) -> {
if (newVal == null) {
order.selectToggle(oldVal);
return;
}
loadQuestions();
});
order.selectToggle(order.getToggles().get(0));
}
use of com.cas.sim.tis.entity.LibraryPublish in project TeachingInSimulation by ScOrPiOzzy.
the class ExamMessageHandler method execute.
@Override
public void execute(HostedConnection source, ExamMessage m) throws Exception {
if (ExamMessage.EXAM_OVER == m.getType()) {
// 获得发布记录对象
LibraryPublish publish = libraryPublishService.findById(m.getPid());
// 更新发布记录状态
publish.setState(true);
libraryPublishService.update(publish);
// 通知当前考试学生考试结束
List<HostedConnection> collection = new ArrayList<>();
for (HostedConnection hostedConnection : serverConfig.getClients()) {
if (publish.getClassId().equals(hostedConnection.getAttribute(Session.KEY_LOGIN_CLASSID.name()))) {
collection.add(hostedConnection);
}
}
serverConfig.getServer().broadcast(Filters.in(collection), m);
}
}
use of com.cas.sim.tis.entity.LibraryPublish in project TeachingInSimulation by ScOrPiOzzy.
the class LibraryRecordServiceImpl method addRecord.
@Override
public void addRecord(LibraryRecord record, List<LibraryAnswer> answers) {
// 1.获取事务控制管理器
DataSourceTransactionManager transactionManager = SpringUtil.getBean(DataSourceTransactionManager.class);
// 2.获取事务定义
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
// 3.设置事务隔离级别,开启新事务
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
// 4.获得事务状态
TransactionStatus status = transactionManager.getTransaction(def);
try {
saveUseGeneratedKeys(record);
int recordId = record.getId();
for (LibraryAnswer answer : answers) {
answer.setRecordId(recordId);
}
answerService.save(answers);
LibraryPublish publish = publishService.findById(record.getPublishId());
// 获得班级总人数
if (publish.getClassId() == null) {
publish.setAverage(MathUtil.round(2, record.getScore()));
} else {
Condition userCon = new Condition(User.class);
Criteria criteria = userCon.createCriteria();
criteria.andEqualTo("classId", publish.getClassId());
criteria.andEqualTo("del", 0);
int total = userService.getTotalBy(userCon);
// 获得已交卷成绩总和
LibraryRecordMapper recordMapper = (LibraryRecordMapper) mapper;
float sum = recordMapper.getRecordScoresSumByPublishId(publish.getId());
publish.setAverage(MathUtil.round(2, sum / total));
}
// 更新平均成绩
publishService.update(publish);
transactionManager.commit(status);
} catch (Exception e) {
e.printStackTrace();
transactionManager.rollback(status);
}
}
Aggregations