def authentication_events_synced_as_df( auth_events: List[AuthenticationEvent], sync_db: sqlalchemy.engine.base.Engine, ) -> DataFrame: """ Fetch AuthenticationEvent API data for a range of courses and return a AuthenticationEvent API DataFrame with current and previously fetched data Parameters ---------- auth_events: List[AuthenticationEvent] a list of Canvas AuthenticationEvent objects sync_db: sqlalchemy.engine.base.Engine an Engine instance for creating database connections Returns ------- DataFrame an AuthenticationEvent API DataFrame with the current and previously fetched data """ auth_events_df: DataFrame = _sync_without_cleanup(to_df(auth_events), sync_db) cleanup_after_sync(AUTH_EVENTS_RESOURCE_NAME, sync_db) return auth_events_df
def sections_synced_as_df( sections: List[Section], sync_db: sqlalchemy.engine.base.Engine, ) -> DataFrame: """ Fetch Sections API data for a range of courses and return a Sections API DataFrame with current and previously fetched data Parameters ---------- sections: List[Section] a list of Canvas Sections objects sync_db: sqlalchemy.engine.base.Engine an Engine instance for creating database connections Returns ------- DataFrame a Sections API DataFrame with the current and previously fetched data """ sections_df: DataFrame = _sync_without_cleanup(to_df(sections), sync_db) cleanup_after_sync(SECTIONS_RESOURCE_NAME, sync_db) return sections_df
def enrollments_synced_as_df( enrollments: List[Enrollment], sync_db: sqlalchemy.engine.base.Engine, ) -> DataFrame: """ Fetch Enrollments API data for a range of students and return a Enrollments API DataFrame with current and previously fetched data Parameters ---------- enrollments: List[Enrollment] a list of Canvas Enrollments objects sync_db: sqlalchemy.engine.base.Engine an Engine instance for creating database connections Returns ------- DataFrame a Enrollments API DataFrame with the current and previously fetched data """ enrollments_df: DataFrame = _sync_without_cleanup(to_df(enrollments), sync_db) cleanup_after_sync(ENROLLMENTS_RESOURCE_NAME, sync_db) return enrollments_df
def request_all_coursework_as_df( resource: Optional[Resource], course_ids: List[str], sync_db: sqlalchemy.engine.base.Engine, ) -> DataFrame: """ Fetch Coursework API data for all courses and return a Coursework API DataFrame Parameters ---------- resource: Optional[Resource] a Google Classroom SDK Resource course_ids: List[str] a list of course ids to retrieve coursework for sync_db: sqlalchemy.engine.base.Engine an Engine instance for creating database connections Returns ------- DataFrame a Coursework API DataFrame with the current and previously fetched data Notes ----- DataFrame columns are: courseId: Identifier of the course id: Classroom-assigned identifier of this course work, unique per course title: Title of this course work description: Optional description of this course work state: Status of this course work alternateLink: Absolute link to this course work in the Classroom web UI creationTime: Timestamp when this course work was created updateTime: Timestamp of the most recent change to this course work maxPoints: Maximum grade for this course work workType: Type of this course work submissionModificationMode: Setting to determine when students are allowed to modify submissions assigneeMode: Assignee mode of the coursework creatorUserId: Identifier for the user that created the coursework dueDate.year: Optional year, in UTC, that submissions are due dueDate.month: Optional month, in UTC, that submissions are due dueDate.day: Optional day, in UTC, that submissions are due dueTime.hours: Optional hour, in UTC, that submissions are due dueTime.minutes: Optional minute, in UTC, that submissions are due scheduledTime: Optional timestamp when this course work is scheduled to be published topicId: Identifier for the topic that this coursework is associated with CreateDate: Date this record was created by the extractor LastModifiedDate: Date this record was last updated by the extractor """ coursework_df: DataFrame = request_latest_coursework_as_df(resource, course_ids) coursework_df = _sync_without_cleanup(coursework_df, sync_db) cleanup_after_sync(ASSIGNMENTS_RESOURCE_NAME, sync_db) return coursework_df
def request_all_submissions_as_df( resource: Optional[Resource], course_ids: List[str], sync_db: sqlalchemy.engine.base.Engine, ) -> DataFrame: """ Fetch StudentSubmissions API data for the given coursework and return a StudentSubmissions API DataFrame Parameters ---------- resource: Optional[Resource] a Google Classroom SDK Resource course_ids: List[str] a list of course ids to retrieve coursework for Returns ------- DataFrame a Coursework API DataFrame with the fetched data Notes ----- DataFrame columns are: courseId: Identifier of the course courseWorkId: Identifier for the course work this corresponds to id: Classroom-assigned Identifier for the student submission, unique per coursework userId: Identifier for the student that owns this submission creationTime: Creation time of this submission updateTime: Last update time of this submission state: Status of this submission late: Whether this submission is late draftGrade: Optional pending grade. If unset, no grade was set. Decimal values are allowed. assignedGrade: Optional grade. If unset, no grade was set. Decimal values are allowed. alternateLink: Absolute link to this course work in the Classroom web UI courseWorkType: Type of course work this submission is for associatedWithDeveloper: Whether this student submission is associated with the Developer Console project making the request submissionHistory: The history of the submission as JSON CreateDate: Date this record was created by the extractor LastModifiedDate: Date this record was last updated by the extractor """ submissions_df: DataFrame = request_latest_submissions_as_df( resource, course_ids) submissions_df = _sync_without_cleanup(submissions_df, sync_db) cleanup_after_sync(SUBMISSIONS_RESOURCE_NAME, sync_db) return submissions_df
def request_all_courses_as_df( resource: Resource, sync_db: sqlalchemy.engine.base.Engine) -> DataFrame: """ Fetch Course API data for all courses and return a Courses API DataFrame Parameters ---------- resource: Optional[Resource] a Google Classroom SDK Resource sync_db: sqlalchemy.engine.base.Engine an Engine instance for creating database connections Returns ------- DataFrame a Courses API DataFrame with the current and previously fetched data Notes ----- DataFrame columns are: id: Identifier for this course assigned by Classroom name: Name of the course section: Section of the course descriptionHeading: Optional heading for the description description: Optional description room: Optional room location ownerId: The identifier of the owner of a course creationTime: Creation time of the course updateTime: Time of the most recent update to this course enrollmentCode: Enrollment code to use when joining this course courseState: State of the course alternateLink: Absolute link to this course in the Classroom web UI teacherGroupEmail: The email address of a Google group containing all teachers of the course courseGroupEmail: The email address of a Google group containing all members of the course teacherFolder.id: The identifier of the teacher folder teacherFolder.title: The identifier of the teacher folder, teacherFolder.alternateLink: Absolute link to the teacher folder in the Classroom web UI guardiansEnabled: Whether or not guardian notifications are enabled for this course calendarId: The Calendar ID for a calendar that all course members can see alias: A course alias selected from the available aliases for the course CreateDate: Date this record was created by the extractor LastModifiedDate: Date this record was last updated by the extractor """ courses_df = request_latest_courses_as_df(resource) courses_df = _sync_without_cleanup(courses_df, sync_db) cleanup_after_sync(COURSES_RESOURCE_NAME, sync_db) return courses_df
def sync_resource( resource_name: str, db_engine: sqlalchemy.engine.base.Engine, data: List[Dict[str, Any]], id_column: str = "id", ) -> DataFrame: if len(data) == 0: return DataFrame() resource_df: DataFrame = DataFrame(data) synced_df = sync_to_db_without_cleanup( resource_df=resource_df, identity_columns=[id_column], resource_name=resource_name, sync_db=db_engine, ) cleanup_after_sync(resource_name, db_engine) return synced_df
def request_all_students_as_df( resource: Optional[Resource], course_ids: List[str], sync_db: sqlalchemy.engine.base.Engine, ) -> DataFrame: """ Fetch Students API data for a range of courses and return a Students API DataFrame with current and previously fetched data Parameters ---------- resource: Optional[Resource] a Google Classroom SDK Resource or None course_ids: List[str] a list of Google Classroom course ids as a string array sync_db: sqlalchemy.engine.base.Engine an Engine instance for creating database connections Returns ------- DataFrame a Students API DataFrame with the current and previously fetched data Notes ----- DataFrame columns are: courseId: Identifier of the course userId: Identifier of the user profile.id: Identifier of the user profile.name.givenName: The user's first name profile.name.familyName: The user's last name profile.name.fullName: The user's full name formed by concatenating the first and last name values profile.emailAddress: Email address of the user """ students_df: DataFrame = request_latest_students_as_df( resource, course_ids) students_df = _sync_without_cleanup(students_df, sync_db) cleanup_after_sync(STUDENTS_RESOURCE_NAME, sync_db) return students_df
def courses_synced_as_df(courses: List[Course], sync_db: sqlalchemy.engine.base.Engine) -> DataFrame: """ Using Course API data, return a Courses API DataFrame Parameters ---------- courses: List[Course] a list of Canvas Course SDK objects sync_db: sqlalchemy.engine.base.Engine an Engine instance for creating database connections Returns ------- DataFrame a Courses API DataFrame with the current and previously fetched data """ courses_df: DataFrame = _sync_without_cleanup(to_df(courses), sync_db) cleanup_after_sync(COURSES_RESOURCE_NAME, sync_db) return courses_df