Exemplo n.º 1
0
  @RequestMapping("/assistAnswer/{examinationId}")
  public ModelAndView assistAnswer(
      @PathVariable String examinationId, HttpServletRequest request, ModelMap modelMap)
      throws Exception {
    String openid = wxQAManager.getOpenid(request);
    //        System.out.println("assist---openid:" + openid + "   unionid:" +
    // request.getParameter("unionid"));

    // 1.找到所属用户
    Consumer consumer = wxQAManager.findConsumerByOpenid(openid);

    // 2.待继续答的题
    Examination examination =
        (Examination) baseManager.getObject(Examination.class.getName(), examinationId);

    // 3.判断是否已经答题
    ParticipationRecord participationRecord =
        wxQAManager.checkIfParticipated(consumer, examination);

    // 4.答案随机排个序
    List randomAnswerList = wxQAManager.randomSortAnswer(examination);
    modelMap.put("randomAnswerList", randomAnswerList);

    modelMap.put("consumer", consumer);
    modelMap.put("examination", examination);
    modelMap.put("openid", openid);
    System.out.println(
        new Date()
            + "\nopenid:"
            + openid
            + "--assistAnswer--examination:"
            + examination.getId()
            + "--participation:"
            + (participationRecord == null ? "null" : participationRecord.getId())
            + "--consumer:"
            + consumer.getId());

    if (participationRecord == null) {
      if (Examination.examFinished.equals(examination.getStatus())
          || Examination.examRewarded.equals(examination.getStatus())) {
        return new ModelAndView("/question/examinationHelpResult", modelMap);
      } else {
        return new ModelAndView("/question/examinationHelp", modelMap);
      }
    } else {
      modelMap.put("participationRecord", participationRecord);
      if (WxQAConst.recordCreatorType.equals(participationRecord.getRecordType())) {
        return new ModelAndView("/question/examinationResult", modelMap);
      } else {
        return new ModelAndView("/question/examinationHelpResult", modelMap);
      }
    }
  }
Exemplo n.º 2
0
  @RequestMapping("/commitHelpAnswer/{examinationId}/{answerList}/{consumerId}")
  public ModelAndView commitHelpAnswer(
      @PathVariable String examinationId,
      @PathVariable String answerList,
      @PathVariable String consumerId,
      HttpServletRequest request,
      ModelMap modelMap)
      throws Exception {
    Examination examination =
        (Examination) baseManager.getObject(Examination.class.getName(), examinationId);

    modelMap.put("answerList", answerList);
    Consumer consumer = (Consumer) baseManager.getObject(Consumer.class.getName(), consumerId);
    modelMap.put("consumer", consumer);

    ParticipationRecord participationRecord =
        wxQAManager.checkIfParticipated(consumer, examination);
    modelMap.put("participationRecord", participationRecord);
    if (!Examination.examFinished.equals(examination.getStatus())
        && !Examination.examRewarded.equals(examination.getStatus())
        && participationRecord == null) {
      String openid = wxQAManager.getOpenid(request);
      modelMap.put("openid", openid);
      List<ExaminationQuestion> eqList = wxQAManager.saveHelpAnswer(examination, modelMap);
      modelMap.put("eqList", eqList);
      // 标记此人已协助答题,再次刷新时会显示另一套提示信息,如“不好意思,您来晚了,已有好友帮助完成!”
      modelMap.put("assistance", "assisted");
    }
    modelMap.put("examination", examination);
    System.out.println(
        new Date()
            + "\nopenid:"
            + wxQAManager.getOpenid(request)
            + "--commitHelpAnswer--examination:"
            + examination.getId()
            + "--participation:"
            + (participationRecord == null ? "null" : participationRecord.getId())
            + "--consumer:"
            + consumer.getId());

    return new ModelAndView("/question/examinationHelpResult", modelMap);
  }