예제 #1
0
    def test_has_instructors(self, client, admin_session):
        """Admins can see instructor changes that might disrupt scheduled recordings."""
        with test_approvals_workflow(app):
            meeting_days, meeting_start_time, meeting_end_time = SisSection.get_meeting_times(
                term_id=self.term_id,
                section_id=section_3_id,
            )
            instructor_uids = SisSection.get_instructor_uids(term_id=self.term_id, section_id=section_3_id)
            Scheduled.create(
                cross_listed_section_ids=[],
                instructor_uids=instructor_uids + ['999999'],
                meeting_days=meeting_days,
                meeting_start_time=meeting_start_time,
                meeting_end_time=meeting_end_time,
                publish_type_='canvas',
                recording_type_='presenter_audio',
                room_id=Room.get_room_id(section_id=section_3_id, term_id=self.term_id),
                section_id=section_3_id,
                term_id=self.term_id,
            )
            std_commit(allow_test_environment=True)

            api_json = self._api_course_changes(client, term_id=self.term_id)
            course = _find_course(api_json=api_json, section_id=section_3_id)
            assert course
            assert course['scheduled']['hasObsoleteRoom'] is False
            assert course['scheduled']['hasObsoleteMeetingTimes'] is False
            assert course['scheduled']['hasObsoleteInstructors'] is True
    def test_alert_admin_of_instructor_change(self):
        """Emails admin when a scheduled course gets a new instructor."""
        with test_approvals_workflow(app):
            term_id = app.config['CURRENT_TERM_ID']
            section_id = 22287
            approved_by_uid = '8765432'
            room_id = Room.find_room('Barker 101').id
            approval = Approval.create(
                approved_by_uid=approved_by_uid,
                approver_type_='instructor',
                cross_listed_section_ids=[],
                publish_type_='canvas',
                recording_type_='presenter_audio',
                room_id=room_id,
                section_id=section_id,
                term_id=term_id,
            )
            meeting_days, meeting_start_time, meeting_end_time = SisSection.get_meeting_times(
                term_id=term_id,
                section_id=section_id,
            )
            Scheduled.create(
                cross_listed_section_ids=approval.cross_listed_section_ids,
                instructor_uids=SisSection.get_instructor_uids(
                    term_id=term_id, section_id=section_id),
                meeting_days=meeting_days,
                meeting_start_time=meeting_start_time,
                meeting_end_time=meeting_end_time,
                publish_type_=approval.publish_type,
                recording_type_=approval.recording_type,
                room_id=room_id,
                section_id=section_id,
                term_id=term_id,
            )

            admin_uid = app.config['EMAIL_DIABLO_ADMIN_UID']
            email_count = _get_email_count(admin_uid)
            std_commit(allow_test_environment=True)
            AdminEmailsJob(app.app_context).run()
            std_commit(allow_test_environment=True)
            assert _get_email_count(admin_uid) > email_count
    def test_alert_admin_of_room_change(self):
        """Emails admin when a scheduled course gets a room change."""
        with test_approvals_workflow(app):
            term_id = app.config['CURRENT_TERM_ID']
            section_id = 26094
            approved_by_uid = '6789'
            the_old_room = 'Wheeler 150'
            scheduled_in_room = Room.find_room(the_old_room)
            approval = Approval.create(
                approved_by_uid=approved_by_uid,
                approver_type_='instructor',
                cross_listed_section_ids=[],
                publish_type_='kaltura_media_gallery',
                recording_type_='presenter_audio',
                room_id=scheduled_in_room.id,
                section_id=section_id,
                term_id=term_id,
            )
            meeting_days, meeting_start_time, meeting_end_time = SisSection.get_meeting_times(
                term_id=term_id,
                section_id=section_id,
            )
            Scheduled.create(
                cross_listed_section_ids=approval.cross_listed_section_ids,
                instructor_uids=SisSection.get_instructor_uids(
                    term_id=term_id, section_id=section_id),
                meeting_days=meeting_days,
                meeting_start_time=meeting_start_time,
                meeting_end_time=meeting_end_time,
                publish_type_=approval.publish_type,
                recording_type_=approval.recording_type,
                room_id=scheduled_in_room.id,
                section_id=section_id,
                term_id=term_id,
            )

            admin_uid = app.config['EMAIL_DIABLO_ADMIN_UID']
            email_count = _get_email_count(admin_uid)
            AdminEmailsJob(app.app_context).run()
            assert _get_email_count(admin_uid) == email_count + 1
예제 #4
0
def _schedule_recordings(
        section_id,
        term_id,
        publish_type='kaltura_media_gallery',
        recording_type='presenter_presentation_audio',
        room_id=None,
):
    meeting_days, meeting_start_time, meeting_end_time = SisSection.get_meeting_times(
        term_id=term_id,
        section_id=section_id,
    )
    Scheduled.create(
        cross_listed_section_ids=[],
        instructor_uids=SisSection.get_instructor_uids(term_id=term_id, section_id=section_id),
        meeting_days=meeting_days,
        meeting_start_time=meeting_start_time,
        meeting_end_time=meeting_end_time,
        publish_type_=publish_type,
        recording_type_=recording_type,
        room_id=room_id or Room.get_room_id(section_id=section_id, term_id=term_id),
        section_id=section_id,
        term_id=term_id,
    )
    std_commit(allow_test_environment=True)
예제 #5
0
def _schedule_recordings(all_approvals, course):
    term_id = course['termId']
    section_id = int(course['sectionId'])
    all_approvals.sort(key=lambda a: a.created_at.isoformat())
    approval = all_approvals[-1]

    room = Room.get_room(approval.room_id)
    meeting_days, meeting_start_time, meeting_end_time = SisSection.get_meeting_times(
        term_id=term_id,
        section_id=section_id,
    )
    time_format = '%H:%M'
    # Recording starts X minutes before/after official start; it ends Y minutes before/after official end time.
    recording_offset_start = app.config['KALTURA_RECORDING_OFFSET_START']
    recording_offset_end = app.config['KALTURA_RECORDING_OFFSET_END']
    adjusted_start_time = datetime.strptime(
        meeting_start_time,
        time_format) + timedelta(minutes=recording_offset_start)
    adjusted_end_time = datetime.strptime(
        meeting_end_time,
        time_format) + timedelta(minutes=recording_offset_end)
    days = format_days(meeting_days)
    instructor_uids = [
        instructor['uid'] for instructor in course['instructors']
    ]

    app.logger.info(f"""
        Prepare to schedule recordings for {course["label"]}:
            Room: {room.location}
            Instructor UIDs: {instructor_uids}
            Schedule: {days}, {adjusted_start_time} to {adjusted_end_time}
            Recording: {approval.recording_type}; {approval.publish_type}
    """)

    if room.kaltura_resource_id:
        Kaltura().schedule_recording(
            course_label=course['label'],
            instructor_uids=instructor_uids,
            days=days,
            start_time=adjusted_start_time,
            end_time=adjusted_end_time,
            publish_type=approval.publish_type,
            recording_type=approval.recording_type,
            room=room,
        )
        scheduled = Scheduled.create(
            cross_listed_section_ids=approval.cross_listed_section_ids,
            instructor_uids=SisSection.get_instructor_uids(
                term_id=term_id, section_id=section_id),
            meeting_days=meeting_days,
            meeting_start_time=meeting_start_time,
            meeting_end_time=meeting_end_time,
            publish_type_=approval.publish_type,
            recording_type_=approval.recording_type,
            room_id=approval.room_id,
            section_id=section_id,
            term_id=term_id,
        )
        notify_instructors_recordings_scheduled(course=course,
                                                scheduled=scheduled)

        uids = [approval.approved_by_uid for approval in all_approvals]
        app.logger.info(
            f'Recordings scheduled for course {section_id} per approvals: {", ".join(uids)}'
        )

    else:
        app.logger.error(f"""
            FAILED to schedule recordings because room has no 'kaltura_resource_id'.
            Course: {course}
            Room: {room}
            Latest approval: {approval}
        """)
예제 #6
0
def _get_instructor_uids(section_id, term_id):
    return SisSection.get_instructor_uids(term_id=term_id, section_id=section_id)