use of com.instructure.canvasapi.model.Course in project instructure-android by instructure.
the class CanvasContextPermissionUnitTest method testCoursePermissions.
@Test
public void testCoursePermissions() {
Gson gson = CanvasRestAdapter.getGSONParser();
Course course = gson.fromJson(coursePermissionJSON, Course.class);
assertNotNull(course);
assertNotNull(course.getPermissions());
assertTrue(course.canCreateDiscussion());
assertTrue(course.getPermissions().canCreateDiscussionTopic());
assertFalse(course.getPermissions().canUpdateAvatar());
assertFalse(course.getPermissions().canUpdateName());
}
use of com.instructure.canvasapi.model.Course in project instructure-android by instructure.
the class CourseUnitTest method testCourse.
@Test
public void testCourse() {
Gson gson = CanvasRestAdapter.getGSONParser();
Course course = gson.fromJson(courseJSON, Course.class);
assertNotNull(course);
assertTrue(course.getId() == 1383418);
assertTrue(course.getApplyAssignmentGroupWeights());
assertNotNull(course.getName());
assertTrue(course.getNeedsGradingCount() == 0);
assertFalse(course.isFinalGradeHidden());
assertFalse(course.isPublic());
assertTrue(course.canCreateDiscussion());
assertTrue(course.getTerm().getId() == 3142);
}
use of com.instructure.canvasapi.model.Course in project instructure-android by instructure.
the class GuessWhoFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (getArguments() != null) {
Course course = getArguments().getParcelable(Const.COURSE);
courseName.setText(course.getName());
canvasContext = getArguments().getParcelable(Const.SECTION);
sectionName.setText(canvasContext.getName());
sectionPeople = getArguments().getParcelableArrayList(Const.SECTION_PEOPLE);
for (User user : sectionPeople) {
adapter.addItem(user);
}
if (adapter.getCount() == 0) {
// show the empty view
pager.setVisibility(View.INVISIBLE);
emptyView.setVisibility(View.VISIBLE);
}
}
getParentActivity().setActionBarTitle(getString(R.string.guessWho));
}
use of com.instructure.canvasapi.model.Course in project instructure-android by instructure.
the class CourseAPI method getFavCoursesSynchronous.
public static Course[] getFavCoursesSynchronous(Context context) {
RestAdapter restAdapter = CanvasRestAdapter.buildAdapter(context);
// If not able to parse (no network for example), this will crash. Handle that case.
try {
ArrayList<Course> allCourses = new ArrayList<>();
int page = 1;
long firstItemId = -1;
// for(ever) loop. break once we've run outta stuff;
for (; ; ) {
Course[] courses = restAdapter.create(CoursesInterface.class).getFavCoursesSynchronous(page);
page++;
// This is all or nothing. We don't want partial data.
if (courses == null) {
return null;
} else if (courses.length == 0) {
break;
} else if (courses[0].getId() == firstItemId) {
break;
} else {
firstItemId = courses[0].getId();
Collections.addAll(allCourses, courses);
}
}
return allCourses.toArray(new Course[allCourses.size()]);
} catch (Exception E) {
return null;
}
}
use of com.instructure.canvasapi.model.Course in project instructure-android by instructure.
the class CourseUnitTest method testFavoriteCourses.
@Test
public void testFavoriteCourses() {
Gson gson = CanvasRestAdapter.getGSONParser();
Course[] favoriteCourses = gson.fromJson(favoriteCoursesJSON, Course[].class);
Course course = favoriteCourses[0];
assertNotNull(favoriteCourses);
assertNotNull(course);
assertTrue(course.getId() == 1383420);
assertFalse(course.getApplyAssignmentGroupWeights());
assertNotNull(course.getName());
assertTrue(course.getNeedsGradingCount() == 0);
assertFalse(course.isFinalGradeHidden());
assertTrue(course.isPublic());
assertTrue(course.getTerm().getId() == 3142);
}
Aggregations