Commit c1c050a6 by Victor Shnayder

WIP on an inputtype for heroesX annotation

- has a text area for saved but (currently) ungraded comments
- has a set of tags with weights
parent 821e2d06
......@@ -939,3 +939,46 @@ class EditAGeneInput(InputTypeBase):
registry.register(EditAGeneInput)
#---------------------------------------------------------------------
class AnnotationInput(InputTypeBase):
"""
Input type for annotations / tags: students can enter some notes or other text
(currently ungraded), and then choose from a set of tags, which are graded.
Example:
<annotationinput>
<text>Dr Seuss uses colors! How?</text>
<comment_prompt>Write down some notes:</comment_prompt>
<tag_prompt>Now pick the right color</tag_prompt>
<options>
<option score="0">blue -- color of grass</option>
<option score="1">ham -- color of grass</option>
<option score="2">green -- color of grass</option>
</options>
</annotationinput>
<text>The location of the sky</text>
# TODO: allow ordering to be randomized
"""
template = "annotationinput.html"
tags = ['annotationinput']
def setup(self):
# Pull out all the things from the xml
self.text = 'text'
self.comment_prompt = 'comment_prompt'
self.tag_prompt = 'tag_prompt'
self.options = [(0, 'blue'), (1, 'green'), (2, 'red')]
def _extra_context(self):
return {'text': self.text,
'comment_prompt': self.comment_prompt,
'tag_prompt': self.tag_prompt,
'options': self.options}
registry.register(AnnotationInput)
......@@ -882,7 +882,8 @@ def sympy_check2():
allowed_inputfields = ['textline', 'textbox', 'crystallography',
'chemicalequationinput', 'vsepr_input',
'drag_and_drop_input', 'editamoleculeinput',
'designprotein2dinput', 'editageneinput']
'designprotein2dinput', 'editageneinput',
'annotationinput']
def setup_response(self):
xml = self.xml
......
<form class="annotation-input">
TODO: make the textline hidden once it all works
<div class="script_placeholder" data-src="/static/js/capa/annotationinput.js"/>
<p>Text: ${text}</p>
<p>Comment prompt: ${comment_prompt}</p>
<textarea id="input_${id}_comment" name="input_${id}_comment"/>
<p>Tag prompt: ${tag_prompt}</p>
<input type="text" style="" name="input_${id}" id="input_${id}"/>
Value: ${value}
% for option_id, option_description in options:
<p>${option_id}, ${option_description}</p>
% endfor
<span id="answer_${id}"></span>
% if status == 'unsubmitted':
<span class="unanswered" style="display:inline-block;" id="status_${id}"></span>
% elif status == 'correct':
<span class="correct" id="status_${id}"></span>
% elif status == 'incorrect':
<span class="incorrect" id="status_${id}"></span>
% elif status == 'incomplete':
<span class="incorrect" id="status_${id}"></span>
% endif
</form>
% if msg:
<span class="message">${msg|n}</span>
% endif
(function () {
var update = function() {
alert("o hi");
};
var inputs = $('.annotation-input input');
// update on load
inputs.each(update);
// and on every change
inputs.bind("input", update);
}).call(this);
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