Search in sources :

Example 6 with Student

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

the class CourseListPresenterTest method setUp.

@Before
public void setUp() throws Exception {
    course1 = new Course();
    course2 = new Course();
    Student student = new Student();
    presenter = new CourseListPresenter(student);
}
Also used : CourseListPresenter(com.instructure.parentapp.presenters.CourseListPresenter) Course(com.instructure.canvasapi2.models.Course) Student(com.instructure.canvasapi2.models.Student) Before(org.junit.Before)

Example 7 with Student

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

the class WeekPresenterTest method setUp.

@Before
public void setUp() throws Exception {
    Student student = new Student();
    student.setStudentId("student_12345");
    student.setParentId("parent_12345");
    student.setStudentDomain("https://localhost.com");
    student.setStudentName("Man in the Yellow Hat");
    Course course = new Course();
    course.setName("Curious George and the Hidden Course of Doom");
    course.setCourseCode("course_12345");
    mPresenter = new WeekViewPresenterFactory(student, course).create();
}
Also used : WeekViewPresenterFactory(com.instructure.parentapp.factorys.WeekViewPresenterFactory) Student(com.instructure.canvasapi2.models.Student) Course(com.instructure.canvasapi2.models.Course) Before(org.junit.Before)

Example 8 with Student

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

the class Analytics method trackEnrollment.

public static void trackEnrollment(Activity context, List<Course> courseList) {
    if (context == null || courseList == null) {
        return;
    }
    String enrollment = "Unknown";
    // used to track how many teacher/student enrollments
    int teacherCount = 0;
    int studentCount = 0;
    int observerCount = 0;
    for (Course course : courseList) {
        if (course.isTeacher()) {
            teacherCount++;
        } else if (course.isStudent()) {
            studentCount++;
        } else if (course.isObserver()) {
            observerCount++;
        }
    }
    // variable. This will set the custom dimension as whatever role is set the most
    if (studentCount > teacherCount && studentCount > observerCount) {
        // Set the dimension value for index 1 (Enrollment in GA, it is a 1 based list).
        enrollment = "Student";
    } else if (teacherCount >= studentCount && teacherCount >= observerCount) {
        // Set the dimension value for index 1.(Enrollment in GA, it is a 1 based list).
        enrollment = "Teacher";
    } else {
        // Set the dimension value for index 1.(Enrollment in GA, it is a 1 based list).
        enrollment = "Observer";
    }
    Application application = context.getApplication();
    if (application instanceof AnalyticsEventHandling) {
        ((AnalyticsEventHandling) application).trackEnrollment(enrollment);
    }
}
Also used : Course(com.instructure.canvasapi2.models.Course) Application(android.app.Application)

Example 9 with Student

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

the class UserManager_Test method getObserveesForParent.

public static void getObserveesForParent(String airwolfDomain, RestBuilder adapter, RestParams params, String parentId, StatusCallback<List<Student>> callback) {
    adapter.setStatusCallback(callback);
    Response response = new Response.Builder().code(200).message("success").protocol(Protocol.HTTP_1_0).body(ResponseBody.create(MediaType.parse("application/json"), "success".getBytes())).addHeader("content-type", "application/json").build();
    retrofit2.Response response1 = retrofit2.Response.success(response);
    callback.onResponse(response1, new LinkHeaders(), ApiType.API);
}
Also used : Response(okhttp3.Response) ParentResponse(com.instructure.canvasapi2.models.ParentResponse) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 10 with Student

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

the class CourseTest method isCourseGradeLocked_hideAllGradingPeriods.

@Test
public void isCourseGradeLocked_hideAllGradingPeriods() {
    Course course = new Course();
    course.setHasGradingPeriods(true);
    Enrollment enrollment = new Enrollment();
    enrollment.setType("student");
    enrollment.setCurrentGradingPeriodId(0);
    enrollment.setMultipleGradingPeriodsEnabled(true);
    enrollment.setTotalsForAllGradingPeriodsOption(false);
    ArrayList<Enrollment> enrollments = new ArrayList<>();
    enrollments.add(enrollment);
    course.setEnrollments(enrollments);
    assertTrue(course.getCourseGrade(false).isLocked());
}
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)24 Course (com.instructure.canvasapi2.models.Course)23 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)21 Student (com.instructure.canvasapi2.models.Student)6 LinkHeaders (com.instructure.canvasapi2.utils.LinkHeaders)6 ApiPrefs (com.instructure.canvasapi2.utils.ApiPrefs)4 ApiType (com.instructure.canvasapi2.utils.ApiType)4 Prefs (com.instructure.pandautils.utils.Prefs)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)3 Student (models.Student)3 Before (org.junit.Before)3 NonNull (android.support.annotation.NonNull)2 StatusCallback (com.instructure.canvasapi2.StatusCallback)2 BlockedStudentResponse (com.instructure.canvasapi2.models.BlockedStudentResponse)2 MismatchedRegionResponse (com.instructure.canvasapi2.models.MismatchedRegionResponse)2 ParentResponse (com.instructure.canvasapi2.models.ParentResponse)2 RevokedTokenResponse (com.instructure.canvasapi2.models.RevokedTokenResponse)2 Response (okhttp3.Response)2