Search in sources :

Example 1 with LibraryPublish

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

Example 2 with LibraryPublish

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

Example 3 with LibraryPublish

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

Example 4 with LibraryPublish

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);
    }
}
Also used : ArrayList(java.util.ArrayList) HostedConnection(com.jme3.network.HostedConnection) LibraryPublish(com.cas.sim.tis.entity.LibraryPublish)

Example 5 with LibraryPublish

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);
    }
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) LibraryAnswer(com.cas.sim.tis.entity.LibraryAnswer) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) LibraryRecordMapper(com.cas.sim.tis.mapper.LibraryRecordMapper) TransactionStatus(org.springframework.transaction.TransactionStatus) Criteria(tk.mybatis.mapper.entity.Example.Criteria) DataSourceTransactionManager(org.springframework.jdbc.datasource.DataSourceTransactionManager) LibraryPublish(com.cas.sim.tis.entity.LibraryPublish)

Aggregations

LibraryPublish (com.cas.sim.tis.entity.LibraryPublish)8 LibraryPublishAction (com.cas.sim.tis.action.LibraryPublishAction)4 ExamController (com.cas.sim.tis.view.controller.ExamController)2 LibraryAnswer (com.cas.sim.tis.entity.LibraryAnswer)1 LibraryRecordMapper (com.cas.sim.tis.mapper.LibraryRecordMapper)1 HostedConnection (com.jme3.network.HostedConnection)1 ArrayList (java.util.ArrayList)1 FXML (javafx.fxml.FXML)1 DataSourceTransactionManager (org.springframework.jdbc.datasource.DataSourceTransactionManager)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)1 Condition (tk.mybatis.mapper.entity.Condition)1 Criteria (tk.mybatis.mapper.entity.Example.Criteria)1