Search in sources :

Example 36 with Student

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

the class UserManager method getStudentsForParentAirwolf.

public static void getStudentsForParentAirwolf(String airwolfDomain, String parentId, StatusCallback<List<Student>> callback) {
    if (isTesting() || mTesting) {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(true).withDomain(airwolfDomain).withAPIVersion("").build();
        UserManager_Test.getStudentsForParentAirwolf(airwolfDomain, adapter, params, parentId, callback);
    } else {
        RestBuilder adapter = new RestBuilder(callback);
        RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(true).withDomain(airwolfDomain).withAPIVersion("").withForceReadFromNetwork(true).build();
        UserAPI.getStudentsForParentAirwolf(adapter, params, parentId, callback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 37 with Student

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

the class UserTest method getEnrollmentsHash_Test2.

@Test
public void getEnrollmentsHash_Test2() {
    Enrollment enrollment1 = new Enrollment();
    enrollment1.setCourseId(1234);
    enrollment1.setRole("student");
    Enrollment enrollment2 = new Enrollment();
    enrollment2.setCourseId(1234);
    enrollment2.setRole("teacher");
    List<Enrollment> enrollmentList = new ArrayList<>();
    enrollmentList.add(enrollment1);
    enrollmentList.add(enrollment2);
    user1.setEnrollments(enrollmentList);
    user1.getEnrollmentsHash();
    assertEquals("teacher", user1.getEnrollmentsHash().get("1234")[1]);
}
Also used : ArrayList(java.util.ArrayList) Enrollment(com.instructure.canvasapi2.models.Enrollment) Test(org.junit.Test)

Example 38 with Student

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

the class UserTest method getEnrollmentsHash_Test1.

// endregion
@Test
public void getEnrollmentsHash_Test1() {
    Enrollment enrollment1 = new Enrollment();
    enrollment1.setCourseId(1234);
    enrollment1.setRole("student");
    Enrollment enrollment2 = new Enrollment();
    enrollment2.setCourseId(1234);
    enrollment2.setRole("teacher");
    List<Enrollment> enrollmentList = new ArrayList<>();
    enrollmentList.add(enrollment1);
    enrollmentList.add(enrollment2);
    user1.setEnrollments(enrollmentList);
    user1.getEnrollmentsHash();
    assertEquals("student", user1.getEnrollmentsHash().get("1234")[0]);
}
Also used : ArrayList(java.util.ArrayList) Enrollment(com.instructure.canvasapi2.models.Enrollment) Test(org.junit.Test)

Example 39 with Student

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

the class UserBinder method bind.

public static void bind(final Context context, final User user, final AdapterToFragmentCallback<User> adapterToFragmentCallback, final UserViewHolder holder, final int position) {
    // Set student avatar
    BasicUser basicUser = new BasicUser();
    basicUser.setName(user.getName());
    basicUser.setAvatarUrl(user.getAvatarUrl());
    ProfileUtils.loadAvatarForUser(holder.studentAvatar, basicUser);
    // Set student name
    holder.userName.setText(user.getName());
    holder.itemView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            adapterToFragmentCallback.onRowClicked(user, position);
        }
    });
    // List enrollmentApiModel type(s)
    // get a list of strings of the enrollments
    // Use hashSet to prevent duplicate enrollments
    HashSet<String> enrollments = new HashSet<>();
    for (Enrollment enrollment : user.getEnrollments()) {
        enrollments.add(enrollment.getType());
    }
    holder.userRole.setText(android.text.TextUtils.join(", ", enrollments));
}
Also used : BasicUser(com.instructure.canvasapi2.models.BasicUser) Enrollment(com.instructure.canvasapi2.models.Enrollment) View(android.view.View) HashSet(java.util.HashSet)

Example 40 with Student

use of com.instructure.canvasapi2.models.Student in project tutorials by eugenp.

the class StudentController method listStudents.

public Result listStudents() {
    Set<Student> result = StudentStore.getInstance().getAllStudents();
    ObjectMapper mapper = new ObjectMapper();
    JsonNode jsonData = mapper.convertValue(result, JsonNode.class);
    return ok(Util.createResponse(jsonData, true));
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) Student(models.Student) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

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