From d7781e923e72e51a99cfb8a91a18780e094f7fe6 Mon Sep 17 00:00:00 2001 From: "Code Hugger (Matthew Jones)" Date: Tue, 26 Apr 2022 11:50:40 -0400 Subject: [PATCH] Fixes #101 (#102) Update for 23-SNAPSHOT Update to GradingService Removing unused continueButton that gives an error in wicket debug mode --- api/pom.xml | 2 +- .../api/AttendanceGradebookProvider.java | 10 +- impl/pom.xml | 10 +- .../impl/AttendanceGradebookProviderImpl.java | 101 ++++++++---------- pack/pom.xml | 2 +- pack/src/webapp/WEB-INF/components.xml | 2 +- pom.xml | 2 +- tool/pom.xml | 2 +- .../attendance/tool/pages/ExportPage.java | 1 - .../tool/panels/AttendanceGradeFormPanel.java | 5 +- 10 files changed, 57 insertions(+), 80 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index f7a2900a..16a6776a 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -20,7 +20,7 @@ attendance org.sakaiproject.attendance - 22-SNAPSHOT + 23-SNAPSHOT attendance - API diff --git a/api/src/java/org/sakaiproject/attendance/api/AttendanceGradebookProvider.java b/api/src/java/org/sakaiproject/attendance/api/AttendanceGradebookProvider.java index 61ac187f..058b7e5c 100644 --- a/api/src/java/org/sakaiproject/attendance/api/AttendanceGradebookProvider.java +++ b/api/src/java/org/sakaiproject/attendance/api/AttendanceGradebookProvider.java @@ -52,15 +52,7 @@ public interface AttendanceGradebookProvider { */ boolean sendToGradebook(AttendanceGrade ag); - /** - * Returns if a Gradebook has been Defined in a site - * @param gbUID - * @return - */ - boolean isGradebookDefined(String gbUID); - - /** - * Returns if gradebook has an assignment defined with the provided title + /**assignment defined with the provided title * @param gbUID * @param title * @return diff --git a/impl/pom.xml b/impl/pom.xml index 67151a13..de149962 100644 --- a/impl/pom.xml +++ b/impl/pom.xml @@ -20,7 +20,7 @@ attendance org.sakaiproject.attendance - 22-SNAPSHOT + 23-SNAPSHOT attendance - Implementation @@ -90,10 +90,10 @@ org.sakaiproject.genericdao generic-dao - - org.sakaiproject.edu-services.gradebook - gradebook-service-api - + + org.sakaiproject.grading + sakai-grading-api + diff --git a/impl/src/java/org/sakaiproject/attendance/impl/AttendanceGradebookProviderImpl.java b/impl/src/java/org/sakaiproject/attendance/impl/AttendanceGradebookProviderImpl.java index 8ee9b565..93ea60e7 100644 --- a/impl/src/java/org/sakaiproject/attendance/impl/AttendanceGradebookProviderImpl.java +++ b/impl/src/java/org/sakaiproject/attendance/impl/AttendanceGradebookProviderImpl.java @@ -24,9 +24,9 @@ import org.sakaiproject.attendance.model.AttendanceGrade; import org.sakaiproject.attendance.model.AttendanceSite; import org.sakaiproject.attendance.util.AttendanceConstants; -import org.sakaiproject.service.gradebook.shared.AssessmentNotFoundException; -import org.sakaiproject.service.gradebook.shared.ConflictingAssignmentNameException; -import org.sakaiproject.service.gradebook.shared.GradebookExternalAssessmentService; +import org.sakaiproject.grading.api.AssessmentNotFoundException; +import org.sakaiproject.grading.api.ConflictingAssignmentNameException; +import org.sakaiproject.grading.api.GradingService; import org.sakaiproject.tool.api.Tool; import org.sakaiproject.tool.api.ToolManager; @@ -42,7 +42,7 @@ public class AttendanceGradebookProviderImpl implements AttendanceGradebookProvi @Setter private AttendanceLogic attendanceLogic; @Setter private SakaiProxy sakaiProxy; @Setter private ToolManager toolManager; - @Setter private GradebookExternalAssessmentService gbExtAssesService; + @Setter private GradingService gradingService; /** * {@inheritDoc} @@ -63,24 +63,22 @@ public boolean create(AttendanceSite aS) { String siteID = aS.getSiteID(); - if(isGradebookDefined(siteID)) { - Tool tool = toolManager.getCurrentTool(); - String appName = AttendanceConstants.TOOL_NAME; - if(tool != null ) { - appName = tool.getTitle(); + Tool tool = toolManager.getCurrentTool(); + String appName = AttendanceConstants.TOOL_NAME; + if(tool != null ) { + appName = tool.getTitle(); - } + } - String aSUID = getAttendanceUID(aS); - try { - gbExtAssesService.addExternalAssessment(siteID, aSUID, null, aS.getGradebookItemName(), aS.getMaximumGrade(), null, appName, null, false, null);// add it to the gradebook + String aSUID = getAttendanceUID(aS); + try { + gradingService.addExternalAssessment(siteID, aSUID, null, aS.getGradebookItemName(), aS.getMaximumGrade(), null, appName, null, false, null);// add it to the gradebook - Map scores = attendanceLogic.getAttendanceGradeScores(); - gbExtAssesService.updateExternalAssessmentScoresString(siteID, aSUID, scores); - returnVal = true; - } catch (Exception e) { - log.warn("Error creating external GB", e); - } + Map scores = attendanceLogic.getAttendanceGradeScores(); + gradingService.updateExternalAssessmentScoresString(siteID, aSUID, scores); + returnVal = true; + } catch (Exception e) { + log.warn("Error creating external GB", e); } return returnVal; @@ -94,12 +92,14 @@ public boolean remove(AttendanceSite aS) { log.debug("remove GB for AS " + aS.getSiteID()); } - if(isGradebookDefined(aS.getSiteID())) { + String siteID = aS.getSiteID(); + String aUID = getAttendanceUID(aS); + if(gradingService.isExternalAssignmentDefined(siteID, aUID)) { try { - gbExtAssesService.removeExternalAssessment(aS.getSiteID(), getAttendanceUID(aS)); + gradingService.removeExternalAssignment(siteID, aUID); return true; } catch (AssessmentNotFoundException e) { - log.warn("Attempted to remove AttendanceSite " + aS.getSiteID() + " from GB failed. Assessment not found", e); + log.warn("Attempted to remove AttendanceSite " + siteID + " from GB failed. Assessment not found", e); return false; } } @@ -115,16 +115,14 @@ public boolean update(AttendanceSite aS) { } String siteID = aS.getSiteID(); - if(isGradebookDefined(siteID)) { - String aUID = getAttendanceUID(aS); - if(isAssessmentDefined(siteID, aUID)){ - try { - gbExtAssesService.updateExternalAssessment(siteID, aUID, null, null, aS.getGradebookItemName(), aS.getMaximumGrade(), null, false); + String aUID = getAttendanceUID(aS); + if(gradingService.isExternalAssignmentDefined(siteID, aUID)) { + try { + gradingService.updateExternalAssessment(siteID, aUID, null, null, aS.getGradebookItemName(), aS.getMaximumGrade(), null, false); return true; - } catch (ConflictingAssignmentNameException e) { - log.warn("Failed to update AttendanceSite for site " + siteID + " in Gradebook", e); - return false; - } + } catch (ConflictingAssignmentNameException e) { + log.warn("Failed to update AttendanceSite for site " + siteID + " in Gradebook", e); + return false; } } @@ -141,41 +139,30 @@ public boolean sendToGradebook(final AttendanceGrade aG) { final AttendanceSite aS = aG.getAttendanceSite(); final String siteID = aS.getSiteID(); - - // check if there is a gradebook. siteID ~= gradebookUID - if (isGradebookDefined(siteID)) { - String aSUID = getAttendanceUID(aS); - - final Boolean sendToGradebook = aS.getSendToGradebook(); - if(sendToGradebook != null && sendToGradebook) { - if(isAssessmentDefined(siteID, aSUID)) { - // exists, update current grade - String grade = aG.getGrade() == null ? null : aG.getGrade().toString(); - gbExtAssesService.updateExternalAssessmentScore(siteID, aSUID, aG.getUserID(), grade); - return true; - } else { - //does not exist, add to GB and add all grades - return create(aS); - } + String aSUID = getAttendanceUID(aS); + + + final Boolean sendToGradebook = aS.getSendToGradebook(); + if(sendToGradebook != null && sendToGradebook) { + if(isAssessmentDefined(siteID, aSUID)) { + // exists, update current grade + String grade = aG.getGrade() == null ? null : aG.getGrade().toString(); + gradingService.updateExternalAssessmentScore(siteID, aSUID, aG.getUserID(), grade); + return true; + } else { + //does not exist, add to GB and add all grades + return create(aS); } } return false; } - /** - * {@inheritDoc} - */ - public boolean isGradebookDefined(String gbUID) { - // siteID should be equivalent to GradebookUID - return gbExtAssesService.isGradebookDefined(gbUID); - } - /** * {@inheritDoc} */ public boolean isGradebookAssignmentDefined(String gbUID, String title) { - return gbExtAssesService.isAssignmentDefined(gbUID, title); + return gradingService.isAssignmentDefined(gbUID, title); } /** @@ -186,7 +173,7 @@ public boolean isAssessmentDefined(String gbUID, Long aSID) { } private boolean isAssessmentDefined(String gbUID, String id) { - return gbExtAssesService.isExternalAssignmentDefined(gbUID, id); + return gradingService.isExternalAssignmentDefined(gbUID, id); } //this is hacky diff --git a/pack/pom.xml b/pack/pom.xml index 9964f646..489d27d2 100644 --- a/pack/pom.xml +++ b/pack/pom.xml @@ -20,7 +20,7 @@ attendance org.sakaiproject.attendance - 22-SNAPSHOT + 23-SNAPSHOT attendance - Components diff --git a/pack/src/webapp/WEB-INF/components.xml b/pack/src/webapp/WEB-INF/components.xml index 6ea9cbb6..0e821185 100644 --- a/pack/src/webapp/WEB-INF/components.xml +++ b/pack/src/webapp/WEB-INF/components.xml @@ -83,7 +83,7 @@ - + diff --git a/pom.xml b/pom.xml index 7e26c749..19d67c95 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ org.sakaiproject master - 22-SNAPSHOT + 23-SNAPSHOT diff --git a/tool/pom.xml b/tool/pom.xml index c5da43cd..d4f06826 100644 --- a/tool/pom.xml +++ b/tool/pom.xml @@ -22,7 +22,7 @@ attendance org.sakaiproject.attendance - 22-SNAPSHOT + 23-SNAPSHOT attendance - Tool diff --git a/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.java b/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.java index cad7be17..e7f67118 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/pages/ExportPage.java @@ -281,7 +281,6 @@ public UploadForm(final String id) { this.fileUploadField = new FileUploadField("upload"); add(this.fileUploadField); - add(new Button("continuebutton")); SubmitLink submit = new SubmitLink("submitLink"); add(submit); } diff --git a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradeFormPanel.java b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradeFormPanel.java index 50de7bb7..1c1d8f4f 100644 --- a/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradeFormPanel.java +++ b/tool/src/java/org/sakaiproject/attendance/tool/panels/AttendanceGradeFormPanel.java @@ -174,7 +174,6 @@ public boolean isVisible() { gradebook.add(gradebookItemName); grading.add(gradebook); - final boolean gradebookDefined = attendanceGradebookProvider.isGradebookDefined(aS.getSiteID()); final AjaxCheckBox sendToGradebook = new AjaxCheckBox("sendToGradebook") { @Override protected void onUpdate(AjaxRequestTarget target) { @@ -183,14 +182,14 @@ protected void onUpdate(AjaxRequestTarget target) { @Override public boolean isVisible() { - return gradebookDefined; + return true; } }; Label sendToGBLabel = new Label("send-to-gradebook", new ResourceModel("attendance.settings.grading.send.to.gradebook")) { @Override public boolean isVisible() { - return gradebookDefined; + return true; } }; grading.add(sendToGradebook);