use of com.instructure.canvasapi2.models.GradingPeriod in project instructure-android by instructure.
the class GradesListFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
allTermsGradingPeriod = new GradingPeriod();
allTermsGradingPeriod.setTitle(getString(R.string.allGradingPeriods));
setRetainInstance(this, true);
}
use of com.instructure.canvasapi2.models.GradingPeriod in project instructure-android by instructure.
the class AssignmentListFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getParentFragment() != null && !getParentFragment().getRetainInstance()) {
setRetainInstance(this, true);
}
mAllTermsGradingPeriod = new GradingPeriod();
mAllTermsGradingPeriod.setTitle(getString(R.string.allGradingPeriods));
}
use of com.instructure.canvasapi2.models.GradingPeriod in project instructure-android by instructure.
the class AssignmentDateListRecyclerAdapter method loadData.
@Override
public void loadData() {
/*Logic regarding MGP is similar here as it is in both assignment recycler adapters,
if changes are made here, check if they are needed in the other recycler adapters.*/
Course course = (Course) mCanvasContext;
// This check is for the "all grading periods" option
if (mCurrentGradingPeriod != null && mCurrentGradingPeriod.getTitle() != null && mCurrentGradingPeriod.getTitle().equals(getContext().getString(R.string.allGradingPeriods))) {
loadAssignment();
return;
}
for (Enrollment enrollment : course.getEnrollments()) {
// Date list is for students
if (enrollment.isMultipleGradingPeriodsEnabled()) {
if (mCurrentGradingPeriod == null || mCurrentGradingPeriod.getTitle() == null) {
// we load current term by setting up the current GP
mCurrentGradingPeriod = new GradingPeriod();
mCurrentGradingPeriod.setId(enrollment.getCurrentGradingPeriodId());
mCurrentGradingPeriod.setTitle(enrollment.getCurrentGradingPeriodTitle());
// request the grading period objects and make the assignment calls
// This callback is fulfilled in the grade list fragment.
CourseManager.getGradingPeriodsForCourse(mGradingPeriodsCallback, course.getId(), true);
// Then we go ahead and load up the assignments for the current period
loadAssignmentsForGradingPeriod(mCurrentGradingPeriod.getId(), false);
return;
} else {
// Otherwise we load the info from the currently selected grading period
loadAssignmentsForGradingPeriod(mCurrentGradingPeriod.getId(), true);
return;
}
}
}
// If we made it this far, MGP is disabled so we just go forward with the standard
loadAssignment();
}
use of com.instructure.canvasapi2.models.GradingPeriod in project instructure-android by instructure.
the class AssignmentGroupListRecyclerAdapter method loadData.
@Override
public void loadData() {
/*Logic regarding MGP is similar here as it is in both assignment recycler adapters,
if changes are made here, check if they are needed in the other recycler adapters.*/
Course course = (Course) mCanvasContext;
// This check is for the "all grading periods" option
if (mCurrentGradingPeriod != null && mCurrentGradingPeriod.getTitle() != null && mCurrentGradingPeriod.getTitle().equals(getContext().getString(R.string.allGradingPeriods))) {
loadAssignment();
return;
}
for (Enrollment enrollment : course.getEnrollments()) {
// so we'll check the first student enrollment they have for the course
if (enrollment.isStudent() && enrollment.isMultipleGradingPeriodsEnabled()) {
if (mCurrentGradingPeriod == null || mCurrentGradingPeriod.getTitle() == null) {
// we load current term by setting up the current GP
mCurrentGradingPeriod = new GradingPeriod();
mCurrentGradingPeriod.setId(enrollment.getCurrentGradingPeriodId());
mCurrentGradingPeriod.setTitle(enrollment.getCurrentGradingPeriodTitle());
// request the grading period objects and make the assignment calls
// This callback is fulfilled in the grade list fragment.
CourseManager.getGradingPeriodsForCourse(mGradingPeriodsCallback, course.getId(), true);
// Then we go ahead and load up the assignments for the current period
loadAssignmentsForGradingPeriod(mCurrentGradingPeriod.getId(), false);
return;
} else {
// Otherwise we load the info from the currently selected grading period
loadAssignmentsForGradingPeriod(mCurrentGradingPeriod.getId(), true);
return;
}
}
}
// If we made it this far, MGP is disabled so we just go forward with the standard
loadAssignment();
}
use of com.instructure.canvasapi2.models.GradingPeriod in project instructure-android by instructure.
the class CourseManager_Test method getGradingPeriodsForCourse.
public static void getGradingPeriodsForCourse(StatusCallback<GradingPeriodResponse> callback, long courseId) {
// Create mock HTTP response
Response httpResponse = new Response.Builder().request(new Request.Builder().url("https://test.com").build()).code(200).message("test").protocol(Protocol.HTTP_1_0).body(ResponseBody.create(MediaType.parse("application/json"), "test".getBytes())).addHeader("content-type", "application/json").build();
// Create mock API response
GradingPeriodResponse gradingPeriodResponse = new GradingPeriodResponse();
ArrayList<GradingPeriod> gradingPeriods = new ArrayList<>();
GradingPeriod gp1 = new GradingPeriod();
gp1.setId(1);
GradingPeriod gp2 = new GradingPeriod();
gp2.setId(2);
GradingPeriod gp3 = new GradingPeriod();
gp3.setId(3);
gradingPeriods.add(gp1);
gradingPeriods.add(gp2);
gradingPeriods.add(gp3);
gradingPeriodResponse.setGradingPeriodList(gradingPeriods);
retrofit2.Response<GradingPeriodResponse> response = retrofit2.Response.success(gradingPeriodResponse, httpResponse);
callback.onResponse(response, new LinkHeaders(), ApiType.CACHE);
callback.onFinished(ApiType.API);
}
Aggregations