コード例 #1
0
ファイル: PostemTool.java プロジェクト: philsawa/sakai
  public String processInstructorView() {
    try {
      if (!this.checkAccess()) {
        throw new PermissionException(
            SessionManager.getCurrentSessionUserId(), "syllabus_access_athz", "");
      }

    } catch (PermissionException e) {
      // logger.info(this + ".getEntries() in PostemTool " + e);
      FacesContext.getCurrentInstance()
          .addMessage(
              null,
              MessageUtils.getMessage(
                  FacesMessage.SEVERITY_ERROR,
                  "error_permission",
                  (new Object[] {e.toString()}),
                  FacesContext.getCurrentInstance()));
      return "permission_error";
    }
    Long currentGbId = ((Gradebook) gradebookTable.getRowData()).getId();
    currentGradebook = gradebookManager.getGradebookByIdWithHeadingsAndStudents(currentGbId);

    students = new ArrayList(currentGradebook.getStudents());

    return "view_gradebook";
  }
コード例 #2
0
ファイル: PostemTool.java プロジェクト: philsawa/sakai
  public String processGradebookUpdate() {
    try {
      if (!this.checkAccess()) {
        throw new PermissionException(
            SessionManager.getCurrentSessionUserId(), "syllabus_access_athz", "");
      }

    } catch (PermissionException e) {
      // logger.info(this + ".getEntries() in PostemTool " + e);
      FacesContext.getCurrentInstance()
          .addMessage(
              null,
              MessageUtils.getMessage(
                  FacesMessage.SEVERITY_ERROR,
                  "error_permission",
                  (new Object[] {e.toString()}),
                  FacesContext.getCurrentInstance()));
      this.currentGradebook = null;
      this.csv = null;
      this.newTemplate = null;
      return "permission_error";
    }
    this.userId = SessionManager.getCurrentSessionUserId();
    this.siteId = ToolManager.getCurrentPlacement().getContext();

    Long currentGbId = ((Gradebook) gradebookTable.getRowData()).getId();
    currentGradebook = gradebookManager.getGradebookByIdWithHeadingsAndStudents(currentGbId);

    oldGradebook =
        gradebookManager.createEmptyGradebook(
            currentGradebook.getCreator(), currentGradebook.getContext());
    oldGradebook.setId(currentGradebook.getId());
    oldGradebook.setStudents(currentGradebook.getStudents());

    gradebooks = null;

    /*
     * if(new Boolean(true).equals(currentGradebook.getReleased())) {
     * this.release = "Yes"; } else { this.release = "No"; }
     */

    if (currentGradebook.getFileReference() != null) {
      attachment =
          EntityManager.newReference(
              contentHostingService.getReference(currentGradebook.getFileReference()));
    }

    this.csv = null;
    this.newTemplate = null;
    this.delimiter = COMMA_DELIM_STR;

    return "create_gradebook";
  }
コード例 #3
0
ファイル: PostemTool.java プロジェクト: philsawa/sakai
  public String processCsvDownload() {
    try {
      if (!this.checkAccess()) {
        throw new PermissionException(
            SessionManager.getCurrentSessionUserId(), "syllabus_access_athz", "");
      }

    } catch (PermissionException e) {
      // logger.info(this + ".getEntries() in PostemTool " + e);
      FacesContext.getCurrentInstance()
          .addMessage(
              null,
              MessageUtils.getMessage(
                  FacesMessage.SEVERITY_ERROR,
                  "error_permission",
                  (new Object[] {e.toString()}),
                  FacesContext.getCurrentInstance()));
      return "permission_error";
    }
    Long currentGbId = ((Gradebook) gradebookTable.getRowData()).getId();
    currentGradebook = gradebookManager.getGradebookByIdWithHeadingsAndStudents(currentGbId);

    List csvContents = new ArrayList();
    if (currentGradebook.getHeadings().size() > 0) {
      csvContents.add(currentGradebook.getHeadings());
    }
    Iterator si = currentGradebook.getStudents().iterator();
    while (si.hasNext()) {
      List sgl = new ArrayList();
      StudentGrades sg = (StudentGrades) si.next();
      sgl.add(sg.getUsername());
      sgl.addAll(sg.getGrades());
      csvContents.add(sgl);
    }

    CSV newCsv = new CSV(csvContents, currentGradebook.getHeadings().size() > 0);

    this.csv = newCsv.getCsv();
    return "download_csv";
  }