Skip to content

Commit

Permalink
Merge pull request openedx#434 from MITx/sarina/max-attempts-fix
Browse files Browse the repository at this point in the history
Add facility for fixed number of problem attempts
  • Loading branch information
ichuang committed Aug 16, 2012
2 parents 9c0e5fd + 9f158db commit 108ab51
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions common/lib/xmodule/xmodule/capa_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,9 @@ def __init__(self, system, location, definition, descriptor, instance_state=None
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')

Expand Down Expand Up @@ -244,7 +242,14 @@ def get_problem_html(self, encapsulate=True):

# 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

Expand Down

0 comments on commit 108ab51

Please sign in to comment.