Commit a40f5e7d by solashirai

fixed issue with answers containing spaces

parent eecc234b
......@@ -286,10 +286,10 @@ class CrowdsourceHinter(XBlock):
# for the time being only the first answer/hint pair will be shown to the studen
if self.used[0] in self.hint_database[self.incorrect_answers[0]]:
# add new key (hint) to used_hint_answer_text with a value (incorrect answer)
used_hint_answer_text[json.dumps(self.used[0])] = json.dumps(self.incorrect_answers[0])
used_hint_answer_text[self.used[0]] = self.incorrect_answers[0]
else:
# if the student's answer had no hints (or all the hints were reported and unavailable) return None
used_hint_answer_text[None] = json.dumps(self.incorrect_answers[0])
used_hint_answer_text[None] = self.incorrect_answers[0]
self.incorrect_answers = []
self.used = []
return used_hint_answer_text
......@@ -356,7 +356,7 @@ class CrowdsourceHinter(XBlock):
data['answer']: This is the incorrect answer for which the student is submitting a new hint.
"""
submission = data['new_hint_submission']
answer = data['answer']
answer = urllib.unquote_plus(data['answer'])
# If we don't have the hint already, add it
if submission not in self.hint_database[answer]:
......
<script type='x-tmpl/mustache' id='show_hint_rating_ux'>
<div class='csh_hint_value' value="{{hintText}}">
<div class='csh_hint_data'>
<div class="csh_hint">You received the following hint: <b>{{hintText}}</b></div>
<div class="csh_hint">You received the following hint: <b>{{visual_hintText}}</b></div>
</div>
<div class='csh_rating_data'>
<div role="button" class="csh_rate_hint" data-rate="upvote">
......@@ -19,7 +19,7 @@
<script type="x-tmpl/mustache" id="show_reported_moderation">
<div class="csh_hint_value" value ="{{reportedHintText}}">
<div class="csh_hint">{{reportedHintText}}</div>
<div class="csh_hint">{{visual_reportedHintText}}</div>
<div role="button" class="csh_staff_rate" data-rate="unreport" aria-label="unreport">
<u><b>Return hint for use in the hinter</b></u>
</div>
......@@ -50,7 +50,7 @@
<div role="button" class="csh_reveal_info">Help us improve hints for this problem </div>
<div class="csh_user_info" style="display: none;"> <br> Submitting an incorrect answer for this problem provides you with a hint specific to the mistake that you made - these hints are made by other students who made the same mistake as you did. Help to make the hints for this problem better by rating the hint that you received, or if you might have better advice to give other students, submit a new hint! <br> If you choose to submit a new hint, keep in mind that the hints are specific to one incorrect answer; specific advice (perhaps on some aspect of the problem that you overlooked) is more helpful than generic advice.</div>
<br>
Your original answer was: <b>{{answer}}</b></h>
Your original answer was: <b>{{visual_answer}}</b></h>
</div>
</script>
......
......@@ -119,7 +119,7 @@ function CrowdsourceHinter(runtime, element, data){
* @param student_answer is the first incorrect answer submitted by the student
*/
function showStudentHintRatingUX(hint, student_answer){
var hintRatingUXTemplate = $(Mustache.render($('#show_hint_rating_ux').html(), {hintText: hint}));
var hintRatingUXTemplate = $(Mustache.render($('#show_hint_rating_ux').html(), {hintText: encodeURI(hint), visual_hintText: hint}));
$('.csh_answer_text', element).append(hintRatingUXTemplate);
var hintCreationTemplate = $(Mustache.render($('#add_hint_creation').html(), {}));
$('.csh_answer_text', element).append(hintCreationTemplate);
......@@ -134,7 +134,7 @@ function CrowdsourceHinter(runtime, element, data){
* @param reportedHint is the reported hint text
*/
function showReportedModeration(reportedHint){
var reportedModerationTemplate = $(Mustache.render($('#show_reported_moderation').html(), {reportedHintText: reportedHint}));
var reportedModerationTemplate = $(Mustache.render($('#show_reported_moderation').html(), {reportedHintText: encodeURI(reportedHint), visual_reportedHintText: reportedHint}));
$('.csh_reported_hints', element).append(reportedModerationTemplate);
}
......@@ -145,7 +145,7 @@ function CrowdsourceHinter(runtime, element, data){
* @param student_answers is the text of the student's incorrect answer
*/
function showStudentSubmissionHistory(student_answer){
var showStudentSubmissionTemplate = $(Mustache.render($('#show_student_submission').html(), {answer:student_answer}));
var showStudentSubmissionTemplate = $(Mustache.render($('#show_student_submission').html(), {answer: encodeURI(student_answer),visual_answer: student_answer}));
$('.csh_student_submission', element).append(showStudentSubmissionTemplate);
}
......@@ -169,7 +169,7 @@ function CrowdsourceHinter(runtime, element, data){
}
$.each(result, function(index, value) {
if(value != "Reported"){
showStudentSubmissionHistory($.parseJSON(value));
showStudentSubmissionHistory(value);
student_answer = value;
hint = index;
//hints return null if no answer-specific hints exist
......@@ -213,7 +213,7 @@ function CrowdsourceHinter(runtime, element, data){
function submitNewHint(){ return function(submitHintButtonHTML){
//add the newly created hint to the hinter's pool of hints
if($('.csh_student_text_input', element).val().length > 0){
var studentAnswer = unescape(submitHintButtonHTML.currentTarget.attributes['answer'].value);
var studentAnswer = decodeURI(submitHintButtonHTML.currentTarget.attributes['answer'].value);
var newHint = unescape($('.csh_student_text_input').val());
$('.csh_submitbutton', element).show();
$.ajax({
......@@ -242,7 +242,7 @@ function CrowdsourceHinter(runtime, element, data){
$('.csh_hint_text', element).attr('rating', rating);
$('.csh_hint', element).attr('rating', rating);
hint = $('.csh_hint_text', element).attr('hint_received');
student_answer = $('.csh_hint_text', element).attr('student_answer');
student_answer = decodeURI($('.csh_hint_text', element).attr('student_answer'));
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'),
......@@ -257,7 +257,7 @@ function CrowdsourceHinter(runtime, element, data){
function reportHint(){ return function(reportHintButtonHTML){
hint = $('.csh_hint_text', element).attr('hint_received');
student_answer = $('.csh_hint_text', element).attr('student_answer');
student_answer = decodeURI($('.csh_hint_text', element).attr('student_answer'));
$('.csh_hint_text', element).text('This hint has been reported for review.');
$('.csh_hint', element).text('This hint has been reported for review.');
$.ajax({
......
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