From 725e9a2a7bf73a6c93a3b096e04b4f23b896cfe4 Mon Sep 17 00:00:00 2001 From: Sarina Canelake Date: Thu, 16 Aug 2012 14:27:28 -0400 Subject: [PATCH] Add facility for fixed number of problem attempts --- common/lib/xmodule/xmodule/capa_module.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index b90a94279c..e6da87b5c6 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -108,11 +108,9 @@ class CapaModule(XModule): self.grace_period = None self.close_date = self.display_due_date - self.max_attempts = only_one(dom2.xpath('/problem/@attempts')) - if len(self.max_attempts) > 0: + self.max_attempts = self.metadata.get('attempts', None) + if self.max_attempts is not None: self.max_attempts = int(self.max_attempts) - else: - self.max_attempts = None self.show_answer = self.metadata.get('showanswer', 'closed') @@ -244,7 +242,14 @@ class CapaModule(XModule): # We using strings as truthy values, because the terminology of the # check button is context-specific. - check_button = "Grade" if self.max_attempts else "Check" + + # Put a "Check" button if unlimited attempts or still some left + if self.max_attempts is None or self.attempts < self.max_attempts-1: + check_button = "Check" + else: + # Will be final check so let user know that + check_button = "Final Check" + reset_button = True save_button = True