Search in sources :

Example 1 with PreparationQuiz

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

the class PreparationDetail method addQuiz.

private void addQuiz(Integer id, int type) {
    PreparationQuiz quiz = new PreparationQuiz();
    quiz.setRelationId(id);
    quiz.setPreparationId(preparation.getId());
    quiz.setType(type);
    try {
        SpringUtil.getBean(PreparationQuizAction.class).addQuiz(quiz);
        loadQuizs();
        AlertUtil.showAlert(AlertType.INFORMATION, MsgUtil.getMessage("alert.information.data.add.success"));
    } catch (Exception e) {
        e.printStackTrace();
        AlertUtil.showAlert(AlertType.ERROR, e.getMessage());
    }
}
Also used : PreparationQuizAction(com.cas.sim.tis.action.PreparationQuizAction) PreparationQuiz(com.cas.sim.tis.entity.PreparationQuiz) IOException(java.io.IOException)

Example 2 with PreparationQuiz

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

the class PreparationDetail method createQuizTable.

private void createQuizTable() {
    // 数据库唯一表示
    Column<Integer> id = new Column<>();
    id.setPrimary(true);
    id.setVisible(false);
    id.setKey("id");
    // 资源图标
    Column<Integer> icon = new Column<>();
    icon.setAlignment(Pos.CENTER_RIGHT);
    icon.setKey("icon");
    icon.setText("");
    icon.setMaxWidth(25);
    Function<Integer, SVGGlyph> converter = new Function<Integer, SVGGlyph>() {

        @Override
        public SVGGlyph apply(Integer type) {
            if (type == null) {
                return null;
            }
            ResourceType resourceType = ResourceType.getResourceType(type);
            return new SVGGlyph(resourceType.getIcon(), resourceType.getColor(), 22);
        }
    };
    icon.setCellFactory(SVGIconCell.forTableColumn(converter));
    // 资源名称
    Column<String> name = new Column<>();
    name.setAlignment(Pos.CENTER_LEFT);
    name.setKey("name");
    name.setText(MsgUtil.getMessage("resource.name"));
    name.setMaxWidth(250);
    quizs.getColumns().addAll(id, icon, name);
    // 查看按钮
    Column<String> view = new Column<String>();
    view.setCellFactory(BtnCell.forTableColumn(MsgUtil.getMessage("button.view"), Priority.ALWAYS, "blue-btn", rid -> {
        PreparationQuiz preparationQuiz = SpringUtil.getBean(PreparationQuizAction.class).findQuizById((Integer) rid);
        int type = preparationQuiz.getType();
        if (PreparationQuizType.LIBRARY.getType() == type) {
            openLibrary(preparationQuiz.getRelationId());
        } else if (PreparationQuizType.BROKEN_CASE.getType() == type) {
            openBrokenCase(preparationQuiz.getRelationId());
        } else if (PreparationQuizType.FREE.getType() == type) {
            openFreeMode();
        }
    }));
    view.setAlignment(Pos.CENTER_RIGHT);
    quizs.getColumns().add(view);
    if (RoleConst.TEACHER == Session.get(Session.KEY_LOGIN_ROLE, -1)) {
        // 删除按钮
        Column<String> delete = new Column<String>();
        delete.setCellFactory(BtnCell.forTableColumn(MsgUtil.getMessage("button.delete"), "blue-btn", rid -> {
            AlertUtil.showConfirm(MsgUtil.getMessage("alert.confirmation.data.delete"), response -> {
                if (response == ButtonType.YES) {
                    SpringUtil.getBean(PreparationResourceAction.class).detele((Integer) rid);
                    loadResources();
                }
            });
        }));
        delete.setAlignment(Pos.CENTER_RIGHT);
        delete.setMaxWidth(58);
        quizs.getColumns().add(delete);
    }
}
Also used : Pos(javafx.geometry.Pos) Title(com.cas.sim.tis.view.control.imp.Title) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) PreparationInfo(com.cas.sim.tis.vo.PreparationInfo) PreparationResource(com.cas.sim.tis.entity.PreparationResource) TypicalCase(com.cas.sim.tis.entity.TypicalCase) PreviewQuestionPaper(com.cas.sim.tis.view.control.imp.question.PreviewQuestionPaper) VBox(javafx.scene.layout.VBox) SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) ResourceViewer(com.cas.sim.tis.view.control.imp.ResourceViewer) AlertType(javafx.scene.control.Alert.AlertType) ElecCompAction(com.cas.sim.tis.action.ElecCompAction) ElecComp(com.cas.sim.tis.entity.ElecComp) Map(java.util.Map) HBox(javafx.scene.layout.HBox) RoleConst(com.cas.sim.tis.consts.RoleConst) IContent(com.cas.sim.tis.view.control.IContent) Recongnize3D(com.cas.sim.tis.view.control.imp.jme.Recongnize3D) Table(com.cas.sim.tis.view.control.imp.table.Table) Preparation(com.cas.sim.tis.entity.Preparation) PageController(com.cas.sim.tis.view.controller.PageController) Resource(com.cas.sim.tis.entity.Resource) TypicalCaseAction(com.cas.sim.tis.action.TypicalCaseAction) PreparationQuizType(com.cas.sim.tis.consts.PreparationQuizType) PreparationResourceType(com.cas.sim.tis.consts.PreparationResourceType) Session(com.cas.sim.tis.consts.Session) FXML(javafx.fxml.FXML) Priority(javafx.scene.layout.Priority) List(java.util.List) Region(javafx.scene.layout.Region) FlowPane(javafx.scene.layout.FlowPane) CatalogAction(com.cas.sim.tis.action.CatalogAction) ResourceAction(com.cas.sim.tis.action.ResourceAction) PreparationQuiz(com.cas.sim.tis.entity.PreparationQuiz) ButtonType(javafx.scene.control.ButtonType) TypicalCase3D(com.cas.sim.tis.view.control.imp.jme.TypicalCase3D) Function(java.util.function.Function) BrokenCase(com.cas.sim.tis.entity.BrokenCase) SVGIconCell(com.cas.sim.tis.view.control.imp.table.SVGIconCell) JSONArray(com.alibaba.fastjson.JSONArray) PageLevel(com.cas.sim.tis.view.controller.PageController.PageLevel) ResourceBundle(java.util.ResourceBundle) BtnCell(com.cas.sim.tis.view.control.imp.table.BtnCell) Column(com.cas.sim.tis.view.control.imp.table.Column) FXMLLoader(javafx.fxml.FXMLLoader) SpringUtil(com.cas.sim.tis.util.SpringUtil) PreparationAction(com.cas.sim.tis.action.PreparationAction) MsgUtil(com.cas.sim.tis.util.MsgUtil) Logger(org.slf4j.Logger) User(com.cas.sim.tis.entity.User) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) IOException(java.io.IOException) AlertUtil(com.cas.sim.tis.util.AlertUtil) PreparationResourceAction(com.cas.sim.tis.action.PreparationResourceAction) ResourceType(com.cas.sim.tis.consts.ResourceType) Dialog(com.cas.sim.tis.view.control.imp.dialog.Dialog) BrokenCaseAction(com.cas.sim.tis.action.BrokenCaseAction) Catalog(com.cas.sim.tis.entity.Catalog) PreparationQuizAction(com.cas.sim.tis.action.PreparationQuizAction) UserAction(com.cas.sim.tis.action.UserAction) Function(java.util.function.Function) PreparationQuiz(com.cas.sim.tis.entity.PreparationQuiz) SVGGlyph(com.cas.sim.tis.svg.SVGGlyph) Column(com.cas.sim.tis.view.control.imp.table.Column) PreparationResourceType(com.cas.sim.tis.consts.PreparationResourceType) ResourceType(com.cas.sim.tis.consts.ResourceType)

Aggregations

PreparationQuizAction (com.cas.sim.tis.action.PreparationQuizAction)2 PreparationQuiz (com.cas.sim.tis.entity.PreparationQuiz)2 IOException (java.io.IOException)2 JSONArray (com.alibaba.fastjson.JSONArray)1 BrokenCaseAction (com.cas.sim.tis.action.BrokenCaseAction)1 CatalogAction (com.cas.sim.tis.action.CatalogAction)1 ElecCompAction (com.cas.sim.tis.action.ElecCompAction)1 PreparationAction (com.cas.sim.tis.action.PreparationAction)1 PreparationResourceAction (com.cas.sim.tis.action.PreparationResourceAction)1 ResourceAction (com.cas.sim.tis.action.ResourceAction)1 TypicalCaseAction (com.cas.sim.tis.action.TypicalCaseAction)1 UserAction (com.cas.sim.tis.action.UserAction)1 PreparationQuizType (com.cas.sim.tis.consts.PreparationQuizType)1 PreparationResourceType (com.cas.sim.tis.consts.PreparationResourceType)1 ResourceType (com.cas.sim.tis.consts.ResourceType)1 RoleConst (com.cas.sim.tis.consts.RoleConst)1 Session (com.cas.sim.tis.consts.Session)1 BrokenCase (com.cas.sim.tis.entity.BrokenCase)1 Catalog (com.cas.sim.tis.entity.Catalog)1 ElecComp (com.cas.sim.tis.entity.ElecComp)1