Skip to content

Commit

Permalink
Fix for SOL-475 (double exam grader bug)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdrayer committed Apr 27, 2015
1 parent 4a4c3c5 commit 90f138b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cms/djangoapps/contentstore/views/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,16 @@ def create_xblock(parent_locator, user, category, display_name, boilerplate=None

# Entrance Exams: Grader assignment
if settings.FEATURES.get('ENTRANCE_EXAMS', False):
course = store.get_course(usage_key.course_key)
course_key = usage_key.course_key
course = store.get_course(course_key)
if hasattr(course, 'entrance_exam_enabled') and course.entrance_exam_enabled:
if category == 'sequential' and parent_locator == course.entrance_exam_id:
grading_model = CourseGradingModel.fetch(course_key)
graders = grading_model.graders
# Clean up any pre-existing Entrance Exam grader cruft
for i, grader in enumerate(graders):
if grader['type'] == 'Entrance Exam':
CourseGradingModel.delete_grader(course_key, i, user)
grader = {
"type": "Entrance Exam",
"min_count": 0,
Expand Down
8 changes: 8 additions & 0 deletions cms/djangoapps/contentstore/views/tests/test_entrance_exam.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ def test_contentstore_views_entrance_exam_delete(self):
resp = self.client.get(self.exam_url)
self.assertEqual(resp.status_code, 200)

# Confirm that we have only one Entrance Exam grader after re-adding the exam (validates SOL-475)
graders = CourseGradingModel.fetch(self.course_key).graders
count = 0
for grader in graders:
if grader['type'] == 'Entrance Exam':
count += 1
self.assertEqual(count, 1)

def test_contentstore_views_entrance_exam_delete_bogus_course(self):
"""
Unit Test: test_contentstore_views_entrance_exam_delete_bogus_course
Expand Down

0 comments on commit 90f138b

Please sign in to comment.