def test_completion_does_not_treat_unreleased_as_complete(self): """ Test that unreleased assignments are not treated as complete. """ course = CourseFactory() chapter = ItemFactory( parent=course, category='chapter', graded=True, due=datetime.datetime.now() + datetime.timedelta(hours=2), start=datetime.datetime.now() + datetime.timedelta(hours=1)) sequential = ItemFactory(parent=chapter, category='sequential') problem = ItemFactory(parent=sequential, category='problem', has_score=True) ItemFactory(parent=sequential, category='video', has_score=False) self.override_waffle_switch(True) BlockCompletion.objects.submit_completion(self.user, problem.location, 1) assignments = get_course_assignments(course.location.context_key, self.user, None) assert len(assignments) == 1 assert not assignments[0].complete
def test_completion_ignores_non_scored_items(self): """ Test that we treat a sequential with incomplete (but not scored) items (like a video maybe) as complete. """ course = CourseFactory() chapter = ItemFactory(parent=course, category='chapter', graded=True, due=datetime.datetime.now(), start=datetime.datetime.now() - datetime.timedelta(hours=1)) sequential = ItemFactory(parent=chapter, category='sequential') problem = ItemFactory(parent=sequential, category='problem', has_score=True) ItemFactory(parent=sequential, category='video', has_score=False) self.override_waffle_switch(True) BlockCompletion.objects.submit_completion(self.user, problem.location, 1) assignments = get_course_assignments(course.location.context_key, self.user, None) assert len(assignments) == 1 assert assignments[0].complete
def generate_ics_for_user_course(course, user, request): """ Generates ics-formatted bytestrings of all assignments for a given course and user. To pretty-print each bytestring, do: `ics.decode('utf8').replace('\r\n', '\n')` Returns an iterable of ics files, each one representing an assignment. """ assignments = get_course_assignments(course.id, user, request) platform_name = get_value('platform_name', settings.PLATFORM_NAME) platform_email = get_value('email_from_address', settings.DEFAULT_FROM_EMAIL) now = datetime.now(pytz.utc) return ( generate_ics_for_event( now=now, organizer_name=platform_name, organizer_email=platform_email, start=assignment.date, title=assignment.title, course_name=course.display_name_with_default, uid=get_calendar_event_id(user, str(assignment.block_key), 'due', request.site.domain), ) for assignment in assignments )
def generate_ics_files_for_user_course(course, user, user_calendar_sync_config_instance): """ Generates ics-formatted bytestrings of all assignments for a given course and user. To pretty-print each bytestring, do: `ics.decode('utf8').replace('\r\n', '\n')` Returns a dictionary of ics files, each one representing an assignment. """ assignments = get_course_assignments(course.id, user) platform_name = get_value('platform_name', settings.PLATFORM_NAME) platform_email = get_value('email_from_address', settings.DEFAULT_FROM_EMAIL) now = datetime.now(pytz.utc) site_config = SiteConfiguration.get_configuration_for_org(course.org) ics_files = {} for assignment in assignments: ics_files[assignment.title] = generate_ics_for_event( now=now, organizer_name=platform_name, organizer_email=platform_email, start=assignment.date, title=assignment.title, course_name=course.display_name_with_default, uid=get_calendar_event_id(user, str(assignment.block_key), 'due', site_config.site.domain), config=user_calendar_sync_config_instance, ) return ics_files
def test_completion_does_not_count_empty_sequentials(self): """ Test that we treat a sequential with no content as incomplete. This can happen with unreleased assignments, for example (start date in future). """ course = CourseFactory() chapter = ItemFactory(parent=course, category='chapter', graded=True, due=datetime.datetime.now()) ItemFactory(parent=chapter, category='sequential') assignments = get_course_assignments(course.location.context_key, self.user, None) assert len(assignments) == 1 assert not assignments[0].complete