Merge branch 'release' into release-10-06-conflict

This commit is contained in:
Eric Fischer
2016-10-06 14:25:47 -04:00
21 changed files with 567 additions and 295 deletions

View File

@@ -18,8 +18,8 @@ from courseware.model_data import FieldDataCache
from courseware.module_render import get_module_for_descriptor
from courseware.models import StudentModule
from edxmako.shortcuts import render_to_string
from grades.scores import weighted_score
from grades.signals.signals import SCORE_CHANGED
from lms.djangoapps.grades.scores import weighted_score
from lms.djangoapps.grades.signals.signals import SCORE_CHANGED
from lang_pref import LANGUAGE_KEY
from student.models import CourseEnrollment, CourseEnrollmentAllowed
from submissions import api as sub_api # installed from the edx-submissions repository
@@ -317,7 +317,11 @@ def _fire_score_changed_for_block(course_id, student, block, module_state_key):
field_data_cache=cache,
course_key=course_id
)
points_earned, points_possible = weighted_score(0, module.max_score(), getattr(module, 'weight', None))
max_score = module.max_score()
if max_score is None:
return
else:
points_earned, points_possible = weighted_score(0, max_score, getattr(module, 'weight', None))
else:
points_earned, points_possible = 0, 0
SCORE_CHANGED.send(
@@ -325,8 +329,8 @@ def _fire_score_changed_for_block(course_id, student, block, module_state_key):
points_possible=points_possible,
points_earned=points_earned,
user=student,
course_id=course_id,
usage_id=module_state_key
course_id=unicode(course_id),
usage_id=unicode(module_state_key)
)

View File

@@ -3190,7 +3190,8 @@ class TestInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginEnrollmentTes
})
self.assertEqual(response.status_code, 400)
def test_reset_student_attempts_delete(self):
@patch('courseware.module_render.SCORE_CHANGED.send')
def test_reset_student_attempts_delete(self, _mock_signal):
""" Test delete single student state. """
url = reverse('reset_student_attempts', kwargs={'course_id': self.course.id.to_deprecated_string()})
response = self.client.post(url, {

View File

@@ -378,7 +378,8 @@ class TestInstructorEnrollmentStudentModule(SharedModuleStoreTestCase):
reset_student_attempts(self.course_key, self.user, msk, requesting_user=self.user)
self.assertEqual(json.loads(module().state)['attempts'], 0)
def test_delete_student_attempts(self):
@mock.patch('courseware.module_render.SCORE_CHANGED.send')
def test_delete_student_attempts(self, _mock_signal):
msk = self.course_key.make_usage_key('dummy', 'module')
original_state = json.dumps({'attempts': 32, 'otherstuff': 'alsorobots'})
StudentModule.objects.create(
@@ -404,7 +405,7 @@ class TestInstructorEnrollmentStudentModule(SharedModuleStoreTestCase):
# Disable the score change signal to prevent other components from being
# pulled into tests.
@mock.patch('courseware.module_render.SCORE_CHANGED.send')
def test_delete_submission_scores(self, _lti_mock):
def test_delete_submission_scores(self, _mock_signal):
user = UserFactory()
problem_location = self.course_key.make_usage_key('dummy', 'module')
@@ -548,7 +549,7 @@ class TestStudentModuleGrading(SharedModuleStoreTestCase):
self.course,
get_course_blocks(self.user, self.course.location)
)
grade = subsection_grade_factory.update(self.sequence)
grade = subsection_grade_factory.create(self.sequence)
self.assertEqual(grade.all_total.earned, all_earned)
self.assertEqual(grade.graded_total.earned, graded_earned)
self.assertEqual(grade.all_total.possible, all_possible)

View File

@@ -49,7 +49,8 @@ class InstructorServiceTests(SharedModuleStoreTestCase):
state=json.dumps({'attempts': 2}),
)
def test_reset_student_attempts_delete(self):
@mock.patch('courseware.module_render.SCORE_CHANGED.send')
def test_reset_student_attempts_delete(self, _mock_signal):
"""
Test delete student state.
"""