Search in sources :

Example 66 with Assignment

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

Example 67 with Assignment

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

the class AssignmentUtils2Test method getAssignmentState_stateExcused.

@Test
public void getAssignmentState_stateExcused() throws Exception {
    Assignment assignment = new Assignment();
    Submission submission = new Submission();
    submission.setExcused(true);
    assignment.setSubmission(submission);
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_EXCUSED);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Test(org.junit.Test)

Example 68 with Assignment

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

the class AssignmentUtils2Test method getAssignmentState_stateSubmittedLate.

@Test
public void getAssignmentState_stateSubmittedLate() throws Exception {
    Assignment assignment = new Assignment();
    Submission submission = new Submission();
    long time = Calendar.getInstance().getTimeInMillis() + 100000;
    Date date = new Date(time);
    submission.setAttempt(1);
    submission.setLate(true);
    assignment.setSubmission(submission);
    assignment.setDueAt(APIHelper.dateToString(date));
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_SUBMITTED_LATE);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Date(java.util.Date) Test(org.junit.Test)

Example 69 with Assignment

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

the class AssignmentUtils2Test method getAssignmentState_stateDue.

@Test
public void getAssignmentState_stateDue() throws Exception {
    Assignment assignment = new Assignment();
    Submission submission = null;
    long time = Calendar.getInstance().getTimeInMillis() + 100000;
    Date date = new Date(time);
    assignment.setSubmission(submission);
    assignment.setDueAt(APIHelper.dateToString(date));
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_DUE);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Date(java.util.Date) Test(org.junit.Test)

Example 70 with Assignment

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

the class AssignmentUtils2Test method getAssignmentState_stateGradedLate.

@Test
public void getAssignmentState_stateGradedLate() throws Exception {
    Assignment assignment = new Assignment();
    Submission submission = new Submission();
    long time = Calendar.getInstance().getTimeInMillis() + 100000;
    Date date = new Date(time);
    submission.setAttempt(1);
    submission.setGrade("A");
    submission.setLate(true);
    assignment.setSubmission(submission);
    assignment.setDueAt(APIHelper.dateToString(date));
    int testValue = AssignmentUtils2.getAssignmentState(assignment, submission);
    assertEquals("", testValue, AssignmentUtils2.ASSIGNMENT_STATE_GRADED_LATE);
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) Submission(com.instructure.canvasapi2.models.Submission) Date(java.util.Date) Test(org.junit.Test)

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