diff --git a/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/CategoryDefinition.java b/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/CategoryDefinition.java index 4998c812e10f..05d934e24a5a 100644 --- a/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/CategoryDefinition.java +++ b/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/CategoryDefinition.java @@ -33,6 +33,10 @@ public class CategoryDefinition { private Long id; private String name; private Double weight; + private Integer drop_lowest; + private Integer dropHighest; + private Integer keepHighest; + private List assignmentList; /** @@ -106,4 +110,28 @@ public List getAssignmentList() { public void setAssignmentList(List assignmentList) { this.assignmentList = assignmentList; } + + public Integer getDrop_lowest() { + return drop_lowest; + } + + public void setDrop_lowest(Integer drop_lowest) { + this.drop_lowest = drop_lowest; + } + + public Integer getDropHighest() { + return dropHighest; + } + + public void setDropHighest(Integer dropHighest) { + this.dropHighest = dropHighest; + } + + public Integer getKeepHighest() { + return keepHighest; + } + + public void setKeepHighest(Integer keepHighest) { + this.keepHighest = keepHighest; + } } diff --git a/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/GradebookInformation.java b/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/GradebookInformation.java new file mode 100644 index 000000000000..c11a3812fcb9 --- /dev/null +++ b/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/GradebookInformation.java @@ -0,0 +1,92 @@ +/********************************************************************************** +* +* $Id$ +* +*********************************************************************************** +* + * Copyright (c) 2014 The Sakai Foundation + * + * Licensed under the Educational Community License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.opensource.org/licenses/ECL-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +* +**********************************************************************************/ + +package org.sakaiproject.service.gradebook.shared; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +public class GradebookInformation { + private String selectedGradingScaleUid; + private Map selectedGradingScaleBottomPercents; + private Collection assignments; + private boolean displayReleasedGradeItemsToStudents; + + private int gradeType; + private int categoryType; + private List category; + private String gradeScale; + + + public String getSelectedGradingScaleUid() { + return selectedGradingScaleUid; + } + public void setSelectedGradingScaleUid(String selectedGradingScaleUid) { + this.selectedGradingScaleUid = selectedGradingScaleUid; + } + public Map getSelectedGradingScaleBottomPercents() { + return selectedGradingScaleBottomPercents; + } + public void setSelectedGradingScaleBottomPercents( + Map selectedGradingScaleBottomPercents) { + this.selectedGradingScaleBottomPercents = selectedGradingScaleBottomPercents; + } + public Collection getAssignments() { + return assignments; + } + public void setAssignments(Collection assignments) { + this.assignments = assignments; + } + public boolean isDisplayReleasedGradeItemsToStudents() { + return displayReleasedGradeItemsToStudents; + } + public void setDisplayReleasedGradeItemsToStudents( + boolean displayReleasedGradeItemsToStudents) { + this.displayReleasedGradeItemsToStudents = displayReleasedGradeItemsToStudents; + } + public int getGradeType() { + return gradeType; + } + public void setGradeType(int gradeType) { + this.gradeType = gradeType; + } + public int getCategoryType() { + return categoryType; + } + public void setCategoryType(int categoryType) { + this.categoryType = categoryType; + } + public List getCategory() { + return category; + } + public void setCategory(List category) { + this.category = category; + } + public String getGradeScale() { + return gradeScale; + } + public void setGradeScale(String gradeScale) { + this.gradeScale = gradeScale; + } + +} diff --git a/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/GradebookService.java b/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/GradebookService.java index d79d4d62a3dc..4e705a5ef7e9 100644 --- a/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/GradebookService.java +++ b/edu-services/gradebook-service/api/src/java/org/sakaiproject/service/gradebook/shared/GradebookService.java @@ -335,6 +335,15 @@ public boolean isAssignmentDefined(String gradebookUid, */ public void transferGradebookDefinitionXml(String fromGradebookUid, String toGradebookUid, String fromGradebookXml); + /** + * + * @param gradebookUid + * @return a {@link GradebookInformation} object that contains information about this + * Gradebook that may be useful to consumers outside the Gradebook tool + * + */ + public GradebookInformation getGradebookInformation(String gradebookUid); + /** * Attempt to merge archived gradebook data (notably the assignnments) into a new gradebook. * diff --git a/edu-services/gradebook-service/impl/src/java/org/sakaiproject/component/gradebook/GradebookServiceHibernateImpl.java b/edu-services/gradebook-service/impl/src/java/org/sakaiproject/component/gradebook/GradebookServiceHibernateImpl.java index e4bb548cb9b6..5ce2ef713d45 100644 --- a/edu-services/gradebook-service/impl/src/java/org/sakaiproject/component/gradebook/GradebookServiceHibernateImpl.java +++ b/edu-services/gradebook-service/impl/src/java/org/sakaiproject/component/gradebook/GradebookServiceHibernateImpl.java @@ -54,6 +54,7 @@ import org.sakaiproject.service.gradebook.shared.ConflictingExternalIdException; import org.sakaiproject.service.gradebook.shared.GradebookExternalAssessmentService; import org.sakaiproject.service.gradebook.shared.GradebookFrameworkService; +import org.sakaiproject.service.gradebook.shared.GradebookInformation; import org.sakaiproject.service.gradebook.shared.GradebookNotFoundException; import org.sakaiproject.service.gradebook.shared.GradebookService; import org.sakaiproject.service.gradebook.shared.GradebookPermissionService; @@ -460,6 +461,38 @@ public String getGradebookDefinitionXml(String gradebookUid) { return VersionedExternalizable.toXml(gradebookDefinition); } + + public GradebookInformation getGradebookInformation(String gradebookUid) { + + if (gradebookUid == null ) { + throw new IllegalArgumentException("null gradebookUid " + gradebookUid) ; + } + + if (!currentUserHasEditPerm(gradebookUid) && !currentUserHasGradingPerm(gradebookUid)) { + log.error("AUTHORIZATION FAILURE: User " + getUserUid() + " in gradebook " + gradebookUid + " attempted to access gb information"); + throw new SecurityException("You do not have permission to access gradebook information in site " + gradebookUid); + } + + Gradebook gradebook = getGradebook(gradebookUid); + if(gradebook==null) { + throw new IllegalArgumentException("Their is no gradbook associated with this Id: "+gradebookUid); + } + + GradebookInformation gradebookInfo = new GradebookInformation(); + GradeMapping selectedGradeMapping = gradebook.getSelectedGradeMapping(); + if(selectedGradeMapping!=null) { + gradebookInfo.setSelectedGradingScaleUid(selectedGradeMapping.getGradingScale().getUid()); + gradebookInfo.setSelectedGradingScaleBottomPercents(new HashMap(selectedGradeMapping.getGradeMap())); + gradebookInfo.setGradeScale(selectedGradeMapping.getGradingScale().getName()); + } + gradebookInfo.setAssignments(getAssignments(gradebookUid)); + gradebookInfo.setGradeType(gradebook.getGrade_type()); + gradebookInfo.setCategoryType(gradebook.getCategory_type()); + gradebookInfo.setCategory(getCategories(gradebook.getId())); + gradebookInfo.setDisplayReleasedGradeItemsToStudents(gradebook.isAssignmentsDisplayed()); + return gradebookInfo; + } + public void transferGradebookDefinitionXml(String fromGradebookUid, String toGradebookUid, String fromGradebookXml) { final Gradebook gradebook = getGradebook(toGradebookUid); final Gradebook fromGradebook = getGradebook(fromGradebookUid); @@ -2696,6 +2729,9 @@ private CategoryDefinition getCategoryDefinition(Category category) { categoryDef.setId(category.getId()); categoryDef.setName(category.getName()); categoryDef.setWeight(category.getWeight()); + categoryDef.setDrop_lowest(category.getDrop_lowest()); + categoryDef.setDropHighest(category.getDropHighest()); + categoryDef.setKeepHighest(category.getKeepHighest()); categoryDef.setAssignmentList(getAssignments(category.getGradebook().getUid(), category.getName())); }