/** Sets the inner HTML according to an icon */ public void setMarkHTML() { // Starts with an empty HTML String html = ""; String iconhtml = ""; // Create the icon string if any if (this.iconType != null) { Icon icon = new Icon(this.iconType); iconhtml = icon.toString(); } else if (this.iconOnly && this instanceof CustomMark) { CustomMark cmark = (CustomMark) this; iconhtml = cmark.getTitle(); } String markername = EMarkingConfiguration.isMarkerAnonymous() ? MarkingInterface.messages.MarkerDetails(MarkingInterface.messages.Anonymous()) : MarkingInterface.messages.MarkerDetails(this.getMarkername()); String styleColor = ""; // If the mark has a color, we use the background to color it if (this.criterionid > 0 && this.iconOnly) { styleColor = "style=\"color:" + Color.getCSSHueColor(criterionid) + "\""; } html += "<div class=\"" + Resources.INSTANCE.css().markicon() + "\" title=\"" + markername + "\" " + styleColor + ">" + iconhtml + "</div>"; // If the mark is an icon if (!this.iconOnly && this.getRawtext().trim().length() > 0) { html += "<div class=\"" + Resources.INSTANCE.css().markrawtext() + "\">" + SafeHtmlUtils.htmlEscape(this.getRawtext()) + "</div>"; // Show the marker's name if the marking process is not anonymous if (!EMarkingConfiguration.isMarkerAnonymous()) { html += "<div class=\"" + Resources.INSTANCE.css().markmarkername() + "\">" + markername + "</div>"; } } this.setHTML(html); }
public CriterionHeader(int idx, int cid, String cdesc, float b, int regrid, int regraccepted) { this.mainPanel = new VerticalPanel(); this.mainPanel.addStyleName(Resources.INSTANCE.css().criterionrow()); this.criterionId = cid; this.criterionDescription = cdesc; this.index = idx; Label lbl = new Label(cdesc); lbl.addStyleName(Resources.INSTANCE.css().criterionheader()); lbl.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { if (commentId > 0 && commentPage > 0) EMarkingWeb.markingInterface .getMarkingPagesInterface() .highlightRubricMark(commentId, commentPage); } }); mainPanel.add(lbl); HorizontalPanel horizontal = new HorizontalPanel(); horizontal.addStyleName(Resources.INSTANCE.css().colorsquaretable()); // the square with the color if (EMarkingConfiguration.isColoredRubric()) { Label lbl2 = new Label(""); Color.setWidgetBackgroundHueColor(cid, lbl2); lbl2.addStyleName(Resources.INSTANCE.css().colorsquare()); lbl2.setTitle(String.valueOf(idx)); // lbl2.addStyleName(MarkingInterface.getMapCss().get("colorsquare")); // HTML rectangle = new HTML(); // rectangle.setHTML("<div data-index='"+idx+"' style='width:20px; height:20px;border:1px // solid #000;' class='"+ MarkingInterface.getMapCss().get("color"+idx) +" // "+MarkingInterface.getMapCss().get("colorsquare") + "' ></div>"); lbl2.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { Label rectangle = (Label) event.getSource(); int index = Integer.parseInt(rectangle.getTitle()); EMarkingWeb.markingInterface .getToolbar() .getMarkingButtons() .changeCriterionList(index); } }); horizontal.add(lbl2); } HTML separation = new HTML(); separation.setHTML("<div style='width:20px;height:20px;'></div>"); horizontal.add(separation); mainPanel.add(horizontal); bonusHtml = new HTML(); setBonus(b); mainPanel.add(bonusHtml); regradeHtml = new HTML(); regradeHtml.setVisible(false); mainPanel.add(regradeHtml); this.setRegradeData(regrid, regraccepted); loadingIcon = new HTML(); loadingIcon.setVisible(false); Icon iconloading = new Icon(IconType.COG); loadingIcon.setHTML(iconloading.toString()); loadingIcon.addStyleName(Resources.INSTANCE.css().loadingicon()); loadingIcon.addStyleName("icon-spin"); mainPanel.add(loadingIcon); mainPanel.setCellHorizontalAlignment(loadingIcon, HasHorizontalAlignment.ALIGN_CENTER); initWidget(mainPanel); }
/** * Updates a mark's comment, position or bonus * * @param newcomment the new comment * @param newposx the new X coordinate in the page * @param newposy the new Y coordinate in the page * @param newbonus the new bonus */ public void update( final String newcomment, int newposx, int newposy, final int newlevel, final float newbonus, final String newregrademarkercomment, final int newregradeaccepted, int widthPage, int heightPage) { final Mark mark = this; int regradeid = 0; if (mark instanceof RubricMark) regradeid = ((RubricMark) mark).getRegradeid(); // This shouldn't happen so log it for debugging if (this.id == 0) { logger.severe("Fatal error! A comment with id 0!"); return; } EMarkingWeb.markingInterface.addLoading(true); this.setLoading(); final String feedbackToAjax; if (feedback.size() > 0) { feedbackToAjax = getFeedbackToAjax(); } else { feedbackToAjax = ""; } // Call the ajax request to update the data AjaxRequest.ajaxRequest( "action=updcomment&cid=" + this.id + "&posx=" + newposx + "&posy=" + newposy + "&bonus=" + newbonus + "&format=" + this.format + "&levelid=" + newlevel + "®radeid=" + regradeid + "®radeaccepted=" + newregradeaccepted + "®rademarkercomment=" + newregrademarkercomment + "&markerid=" + EMarkingConfiguration.getMarkerId() + "&width=" + this.width + "&height=" + this.height + "&comment=" + URL.encode(newcomment) + "&windowswidth=" + widthPage + "&windowsheight=" + heightPage + feedbackToAjax, new AsyncCallback<AjaxData>() { @Override public void onFailure(Throwable caught) { logger.severe("Error updating mark to Moodle!"); logger.severe(caught.getMessage()); Window.alert(caught.getMessage()); EMarkingWeb.markingInterface.finishLoading(); } @Override public void onSuccess(AjaxData result) { Map<String, String> value = AjaxRequest.getValueFromResult(result); if (!result.getError().equals("")) { Window.alert(result.getError()); setMarkHTML(); removeStyleName(Resources.INSTANCE.css().updating()); EMarkingWeb.markingInterface.finishLoading(); return; } // Parse json values from Moodle long timemodified = Long.parseLong(value.get("timemodified")); float newgrade = Float.parseFloat(value.get("newgrade")); mark.setPreviousText(mark.getRawtext()); mark.setRawtext(newcomment); if (mark instanceof RubricMark) { RubricMark rmark = (RubricMark) mark; // Update submission data int previousLevelid = rmark.getLevelId(); float previousBonus = rmark.getBonus(); rmark.setLevelId(newlevel); rmark.setBonus(newbonus); rmark.setRegradeaccepted(newregradeaccepted); rmark.setRegrademarkercomment(newregrademarkercomment); if (rmark.getLevelId() != previousLevelid || rmark.getBonus() != previousBonus) { rmark.setMarkername( MarkingInterface.submissionData.getMarkerfirstname() + " " + MarkingInterface.submissionData.getMarkerlastname()); rmark.setMarkerid(MarkingInterface.submissionData.getMarkerid()); Mark.showIcons(rmark); } EMarkingWeb.markingInterface .getRubricInterface() .getRubricPanel() .addMarkToRubric(rmark); EMarkingWeb.markingInterface .getRubricInterface() .getRubricPanel() .finishloadingRubricCriterion(newlevel); } // Update the marking interface with the final grade and time EMarkingWeb.markingInterface.setFinalgrade(newgrade, timemodified); setMarkHTML(); EMarkingWeb.markingInterface .getRubricInterface() .getToolsPanel() .getPreviousComments() .addMarkAsCommentToInterface(mark, true); removeStyleName(Resources.INSTANCE.css().updating()); EMarkingWeb.markingInterface.finishLoading(); } }); }
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); } }