Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -88,7 +88,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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look like the right way to do this. has_score is a class attribute that is never modified. Is it correct to make it a field in this module that shadows the class attribute? @cpennington ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nedbat This is result of discussion with @cpennington

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, that class attribute is removed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we talked about this this morning. has_score is never accessed as a class attribute, and it covers exactly the use-case that @auraz was concerned about (distinguishing between non-scored and scored LTI modules), in a way that 'graded' doesn't.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.



class LTIModule(LTIFields, XModule):
Expand Down Expand Up @@ -375,7 +381,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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_score should also be conditional on self.has_score.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LTI has no get_score, and it works successfully. Why it needs get_score? @cpennington

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[дек.-3 19:38] Calen Pennington: if it's working w/o, then leave it as is. we need to clarify how grading works in the LMS wrt to XBlocks



@XBlock.handler
Expand Down Expand Up @@ -581,6 +587,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