Commit 26fe94bd by Vik Paruchuri

capa module integration

parent 37b85933
...@@ -8,6 +8,8 @@ $(document).on('click', 'section.sa-wrapper input#show', ( -> ...@@ -8,6 +8,8 @@ $(document).on('click', 'section.sa-wrapper input#show', ( ->
$('section.sa-wrapper textarea#answer').remove() $('section.sa-wrapper textarea#answer').remove()
$('section.sa-wrapper p#rubric').append(answer) $('section.sa-wrapper p#rubric').append(answer)
$('section.sa-wrapper p#rubric').append(response.rubric) $('section.sa-wrapper p#rubric').append(response.rubric)
else
$('section.sa-wrapper p#rubric').append(response.message)
)); ));
$(document).on('click', 'section.sa-wrapper input#save', ( -> $(document).on('click', 'section.sa-wrapper input#save', ( ->
......
...@@ -21,6 +21,8 @@ from xmodule.contentstore.content import XASSET_SRCREF_PREFIX, StaticContent ...@@ -21,6 +21,8 @@ from xmodule.contentstore.content import XASSET_SRCREF_PREFIX, StaticContent
log = logging.getLogger("mitx.courseware") log = logging.getLogger("mitx.courseware")
max_attempts=100
def only_one(lst, default="", process=lambda x: x): def only_one(lst, default="", process=lambda x: x):
""" """
If lst is empty, returns default If lst is empty, returns default
...@@ -88,7 +90,7 @@ class SelfAssessmentModule(XModule): ...@@ -88,7 +90,7 @@ class SelfAssessmentModule(XModule):
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=1 self.max_attempts=max_attempts
self.correctness="incorrect" self.correctness="incorrect"
self.done=False self.done=False
...@@ -111,9 +113,8 @@ class SelfAssessmentModule(XModule): ...@@ -111,9 +113,8 @@ class SelfAssessmentModule(XModule):
self.correctness=instance_state['correct_map']['self_assess']['correctness'] self.correctness=instance_state['correct_map']['self_assess']['correctness']
def get_score(self): def get_score(self):
return self.score return {'score' : self.score}
def max_score(self): def max_score(self):
return self.top_score return self.top_score
...@@ -121,8 +122,8 @@ class SelfAssessmentModule(XModule): ...@@ -121,8 +122,8 @@ class SelfAssessmentModule(XModule):
def get_progress(self): def get_progress(self):
''' For now, just return score / max_score ''' For now, just return score / max_score
''' '''
score = self.get_score() score = self.score
total = self.max_score() total = self.top_score
if total > 0: if total > 0:
try: try:
return Progress(score, total) return Progress(score, total)
...@@ -161,9 +162,12 @@ class SelfAssessmentModule(XModule): ...@@ -161,9 +162,12 @@ class SelfAssessmentModule(XModule):
return json.dumps(d, cls=ComplexEncoder) return json.dumps(d, cls=ComplexEncoder)
def show_rubric(self,get): def show_rubric(self,get):
if(self.attempts<self.max_attempts):
self.answer=get.keys()[0] self.answer=get.keys()[0]
log.debug(self.answer) log.debug(self.answer)
return {'success': True, 'rubric' : self.rubric} return {'success': True, 'rubric' : self.rubric}
else:
return{'success' : False, 'message' : 'Too many attempts.'}
def save_problem(self, get): def save_problem(self, get):
''' '''
......
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