Search in sources :

Example 61 with Assignment

use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.

the class AssignmentManager method editAssignment.

public static void editAssignment(long courseId, long assignmentId, AssignmentPostBody body, final StatusCallback<Assignment> callback, boolean serializeNulls) {
    if (isTesting() || mTesting) {
        AssignmentManager_Test.editAssignment(body, callback);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(false).withShouldIgnoreToken(false).build();
        AssignmentPostBodyWrapper bodyWrapper = new AssignmentPostBodyWrapper();
        bodyWrapper.setAssignment(body);
        AssignmentAPI.editAssignment(courseId, assignmentId, bodyWrapper, adapter, callback, params, serializeNulls);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) AssignmentPostBodyWrapper(com.instructure.canvasapi2.models.post_models.AssignmentPostBodyWrapper) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 62 with Assignment

use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.

the class AssignmentManager method getAssignment.

public static void getAssignment(long assignmentId, long courseId, boolean forceNetwork, StatusCallback<Assignment> callback) {
    if (isTesting() || mTesting) {
        AssignmentManager_Test.getAssignment(assignmentId, courseId, callback);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withPerPageQueryParam(false).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
        AssignmentAPI.getAssignment(courseId, assignmentId, adapter, callback, params);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 63 with Assignment

use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.

the class AssignmentManager method getNextPageAssignments.

public static void getNextPageAssignments(String nextUrl, final boolean forceNetwork, StatusCallback<List<Assignment>> callback) {
    if (isTesting() || mTesting) {
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        AssignmentAPI.getNextPageAssignments(nextUrl, adapter, forceNetwork, callback);
    }
}
Also used : RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 64 with Assignment

use of com.instructure.canvasapi2.models.Assignment in project instructure-android by instructure.

the class AssignmentManager method getAllAssignments.

public static void getAllAssignments(long courseId, final boolean forceNetwork, StatusCallback<List<Assignment>> callback) {
    if (isTesting() || mTesting) {
        AssignmentManager_Test.getAllAssignments(courseId, callback);
    } else {
        final RestBuilder adapter = new RestBuilder(callback);
        StatusCallback<List<Assignment>> depaginatedCallback = new ExhaustiveListCallback<Assignment>(callback) {

            @Override
            public void getNextPage(@NonNull StatusCallback<List<Assignment>> callback, @NonNull String nextUrl, boolean isCached) {
                AssignmentAPI.getNextPageAssignments(nextUrl, adapter, forceNetwork, callback);
            }
        };
        adapter.setStatusCallback(depaginatedCallback);
        AssignmentAPI.getFirstPageAssignments(courseId, forceNetwork, adapter, depaginatedCallback);
    }
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) NonNull(android.support.annotation.NonNull) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) List(java.util.List) StatusCallback(com.instructure.canvasapi2.StatusCallback) ExhaustiveListCallback(com.instructure.canvasapi2.utils.ExhaustiveListCallback)

Example 65 with Assignment

use of com.instructure.canvasapi2.models.Assignment 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();
}
Also used : GradingPeriod(com.instructure.canvasapi2.models.GradingPeriod) Enrollment(com.instructure.canvasapi2.models.Enrollment) Course(com.instructure.canvasapi2.models.Course)

Aggregations

Assignment (com.instructure.canvasapi2.models.Assignment)62 Test (org.junit.Test)46 Submission (com.instructure.canvasapi2.models.Submission)25 Date (java.util.Date)18 ArrayList (java.util.ArrayList)15 View (android.view.View)10 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)10 Course (com.instructure.canvasapi2.models.Course)9 RestParams (com.instructure.canvasapi2.builders.RestParams)7 Bundle (android.os.Bundle)6 ScheduleItem (com.instructure.canvasapi2.models.ScheduleItem)6 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)6 Navigation (com.instructure.interactions.Navigation)5 DrawableRes (android.support.annotation.DrawableRes)4 AdapterView (android.widget.AdapterView)4 TextView (android.widget.TextView)4 Request (okhttp3.Request)4 Response (okhttp3.Response)4 Paint (android.graphics.Paint)3 Drawable (android.graphics.drawable.Drawable)3