edu.ksu.canvas.requestOptions.GetAssignmentGroupOptions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of canvas-api Show documentation
Show all versions of canvas-api Show documentation
A native Java library to talk to the Canvas REST API
The newest version!
package edu.ksu.canvas.requestOptions;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
public class GetAssignmentGroupOptions extends BaseOptions {
public enum Include {
ASSIGNMENTS, DISCUSSION_TOPIC, ASSIGNMENT_VISIBILITY, SUBMISSION;
@Override
public String toString() {
return name().toLowerCase();
}
}
private String courseId;
private Long assignmentGroupId;
public GetAssignmentGroupOptions(String courseId, Long assignmentGroupId) {
if(StringUtils.isBlank(courseId) || assignmentGroupId == null || assignmentGroupId == 0) {
throw new IllegalArgumentException("Must supply a course ID and assignment group ID");
}
this.courseId = courseId;
this.assignmentGroupId = assignmentGroupId;
}
public String getCourseId() {
return courseId;
}
public Long getAssignmentGroupId() {
return assignmentGroupId;
}
/**
* Additional objects to include with the requested group.
* Note that all the optional includes depend on "assignments" also being included.
* @param includes List of included objects to return
* @return this object to continue building options
*/
public GetAssignmentGroupOptions includes(List includes) {
List assignmentDependents = Arrays.asList(Include.DISCUSSION_TOPIC, Include.ASSIGNMENT_VISIBILITY, Include.SUBMISSION);
if(includes.stream().anyMatch(assignmentDependents::contains) && !includes.contains(Include.ASSIGNMENTS)) {
throw new IllegalArgumentException("Including discussion topics, all dates, assignment visibility or submissions is only valid if you also include submissions");
}
addEnumList("include[]", includes);
return this;
}
/**
* Whether or not to apply assignment overrides for each assignment. Defaults to true.
* @param overrideDates Boolean indicating whether to apply assignment overrides
* @return this object to continue building options
*/
public GetAssignmentGroupOptions overrideAssignmentDates (Boolean overrideDates){
addSingleItem("override_assignment_dates", overrideDates.toString());
return this;
}
/**
* Limit assignment groups to a grading period.
* Requires grading periods to exist at the account level
* @param periodId The ID of the grading period
* @return this object to continue building options
*/
public GetAssignmentGroupOptions gradingPeriodId (Long periodId){
addSingleItem("grading_period_id", periodId.toString());
return this;
}
}