use of com.instructure.canvasapi2.models.Student in project instructure-android by instructure.
the class StudentViewActivity method configureUserCarousel.
private void configureUserCarousel() {
mCarouselViewPager = (ViewPager) findViewById(R.id.carouselPager);
mCarouselAdapter = new CarouselPagerAdapter(this);
mCarouselViewPager.addOnPageChangeListener(this);
mCarouselViewPager.setPageTransformer(true, new CarouselTransformer());
if (getIntent().getExtras().getParcelableArrayList(Const.USER) != null) {
ArrayList<Student> students = getIntent().getExtras().getParcelableArrayList(Const.USER);
if (students != null && students.size() > 0) {
mCarouselAdapter.clear();
mCarouselViewPager.setOffscreenPageLimit(students.size());
mCarouselAdapter.addAll(students);
}
}
mCarouselViewPager.post(new Runnable() {
@Override
public void run() {
mCarouselViewPager.setAdapter(mCarouselAdapter);
// Use this to set the offset for the viewpager
int childWidth = (int) getResources().getDimension(R.dimen.carousel_avatar_size);
double factor = 1.30;
if (getResources().getBoolean(R.bool.isTablet)) {
// adjust for tablets so the student's icons are closer together
factor = 1.15;
}
double width = (mCarouselViewPager.getWidth() / factor) + (childWidth / 2);
int truncWidth = (int) width;
mCarouselViewPager.setPageMargin(-truncWidth);
if (mCarouselAdapter.getCount() > 1) {
Prefs prefs = new Prefs(StudentViewActivity.this, com.instructure.parentapp.util.Const.CANVAS_PARENT_SP);
int pos = prefs.load(Const.POSITION, mCarouselAdapter.getCount() / 2);
mCarouselViewPager.setCurrentItem(pos);
onPageSelected(pos);
} else if (mCarouselAdapter.getCount() == 1) {
// need to call onPageSelected so that it shows the user's name
onPageSelected(0);
}
}
});
}
use of com.instructure.canvasapi2.models.Student in project instructure-android by instructure.
the class UserManager_Test method getStudentsForParentAirwolf.
public static void getStudentsForParentAirwolf(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);
}
use of com.instructure.canvasapi2.models.Student in project instructure-android by instructure.
the class CourseTest method isObserver_noObserverEnrollment.
@Test
public void isObserver_noObserverEnrollment() {
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.isObserver());
}
use of com.instructure.canvasapi2.models.Student in project instructure-android by instructure.
the class CourseTest method courseGrade_currentScoreMGP.
@Test
public void courseGrade_currentScoreMGP() {
Course course = new Course();
course.setHasGradingPeriods(true);
double currentScore = 96.0;
double finalScore = 47.0;
Enrollment enrollment = new Enrollment();
enrollment.setType("student");
enrollment.setCurrentGradingPeriodId(27);
enrollment.setMultipleGradingPeriodsEnabled(true);
enrollment.setCurrentPeriodComputedCurrentScore(currentScore);
enrollment.setCurrentPeriodComputedFinalScore(finalScore);
ArrayList<Enrollment> enrollments = new ArrayList<>();
enrollments.add(enrollment);
course.setEnrollments(enrollments);
assertTrue(course.getCourseGrade(false).getCurrentScore() == currentScore);
}
use of com.instructure.canvasapi2.models.Student in project instructure-android by instructure.
the class CourseTest method courseHasNoCurrentGrade.
@Test
public void courseHasNoCurrentGrade() {
Course course = new Course();
Enrollment enrollment = new Enrollment();
enrollment.setType("student");
enrollment.setComputedCurrentGrade("");
enrollment.setComputedCurrentScore(null);
ArrayList<Enrollment> enrollments = new ArrayList<>();
enrollments.add(enrollment);
course.setEnrollments(enrollments);
assertTrue(course.getCourseGrade(false).getNoCurrentGrade());
}
Aggregations