Commit 25fb2103 by Arthur Barrett

move return link to problem header

parent afa7fca1
...@@ -1848,28 +1848,27 @@ class AnnotationResponse(LoncapaResponse): ...@@ -1848,28 +1848,27 @@ class AnnotationResponse(LoncapaResponse):
response_tag = 'annotationresponse' response_tag = 'annotationresponse'
allowed_inputfields = ['annotationinput'] allowed_inputfields = ['annotationinput']
max_inputfields = 1 max_inputfields = 1
default_scoring = { 'incorrect': 0, 'partial': 1, 'correct': 2 } default_scoring = {'incorrect': 0, 'partial': 1, 'correct': 2 }
def setup_response(self): def setup_response(self):
xml = self.xml xml = self.xml
self.points_map = self._get_points_map() self.scoring_map = self._get_scoring_map()
self.answer_map = self._get_answer_map() self.answer_map = self._get_answer_map()
def _get_points_map(self): def _get_scoring_map(self):
''' Returns a dict of option->scoring for each input. ''' ''' Returns a dict of option->scoring for each input. '''
scoring = self.default_scoring scoring = self.default_scoring
choices = dict(zip(scoring.keys(), scoring.keys())) choices = dict([(choice,choice) for choice in scoring])
points_map = {} scoring_map = {}
for inputfield in self.inputfields: for inputfield in self.inputfields:
option_map = dict([(option['id'], { option_scoring = dict([(option['id'], {
'correctness': choices.get(option['choice']), 'correctness': choices.get(option['choice']),
'points': scoring.get(option['choice']) 'points': scoring.get(option['choice'])
}) for option in self._find_options(inputfield) ]) }) for option in self._find_options(inputfield) ])
points_map[inputfield.get('id')] = option_map scoring_map[inputfield.get('id')] = option_scoring
return points_map return scoring_map
def _get_answer_map(self): def _get_answer_map(self):
''' Returns a dict of answers for each input.''' ''' Returns a dict of answers for each input.'''
...@@ -1913,21 +1912,21 @@ class AnnotationResponse(LoncapaResponse): ...@@ -1913,21 +1912,21 @@ class AnnotationResponse(LoncapaResponse):
'comment_value': comment_value 'comment_value': comment_value
} }
def _get_submitted_option(self, student_answer): def _get_submitted_option_id(self, student_answer):
''' Return the single option that was selected, otherwise None.''' ''' Return the single option that was selected, otherwise None.'''
value = self._unpack(student_answer) submitted = self._unpack(student_answer)
options = value['options_value'] option_ids = submitted['options_value']
if len(options) == 1: if len(option_ids) == 1:
return options[0] return option_ids[0]
return None return None
def get_score(self, student_answers): def get_score(self, student_answers):
''' Returns a CorrectMap for the student answer, which may include ''' Returns a CorrectMap for the student answer, which may include
partially correct answers.''' partially correct answers.'''
student_answer = student_answers[self.answer_id] student_answer = student_answers[self.answer_id]
student_option = self._get_submitted_option(student_answer) student_option = self._get_submitted_option_id(student_answer)
scoring = self.points_map[self.answer_id] scoring = self.scoring_map[self.answer_id]
is_valid = student_option is not None and student_option in scoring.keys() is_valid = student_option is not None and student_option in scoring.keys()
(correctness, points) = ('incorrect', None) (correctness, points) = ('incorrect', None)
......
<form class="annotation-input"> <form class="annotation-input">
<div class="script_placeholder" data-src="/static/js/capa/annotationinput.js"/> <div class="script_placeholder" data-src="/static/js/capa/annotationinput.js"/>
<div class="annotation-header">${title}</div> <div class="annotation-header">
${title}
% if return_to_annotation:
<a class="annotation-return" href="javascript:void(0)">Return to Annotation</a><br/>
% endif
</div>
<div class="annotation-body"> <div class="annotation-body">
<div class="block block-highlight">${text}</div> <div class="block block-highlight">${text}</div>
...@@ -32,7 +38,7 @@ ...@@ -32,7 +38,7 @@
<input type="hidden" class="value" name="input_${id}" id="input_${id}" value="${value|h}" /> <input type="hidden" class="value" name="input_${id}" id="input_${id}" value="${value|h}" />
% endif % endif
<span id="answer_${id}"></span> <p id="answer_${id}" class="answer answer-annotation"></p>
% if status == 'unsubmitted': % if status == 'unsubmitted':
<span class="unanswered" style="display:inline-block;" id="status_${id}"></span> <span class="unanswered" style="display:inline-block;" id="status_${id}"></span>
...@@ -46,9 +52,6 @@ ...@@ -46,9 +52,6 @@
<span class="incorrect" id="status_${id}"></span> <span class="incorrect" id="status_${id}"></span>
% endif % endif
% if return_to_annotation:
<a class="annotation-return" href="javascript:void(0)">Return to Annotation</a><br/>
% endif
</div> </div>
</form> </form>
......
...@@ -816,8 +816,12 @@ section.problem { ...@@ -816,8 +816,12 @@ section.problem {
padding: .5em 1em; padding: .5em 1em;
} }
.annotation-body { padding: .5em 1em; } .annotation-body { padding: .5em 1em; }
.annotation-return { float: right; } a.annotation-return {
.annotation-return:after { content: " \2191" } float: right;
font: inherit;
font-weight: normal;
}
a.annotation-return:after { content: " \2191" }
.block, ul.tags { .block, ul.tags {
margin: .5em 0; margin: .5em 0;
...@@ -851,6 +855,9 @@ section.problem { ...@@ -851,6 +855,9 @@ section.problem {
} }
} }
textarea.comment { width: 100%; } textarea.comment { width: 100%; }
.answer-annotation { display: block; margin: 0; }
/* for debugging the input value field. enable the debug flag on the inputtype */
.debug-value { .debug-value {
color: #fff; color: #fff;
padding: 1em; padding: 1em;
......
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