Skip to content

Commit

Permalink
SAK-26583
Browse files Browse the repository at this point in the history
Add grading options into Gradebook feed

git-svn-id: https://source.sakaiproject.org/svn/edu-services/trunk@311866 66ffb92e-73f9-0310-93c1-f5514f145a0a
  • Loading branch information
mrw-iu committed Aug 12, 2014
1 parent ebdd69b commit 70a34ed
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Assignment> assignmentList;

/**
Expand Down Expand Up @@ -106,4 +110,28 @@ public List<Assignment> getAssignmentList() {
public void setAssignmentList(List<Assignment> 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;
}
}
Original file line number Diff line number Diff line change
@@ -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<String, Double> selectedGradingScaleBottomPercents;
private Collection<Assignment> 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<String, Double> getSelectedGradingScaleBottomPercents() {
return selectedGradingScaleBottomPercents;
}
public void setSelectedGradingScaleBottomPercents(
Map<String, Double> selectedGradingScaleBottomPercents) {
this.selectedGradingScaleBottomPercents = selectedGradingScaleBottomPercents;
}
public Collection<Assignment> getAssignments() {
return assignments;
}
public void setAssignments(Collection<Assignment> 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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String,Double>(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);
Expand Down Expand Up @@ -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()));
}

Expand Down

0 comments on commit 70a34ed

Please sign in to comment.