From c639bbc6f05130201e4630043a413afe94f6fc7c Mon Sep 17 00:00:00 2001 From: Julian Arni Date: Mon, 3 Jun 2013 11:15:45 -0400 Subject: [PATCH 1/2] Add partial credit for foldit --- common/lib/xmodule/xmodule/foldit_module.py | 33 +++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/foldit_module.py b/common/lib/xmodule/xmodule/foldit_module.py index d5afc15bc7..f237bec866 100644 --- a/common/lib/xmodule/xmodule/foldit_module.py +++ b/common/lib/xmodule/xmodule/foldit_module.py @@ -16,6 +16,8 @@ log = logging.getLogger(__name__) class FolditFields(object): # default to what Spring_7012x uses + required_level_half_credit = Integer(default=3, scope=Scope.settings) + required_sublevel_half_credit = Integer(default=5, scope=Scope.settings) required_level = Integer(default=4, scope=Scope.settings) required_sublevel = Integer(default=5, scope=Scope.settings) due = Date(help="Date that this problem is due by", scope=Scope.settings) @@ -36,6 +38,8 @@ class FolditModule(FolditFields, XModule): """ @@ -57,6 +61,22 @@ class FolditModule(FolditFields, XModule): self.due_time) return complete + def is_half_complete(self): + """ + Did the user reach the required level for half credit? + + Ideally this would be more flexible than just 0, 0.5, or 1 credit. On + the other hand, the xml attributes for specifying more specific + cut-offs and partial grades can get more confusing. + """ + from foldit.models import PuzzleComplete + complete = PuzzleComplete.is_level_complete( + self.system.anonymous_student_id, + self.required_level_half_credit, + self.required_sublevel_half_credit, + self.due_time) + return complete + def completed_puzzles(self): """ Return a list of puzzles that this user has completed, as an array of @@ -139,9 +159,18 @@ class FolditModule(FolditFields, XModule): def get_score(self): """ - 0 / 1 based on whether student has gotten far enough. + 0 if required_level_half_credit - required_sublevel_half_credit not + reached. + 1/2 if required_level_half_credit and required_sublevel_half_credit + reached. + 2/2 if requred_level and required_sublevel reached. """ - score = 1 if self.is_complete() else 0 + if self.is_complete(): + score = 1 + elif self.is_half_complete(): + score = 0.5 + else: + score = 0 return {'score': score, 'total': self.max_score()} From 198d63db86d1a4c31a768ace27ead049a60102a4 Mon Sep 17 00:00:00 2001 From: Julian Arni Date: Mon, 3 Jun 2013 12:13:05 -0400 Subject: [PATCH 2/2] Update docstring for get_score --- common/lib/xmodule/xmodule/foldit_module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/foldit_module.py b/common/lib/xmodule/xmodule/foldit_module.py index f237bec866..62c5ea416e 100644 --- a/common/lib/xmodule/xmodule/foldit_module.py +++ b/common/lib/xmodule/xmodule/foldit_module.py @@ -161,9 +161,9 @@ class FolditModule(FolditFields, XModule): """ 0 if required_level_half_credit - required_sublevel_half_credit not reached. - 1/2 if required_level_half_credit and required_sublevel_half_credit + 0.5 if required_level_half_credit and required_sublevel_half_credit reached. - 2/2 if requred_level and required_sublevel reached. + 1 if requred_level and required_sublevel reached. """ if self.is_complete(): score = 1