Search in sources :

Example 1 with Student

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

the class BaseParentActivity method showMismatchedRegionDialog.

private void showMismatchedRegionDialog(final String regionString, final Context context) {
    new AlertDialog.Builder(context).setTitle(R.string.unauthorizedRegion).setMessage(getString(R.string.mismatchedRegionMessage, getReadableRegion(this, regionString))).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Prefs prefs = new Prefs(BaseParentActivity.this, getString(R.string.app_name_parent));
            String parentId = prefs.load(Const.ID, "");
            UserManager.getStudentsForParentAirwolf(ApiPrefs.getAirwolfDomain(), parentId, new StatusCallback<List<Student>>() {

                @Override
                public void onResponse(@NonNull Response<List<Student>> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
                    if (response.body() != null && !response.body().isEmpty()) {
                        // They have students that they are observing, take them to that activity
                        startActivity(StudentViewActivity.createIntent(BaseParentActivity.this, response.body()));
                        overridePendingTransition(0, 0);
                        finish();
                    } else {
                        // Log the user out
                        new LogoutAsyncTask(BaseParentActivity.this, "").execute();
                    }
                }
            });
        }
    }).setCancelable(false).show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) LinkHeaders(com.instructure.canvasapi2.utils.LinkHeaders) StatusCallback(com.instructure.canvasapi2.StatusCallback) Prefs(com.instructure.pandautils.utils.Prefs) ApiPrefs(com.instructure.canvasapi2.utils.ApiPrefs) Student(com.instructure.canvasapi2.models.Student) RevokedTokenResponse(com.instructure.canvasapi2.models.RevokedTokenResponse) Response(retrofit2.Response) MismatchedRegionResponse(com.instructure.canvasapi2.models.MismatchedRegionResponse) BlockedStudentResponse(com.instructure.canvasapi2.models.BlockedStudentResponse) LogoutAsyncTask(com.instructure.parentapp.asynctask.LogoutAsyncTask) NonNull(android.support.annotation.NonNull) ApiType(com.instructure.canvasapi2.utils.ApiType)

Example 2 with Student

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

the class DetailViewActivity method routeFromIntent.

private void routeFromIntent(Intent intent) {
    DETAIL_FRAGMENT fragmentType = (DETAIL_FRAGMENT) intent.getExtras().getSerializable(Const.FRAGMENT_TYPE);
    if (fragmentType != null) {
        Student student = intent.getExtras().getParcelable(Const.STUDENT);
        switch(fragmentType) {
            case WEEK:
                Student user = intent.getExtras().getParcelable(Const.USER);
                Course course = (Course) intent.getExtras().getSerializable(Const.COURSE);
                if (user != null && course != null) {
                    addFragment(CourseWeekFragment.newInstance(user, course));
                }
                break;
            case ASSIGNMENT:
                Assignment assignment = intent.getExtras().getParcelable(Const.ASSIGNMENT);
                String courseName = intent.getExtras().getString(Const.NAME);
                addFragment(AssignmentFragment.newInstance(assignment, courseName, student), false);
                break;
            case ANNOUNCEMENT:
                DiscussionTopicHeader announcement = intent.getExtras().getParcelable(Const.ANNOUNCEMENT);
                String announcementCourseName = intent.getExtras().getString(Const.NAME);
                addFragment(AnnouncementFragment.newInstance(announcement, announcementCourseName, student), false);
                break;
            case EVENT:
                ScheduleItem item = intent.getExtras().getParcelable(Const.SCHEDULE_ITEM);
                addFragment(EventFragment.newInstance(item, student), false);
                break;
            case SYLLABUS:
                Course syllabusCourse = (Course) intent.getExtras().getSerializable(Const.COURSE);
                addFragment(CourseSyllabusFragment.newInstance(syllabusCourse, student), false);
                break;
            case ACCOUNT_NOTIFICATION:
                AccountNotification accountNotification = intent.getExtras().getParcelable(Const.ACCOUNT_NOTIFICATION);
                addFragment(AccountNotificationFragment.newInstance(accountNotification, student));
        }
    }
}
Also used : Assignment(com.instructure.canvasapi2.models.Assignment) ScheduleItem(com.instructure.canvasapi2.models.ScheduleItem) DiscussionTopicHeader(com.instructure.canvasapi2.models.DiscussionTopicHeader) Student(com.instructure.canvasapi2.models.Student) Course(com.instructure.canvasapi2.models.Course) AccountNotification(com.instructure.canvasapi2.models.AccountNotification)

Example 3 with Student

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

the class AlertPresenterTest method setup.

@Before
public void setup() {
    presenter = new AlertPresenter(new Student());
    alert1 = new Alert();
    alert2 = new Alert();
}
Also used : AlertPresenter(com.instructure.parentapp.presenters.AlertPresenter) Alert(com.instructure.canvasapi2.models.Alert) Student(com.instructure.canvasapi2.models.Student) Before(org.junit.Before)

Example 4 with Student

use of 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 5 with Student

use of 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)

Aggregations

Student (com.instructure.canvasapi2.models.Student)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 Course (com.instructure.canvasapi2.models.Course)3 Student (models.Student)3 Before (org.junit.Before)3 ApiPrefs (com.instructure.canvasapi2.utils.ApiPrefs)2 Prefs (com.instructure.pandautils.utils.Prefs)2 DialogInterface (android.content.DialogInterface)1 NonNull (android.support.annotation.NonNull)1 AlertDialog (android.support.v7.app.AlertDialog)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 StatusCallback (com.instructure.canvasapi2.StatusCallback)1 AccountNotification (com.instructure.canvasapi2.models.AccountNotification)1 Alert (com.instructure.canvasapi2.models.Alert)1 Assignment (com.instructure.canvasapi2.models.Assignment)1 BlockedStudentResponse (com.instructure.canvasapi2.models.BlockedStudentResponse)1 DiscussionTopicHeader (com.instructure.canvasapi2.models.DiscussionTopicHeader)1 MismatchedRegionResponse (com.instructure.canvasapi2.models.MismatchedRegionResponse)1 RevokedTokenResponse (com.instructure.canvasapi2.models.RevokedTokenResponse)1 ScheduleItem (com.instructure.canvasapi2.models.ScheduleItem)1