Esempio n. 1
0
  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";
  }
Esempio n. 2
0
  public String processGradebookView() {
    Long currentGbId = ((Gradebook) gradebookTable.getRowData()).getId();

    // if instructor, we need to load all students
    if (isEditable()) {
      currentGradebook = gradebookManager.getGradebookByIdWithHeadings(currentGbId);
      currentGradebook.setUsernames(gradebookManager.getUsernamesInGradebook(currentGradebook));
      studentMap = currentGradebook.getStudentMap();
      setSelectedStudent((String) studentMap.firstKey());
      return "view_student";
    }

    // otherwise, just load what we need for the current user
    currentGradebook = gradebookManager.getGradebookByIdWithHeadings(currentGbId);
    this.userId = SessionManager.getCurrentSessionUserId();

    currentStudent = gradebookManager.getStudentByGBAndUsername(currentGradebook, this.userEid);
    if (currentStudent != null) {
      currentStudent.setLastChecked(new Timestamp(new Date().getTime()));
      gradebookManager.updateStudent(currentStudent);

      currentStudent.setGradebook(currentGradebook);
    }

    return "view_grades";
  }
  /**
   * Queries the UIData for the current row of data to get the current cheese.
   *
   * @return String for the cheese name.
   * @throws NullPointerException if the rowdata returns a null Cheese.
   */
  private String getSelectedCheeseName() {
    Cheese cheese = (Cheese) cheeseList.getRowData(); //  make sure it still exists
    if (cheese == null) {
      throw new NullPointerException("cheese");
    }

    return cheese.getName();
  }
Esempio n. 4
0
  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";
  }
 public void specialAccessAction(ActionEvent evt) {
   resetSelectedLists();
   if (!saveModuleDates()) return;
   FacesContext ctx = FacesContext.getCurrentInstance();
   UIViewRoot root = ctx.getViewRoot();
   UIData table = (UIData) root.findComponent("listauthmodulesform").findComponent("table");
   ModuleDateBean mdbean = (ModuleDateBean) table.getRowData();
   Integer selModId = mdbean.getModuleId();
   try {
     ctx.getExternalContext().redirect("list_special_access.jsf?editmodid=" + selModId.toString());
   } catch (Exception e) {
     return;
   }
 }
  /**
   * Get module id to print
   *
   * @return module id to print
   */
  public Integer getPrintModuleId() {
    FacesContext ctx = FacesContext.getCurrentInstance();
    ResourceLoader bundle = new ResourceLoader("org.etudes.tool.melete.bundle.Messages");

    try {
      resetSelectedLists();
      UIViewRoot root = ctx.getViewRoot();
      UIData table = (UIData) root.findComponent("listauthmodulesform").findComponent("table");
      ModuleDateBean mdbean = (ModuleDateBean) table.getRowData();
      printModuleId = mdbean.getModule().getModuleId();
      return printModuleId;
    } catch (Exception me) {
      logger.error(me.toString());
      String msg = bundle.getString("print_module_fail");
      addMessage(ctx, "Error Message", msg, FacesMessage.SEVERITY_ERROR);
    }
    return 0;
  }
 /**
  * Method to expand or collapse individual modules' sections
  *
  * @return list_auth_modules
  */
 public String showHideSections() {
   resetSelectedLists();
   if (getExpandAllFlag() == true) {
     setShowModuleId(-1);
     setExpandAllFlag(false);
   } else {
     FacesContext ctx = FacesContext.getCurrentInstance();
     UIViewRoot root = ctx.getViewRoot();
     UIData table = (UIData) root.findComponent("listauthmodulesform").findComponent("table");
     ModuleDateBean mdbean = (ModuleDateBean) table.getRowData();
     if (getShowModuleId() != mdbean.getModuleId()) {
       setShowModuleId(mdbean.getModuleId());
     } else {
       setShowModuleId(-1);
       setExpandAllFlag(false);
     }
   }
   saveModuleDates();
   return "list_auth_modules";
 }
  /**
   * Make a copy of the selected module
   *
   * @return list_auth_modules
   */
  public String duplicateAction() {
    FacesContext ctx = FacesContext.getCurrentInstance();
    ResourceLoader bundle = new ResourceLoader("org.etudes.tool.melete.bundle.Messages");
    if (!saveModuleDates()) return "list_auth_modules";

    try {
      resetSelectedLists();
      UIViewRoot root = ctx.getViewRoot();
      UIData table = (UIData) root.findComponent("listauthmodulesform").findComponent("table");
      ModuleDateBean mdbean = (ModuleDateBean) table.getRowData();
      logger.debug("calling copy for " + mdbean.getModule().getTitle());
      moduleService.copyModule((ModuleObjService) mdbean.getModule(), courseId, userId);
    } catch (MeleteException me) {
      logger.debug(me.toString());
      String msg = bundle.getString("copy_fail");
      addMessage(ctx, "Error Message", msg, FacesMessage.SEVERITY_ERROR);
    }
    resetValues();
    return "list_auth_modules";
  }
Esempio n. 9
0
  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";
  }
Esempio n. 10
0
  public String processTemplateDownload() {
    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";
    }
    currentGradebook = (Gradebook) gradebookTable.getRowData();

    return "download_template";
  }
Esempio n. 11
0
  public void encodeChildren(FacesContext context, UIComponent component) throws IOException {

    if ((context == null) || (component == null)) {
      throw new NullPointerException(
          Util.getExceptionMessageString(Util.NULL_PARAMETERS_ERROR_MESSAGE_ID));
    }
    if (log.isTraceEnabled()) {
      log.trace("Begin encoding children " + component.getId());
    }
    if (!component.isRendered()) {
      if (log.isTraceEnabled()) {
        log.trace(
            "No encoding necessary "
                + component.getId()
                + " since "
                + "rendered attribute is set to false ");
      }
      return;
    }
    UIData data = (UIData) component;

    ValueBinding msgsBinding = component.getValueBinding("value");
    List msgBeanList = (List) msgsBinding.getValue(context);

    // Set up variables we will need
    String columnClasses[] = getColumnClasses(data);
    int columnStyle = 0;
    int columnStyles = columnClasses.length;
    String rowClasses[] = getRowClasses(data);
    int rowStyles = rowClasses.length;
    ResponseWriter writer = context.getResponseWriter();
    Iterator kids = null;
    Iterator grandkids = null;

    // Iterate over the rows of data that are provided
    int processed = 0;
    int rowIndex = data.getFirst() - 1;
    int rows = data.getRows();
    int rowStyle = 0;

    writer.startElement("tbody", component);
    writer.writeText("\n", null);
    int hideDivNo = 0;
    while (true) {
      //			PrivateMessageDecoratedBean dmb = null;
      //			if(msgBeanList !=null && msgBeanList.size()>(rowIndex+1) &&
      // rowIndex>=-1)
      //			{
      //				dmb = (PrivateMessageDecoratedBean)msgBeanList.get(rowIndex+1);
      //			}
      //			boolean hasChildBoolean = false;
      //			if(dmb != null)
      //			{
      //				for(int i=0; i<msgBeanList.size(); i++)
      //				{
      //					PrivateMessageDecoratedBean tempDmb =
      // (PrivateMessageDecoratedBean)msgBeanList.get(i);
      //					if(tempDmb.getUiInReply() != null &&
      // tempDmb.getUiInReply().getId().equals(dmb.getMsg().getId()))
      //					{
      //						hasChildBoolean = true;
      //						break;
      //					}
      //				}
      //			}
      // Have we displayed the requested number of rows?
      if ((rows > 0) && (++processed > rows)) {
        break;
      }
      // Select the current row
      data.setRowIndex(++rowIndex);
      if (!data.isRowAvailable()) {
        break; // Scrolled past the last row
      }

      PrivateMessageDecoratedBean dmb = null;
      dmb = (PrivateMessageDecoratedBean) data.getRowData();
      boolean hasChildBoolean = false;
      if (dmb != null) {
        // if dmb has depth = 0, check for children
        if (dmb.getDepth() == 0) {
          // first, get the index of the dmb
          int index = -1;

          for (int i = 0; i < msgBeanList.size(); i++) {
            PrivateMessageDecoratedBean tempDmb = (PrivateMessageDecoratedBean) msgBeanList.get(i);
            if (dmb.getMsg().getId().equals(tempDmb.getMsg().getId())) {
              index = i;
              break;
            }
          }
          if (index < (msgBeanList.size() - 1) && index >= 0) {
            PrivateMessageDecoratedBean nextDmb =
                (PrivateMessageDecoratedBean) msgBeanList.get(index + 1);

            if (nextDmb.getDepth() > 0) {
              hasChildBoolean = true;
            }
          }
        }
      }

      if (dmb != null && dmb.getDepth() > 0) {
        writer.write(
            "<tr style=\"display:none\" id=\"_id_"
                + new Integer(hideDivNo).toString()
                + "__hide_division_"
                + "\">");
      } else {
        writer.write("<tr>");
      }

      if (rowStyles > 0) {
        writer.writeAttribute("class", rowClasses[rowStyle++], "rowClasses");
        if (rowStyle >= rowStyles) {
          rowStyle = 0;
        }
      }
      writer.writeText("\n", null);

      // Iterate over the child UIColumn components for each row
      columnStyle = 0;
      kids = getColumns(data);
      while (kids.hasNext()) {

        // Identify the next renderable column
        UIColumn column = (UIColumn) kids.next();

        // Render the beginning of this cell
        writer.startElement("td", column);
        if (columnStyles > 0) {
          writer.writeAttribute("class", columnClasses[columnStyle++], "columnClasses");
          if (columnStyle >= columnStyles) {
            columnStyle = 0;
          }
        }

        if (dmb != null && dmb.getDepth() > 0) {
          if (column.getId().endsWith("_msg_subject")) {
            StringBuilder indent = new StringBuilder();
            int indentInt = dmb.getDepth() * 4;
            for (int i = 0; i < indentInt; i++) {
              indent.append("&nbsp;");
            }
            writer.write(indent.toString());
          }
        } else {
          if (column.getId().endsWith("_msg_subject")) {
            if (hasChildBoolean && dmb.getDepth() == 0) {
              writer.write(
                  " <img src=\""
                      + BARIMG
                      + "\" style=\""
                      + CURSOR
                      + "\" id=\"_id_"
                      + Integer.valueOf(hideDivNo).toString()
                      + "__img_hide_division_\""
                      + " onclick=\"");
              int childNo = getTotalChildNo(dmb, msgBeanList);
              String hideTr = "";
              for (int i = 0; i < childNo; i++) {
                hideTr +=
                    "javascript:showHideDiv('_id_"
                        + (hideDivNo + i)
                        + "', '"
                        + RESOURCE_PATH
                        + "');";
              }
              writer.write(hideTr);
              writer.write("\" />");
            }
          }
        }
        // Render the contents of this cell by iterating over
        // the kids of our kids
        grandkids = getChildren(column);
        while (grandkids.hasNext()) {
          encodeRecursive(context, (UIComponent) grandkids.next());
        }

        // Render the ending of this cell
        writer.endElement("td");
        writer.writeText("\n", null);
      }

      // Render the ending of this row
      writer.endElement("tr");
      writer.writeText("\n", null);
      if (dmb != null && dmb.getDepth() > 0) {
        ////
        /*ValueBinding expandedBinding =
        	component.getValueBinding("expanded");
        String expanded = "";
        if(expandedBinding != null)
        	expanded = (String)expandedBinding.getValue(context);

        if(expanded.equalsIgnoreCase("true"))
        {*/
        writer.write("<script type=\"text/javascript\">");
        writer.write(" showHideDiv('_id_" + hideDivNo + "', '" + RESOURCE_PATH + "');");
        writer.write("</script>");
        //////				}

        hideDivNo++;
      }
    }
    writer.endElement("tbody");
    writer.writeText("\n", null);

    // Clean up after ourselves
    data.setRowIndex(-1);
    if (log.isTraceEnabled()) {
      log.trace("End encoding children " + component.getId());
    }
  }
Esempio n. 12
0
 public String deleteContact() {
   final UIData table = (UIData) FacesUtils.getComponent("tag:contacts");
   final Contact toDelete = (Contact) table.getRowData();
   tag.getContactTags().remove(toDelete);
   return NavigationResults.EDIT;
 }
Esempio n. 13
0
 /**
  * Delete selected instance of the one-to-many field
  *
  * @return forward to the same page
  */
 public String deleteOrganizationTags() {
   UIData table = (UIData) FacesUtils.getComponent("tag:organizationTags");
   tag.getOrganizationTags().remove(table.getRowData());
   return null;
 }
Esempio n. 14
0
 /**
  * Delete selected instance of the one-to-many field
  *
  * @return forward to the same page
  */
 public String deleteDepartmentTags() {
   UIData table = (UIData) FacesUtils.getComponent("tag:departmentTags");
   tag.getDepartmentTags().remove(table.getRowData());
   return null;
 }
Esempio n. 15
0
 public String deleteOrganization() {
   final UIData table = (UIData) FacesUtils.getComponent("tag:organizations");
   final Organization toDelete = (Organization) table.getRowData();
   tag.getOrganizationTags().remove(toDelete);
   return NavigationResults.EDIT;
 }
Esempio n. 16
0
 public String deleteDepartment() {
   final UIData table = (UIData) FacesUtils.getComponent("tag:departments");
   final Department toDelete = (Department) table.getRowData();
   tag.getDepartmentTags().remove(toDelete);
   return NavigationResults.EDIT;
 }