def show_grades(self, has_staff_access): """ Returns whether subsection scores are currently available to users with or without staff access. """ return ShowCorrectness.correctness_available(self.show_correctness, self.due, has_staff_access)
def test_show_correctness_always(self, show_correctness, has_staff_access): """ Test that correctness is visible when show_correctness is turned on. """ assert ShowCorrectness.correctness_available( show_correctness=show_correctness, has_staff_access=has_staff_access)
def test_show_correctness_never(self, has_staff_access): """ Test that show_correctness="never" hides correctness from learners and course staff. """ assert not ShowCorrectness.correctness_available( show_correctness=ShowCorrectness.NEVER, has_staff_access=has_staff_access)
def test_show_correctness_never(self, has_staff_access): """ Test that show_correctness="never" hides correctness from learners and course staff. """ self.assertFalse(ShowCorrectness.correctness_available( show_correctness=ShowCorrectness.NEVER, has_staff_access=has_staff_access ))
def test_show_correctness_always(self, show_correctness, has_staff_access): """ Test that correctness is visible when show_correctness is turned on. """ self.assertTrue(ShowCorrectness.correctness_available( show_correctness=show_correctness, has_staff_access=has_staff_access ))
def test_show_correctness_past_due(self, due_date_str, has_staff_access, expected_result): """ Test show_correctness="past_due" to ensure: * correctness is always visible to course staff * correctness is always visible to everyone if there is no due date * correctness is visible to learners after the due date, when there is a due date. """ if due_date_str is None: due_date = None else: due_date = getattr(self, due_date_str) assert ShowCorrectness.correctness_available(ShowCorrectness.PAST_DUE, due_date, has_staff_access) ==\ expected_result
def test_show_correctness_past_due(self, due_date_str, has_staff_access, expected_result): """ Test show_correctness="past_due" to ensure: * correctness is always visible to course staff * correctness is always visible to everyone if there is no due date * correctness is visible to learners after the due date, when there is a due date. """ if due_date_str is None: due_date = None else: due_date = getattr(self, due_date_str) self.assertEquals( ShowCorrectness.correctness_available(ShowCorrectness.PAST_DUE, due_date, has_staff_access), expected_result )
def test_show_correctness_default(self): """ Test that correctness is visible by default. """ self.assertTrue(ShowCorrectness.correctness_available())