use of com.instructure.canvasapi2.models.Enrollment in project instructure-android by instructure.
the class EnrollmentTest method getType.
@Test
public void getType() {
Enrollment enrollment = new Enrollment();
enrollment.setType("studentenrollment");
assertEquals("student", enrollment.getType());
}
use of com.instructure.canvasapi2.models.Enrollment 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]);
}
use of com.instructure.canvasapi2.models.Enrollment 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]);
}
use of com.instructure.canvasapi2.models.Enrollment in project instructure-android by instructure.
the class PeopleListPresenter method convertRecipientToUser.
@NonNull
private User convertRecipientToUser(Recipient recipient) {
User user = new User();
user.setAvatarUrl(recipient.getAvatarURL());
user.setId(recipient.getIdAsLong());
user.setName(recipient.getName());
user.setSortableName(recipient.getName());
// get enrollments
ArrayList<Enrollment> enrollments = new ArrayList<>();
if (recipient.getCommonCourses() != null) {
String[] commonCoursesEnrollments = recipient.getCommonCourses().get(Long.toString(mCanvasContext.getId()));
if (commonCoursesEnrollments != null) {
for (String enrollment : commonCoursesEnrollments) {
Enrollment newEnrollment = new Enrollment();
newEnrollment.setType(enrollment);
enrollments.add(newEnrollment);
}
user.setEnrollments(enrollments);
}
}
return user;
}
use of com.instructure.canvasapi2.models.Enrollment 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));
}
Aggregations