Ejemplo n.º 1
0
  public void updateMark(int posx, int posy) {
    // Edit works for both comment and rubric marks only
    if (this instanceof RubricMark || this instanceof CommentMark) {
      final Mark mark = (Mark) this;

      // If the mark is a rubric get its level
      int level = 0;
      int regradeid = 0;
      if (mark instanceof RubricMark) {
        regradeid = ((RubricMark) mark).getRegradeid();
        level = ((RubricMark) mark).getLevelId();
      }

      // Create the comment dialog with the corresponding rubric level
      EditMarkDialog dialog = new EditMarkDialog(posx, posy, level, regradeid);

      if (mark instanceof RubricMark && regradeid > 0) {
        dialog.getTxtRegradeComment().setText(((RubricMark) mark).getRegrademarkercomment());
      }

      // Set dialog's current values to the mark's
      dialog.setTxtComment(mark.getRawtext());

      // Update when closing
      dialog.addCloseHandler(
          new CloseHandler<PopupPanel>() {
            @Override
            public void onClose(CloseEvent<PopupPanel> event) {
              EditMarkDialog dialog = (EditMarkDialog) event.getSource();

              MarkingPage page =
                  EMarkingWeb.markingInterface
                      .getMarkingPagesInterface()
                      .getPageByIndex(pageno - 1);
              int widthPage = page.getWidth();
              int heightPage = page.getHeight();
              // If the dialog was not cancelled update the mark with the dialog values
              if (!dialog.isCancelled()) {
                mark.update(
                    dialog.getTxtComment(),
                    mark.getPosx(),
                    mark.getPosy(),
                    dialog.getLevelId(),
                    dialog.getBonus(),
                    dialog.getRegradeComment(),
                    dialog.getRegradeAccepted(),
                    widthPage,
                    heightPage);
              }
            }
          });

      // Show the dialog
      dialog.show();
    }
  }
Ejemplo n.º 2
0
  public static void showIcons(Mark mark) {
    // Gets the absolute panel which contains the mark to calculate its coordinates
    AbsolutePanel abspanel = (AbsolutePanel) mark.getParent();

    int topdiff = -20;
    int widthdiff = -12;

    if (mark instanceof RubricMark) {
      topdiff = -20;
      widthdiff = -0;
    }
    // Calculates basic left, top position for icons
    int top = mark.getAbsoluteTop() - abspanel.getAbsoluteTop() + (topdiff);
    int left = mark.getAbsoluteLeft() + mark.getOffsetWidth() + (widthdiff);

    // Check if icons and popup are already added in the panel, if not adds them
    if (abspanel.getWidgetIndex(Mark.editIcon) < 0) abspanel.add(Mark.editIcon, left, top);

    if (abspanel.getWidgetIndex(Mark.deleteIcon) < 0) abspanel.add(Mark.deleteIcon, left, top);

    if (abspanel.getWidgetIndex(Mark.regradeIcon) < 0) abspanel.add(Mark.regradeIcon, left, top);

    if (abspanel.getWidgetIndex(Mark.minimizeIcon) < 0) abspanel.add(Mark.minimizeIcon, left, top);

    if (abspanel.getWidgetIndex(Mark.markPopup) < 0) abspanel.add(Mark.markPopup, left, top);

    // Make sure no other icons are left
    Mark.hideIcons();

    // If we are in grading mode, show delete and edit icons
    if (!EMarkingConfiguration.isReadonly()) {

      if (mark instanceof RubricMark) {
        abspanel.setWidgetPosition(Mark.minimizeIcon, left, top);
        Mark.minimizeIcon.setVisible(true);
        Mark.minimizeIcon.setMark(mark);
        left -= 15;
      }

      // Edit icon is only for comments and rubrics
      if (mark instanceof CommentMark || mark instanceof RubricMark) {
        abspanel.setWidgetPosition(Mark.editIcon, left, top);
        Mark.editIcon.setVisible(true);
        Mark.editIcon.setMark(mark);
        left -= 15;
        top -= 1;
      }

      // Delete icon
      abspanel.setWidgetPosition(Mark.deleteIcon, left, top);
      Mark.deleteIcon.setVisible(true);
      Mark.deleteIcon.setMark(mark);
    }

    // If the user owns the submission and the dates are ok we show the regrade icon
    if (EMarkingConfiguration.isOwnDraft()
        && MarkingInterface.submissionData.isRegradingAllowed()) {
      // Edit icon is only for comments and rubrics
      if (mark instanceof RubricMark) {
        abspanel.setWidgetPosition(Mark.regradeIcon, left, top);
        Mark.regradeIcon.setVisible(true);
        Mark.regradeIcon.setMark(mark);
      }
    }

    // Highlight the rubric interface if the mark is a RubricMark
    if (mark instanceof RubricMark) {
      Mark.markPopup.setHTML(((RubricMark) mark).getMarkPopupHTML());
      Mark.markPopup.setVisible(true);
      top += 50;
      abspanel.setWidgetPosition(Mark.markPopup, left, top);
    }
  }