Skip to content

Commit

Permalink
Fixes #101 (#102)
Browse files Browse the repository at this point in the history
Update for 23-SNAPSHOT
Update to GradingService
Removing unused continueButton that gives an error in wicket debug mode
  • Loading branch information
jonespm authored Apr 26, 2022
1 parent 622762b commit d7781e9
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 80 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>attendance</artifactId>
<groupId>org.sakaiproject.attendance</groupId>
<version>22-SNAPSHOT</version>
<version>23-SNAPSHOT</version>
</parent>

<name>attendance - API</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>attendance</artifactId>
<groupId>org.sakaiproject.attendance</groupId>
<version>22-SNAPSHOT</version>
<version>23-SNAPSHOT</version>
</parent>

<name>attendance - Implementation</name>
Expand Down Expand Up @@ -90,10 +90,10 @@
<groupId>org.sakaiproject.genericdao</groupId>
<artifactId>generic-dao</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.edu-services.gradebook</groupId>
<artifactId>gradebook-service-api</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.grading</groupId>
<artifactId>sakai-grading-api</artifactId>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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}
Expand All @@ -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<String, String> scores = attendanceLogic.getAttendanceGradeScores();
gbExtAssesService.updateExternalAssessmentScoresString(siteID, aSUID, scores);
returnVal = true;
} catch (Exception e) {
log.warn("Error creating external GB", e);
}
Map<String, String> scores = attendanceLogic.getAttendanceGradeScores();
gradingService.updateExternalAssessmentScoresString(siteID, aSUID, scores);
returnVal = true;
} catch (Exception e) {
log.warn("Error creating external GB", e);
}

return returnVal;
Expand All @@ -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;
}
}
Expand All @@ -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;
}
}

Expand All @@ -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);
}

/**
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pack/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>attendance</artifactId>
<groupId>org.sakaiproject.attendance</groupId>
<version>22-SNAPSHOT</version>
<version>23-SNAPSHOT</version>
</parent>

<name>attendance - Components</name>
Expand Down
2 changes: 1 addition & 1 deletion pack/src/webapp/WEB-INF/components.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<property name="attendanceLogic" ref="org.sakaiproject.attendance.logic.AttendanceLogic" />
<property name="sakaiProxy" ref="org.sakaiproject.attendance.logic.SakaiProxy" />
<property name="toolManager" ref="org.sakaiproject.tool.api.ToolManager" />
<property name="gbExtAssesService" ref="org.sakaiproject.service.gradebook.GradebookExternalAssessmentService" />
<property name="gradingService" ref="org.sakaiproject.grading.api.GradingService" />
</bean>

<!-- Add our HBM files to the Sakai global session factory -->
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<parent>
<groupId>org.sakaiproject</groupId>
<artifactId>master</artifactId>
<version>22-SNAPSHOT</version>
<version>23-SNAPSHOT</version>
</parent>

<developers>
Expand Down
2 changes: 1 addition & 1 deletion tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>attendance</artifactId>
<groupId>org.sakaiproject.attendance</groupId>
<version>22-SNAPSHOT</version>
<version>23-SNAPSHOT</version>
</parent>

<name>attendance - Tool</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit d7781e9

Please sign in to comment.