exercise_id = str(exercise['id'])
answer = answers[exercise_id]
if exercise['type'] == 'open':
- toret = answer
+ if isinstance(answer, list):
+ toret = ''
+ for part in answer:
+ field = get_option(exercise['fields'], part['id'])
+ toret += '- %s:\n\n%s\n\n' % (field['caption'], part['text'])
+ else:
+ toret = answer
if exercise['type'] == 'edumed_wybor':
ok = set(map(str, exercise['answer'])) == set(map(str,answer['closed_part']))
toret = u'Czesc testowa [%s]:\n' % ('poprawna' if ok else 'niepoprawna')
},
open: function(el) {
- push_answer(el, el.find('textarea').val());
+ var textareas = el.find('textarea'),
+ to_push;
+ if(textareas.length === 1) {
+ to_push = el.find('textarea').val();
+ } else {
+ to_push = [];
+ textareas.each(function() {
+ var textarea = $(this);
+ to_push.push({'id': textarea.attr('data-field-id'), 'text': textarea.val()});
+ });
+ }
+ push_answer(el, to_push);
}
}
{% endautoescape %}
</div>
- <textarea style="width: 100%; margin-top:10px;" rows="10"></textarea>
+ {% if exercise.fields %}
+ {% for field in exercise.fields %}
+ <div class="wtem-open-field">
+ <label class="wtem-caption">{{field.caption}}</label>
+ <textarea style="width: 100%;" rows="10" data-field-id="{{field.id}}"></textarea>
+ </div>
+ {% endfor %}
+ {% else %}
+ <textarea style="width: 100%; margin-top:10px;" rows="10"></textarea>
+ {% endif %}
+
+ {% if exercise.description_after %}
+ <div class="description">
+ {% autoescape off %}
+ {% for para in exercise.description_after %}
+ <p class="paragraph">
+ {{para}}
+ </p>
+ {% endfor %}
+ {% endautoescape %}
+ </div>
+ {% endif%}
</div>
\ No newline at end of file
{% block body %}
-
+<style>
+ .wtem-open-field {
+ margin: 10px 0;
+ }
+ .wtem-open-field textarea {
+ margin-top:0;
+ }
+</style>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}