示例#1
0
  /* (non-Javadoc)
   * @see org.sakaiproject.cheftool.VelocityPortletPaneledAction#toolModeDispatch(java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  protected void toolModeDispatch(
      String methodBase, String methodExt, HttpServletRequest req, HttpServletResponse res)
      throws ToolException {
    ToolSession toolSession = SessionManager.getCurrentToolSession();
    SessionState state = getState(req);

    if (MODE_DONE.equals(toolSession.getAttribute(LINK_MODE))) {

      Tool tool = ToolManager.getCurrentTool();

      String url =
          (String)
              SessionManager.getCurrentToolSession()
                  .getAttribute(tool.getId() + Tool.HELPER_DONE_URL);

      SessionManager.getCurrentToolSession().removeAttribute(tool.getId() + Tool.HELPER_DONE_URL);
      SessionManager.getCurrentToolSession().removeAttribute(LINK_MODE);

      try {
        res.sendRedirect(url);
      } catch (IOException e) {
        logger.warn("IOException: ", e);
      }
      return;
    } else if (sendToHelper(req, res, req.getPathInfo())) {
      return;
    } else {
      super.toolModeDispatch(methodBase, methodExt, req, res);
    }
  }
  protected void toolModeDispatch(
      String methodBase, String methodExt, HttpServletRequest req, HttpServletResponse res)
      throws ToolException {
    SessionState sstate = getState(req);
    ToolSession toolSession = SessionManager.getCurrentToolSession();

    String mode = (String) sstate.getAttribute(STATE_MODE);
    Object started = toolSession.getAttribute(STARTED);

    if (mode == null && started != null) {
      toolSession.removeAttribute(STARTED);
      Tool tool = ToolManager.getCurrentTool();

      String url =
          (String)
              SessionManager.getCurrentToolSession()
                  .getAttribute(tool.getId() + Tool.HELPER_DONE_URL);

      SessionManager.getCurrentToolSession().removeAttribute(tool.getId() + Tool.HELPER_DONE_URL);

      try {
        res.sendRedirect(url);
      } catch (IOException e) {
        Log.warn("chef", this + " : ", e);
      }
      return;
    }

    super.toolModeDispatch(methodBase, methodExt, req, res);
  }
  /**
   * Add a published assessment to gradebook.
   *
   * @param publishedAssessment the published assessment
   * @param g the Gradebook Service
   * @return false: cannot add to gradebook
   * @throws java.lang.Exception
   */
  public boolean addToGradebook(PublishedAssessmentData publishedAssessment, GradebookService g)
      throws Exception {
    // log.info("total point(s) is/are =" +
    //          publishedAssessment.getTotalScore().longValue());
    // log.info("gradebookId =" + GradebookFacade.getGradebookUId());
    boolean added = false;
    // log.info("GradebookService instance=" + g);
    String gradebookUId = GradebookFacade.getGradebookUId();
    if (gradebookUId == null) {
      return false;
    }

    // log.info("inside addToGradebook, gradebook exists? " +
    //          g.isGradebookDefined(gradebookUId));
    if (g.isGradebookDefined(gradebookUId)) {

      // Tool name code added by Josh Holtzman
      Tool tool = ToolManager.getTool("sakai.samigo");
      String appName = null;

      if (tool == null) {
        log.warn(
            "could not get tool named sakai.samigo, "
                + "so we're going to assume we're called 'Tests & Quizzes'");
        appName = "Tests & Quizzes";
      } else {
        appName = tool.getTitle();
      }

      String title = StringEscapeUtils.unescapeHtml(publishedAssessment.getTitle());
      if (!g.isAssignmentDefined(gradebookUId, title)) {
        g.addExternalAssessment(
            gradebookUId,
            publishedAssessment.getPublishedAssessmentId().toString(),
            null,
            title,
            publishedAssessment.getTotalScore().doubleValue(),
            publishedAssessment.getAssessmentAccessControl().getDueDate(),
            appName); // Use the app name from sakai
        added = true;
      }
    }
    return added;
  }
示例#4
0
 public String getToolId() {
   return tool.getId();
 }