Commit 5941f291 by Sola

fixed hint rating

parent 0f434b41
......@@ -256,16 +256,17 @@ class CrowdXBlock(XBlock):
# if student flagged hint
self.hint_flagged(data['used_hint'], answer_data)
return {"rating": 'thiswasflagged', 'origdata': original_data}
print(str(self.Voted))
if str(answer_data) not in self.Voted:
self.Voted.append(str(answer_data)) # add data to Voted to prevent multiple votes
rating = self.change_rating(data_hint, int(data_rating), answer_data) # change hint rating
if str(rating) == str(0):
# if the rating is "0", return "zzeerroo" instead. "0" showed up as "null" in JS
return {"rating": str('zzeerroo'), 'student_answer': original_data}
return {"rating": str('zzeerroo'), 'used_hint': data_hint}
else:
return {"rating": str(rating), 'student_answer': original_data}
return {"rating": str(rating), 'used_hint': data_hint}
else:
return {"rating": str('You have already voted on this hint!'), 'student_answer': original_data}
return {"rating": str('You have already voted on this hint!'), 'used_hint': data_hint}
def hint_flagged(self, data_hint, answer_data):
"""
......
......@@ -131,7 +131,7 @@ function CrowdXBlock(runtime, element){
HintShown.push(index);}
}else{
if($.inArray(index, HintShown) == -1){
console.log('YIESSSSS');
console.log('index is is' + indexid);
$('#hintstoshow'+valueid).prepend("<p \" id =\"thisparagraph" + indexid + "\">" + "<span style=\"display: inline-block;\"><input data-value=\"" + valueid + "\" id=\"" + indexid + "\" type=\"button\" style=\"padding-top: 3px;width:20px; height:35px;\" class=\"hintbutton\" data-rate=\"1\" value=\"^\"><input data-value=\"" + valueid + "\" id=\"" + indexid + "\" style=\"padding-top: 3px;width:20px; height:35px;\" type=\"button\" class=\"hintbutton\" data-rate=\"-1\" value=\"v\"><input data-value=\"" + valueid + "\" style=\"padding-top: 3px;width:20px; height:35px;\" id=\"" + indexid + "\" type=\"button\" class=\"hintbutton\" data-rate=\"0\" value=\"!\"></span><font color=\"blue\">" + index + "</font></p>");
HintShown.push(index);
}}}else{
......@@ -197,7 +197,7 @@ function CrowdXBlock(runtime, element){
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'),
data: JSON.stringify({"student_rating": $(this).attr('data-rate'), "student_answer": $(this).attr('id'), "used_hint": $(this).attr('data-value')}),
data: JSON.stringify({"student_rating": $(this).attr('data-rate'), "used_hint": $(this).attr('id'), "student_answer": $(this).attr('data-value')}),
success: finish
});})
......@@ -206,7 +206,8 @@ function CrowdXBlock(runtime, element){
if(canhint == 0){
canhint = 1;
$('.Thankyou', element).text("Thankyou for your help!");
idtouse = String('thisparagraph' + result.student_answer);
idtouse = String('thisparagraph' + result.used_hint);
console.log(idtouse)
hint_rating = result.rating;
if(result.rating == "zzeerroo"){
hint_rating = 0;
......
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