From e9414915d905cedb2b8011ffefbab52ec4c8ee0d Mon Sep 17 00:00:00 2001 From: Sam Ottenhoff Date: Mon, 22 Apr 2024 14:12:56 -0400 Subject: [PATCH] SAK-49989 Gradebook upgrade wicket 6 to wicket 9 (#12513) Co-authored-by: Code Hugger (Matthew Jones) https://sakaiproject.atlassian.net/browse/SAK-49989 --- gradebookng/pom.xml | 2 +- gradebookng/tool/pom.xml | 4 +- .../gradebookng/GradebookNgApplication.java | 21 +-- .../business/GradebookNgBusinessService.java | 2 +- .../gradebookng/business/model/GbGroup.java | 66 ++----- .../business/util/CourseGradeFormatter.java | 6 +- .../business/util/FormatHelper.java | 20 +- .../GradebookNgStringResourceLoader.java | 9 +- .../tool/actions/ViewGradeSummaryAction.java | 4 +- .../tool/chart/AssignmentGradeChart.java | 20 +- .../tool/component/GbGradeTable.java | 1 + .../tool/model/GbGradebookData.java | 4 +- .../gradebookng/tool/pages/BasePage.html | 3 +- .../gradebookng/tool/pages/ErrorPage.java | 2 +- .../gradebookng/tool/pages/GradebookPage.html | 3 +- .../gradebookng/tool/pages/GradebookPage.java | 29 +-- .../tool/pages/PermissionsPage.html | 1 + .../tool/pages/PermissionsPage.java | 26 +-- .../tool/pages/QuickEntryPage.html | 12 +- .../tool/pages/QuickEntryPage.java | 73 ++++---- .../gradebookng/tool/pages/SettingsPage.java | 6 +- .../gradebookng/tool/pages/StudentPage.java | 2 +- .../tool/panels/AddOrEditGradeItemPanel.java | 12 +- .../AddOrEditGradeItemPanelContent.java | 16 +- .../panels/AssignmentStatisticsPanel.java | 2 +- .../tool/panels/BulkEditItemsPanel.html | 24 ++- .../tool/panels/BulkEditItemsPanel.java | 20 +- .../panels/CourseGradeBreakdownPanel.java | 4 +- .../panels/CourseGradeOverrideLogPanel.java | 12 +- .../tool/panels/CourseGradeOverridePanel.java | 13 +- .../tool/panels/DeleteItemPanel.java | 10 +- .../panels/EditCourseGradeCommentPanel.java | 22 +-- .../tool/panels/EditGradeCommentPanel.java | 32 ++-- .../tool/panels/GradeLogPanel.java | 11 +- .../tool/panels/GradeSummaryTablePanel.html | 3 +- .../tool/panels/GradeSummaryTablePanel.java | 22 +-- .../tool/panels/RubricGradePanel.java | 10 +- .../tool/panels/RubricPreviewPanel.java | 4 +- .../tool/panels/SettingsCategoryPanel.html | 7 +- .../tool/panels/SettingsCategoryPanel.java | 19 +- .../tool/panels/SettingsGradeEntryPanel.java | 7 +- .../panels/SettingsGradeReleasePanel.html | 3 +- .../panels/SettingsGradeReleasePanel.java | 2 +- .../panels/SettingsGradingSchemaPanel.java | 21 +-- .../tool/panels/SettingsStatisticsPanel.html | 1 + .../tool/panels/SortGradeItemsPanel.java | 43 ++--- .../StudentAssignmentStatisticsPanel.java | 4 +- .../panels/StudentCompareGradesPanel.java | 2 +- .../tool/panels/StudentGradeSummaryPanel.html | 3 +- .../tool/panels/StudentGradeSummaryPanel.java | 33 ++-- .../panels/ToggleGradeItemsToolbarPanel.html | 9 +- .../panels/ToggleGradeItemsToolbarPanel.java | 6 +- .../tool/panels/UpdateUngradedItemsPanel.html | 3 +- .../tool/panels/UpdateUngradedItemsPanel.java | 27 +-- .../tool/panels/ZeroUngradedItemsPanel.java | 4 +- .../importExport/CreateGradeItemStep.java | 17 +- .../tool/panels/importExport/ExportPanel.java | 13 +- .../GradeImportConfirmationStep.java | 6 +- .../importExport/GradeImportUploadStep.java | 12 +- .../GradeItemImportOmissionsPanel.java | 6 +- .../GradeItemImportSelectionStep.java | 6 +- .../PreviewImportedGradesPanel.java | 4 +- .../webapp/scripts/gradebook-quick-entry.js | 12 +- master/pom.xml | 5 + wicket/pom.xml | 1 + wicket/wicket6/pom.xml | 2 +- wicket/wicket9/pom.xml | 41 ++++ .../AbstractSakaiSpinnerAjaxCallListener.java | 44 +++++ .../wicket/component/SakaiAjaxButton.java | 62 ++++++ .../wicket/component/SakaiDateTimeField.java | 176 ++++++++++++++++++ .../component/SakaiDateTimeField.properties | 2 + .../SakaiDateTimeField_ar.properties | 1 + .../SakaiDateTimeField_bg.properties | 1 + .../SakaiDateTimeField_ca.properties | 2 + .../SakaiDateTimeField_es.properties | 2 + .../SakaiDateTimeField_eu.properties | 2 + .../SakaiDateTimeField_ro_RO.properties | 1 + .../SakaiDateTimeField_sr.properties | 1 + .../SakaiDateTimeField_tr_TR.properties | 1 + .../SakaiSpinnerAjaxCallListener.java | 58 ++++++ 80 files changed, 767 insertions(+), 438 deletions(-) create mode 100644 wicket/wicket9/pom.xml create mode 100644 wicket/wicket9/src/java/org/sakaiproject/wicket/component/AbstractSakaiSpinnerAjaxCallListener.java create mode 100644 wicket/wicket9/src/java/org/sakaiproject/wicket/component/SakaiAjaxButton.java create mode 100644 wicket/wicket9/src/java/org/sakaiproject/wicket/component/SakaiDateTimeField.java create mode 100644 wicket/wicket9/src/java/org/sakaiproject/wicket/component/SakaiDateTimeField.properties create mode 100644 wicket/wicket9/src/java/org/sakaiproject/wicket/component/SakaiDateTimeField_ar.properties create mode 100644 wicket/wicket9/src/java/org/sakaiproject/wicket/component/SakaiDateTimeField_bg.properties create mode 100644 wicket/wicket9/src/java/org/sakaiproject/wicket/component/SakaiDateTimeField_ca.properties create mode 100644 wicket/wicket9/src/java/org/sakaiproject/wicket/component/SakaiDateTimeField_es.properties create mode 100644 wicket/wicket9/src/java/org/sakaiproject/wicket/component/SakaiDateTimeField_eu.properties create mode 100644 wicket/wicket9/src/java/org/sakaiproject/wicket/component/SakaiDateTimeField_ro_RO.properties create mode 100644 wicket/wicket9/src/java/org/sakaiproject/wicket/component/SakaiDateTimeField_sr.properties create mode 100644 wicket/wicket9/src/java/org/sakaiproject/wicket/component/SakaiDateTimeField_tr_TR.properties create mode 100644 wicket/wicket9/src/java/org/sakaiproject/wicket/component/SakaiSpinnerAjaxCallListener.java diff --git a/gradebookng/pom.xml b/gradebookng/pom.xml index baaa4c86062b..e28af9c818a2 100644 --- a/gradebookng/pom.xml +++ b/gradebookng/pom.xml @@ -14,7 +14,7 @@ UTF-8 - 6.30.0 + 9.17.0 diff --git a/gradebookng/tool/pom.xml b/gradebookng/tool/pom.xml index 5620837215ee..75afa9212f00 100644 --- a/gradebookng/tool/pom.xml +++ b/gradebookng/tool/pom.xml @@ -80,7 +80,7 @@ org.sakaiproject.wicket - wicket-tool-6 + wicket-tool-9 org.apache.commons @@ -160,7 +160,7 @@ chartjs 2.7.0 - + src/java src/webapp diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.java index 7297c09a91ac..4061ce6c5f12 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/GradebookNgApplication.java @@ -19,10 +19,9 @@ import org.apache.wicket.core.request.handler.RenderPageRequestHandler; import org.apache.wicket.protocol.http.WebApplication; import org.apache.wicket.request.IRequestHandler; -import org.apache.wicket.request.cycle.AbstractRequestCycleListener; import org.apache.wicket.request.cycle.RequestCycle; import org.apache.wicket.request.resource.PackageResourceReference; -import org.apache.wicket.settings.IRequestCycleSettings.RenderStrategy; +import org.apache.wicket.settings.RequestCycleSettings.RenderStrategy; import org.apache.wicket.spring.injection.annot.SpringComponentInjector; import org.sakaiproject.gradebookng.framework.GradebookNgStringResourceLoader; @@ -55,6 +54,9 @@ public void init() { mountPage("/accessdenied", AccessDeniedPage.class); mountPage("/error", ErrorPage.class); + // Allow Sakai portal to handle CSP + getCspSettings().blocking().disabled(); + // remove the version number from the URL so that browser refreshes re-render the page getRequestCycleSettings().setRenderStrategy(RenderStrategy.ONE_PASS_RENDER); @@ -70,21 +72,6 @@ public void init() { // Remove the wicket specific tags from the generated markup getMarkupSettings().setStripWicketTags(true); - // Don't add any extra tags around a disabled link (default is ) - getMarkupSettings().setDefaultBeforeDisabledLink(null); - getMarkupSettings().setDefaultAfterDisabledLink(null); - - // On Wicket session timeout, redirect to main page - // getApplicationSettings().setPageExpiredErrorPage(getHomePage()); - - // Intercept any unexpected error stacktrace and take to our page - getRequestCycleListeners().add(new AbstractRequestCycleListener() { - @Override - public IRequestHandler onException(final RequestCycle cycle, final Exception e) { - return new RenderPageRequestHandler(new PageProvider(new ErrorPage(e))); - } - }); - // Disable Wicket's loading of jQuery - we load Sakai's preferred version in BasePage.java getJavaScriptLibrarySettings().setJQueryReference(new PackageResourceReference(GradebookNgApplication.class, "empty.js")); diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/GradebookNgBusinessService.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/GradebookNgBusinessService.java index 11b86f8a624e..4300c3d9b78c 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/GradebookNgBusinessService.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/GradebookNgBusinessService.java @@ -1791,7 +1791,7 @@ public List sortGradeMatrix(Map /** * Get a list of sections and groups in a site * - * @return + * @return a list of sections and groups in the current site */ public List getSiteSectionsAndGroups() { final String siteId = getCurrentSiteId(); diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/model/GbGroup.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/model/GbGroup.java index 7a1d2cf5c574..1667e459fbd7 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/model/GbGroup.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/model/GbGroup.java @@ -16,11 +16,11 @@ package org.sakaiproject.gradebookng.business.model; import java.io.Serializable; +import java.util.Comparator; -import org.apache.commons.lang3.builder.CompareToBuilder; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; - +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.NonNull; import lombok.Getter; import lombok.ToString; @@ -31,21 +31,17 @@ * */ +@Getter @ToString +@AllArgsConstructor +@EqualsAndHashCode public class GbGroup implements Comparable, Serializable { private static final long serialVersionUID = 1L; - @Getter private final String id; - - @Getter private final String title; - - @Getter private final String reference; - - @Getter private final Type type; /** @@ -57,51 +53,11 @@ public enum Type { ALL; } - public GbGroup(final String id, final String title, final String reference, final Type type) { - this.id = id; - this.title = title; - this.reference = reference; - this.type = type; - } - - @Override - public int compareTo(final GbGroup other) { - return new CompareToBuilder() - .append(this.title, other.getTitle()) - .append(this.type, other.getType()) - .toComparison(); - - } - - @Override - public boolean equals(final Object o) { - if (o == null) { - return false; - } - if (o == this) { - return true; - } - if (o.getClass() != getClass()) { - return false; - } - final GbGroup other = (GbGroup) o; - return new EqualsBuilder() - .appendSuper(super.equals(o)) - .append(this.id, other.id) - .append(this.title, other.title) - .append(this.reference, other.reference) - .append(this.type, other.type) - .isEquals(); - } - @Override - public int hashCode() { - return new HashCodeBuilder() - .append(this.id) - .append(this.title) - .append(this.reference) - .append(this.type) - .toHashCode(); + public int compareTo(final @NonNull GbGroup other) { + return Comparator.comparing(GbGroup::getTitle) + .thenComparing(GbGroup::getType) + .compare(this, other); } } diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/util/CourseGradeFormatter.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/util/CourseGradeFormatter.java index d213165a0bad..207a6c5fefa2 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/util/CourseGradeFormatter.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/util/CourseGradeFormatter.java @@ -141,11 +141,9 @@ private String build(final CourseGradeTransferBean courseGrade) { if (StringUtils.isNotBlank(calculatedGrade) && (this.gradebook.getCourseAverageDisplayed() || shouldDisplayFullCourseGrade())) { if (parts.isEmpty()) { - parts.add(new StringResourceModel("coursegrade.display.percentage-first", null, - new Object[] { calculatedGrade }).getString()); + parts.add(new StringResourceModel("coursegrade.display.percentage-first").setParameters(calculatedGrade).getString()); } else { - parts.add(new StringResourceModel("coursegrade.display.percentage-second", null, - new Object[] { calculatedGrade }).getString()); + parts.add(new StringResourceModel("coursegrade.display.percentage-second").setParameters(calculatedGrade).getString()); } } diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/util/FormatHelper.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/util/FormatHelper.java index 6d7d1d343444..7d4f5cbf03b6 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/util/FormatHelper.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/business/util/FormatHelper.java @@ -272,18 +272,6 @@ public static String formatDate(final Date date, final String ifNull) { return formatDate(date); } - /** - * Format a date with a time e.g. MM/dd/yyyy HH:mm - * - * @param date - * @return - */ - public static String formatDateTime(final Date date) { - final String dateTimeFormatString = MessageHelper.getString("format.datetime"); - final SimpleDateFormat df = new SimpleDateFormat(dateTimeFormatString); - return df.format(date); - } - /** * Strips out line breaks * @@ -407,8 +395,8 @@ public static String htmlUnescape(String input){ * @return fully formatted string ready for display */ public static String getGradeFromNumber(String newGrade, Map schema, Locale currentUserLocale) { - Double currentGradeValue = new Double(0.0); - Double maxValue = new Double(0.0); + Double currentGradeValue = 0.0; + Double maxValue = 0.0; String returnGrade = newGrade; try { NumberFormat nf = NumberFormat.getInstance(currentUserLocale); @@ -467,9 +455,9 @@ public static String transformNewGrade(String newGrade, Locale locale) { if (parsePosition.getIndex() != newGrade.length()) { throw new NumberFormatException("Grade has a bad format."); } - Double dValue = n.doubleValue(); + double dValue = n.doubleValue(); - return (dValue.toString()); + return (Double.toString(dValue)); } catch (NumberFormatException e) { diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/framework/GradebookNgStringResourceLoader.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/framework/GradebookNgStringResourceLoader.java index 02bdc7b02b28..bb3626558204 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/framework/GradebookNgStringResourceLoader.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/framework/GradebookNgStringResourceLoader.java @@ -26,7 +26,7 @@ */ public class GradebookNgStringResourceLoader implements IStringResourceLoader { - private ResourceLoader loader = new ResourceLoader("gradebookng"); + private final ResourceLoader loader = new ResourceLoader("gradebookng"); @Override public String loadStringResource(Class clazz, String key, Locale locale, String style, String variation) { @@ -43,6 +43,11 @@ private String loadString(Locale locale, String key) { if (locale != null && sakaiLocale == null) { loader.setContextLocale(locale); } - return loader.getString(key); + // Check the validity first because loader.getString will return a "missing key" string if not found + if (loader.getIsValid(key)) { + return loader.getString(key); + } + // Return null so the Wicket default loader can try to load the string + return null; } } diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/actions/ViewGradeSummaryAction.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/actions/ViewGradeSummaryAction.java index 865f552f9208..e1cc0fa3c7a3 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/actions/ViewGradeSummaryAction.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/actions/ViewGradeSummaryAction.java @@ -71,8 +71,8 @@ public ActionResponse handleEvent(final JsonNode params, final AjaxRequestTarget window.setStudentToReturnFocusTo(studentUuid); content.setOutputMarkupId(true); - final String modalTitle = (new StringResourceModel("heading.studentsummary", - null, new Object[] { student.getDisplayName(), student.getDisplayId() })).getString(); + final String modalTitle = (new StringResourceModel("heading.studentsummary") + .setParameters(student.getDisplayName(), student.getDisplayId())).getString(); window.setTitle(modalTitle); window.show(target); diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/chart/AssignmentGradeChart.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/chart/AssignmentGradeChart.java index 50620b8bc3d6..a39b4ad0644f 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/chart/AssignmentGradeChart.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/chart/AssignmentGradeChart.java @@ -65,18 +65,16 @@ protected GbChartData getData() { // get all grades for this assignment final List allGrades = new ArrayList<>(); - for (int i = 0; i < gradeInfo.size(); i++) { - final GbStudentGradeInfo studentGradeInfo = gradeInfo.get(i); + for (final GbStudentGradeInfo studentGradeInfo : gradeInfo) { + final Map studentGrades = studentGradeInfo.getGrades(); + final GbGradeInfo grade = studentGrades.get(this.assignmentId); - final Map studentGrades = studentGradeInfo.getGrades(); - final GbGradeInfo grade = studentGrades.get(this.assignmentId); + if (grade == null || grade.getGrade() == null) { + continue; + } - if (grade == null || grade.getGrade() == null) { - continue; - } - - allGrades.add(Double.valueOf(grade.getGrade())); - } + allGrades.add(Double.valueOf(grade.getGrade())); + } Collections.sort(allGrades); final GbChartData data = new GbChartData(); @@ -124,7 +122,7 @@ protected GbChartData getData() { * @return eg "0-50" as a string, depending on translation */ private String buildRangeLabel(final int start, final int end) { - return new StringResourceModel("label.statistics.chart.range", null, start, end).getString(); + return new StringResourceModel("label.statistics.chart.range").setParameters(start, end).getString(); } /** diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/component/GbGradeTable.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/component/GbGradeTable.java index 616942714269..ed9fbf583e4d 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/component/GbGradeTable.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/component/GbGradeTable.java @@ -114,6 +114,7 @@ protected void onEvent(final AjaxRequestTarget target) { add(component); } + @Override public void renderHead(final IHeaderResponse response) { final GbGradeTableData gbGradeTableData = (GbGradeTableData) getDefaultModelObject(); diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/model/GbGradebookData.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/model/GbGradebookData.java index bf450aaa7de2..846f906ba2b1 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/model/GbGradebookData.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/model/GbGradebookData.java @@ -591,7 +591,7 @@ private List loadColumns(final List assignments) { && (a2 == null || !a1.getCategoryId().equals(a2.getCategoryId()))) { result.add(new CategoryAverageDefinition(a1.getCategoryId(), FormatHelper.abbreviateMiddle(a1.getCategoryName()), - (new StringResourceModel("label.gradeitem.categoryaverage", null, new Object[] { a1.getCategoryName() })) + (new StringResourceModel("label.gradeitem.categoryaverage").setParameters(a1.getCategoryName())) .getString(), nullable(categoryWeight), getCategoryPoints(a1.getCategoryId()), @@ -617,7 +617,7 @@ private List loadColumns(final List assignments) { result.add(new CategoryAverageDefinition( category.getId(), FormatHelper.abbreviateMiddle(category.getName()), - (new StringResourceModel("label.gradeitem.categoryaverage", null, new Object[] { category.getName() })) + (new StringResourceModel("label.gradeitem.categoryaverage").setParameters(category.getName())) .getString(), nullable(categoryWeight), category.getTotalPoints(), diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/BasePage.html b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/BasePage.html index 6b30360d661c..49964aeba92b 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/BasePage.html +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/BasePage.html @@ -1,3 +1,4 @@ + @@ -55,4 +56,4 @@ - \ No newline at end of file + diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/ErrorPage.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/ErrorPage.java index 172f84780729..bd7ea773cfc4 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/ErrorPage.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/ErrorPage.java @@ -48,7 +48,7 @@ public ErrorPage(final Exception e) { final String code = RandomStringUtils.randomAlphanumeric(10); log.error("User supplied error code for the above stacktrace: {}", code); - final Label error = new Label("error", new StringResourceModel("errorpage.text", null, new Object[] { code })); + final Label error = new Label("error", new StringResourceModel("errorpage.text").setParameters(code)); error.setEscapeModelStrings(false); add(error); diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.html b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.html index ff7ac08729ab..21a1da52569e 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.html +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.html @@ -1,3 +1,4 @@ + @@ -73,7 +74,7 @@
  • - + diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.java index 3b7610525921..9541848839c4 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/GradebookPage.java @@ -155,7 +155,7 @@ public GradebookPage() { // no perms this.permissions = this.businessService.getPermissionsForUser(this.currentUserUuid); if (this.permissions.isEmpty() - || (this.permissions.size() == 1 && StringUtils.equals(((PermissionDefinition) this.permissions.get(0)).getFunctionName(), GraderPermission.NONE.toString()))) { + || (this.permissions.size() == 1 && StringUtils.equals(this.permissions.get(0).getFunctionName(), GraderPermission.NONE.toString()))) { sendToAccessDeniedPage(getString("ta.nopermission")); } } @@ -249,9 +249,6 @@ else if (!this.businessService.isUserAbleToEditAssessments()) { // categories enabled? final boolean categoriesEnabled = this.businessService.categoriesAreEnabled(); - // grading type? - final Integer gradingType = gradebook.getGradeType(); - this.tableArea = new WebMarkupContainer("gradeTableArea"); if (!this.hasGradebookItems) { this.tableArea.add(AttributeModifier.append("class", "gradeTableArea")); @@ -335,7 +332,7 @@ protected void onInitialize() { } @Override - public void onSubmit(AjaxRequestTarget target, Form form) { + public void onSubmit(AjaxRequestTarget target) { settings.setGroupedByCategory(!settings.isGroupedByCategory()); setUiSettings(settings, true); @@ -351,7 +348,7 @@ public boolean isVisible() { toolbarColumnTools.add(toggleCategoriesToolbarItem); // sort grade items button - final GbAjaxLink sortGradeItemsToolbarItem = new GbAjaxLink("sortGradeItemsToolbarItem") { + final GbAjaxLink sortGradeItemsToolbarItem = new GbAjaxLink<>("sortGradeItemsToolbarItem") { @Override public void onClick(final AjaxRequestTarget target) { final GbModalWindow window = GradebookPage.this.getSortGradeItemsWindow(); @@ -374,7 +371,7 @@ public boolean isVisible() { toolbarColumnTools.add(sortGradeItemsToolbarItem); // bulk edit items button - final GbAjaxLink bulkEditItemsToolbarItem = new GbAjaxLink("bulkEditItemsToolbarItem") { + final GbAjaxLink bulkEditItemsToolbarItem = new GbAjaxLink<>("bulkEditItemsToolbarItem") { @Override public void onClick(final AjaxRequestTarget target) { final GbModalWindow window = GradebookPage.this.getBulkEditItemsWindow(); @@ -433,10 +430,10 @@ public boolean isVisible() { allGroupsTitle = getString("groups.available"); } } - groups.add(0, new GbGroup(null, allGroupsTitle, null, GbGroup.Type.ALL)); + groups.add(0, new GbGroup("allGroups", allGroupsTitle, null, GbGroup.Type.ALL)); } - final DropDownChoice groupFilter = new DropDownChoice("groupFilter", new Model(), + final DropDownChoice groupFilter = new DropDownChoice<>("groupFilter", new Model<>(), groups, new ChoiceRenderer() { private static final long serialVersionUID = 1L; @@ -449,14 +446,11 @@ public Object getDisplayValue(final GbGroup g) { public String getIdValue(final GbGroup g, final int index) { return g.getId(); } - }); - groupFilter.add(new AjaxFormComponentUpdatingBehavior("onchange") { - + groupFilter.add(new AjaxFormComponentUpdatingBehavior("change") { @Override protected void onUpdate(final AjaxRequestTarget target) { - final GbGroup selected = (GbGroup) groupFilter.getDefaultModelObject(); // store selected group (null ok) @@ -467,7 +461,6 @@ protected void onUpdate(final AjaxRequestTarget target) { // refresh setResponsePage(GradebookPage.class); } - }); // set selected group, or first item in list @@ -575,7 +568,7 @@ public GradebookUiSettings getUiSettings() { // See if the user has a database-persisted preference for Group by Category String userGbUiCatPref = this.businessService.getUserGbPreference("GROUP_BY_CAT"); if (StringUtils.isNotBlank(userGbUiCatPref)) { - settings.setGroupedByCategory(Boolean.valueOf(userGbUiCatPref)); + settings.setGroupedByCategory(Boolean.parseBoolean(userGbUiCatPref)); } return settings; @@ -663,12 +656,8 @@ public GbAddButton(final String id) { super(id); } - public GbAddButton(final String id, final Form form) { - super(id, form); - } - @Override - public void onSubmit(final AjaxRequestTarget target, final Form form) { + public void onSubmit(final AjaxRequestTarget target) { final GbModalWindow window = getAddOrEditGradeItemWindow(); window.setTitle(getString("heading.addgradeitem")); window.setComponentToReturnFocusTo(this); diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/PermissionsPage.html b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/PermissionsPage.html index c76896fefe8a..f84d8968cac4 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/PermissionsPage.html +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/PermissionsPage.html @@ -1,3 +1,4 @@ + diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/PermissionsPage.java b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/PermissionsPage.java index de5cbe4bf81c..c09f83b1ed0d 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/PermissionsPage.java +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/PermissionsPage.java @@ -17,7 +17,6 @@ import java.io.Serializable; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.Iterator; import java.util.LinkedHashMap; @@ -28,7 +27,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.markup.head.IHeaderResponse; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.Button; @@ -46,7 +44,6 @@ import org.sakaiproject.gradebookng.business.model.GbGroup; import org.sakaiproject.gradebookng.business.model.GbUser; import org.sakaiproject.gradebookng.tool.component.GbAjaxButton; -import org.sakaiproject.portal.util.PortalUtils; import org.sakaiproject.grading.api.CategoryDefinition; import org.sakaiproject.grading.api.GraderPermission; import org.sakaiproject.grading.api.PermissionDefinition; @@ -70,7 +67,7 @@ public class PermissionsPage extends BasePage { // they should not conflict with any real values that might be passed in // and they are parsed out on save private final String ALL_GROUPS = "-1"; - private final Long ALL_CATEGORIES = new Long(-1); + private final Long ALL_CATEGORIES = (long) -1; public PermissionsPage() { @@ -150,8 +147,8 @@ public void onInitialize() { @Override public Object getDisplayValue(final GbUser u) { - return new StringResourceModel("permissionspage.label.tausername", null, - new Object[] { u.getSortName(), u.getDisplayId() }).getString(); + return new StringResourceModel("permissionspage.label.tausername") + .setParameters(u.getSortName(), u.getDisplayId()).getString(); } @Override @@ -167,7 +164,7 @@ public String getIdValue(final GbUser u, final int index) { } // add the onchange to the chooser - taChooser.add(new AjaxFormComponentUpdatingBehavior("onchange") { + taChooser.add(new AjaxFormComponentUpdatingBehavior("change") { private static final long serialVersionUID = 1L; @Override @@ -229,8 +226,7 @@ public boolean isVisible() { add(noPermissions); // FORM - @SuppressWarnings({ "rawtypes", "unchecked" }) - final Form form = new Form("form", Model.of(pageModel)) { + final Form form = new Form<>("form", Model.of(pageModel)) { private static final long serialVersionUID = 1L; @Override @@ -432,7 +428,7 @@ public String getIdValue(final String groupRef, final int index) { private static final long serialVersionUID = 1L; @Override - public void onSubmit(final AjaxRequestTarget target, final Form form) { + public void onSubmit(final AjaxRequestTarget target) { // remove current item final PermissionDefinition current = item.getModelObject(); @@ -459,7 +455,7 @@ public boolean isVisible() { private static final long serialVersionUID = 1L; @Override - public void onSubmit(final AjaxRequestTarget target, final Form form) { + public void onSubmit(final AjaxRequestTarget target) { // add a new entry with default values so the dropdowns are sane final PermissionDefinition newDef = new PermissionDefinition(); @@ -497,16 +493,14 @@ private void refreshPage(String userUUID) { /** * Class for wrapping up the data used by this page */ - private class PermissionsPageModel implements Serializable { + @Setter + @Getter + private class PermissionsPageModel implements Serializable { private static final long serialVersionUID = 1L; - @Getter - @Setter private List permissions; - @Getter - @Setter private Boolean viewCourseGrade; public PermissionsPageModel() { diff --git a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/QuickEntryPage.html b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/QuickEntryPage.html index 346b66508172..17b45e287e3f 100644 --- a/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/QuickEntryPage.html +++ b/gradebookng/tool/src/java/org/sakaiproject/gradebookng/tool/pages/QuickEntryPage.html @@ -6,7 +6,7 @@

    -
    +

    @@ -45,7 +45,7 @@

    -