Commit 1e6ddec4 by Vik Paruchuri

add some documentation

parent 5bcfba9e
...@@ -28,6 +28,7 @@ log = logging.getLogger("mitx.courseware") ...@@ -28,6 +28,7 @@ log = logging.getLogger("mitx.courseware")
#Set the default number of max attempts. Should be 1 for production #Set the default number of max attempts. Should be 1 for production
#Set higher for debugging/testing #Set higher for debugging/testing
#maxattempts specified in xml definition overrides this
max_attempts = 1 max_attempts = 1
def only_one(lst, default="", process=lambda x: x): def only_one(lst, default="", process=lambda x: x):
...@@ -98,16 +99,18 @@ class SelfAssessmentModule(XModule): ...@@ -98,16 +99,18 @@ class SelfAssessmentModule(XModule):
self.max_attempts = self.metadata.get('attempts', None) self.max_attempts = self.metadata.get('attempts', None)
self.hint="" self.hint=""
#Pull variables from instance state if available #Try setting maxattempts, use default if not available in metadata
if self.max_attempts is not None: if self.max_attempts is not None:
self.max_attempts = int(self.max_attempts) self.max_attempts = int(self.max_attempts)
else: else:
self.max_attempts = max_attempts self.max_attempts = max_attempts
#Load instance state
if instance_state is not None: if instance_state is not None:
instance_state = json.loads(instance_state) instance_state = json.loads(instance_state)
log.debug(instance_state) log.debug(instance_state)
#Pull variables from instance state if available
if instance_state is not None and 'attempts' in instance_state: if instance_state is not None and 'attempts' in instance_state:
self.attempts = instance_state['attempts'] self.attempts = instance_state['attempts']
...@@ -131,8 +134,8 @@ class SelfAssessmentModule(XModule): ...@@ -131,8 +134,8 @@ class SelfAssessmentModule(XModule):
#Parse definition file #Parse definition file
dom2 = etree.fromstring("<selfassessment>" + self.definition['data'] + "</selfassessment>") dom2 = etree.fromstring("<selfassessment>" + self.definition['data'] + "</selfassessment>")
#Try setting max_attempts from definition xml
max_attempt_parsed=dom2.xpath('maxattempts')[0].text max_attempt_parsed=dom2.xpath('maxattempts')[0].text
try: try:
self.max_attempts=int(max_attempt_parsed) self.max_attempts=int(max_attempt_parsed)
except: except:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment