Skip to content

Commit

Permalink
Merge pull request #1819 from edx/anton/fix-lti-scores
Browse files Browse the repository at this point in the history
Fix LTI max_score method.
  • Loading branch information
auraz committed Dec 5, 2013
2 parents 68e1985 + 1cd9325 commit bceadd4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
11 changes: 8 additions & 3 deletions common/lib/xmodule/xmodule/lti_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@ class LTIFields(object):
custom_parameters = List(help="Custom parameters (vbid, book_location, etc..)", scope=Scope.settings)
open_in_a_new_page = Boolean(help="Should LTI be opened in new page?", default=True, scope=Scope.settings)
graded = Boolean(help="Grades will be considered in overall score.", default=False, scope=Scope.settings)
weight = Float(help="Weight for student grades.", default=1.0, scope=Scope.settings)
weight = Float(
help="Weight for student grades.",
default=1.0,
scope=Scope.settings,
values={"min": 0},
)
has_score = Boolean(help="Does this LTI module have score?", default=False, scope=Scope.settings)


class LTIModule(LTIFields, XModule):
Expand Down Expand Up @@ -376,7 +382,7 @@ def oauth_params(self, custom_parameters, client_key, client_secret):
return params

def max_score(self):
return self.weight
return self.weight if self.has_score else None


@XBlock.handler
Expand Down Expand Up @@ -582,6 +588,5 @@ class LTIDescriptor(LTIFields, MetadataOnlyEditingDescriptor, EmptyDataRawDescri
"""
Descriptor for LTI Xmodule.
"""
has_score = True
module_class = LTIModule
grade_handler = module_attr('grade_handler')
14 changes: 14 additions & 0 deletions common/lib/xmodule/xmodule/tests/test_lti_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def test_good_request(self):
Response from Tool Provider is correct.
"""
self.xmodule.verify_oauth_body_sign = Mock()
self.xmodule.has_score = True
request = Request(self.environ)
request.body = self.get_request_body()
response = self.xmodule.grade_handler(request, '')
Expand Down Expand Up @@ -249,3 +250,16 @@ def test_verify_oauth_body_sign(self):
def test_client_key_secret(self):
pass

def test_max_score(self):
self.xmodule.weight = 100.0

self.xmodule.graded = True
self.assertEqual(self.xmodule.max_score(), None)

self.xmodule.has_score = True
self.assertEqual(self.xmodule.max_score(), 100.0)

self.xmodule.graded = False
self.assertEqual(self.xmodule.max_score(), 100.0)


4 changes: 2 additions & 2 deletions lms/djangoapps/courseware/features/lti.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ Feature: LMS.LTI component
Scenario: Graded LTI component in LMS is correctly works
Given the course has correct LTI credentials
And the course has an LTI component with correct fields:
| open_in_a_new_page | weight | is_graded |
| False | 10 | True |
| open_in_a_new_page | weight | is_graded | has_score |
| False | 10 | True | True |
And I submit answer to LTI question
And I click on the "Progress" tab
Then I see text "Problem Scores: 5/10"
Expand Down

0 comments on commit bceadd4

Please sign in to comment.