Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LTI max_score method. #1819

Merged
merged 4 commits into from
Dec 5, 2013
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 7 additions & 2 deletions common/lib/xmodule/xmodule/lti_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ 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},
)


class LTIModule(LTIFields, XModule):
Expand Down Expand Up @@ -375,7 +380,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.graded else 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be the case, when this is practice, not graded problem. So student will submit answer, and LTI Provider will return 0.3. But self.graded is False, so 0 * 0.3 will be saved. And this is wrong. I will think how to fix that.



@XBlock.handler
Expand Down
10 changes: 10 additions & 0 deletions common/lib/xmodule/xmodule/tests/test_lti_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,13 @@ 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(), 100)

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