Skip to content

Commit

Permalink
SAK-46151 Categories using equal weighting or extra credit are not in…
Browse files Browse the repository at this point in the history
…dicated to students (sakaiproject#9729)
  • Loading branch information
plukasew authored Aug 31, 2021
1 parent df359d7 commit 8c4c8ae
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@
{if extraCredit}
<span class="gb-flag-extra-credit" wicket:message="title:label.gradeitem.extracreditcategory"></span>
{/if}
{if equalWeight}
<span class="gb-flag-equal-weight" wicket:message="title:label.gradeitem.equalweightcategory"></span>
{/if}
{var tooltip = title.replace(/"/g, '&quot;')}
<a class="gb-title" title="${tooltip}">
<span class="gb-category">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,20 @@ protected final void disableLink(final Link<Void> l) {
* Helper to build a notification flag with a Bootstrap popover
*/
public WebMarkupContainer buildFlagWithPopover(final String componentId, final String message) {
return buildFlagWithPopover(componentId, message, "manual", "#gradebookGrades");
}

public WebMarkupContainer buildFlagWithPopover(final String componentId, final String message,
final String trigger, final String container) {
final WebMarkupContainer flagWithPopover = new WebMarkupContainer(componentId);

flagWithPopover.add(new AttributeModifier("title", message));
flagWithPopover.add(new AttributeModifier("aria-label", message));
flagWithPopover.add(new AttributeModifier("data-toggle", "popover"));
flagWithPopover.add(new AttributeModifier("data-trigger", "manual"));
flagWithPopover.add(new AttributeModifier("data-trigger", trigger));
flagWithPopover.add(new AttributeModifier("data-placement", "bottom"));
flagWithPopover.add(new AttributeModifier("data-html", "true"));
flagWithPopover.add(new AttributeModifier("data-container", "#gradebookGrades"));
flagWithPopover.add(new AttributeModifier("data-container", container));
flagWithPopover.add(new AttributeModifier("data-template",
"<div class=\"gb-popover popover\" role=\"tooltip\"><div class=\"arrow\"></div><div class=\"popover-content\"></div></div>"));
flagWithPopover.add(new AttributeModifier("data-content", generatePopoverContent(message)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
<tbody class="gb-summary-category-tbody">
<tr wicket:id="categoryRow" class="gb-summary-category-row" wicket:message="aria-label:studentsummary.categoryrow">
<th scope="rowgroup">
<a href="javascript:void(0);" class="gb-summary-category-toggle" wicket:message="title:studentsummary.categorytoggle"><span wicket:id="category" class="gb-summary-category-name"></span></a>
<div class="gb-summary-category-toggle-container">
<a href="javascript:void(0);" class="gb-summary-category-toggle" wicket:message="title:studentsummary.categorytoggle"><span wicket:id="category" class="gb-summary-category-name"></span></a>
<span class="gb-summary-grade-flags" wicket:id="flags">
<span wicket:id="isExtraCredit" class="gb-flag-extra-credit"></span>
<span wicket:id="isEqualWeight" class="gb-flag-equal-weight"></span>
</span>
</div>
<p wicket:id="categoryDropInfo" class="gb-summary-grade-category-dropInfo">
<span wicket:id="categoryDropInfo1">Drop Highest: 1 & </span><wbr><span wicket:id="categoryDropInfo2">Drop Lowest: 1</span>
</p>
Expand Down Expand Up @@ -65,7 +71,13 @@
<td class="gb-summary-grade-duedate" wicket:id="dueDate"></td>
<td class="gb-summary-grade-comments"><div wicket:id="comments"></div></td>
<td class="gb-summary-grade-category" wicket:id="category">
<div wicket:id="categoryName"></div>
<div>
<span wicket:id="categoryName"></span>
<span class="gb-summary-grade-category-flags" wicket:id="cflags">
<span wicket:id="isExtraCredit" class="gb-flag-extra-credit"></span>
<span wicket:id="isEqualWeight" class="gb-flag-equal-weight"></span>
</span>
</div>
<p wicket:id="categoryDropInfo" class="gb-summary-grade-category-col-dropInfo">Drop Highest: 1</p>
<p wicket:id="categoryDropInfo2" class="gb-summary-grade-category-col-dropInfo">Drop Lowest: 1</p>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
*/
package org.sakaiproject.gradebookng.tool.panels;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.IAjaxIndicatorAware;
import org.apache.wicket.behavior.AttributeAppender;
Expand Down Expand Up @@ -182,6 +184,13 @@ protected void populateItem(final ListItem<String> categoryItem) {
categoryItem.add(categoryRow);
categoryRow.add(new Label("category", categoryName));

// popover flags
final CategoryFlags cf = getCategoryFlags(categoryName, categoriesMap);
final WebMarkupContainer flags = new WebMarkupContainer("flags");
flags.add(newPopoverFlag("isExtraCredit", getString("label.gradeitem.extracreditcategory"), cf.extraCredit));
flags.add(newPopoverFlag("isEqualWeight", getString("label.gradeitem.equalweightcategory"), cf.equalWeight));
categoryRow.add(flags.setVisible(cf.hasFlags()));

final DropInfoPair pair = getDropInfo(categoryName, categoriesMap);
if (!pair.second.isEmpty()) {
pair.first += " " + getString("label.category.dropSeparator") + " ";
Expand Down Expand Up @@ -307,31 +316,13 @@ public boolean isVisible() {

// popover flags
final WebMarkupContainer flags = new WebMarkupContainer("flags");
flags.add(page.buildFlagWithPopover("isExtraCredit", getString("label.gradeitem.extracredit"))
.add(new AttributeModifier("data-trigger", "focus"))
.add(new AttributeModifier("data-container", "#gradeSummaryTable"))
.setVisible(assignment.isExtraCredit()));
flags.add(page.buildFlagWithPopover("isNotCounted", getString("label.gradeitem.notcounted"))
.add(new AttributeModifier("data-trigger", "focus"))
.add(new AttributeModifier("data-container", "#gradeSummaryTable"))
.setVisible(!assignment.isCounted()));
flags.add(page.buildFlagWithPopover("isNotReleased", getString("label.gradeitem.notreleased"))
.add(new AttributeModifier("data-trigger", "focus"))
.add(new AttributeModifier("data-container", "#gradeSummaryTable"))
.setVisible(!assignment.isReleased()));
flags.add(page.buildFlagWithPopover("isExcused", getString("grade.notifications.excused"))
.add(new AttributeModifier("data-trigger", "focus"))
.add(new AttributeModifier("data-container", "#gradeSummaryTable"))
.setVisible(excused));
flags.add(page
.buildFlagWithPopover("isExternal",
new StringResourceModel("label.gradeitem.externalapplabel", null,
new Object[] { assignment.getExternalAppName() }).getString())
.add(new AttributeModifier("data-trigger", "focus"))
.add(new AttributeModifier("data-container", "#gradeSummaryTable"))
.add(new AttributeModifier("class",
"gb-external-app-flag " + GradeSummaryTablePanel.this.businessService.getIconClass(assignment)))
.setVisible(assignment.isExternallyMaintained()));
flags.add(newPopoverFlag("isExtraCredit", getString("label.gradeitem.extracredit"), assignment.isExtraCredit()));
flags.add(newPopoverFlag("isNotCounted", getString("label.gradeitem.notcounted"), !assignment.isCounted()));
flags.add(newPopoverFlag("isNotReleased", getString("label.gradeitem.notreleased"), !assignment.isReleased()));
flags.add(newPopoverFlag("isExcused", getString("grade.notifications.excused"), excused));
String extAppName = new StringResourceModel("label.gradeitem.externalapplabel", null, new Object[] { assignment.getExternalAppName() }).getString();
flags.add(newPopoverFlag("isExternal", extAppName, assignment.isExternallyMaintained())
.add(new AttributeModifier("class", "gb-external-app-flag " + GradeSummaryTablePanel.this.businessService.getIconClass(assignment))));
flags.setVisible(
assignment.isExtraCredit() ||
!assignment.isCounted() ||
Expand Down Expand Up @@ -423,6 +414,13 @@ public boolean isVisible() {
final WebMarkupContainer catCon = new WebMarkupContainer("category");
catCon.setVisible(categoriesEnabled && !GradeSummaryTablePanel.this.isGroupedByCategory);
catCon.add(new Label("categoryName", assignment.getCategoryName()));

final CategoryFlags cf = getCategoryFlags(assignment.getCategoryName(), categoriesMap);
final WebMarkupContainer cflags = new WebMarkupContainer("cflags");
cflags.add(newPopoverFlag("isExtraCredit", getString("label.gradeitem.extracreditcategory"), cf.extraCredit));
cflags.add(newPopoverFlag("isEqualWeight", getString("label.gradeitem.equalweightcategory"), cf.equalWeight));
catCon.add(cflags.setVisible(cf.hasFlags()));

final DropInfoPair pair = getDropInfo(assignment.getCategoryName(), categoriesMap);
catCon.add(new Label("categoryDropInfo", pair.first).setVisible(!pair.first.isEmpty()));
catCon.add(new Label("categoryDropInfo2", pair.second).setVisible(!pair.second.isEmpty()));
Expand All @@ -446,7 +444,7 @@ private void addInstructorAttributeOrHide(WebMarkupContainer sakaiRubricButton,
}
}

private final class DropInfoPair {
private final class DropInfoPair implements Serializable {
public String first = "";
public String second = "";
}
Expand Down Expand Up @@ -479,4 +477,29 @@ public void renderHead(final IHeaderResponse response) {
response.render(StringHeaderItem.forString(
"<script type=\"module\" src=\"/webcomponents/rubrics/rubric-association-requirements.js" + version + "\"></script>"));
}

private Component newPopoverFlag(String id, String msg, boolean visible) {
final BasePage page = (BasePage) getPage();
return page.buildFlagWithPopover(id, msg, "focus", "#gradeSummaryTable").setVisible(visible);
}

private final class CategoryFlags implements Serializable {
public boolean extraCredit = false;
public boolean equalWeight = false;

public boolean hasFlags() {
return extraCredit || equalWeight;
}
}

private CategoryFlags getCategoryFlags(String catName, final Map<String, CategoryDefinition> categoriesMap) {
CategoryFlags flags = new CategoryFlags();
if (catName != null && !catName.equals(getString(GradebookPage.UNCATEGORISED))) {
CategoryDefinition cat = categoriesMap.get(catName);
flags.extraCredit = cat != null && Boolean.TRUE.equals(cat.getExtraCredit());
flags.equalWeight = cat != null && Boolean.TRUE.equals(cat.getEqualWeight());
}

return flags;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,11 @@
}
.gb-flag-equal-weight:before {
content: '\2696';
color:var(--sakai-color-gold--darker-1);
}
.gb-flag-extra-credit:before {
content: '\f0fe';
}
#gradeTableWrapper .gb-notification.gb-flag-extra-credit:before {
color:var(--sakai-color-gold--darker-1);
}
#gradeTableWrapper .gb-excused {
Expand Down
5 changes: 5 additions & 0 deletions gradebookng/tool/src/webapp/styles/gradebook-grades.css
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,11 @@ div.wicket-modal .w_blue div.w_content
.gb-summary-grade-panel .gb-summary-category-toggle:active {
text-decoration: none;
display: flex;
flex-grow: 2;
}
.gb-summary-grade-panel .gb-summary-category-toggle-container {
display: flex;
justify-content: space-between;
}
.gb-summary-grade-title {
font-weight: normal;
Expand Down

0 comments on commit 8c4c8ae

Please sign in to comment.