Merge pull request #1819 from edx/anton/fix-lti-scores
Fix LTI max_score method.
This commit is contained in:
@@ -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):
|
||||
@@ -376,7 +382,7 @@ oauth_consumer_key="", oauth_signature="frVp4JuvT1mVXlxktiAUjQ7%2F1cw%3D"'}
|
||||
return params
|
||||
|
||||
def max_score(self):
|
||||
return self.weight
|
||||
return self.weight if self.has_score else None
|
||||
|
||||
|
||||
@XBlock.handler
|
||||
@@ -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')
|
||||
|
||||
@@ -194,6 +194,7 @@ class LTIModuleTest(LogicTest):
|
||||
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, '')
|
||||
@@ -249,3 +250,16 @@ class LTIModuleTest(LogicTest):
|
||||
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)
|
||||
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user