コード例 #1
0
 public void index(MainSessionController mainSessionCtrl, ComponentContext context)
     throws QuizzException {
   try {
     scc = new QuizzSessionController(mainSessionCtrl, context);
     Collection<QuestionContainerHeader> quizzes = scc.getAdminQuizzList();
     for (QuestionContainerHeader questionContainerHeader : quizzes) {
       scc.updateQuizzHeader(questionContainerHeader, questionContainerHeader.getPK().getId());
     }
   } catch (Exception e) {
     throw new QuizzException(
         "QuizzIndexer.index", QuizzException.WARNING, "Quizz.EX_CANNOT_UPDATE_QUIZZ_HEADER", e);
   }
 }
コード例 #2
0
 /**
  * return a list of silverContent according to a list of publicationPK
  *
  * @param ids a list of publicationPK
  * @return a list of publicationDetail
  */
 private List getHeaders(List ids) {
   QuestionContainerHeader containerHeader = null;
   ArrayList headers = new ArrayList();
   try {
     ArrayList questionHeaders =
         (ArrayList) getQuestionBm().getQuestionContainerHeaders((ArrayList) ids);
     for (int i = 0; i < questionHeaders.size(); i++) {
       containerHeader = (QuestionContainerHeader) questionHeaders.get(i);
       containerHeader.setIconUrl("quizzSmall.gif");
       headers.add(containerHeader);
     }
   } catch (RemoteException e) {
     // skip unknown and ill formed id.
   }
   return headers;
 }
コード例 #3
0
  public String getDestination(String objectId, HttpServletRequest req, HttpServletResponse res)
      throws Exception {
    QuestionContainerPK questionContainerPK = new QuestionContainerPK(objectId);
    QuestionContainerHeader quizz =
        getQuestionContainerBm().getQuestionContainerHeader(questionContainerPK);

    if (quizz != null) {
      String componentId = quizz.getInstanceId();

      SilverTrace.info(
          "quizz",
          "GoToQuizz.getDestination",
          "root.MSG_GEN_PARAM_VALUE",
          "quizz = " + quizz.getId() + "componentId = " + componentId);

      String gotoURL = URLManager.getURL(null, componentId) + quizz.getURL();

      return "goto=" + URLEncoder.encode(gotoURL, "UTF-8");
    }
    return null;
  }
コード例 #4
0
  /**
   * Method declaration
   *
   * @param con
   * @param questionContainerHeader
   * @throws SQLException
   * @see
   */
  public static void updateQuestionContainerHeader(
      Connection con, QuestionContainerHeader questionContainerHeader) throws SQLException {
    SilverTrace.info(
        "questionContainer",
        "QuestionContainerDAO.updateQuestionContainerHeader()",
        "root.MSG_GEN_ENTER_METHOD",
        "questionContainerHeader = " + questionContainerHeader);

    String insertStatement =
        "update "
            + questionContainerHeader.getPK().getTableName()
            + " set qcTitle = ?,"
            + " qcDescription = ?,"
            + " qcComment = ?,"
            + " qcBeginDate = ?,"
            + " qcEndDate = ?,"
            + " qcNbVoters = ?,"
            + " qcNbQuestionsPage = ?,"
            + " qcNbMaxParticipations = ?,"
            + " qcNbTriesBeforeSolution = ?,"
            + " qcMaxTime = ?, "
            + " instanceId = ?, "
            + " anonymous = ?"
            + " where qcId = ?";

    PreparedStatement prepStmt = null;

    try {
      prepStmt = con.prepareStatement(insertStatement);
      prepStmt.setString(1, questionContainerHeader.getTitle());
      prepStmt.setString(2, questionContainerHeader.getDescription());
      prepStmt.setString(3, questionContainerHeader.getComment());
      if (questionContainerHeader.getBeginDate() == null) {
        prepStmt.setString(4, nullBeginDate);
      } else {
        prepStmt.setString(4, questionContainerHeader.getBeginDate());
      }
      if (questionContainerHeader.getEndDate() == null) {
        prepStmt.setString(5, nullEndDate);
      } else {
        prepStmt.setString(5, questionContainerHeader.getEndDate());
      }
      prepStmt.setInt(6, questionContainerHeader.getNbVoters());
      prepStmt.setInt(7, questionContainerHeader.getNbQuestionsPerPage());
      prepStmt.setInt(8, questionContainerHeader.getNbMaxParticipations());
      prepStmt.setInt(9, questionContainerHeader.getNbParticipationsBeforeSolution());
      prepStmt.setInt(10, questionContainerHeader.getMaxTime());
      prepStmt.setString(11, questionContainerHeader.getPK().getComponentName());
      if (questionContainerHeader.isAnonymous()) {
        prepStmt.setInt(12, 1);
      } else {
        prepStmt.setInt(12, 0);
      }
      prepStmt.setInt(13, Integer.parseInt(questionContainerHeader.getPK().getId()));
      prepStmt.executeUpdate();
    } finally {
      DBUtil.close(prepStmt);
    }
  }
コード例 #5
0
  /**
   * Method declaration
   *
   * @param con
   * @param questionContainerHeader
   * @return
   * @throws SQLException
   * @see
   */
  public static QuestionContainerPK createQuestionContainerHeader(
      Connection con, QuestionContainerHeader questionContainerHeader) throws SQLException {
    SilverTrace.info(
        "questionContainer",
        "QuestionContainerDAO.createQuestionContainerHeader()",
        "root.MSG_GEN_ENTER_METHOD",
        "questionContainerHeader = " + questionContainerHeader);
    int newId = 0;

    String insertStatement =
        "insert into "
            + questionContainerHeader.getPK().getTableName()
            + " values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";

    try {
      /* Retrieve next sequence identifier */
      newId = DBUtil.getNextId(questionContainerHeader.getPK().getTableName(), "qcId");
    } catch (Exception e) {
      throw new QuestionContainerRuntimeException(
          "QuestionContainerDAO.createQuestionContainerHeader()",
          SilverpeasRuntimeException.ERROR,
          "root.EX_GET_NEXTID_FAILED",
          e);
    }

    QuestionContainerPK questionContainerPK = questionContainerHeader.getPK();

    questionContainerPK.setId(Integer.toString(newId));

    PreparedStatement prepStmt = null;

    try {
      prepStmt = con.prepareStatement(insertStatement);
      prepStmt.setInt(1, newId);
      prepStmt.setString(2, questionContainerHeader.getTitle());
      prepStmt.setString(3, questionContainerHeader.getDescription());
      prepStmt.setString(4, questionContainerHeader.getComment());
      prepStmt.setString(5, questionContainerHeader.getCreatorId());
      prepStmt.setString(6, formatter.format(new java.util.Date()));
      if (questionContainerHeader.getBeginDate() == null) {
        prepStmt.setString(7, nullBeginDate);
      } else {
        prepStmt.setString(7, questionContainerHeader.getBeginDate());
      }
      if ((questionContainerHeader.getEndDate() == null)
          || (questionContainerHeader.getEndDate().length() < 10)) {
        prepStmt.setString(8, nullEndDate);
      } else {
        prepStmt.setString(8, questionContainerHeader.getEndDate());
      }
      prepStmt.setInt(9, 0);
      prepStmt.setInt(10, 0);
      prepStmt.setInt(11, questionContainerHeader.getNbQuestionsPerPage());
      prepStmt.setInt(12, questionContainerHeader.getNbMaxParticipations());
      prepStmt.setInt(13, questionContainerHeader.getNbParticipationsBeforeSolution());
      prepStmt.setInt(14, questionContainerHeader.getMaxTime());
      prepStmt.setString(15, questionContainerHeader.getPK().getComponentName());
      if (questionContainerHeader.isAnonymous()) {
        prepStmt.setInt(16, 1);
      } else {
        prepStmt.setInt(16, 0);
      }

      prepStmt.executeUpdate();
    } finally {
      DBUtil.close(prepStmt);
    }
    return questionContainerPK;
  }