/**
   * ACTION.
   *
   * @param ae
   * @throws AbortProcessingException
   */
  public void processAction(ActionEvent ae) throws AbortProcessingException {
    log.debug("TableOfContentsActionListener.processAction() ");

    // get managed bean and set its action accordingly
    DeliveryBean delivery = (DeliveryBean) cu.lookupBean("delivery");
    String nextAction = delivery.checkBeforeProceed();
    if (!("safeToProceed").equals(nextAction)) {
      delivery.setOutcome(nextAction);
    } else {
      UpdateTimerListener u = new UpdateTimerListener();
      u.processAction(ae);

      SubmitToGradingActionListener s = new SubmitToGradingActionListener();
      try {
        s.processAction(ae);
      } catch (FinFormatException e) {
        log.debug(e.getMessage());
        delivery.setOutcome("takeAssessment");
        return;
      } catch (SaLengthException sae) {
        log.debug(sae.getMessage());
        delivery.setOutcome("takeAssessment");
        return;
      }

      DeliveryActionListener d = new DeliveryActionListener();
      delivery.setSkipFlag(true);
      d.processAction(ae);
      delivery.setOutcome("tableOfContents");
    }
  }
  /**
   * This will populate the StudentScoresBean with the data associated with the particular versioned
   * assessment based on the publishedId.
   *
   * @param publishedId String
   * @param bean StudentScoresBean
   * @return boolean
   */
  public boolean studentScores(String publishedId, StudentScoresBean bean, boolean isValueChange) {
    log.debug("studentScores()");
    try {
      //  SAK-4121, do not pass studentName as f:param, will cause javascript error if name contains
      // apostrophe
      //    bean.setStudentName(cu.lookupParam("studentName"));

      bean.setPublishedId(publishedId);
      String studentId = ContextUtil.lookupParam("studentid");
      bean.setStudentId(studentId);
      AgentFacade agent = new AgentFacade(studentId);
      bean.setStudentName(agent.getFirstName() + " " + agent.getLastName());
      bean.setLastName(agent.getLastName());
      bean.setFirstName(agent.getFirstName());
      bean.setAssessmentGradingId(ContextUtil.lookupParam("gradingData"));
      bean.setItemId(ContextUtil.lookupParam("itemId"));
      bean.setEmail(agent.getEmail());

      DeliveryBean dbean = (DeliveryBean) ContextUtil.lookupBean("delivery");
      dbean.setActionString("gradeAssessment");

      DeliveryActionListener listener = new DeliveryActionListener();
      listener.processAction(null);

      // Added for SAK-13930
      DeliveryBean updatedDeliveryBean = (DeliveryBean) ContextUtil.lookupBean("delivery");
      ArrayList parts = updatedDeliveryBean.getPageContents().getPartsContents();
      Iterator iter = parts.iterator();
      while (iter.hasNext()) {
        ArrayList items = ((SectionContentsBean) iter.next()).getItemContents();
        Iterator iter2 = items.iterator();
        while (iter2.hasNext()) {
          ItemContentsBean question = (ItemContentsBean) iter2.next();
          if (question.getGradingComment() != null && !question.getGradingComment().equals("")) {
            question.setGradingComment(
                FormattedText.convertFormattedTextToPlaintext(question.getGradingComment()));
          }
        }
      } // End of SAK-13930

      GradingService service = new GradingService();
      AssessmentGradingData adata =
          (AssessmentGradingData) service.load(bean.getAssessmentGradingId(), false);
      bean.setComments(FormattedText.convertFormattedTextToPlaintext(adata.getComments()));
      buildItemContentsMap(dbean);

      return true;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  }