Search in sources :

Example 11 with Enrollment

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

the class CourseTest method courseGrade_currentGradeNonMGP.

@Test
public void courseGrade_currentGradeNonMGP() {
    Course course = new Course();
    String currentGrade = "A";
    String finalGrade = "C";
    Enrollment enrollment = new Enrollment();
    enrollment.setType("student");
    enrollment.setCurrentGradingPeriodId(27);
    enrollment.setComputedCurrentGrade(currentGrade);
    enrollment.setComputedFinalGrade(finalGrade);
    ArrayList<Enrollment> enrollments = new ArrayList<>();
    enrollments.add(enrollment);
    course.setEnrollments(enrollments);
    assertTrue(course.getCourseGrade(false).getCurrentGrade().equals(currentGrade));
}
Also used : ArrayList(java.util.ArrayList) Enrollment(com.instructure.canvasapi2.models.Enrollment) Course(com.instructure.canvasapi2.models.Course) Test(org.junit.Test)

Example 12 with Enrollment

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

the class CourseTest method courseGrade_finalGradeMGP.

@Test
public void courseGrade_finalGradeMGP() {
    Course course = new Course();
    course.setHasGradingPeriods(true);
    String currentGrade = "A";
    String finalGrade = "C";
    Enrollment enrollment = new Enrollment();
    enrollment.setType("student");
    enrollment.setCurrentGradingPeriodId(27);
    enrollment.setMultipleGradingPeriodsEnabled(true);
    enrollment.setCurrentPeriodComputedFinalGrade(finalGrade);
    enrollment.setCurrentPeriodComputedCurrentGrade(currentGrade);
    ArrayList<Enrollment> enrollments = new ArrayList<>();
    enrollments.add(enrollment);
    course.setEnrollments(enrollments);
    assertTrue(course.getCourseGrade(false).getFinalGrade().equals(finalGrade));
}
Also used : ArrayList(java.util.ArrayList) Enrollment(com.instructure.canvasapi2.models.Enrollment) Course(com.instructure.canvasapi2.models.Course) Test(org.junit.Test)

Example 13 with Enrollment

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

the class CourseTest method courseGrade_finalScoreNonMGP.

@Test
public void courseGrade_finalScoreNonMGP() {
    Course course = new Course();
    double currentScore = 96.0;
    double finalScore = 47.0;
    Enrollment enrollment = new Enrollment();
    enrollment.setType("student");
    enrollment.setComputedFinalScore(finalScore);
    enrollment.setComputedCurrentScore(currentScore);
    ArrayList<Enrollment> enrollments = new ArrayList<>();
    enrollments.add(enrollment);
    course.setEnrollments(enrollments);
    assertTrue(course.getCourseGrade(false).getFinalScore() == finalScore);
}
Also used : ArrayList(java.util.ArrayList) Enrollment(com.instructure.canvasapi2.models.Enrollment) Course(com.instructure.canvasapi2.models.Course) Test(org.junit.Test)

Example 14 with Enrollment

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

the class CourseTest method isTA_hasTaEnrollment.

@Test
public void isTA_hasTaEnrollment() {
    Course course = new Course();
    Enrollment enrollment = new Enrollment();
    enrollment.setType("ta");
    ArrayList<Enrollment> enrollments = new ArrayList<>();
    enrollments.add(enrollment);
    course.setEnrollments(enrollments);
    assertEquals(true, course.isTA());
}
Also used : ArrayList(java.util.ArrayList) Enrollment(com.instructure.canvasapi2.models.Enrollment) Course(com.instructure.canvasapi2.models.Course) Test(org.junit.Test)

Example 15 with Enrollment

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

the class CourseTest method isTeacher_noTeacherEnrollment.

@Test
public void isTeacher_noTeacherEnrollment() {
    Course course = new Course();
    Enrollment enrollment = new Enrollment();
    enrollment.setType("student");
    ArrayList<Enrollment> enrollments = new ArrayList<>();
    enrollments.add(enrollment);
    course.setEnrollments(enrollments);
    assertEquals(false, course.isTeacher());
}
Also used : ArrayList(java.util.ArrayList) Enrollment(com.instructure.canvasapi2.models.Enrollment) Course(com.instructure.canvasapi2.models.Course) Test(org.junit.Test)

Aggregations

Enrollment (com.instructure.canvasapi2.models.Enrollment)55 Test (org.junit.Test)46 Course (com.instructure.canvasapi2.models.Course)30 ArrayList (java.util.ArrayList)25 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)7 RestParams (com.instructure.canvasapi2.builders.RestParams)7 NonNull (android.support.annotation.NonNull)4 Grades (com.instructure.canvasapi2.models.Grades)4 StatusCallback (com.instructure.canvasapi2.StatusCallback)3 ExhaustiveListCallback (com.instructure.canvasapi2.utils.ExhaustiveListCallback)3 List (java.util.List)3 GradingPeriod (com.instructure.canvasapi2.models.GradingPeriod)2 User (com.instructure.canvasapi2.models.User)2 Application (android.app.Application)1 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 View (android.view.View)1 BasicUser (com.instructure.canvasapi2.models.BasicUser)1 ErrorReportResult (com.instructure.canvasapi2.models.ErrorReportResult)1 ApiType (com.instructure.canvasapi2.utils.ApiType)1