Example usage for org.apache.shiro.util StringUtils toDelimitedString

List of usage examples for org.apache.shiro.util StringUtils toDelimitedString

Introduction

In this page you can find the example usage for org.apache.shiro.util StringUtils toDelimitedString.

Prototype

public static String toDelimitedString(Collection c, String delimiter) 

Source Link

Document

Returns the collection's contents as a string, with each element delimited by the specified delimiter argument.

Usage

From source file:com.school.exam.web.student.StudentController.java

License:Apache License

@RequestMapping(value = "submitpaper", method = RequestMethod.POST)
@Token(remove = true)//w  w w.  j  a v a2 s  .c  om
public String submitPaper(Model model, ServletRequest request) {
    ShiroDbRealm.ShiroUser user = getCurrentUser();
    Map<String, String[]> param = request.getParameterMap();
    Long examId = Long.valueOf(param.get("id")[0]);
    //?????
    Integer isNothas = resultService.hasExamPaperByPersonId(user.id, examId);
    if (isNothas > 0) {
        //model.addAttribute("message", "??,?????!");
        return "redirect:examlist";
    } else {
        TeMakeExamVO examvo = questionService.findExamQuestions(examId);
        examvo = addRemark(examvo, examId);
        List<TeExamResultVO> resultList = Lists.newArrayList();
        Double sumScore = 0.0;
        List<TeExamQuestionVO> eqlist = examvo.getQuestionList();
        for (TeExamQuestionVO vo : eqlist) {
            String[] selectval = param.get(vo.getId().toString());
            //
            TeExamResultVO rvo = new TeExamResultVO();
            rvo.setPersonId(user.id);
            rvo.setPersonName(user.getName());
            rvo.setDepdId(examvo.getId());
            rvo.setExamQuestionId(vo.getId());
            rvo.setQuestionAnswer(vo.getQuestionAnswerId());
            rvo.setState(1);
            if (null != selectval) {
                if (vo.getType().equals(1)) {
                    if (vo.getQuestionAnswerId().equals(selectval[0])) {
                        rvo.setQuestionScore(vo.getQuestionScore());
                    } else {
                        rvo.setQuestionScore(0.0);
                    }
                    rvo.setChooseQuestionId(selectval[0]);
                }
                if (vo.getType().equals(2)) {
                    if (vo.getQuestionAnswerId().contentEquals(StringUtils.toDelimitedString(selectval, ","))) {
                        rvo.setQuestionScore(vo.getQuestionScore());
                    } else {
                        rvo.setQuestionScore(0.0);
                    }
                    rvo.setChooseQuestionId(StringUtils.toDelimitedString(selectval, ","));
                }
            }
            if (null != rvo.getQuestionScore()) {
                BigDecimal bd = BigDecimal.valueOf(rvo.getQuestionScore());
                BigDecimal sum = BigDecimal.valueOf(sumScore).add(bd);
                sumScore = sum.doubleValue();
            }
            resultList.add(rvo);
        }
        //?
        questionService.saveExamResult(resultList);
        TeExamPaperResultVO resultvo = new TeExamPaperResultVO();
        resultvo.setExamId(examId);
        resultvo.setExamName(examvo.getExamName());
        resultvo.setExamRemark(examvo.getExamRemark());
        resultvo.setSumScore(sumScore);
        resultvo.setState(1);
        resultvo.setPersonId(user.id);
        resultvo.setPersonName(user.getName());
        //?
        resultService.saveExamPaperResult(resultvo);

        model.addAttribute("sumScore", sumScore);
        model.addAttribute("examvo", examvo);
        model.addAttribute("resultlist", resultList);
        model.addAttribute("nav", NAV_MAP);
        model.addAttribute("project", examvo.getProject().getProjectName());

        return "student/resultlist";
    }
}