Commit dcdb7f36 by Sola Committed by Piotr Mitros

adding isstaff feedback

parent 05e46b62
...@@ -21,10 +21,8 @@ class CrowdXBlock(XBlock): ...@@ -21,10 +21,8 @@ class CrowdXBlock(XBlock):
""" """
# Database of hints. hints are stored as such: {"incorrect_answer": {"hint": rating}}. each key (incorrect answer) # Database of hints. hints are stored as such: {"incorrect_answer": {"hint": rating}}. each key (incorrect answer)
# has a corresponding dictionary (in which hints are keys and the hints' ratings are the values). # has a corresponding dictionary (in which hints are keys and the hints' ratings are the values).
hint_database = Dict(default={'answer': {'Try doing something new': 5, 'you should go review that lesson again': 0}}, scope=Scope.user_state_summary) # TODO: Remove default values once done testing
# This is a dictionary of hints that will be used to determine what hints to show a student. hint_database = Dict(default={'answer': {'Try doing something new': 5, 'you should go review that lesson again': 0}, "answer2": {'new answer hint': 3, "You should go look in your notes": 6, "This is a hint that should be flagged": -4}}, scope=Scope.user_state_summary)
# flagged hints are not included in this dictionary of hints
HintsToUse = Dict({}, scope=Scope.user_state)
# This is a list of incorrect answer submissions made by the student. this list is mostly used for # This is a list of incorrect answer submissions made by the student. this list is mostly used for
# feedback, to find which incorrect answer's hint a student voted on. # feedback, to find which incorrect answer's hint a student voted on.
WrongAnswers = List([], scope=Scope.user_state) WrongAnswers = List([], scope=Scope.user_state)
...@@ -32,7 +30,7 @@ class CrowdXBlock(XBlock): ...@@ -32,7 +30,7 @@ class CrowdXBlock(XBlock):
# student's incorrect answer within the hint_database dictionary (i.e. no students have made hints for the # student's incorrect answer within the hint_database dictionary (i.e. no students have made hints for the
# particular incorrect answer) # particular incorrect answer)
DefaultHints = Dict(default={'default_hint': 0}, scope=Scope.content) DefaultHints = Dict(default={'default_hint': 0}, scope=Scope.content)
# List of which hints from the HintsToUse dictionary have been shown to the student # List of which hints have been shown to the student
# this list is used to prevent the same hint from showing up to a student (if they submit the same incorrect answers # this list is used to prevent the same hint from showing up to a student (if they submit the same incorrect answers
# multiple times) # multiple times)
Used = List([], scope=Scope.user_state) Used = List([], scope=Scope.user_state)
...@@ -43,11 +41,16 @@ class CrowdXBlock(XBlock): ...@@ -43,11 +41,16 @@ class CrowdXBlock(XBlock):
# This is a dictionary of hints that have been flagged. the keys represent the incorrect answer submission, and the # This is a dictionary of hints that have been flagged. the keys represent the incorrect answer submission, and the
# values are the hints the corresponding hints. even if a hint is flagged, if the hint shows up for a different # values are the hints the corresponding hints. even if a hint is flagged, if the hint shows up for a different
# incorrect answer, i believe that the hint will still be able to show for a student # incorrect answer, i believe that the hint will still be able to show for a student
Flagged = Dict(default={}, scope=Scope.user_state_summary) Flagged = Dict(default={"answer2": "THis is a hint that should be flagged"}, scope=Scope.user_state_summary)
# This string determines whether or not to show only the best (highest rated) hint to a student # This string determines whether or not to show only the best (highest rated) hint to a student
# When set to 'True' only the best hint will be shown to the student. # When set to 'True' only the best hint will be shown to the student.
# Details on operation when set to 'False' are to be finalized. # Details on operation when set to 'False' are to be finalized.
# TODO: make this into a boolean instead of a dict
show_best = Dict(default={'showbest': 'True'}, scope=Scope.user_state_summary) show_best = Dict(default={'showbest': 'True'}, scope=Scope.user_state_summary)
# This Dict determine whether or not the user is staff. This in turn will influence whether or not flagged hints
# will be shown. The method to actually determine whether or not the user is staff is not currently implemented.
# TODO: make this into a boolean instead of a dict
isStaff = Dict(default={'isStaff': 'true'}, scope=Scope.user_state_summary)
def student_view(self, context=None): def student_view(self, context=None):
""" """
...@@ -161,9 +164,7 @@ class CrowdXBlock(XBlock): ...@@ -161,9 +164,7 @@ class CrowdXBlock(XBlock):
isflagged = [] isflagged = []
isused = 0 isused = 0
testvar = 0 testvar = 0
self.WrongAnswers.append(str(answer)) # add the student's input to the temporary list, for later use self.WrongAnswers.append(str(answer)) # add the student's input to the temporary list
# add hints to the self.HintsToUse dictionary. Will likely be replaced
# soon by simply looking within the self.hint_database for hints.
if str(answer) not in self.hint_database: if str(answer) not in self.hint_database:
# add incorrect answer to hint_database if no precedent exists # add incorrect answer to hint_database if no precedent exists
self.hint_database[str(answer)] = {} self.hint_database[str(answer)] = {}
...@@ -192,12 +193,15 @@ class CrowdXBlock(XBlock): ...@@ -192,12 +193,15 @@ class CrowdXBlock(XBlock):
for the question, all the hints the student recieved, as well as two for the question, all the hints the student recieved, as well as two
more random hints that exist for an incorrect answer in the hint_database more random hints that exist for an incorrect answer in the hint_database
""" """
feedback_data = {}
# feedback_data is a dictionary of hints (or lack thereof) used for a # feedback_data is a dictionary of hints (or lack thereof) used for a
# specific answer, as well as 2 other random hints that exist for each answer # specific answer, as well as 2 other random hints that exist for each answer
# that were not used. The keys are the used hints, the values are the # that were not used. The keys are the used hints, the values are the
# corresponding incorrect answer # corresponding incorrect answer
feedback_data = {}
number_of_hints = 0 number_of_hints = 0
if self.isStaff['isStaff'] == 'true':
feedback_data = get_staff_feedback()
return feedback_data
if len(self.WrongAnswers) == 0: if len(self.WrongAnswers) == 0:
return return
else: else:
...@@ -237,8 +241,31 @@ class CrowdXBlock(XBlock): ...@@ -237,8 +241,31 @@ class CrowdXBlock(XBlock):
This function is used when no hints exist for an answer. The feedback_data within This function is used when no hints exist for an answer. The feedback_data within
get_feedback is set to "there are no hints for" + " " + str(self.WrongAnswers[index]) get_feedback is set to "there are no hints for" + " " + str(self.WrongAnswers[index])
""" """
self.WrongAnswers.append(str(self.WrongAnswers[index]))
self.Used.append(str("There are no hints for" + " " + str(self.WrongAnswers[index]))) self.Used.append(str("There are no hints for" + " " + str(self.WrongAnswers[index])))
for answer_keys in self.hint_database:
if str(len(self.hint_database[str(answer_keys)])) != str(0):
hint_key = self.hint_database[str(answer_keys)].keys()
for hints in hint_key:
if str(hints) not in self.Flagged.keys():
feedback_data[str(hints)] = str(answer_keys)
else:
feedback_data[str(hints)] = str("Flagged Hint")
else:
feedback_data[str("There are no hints for" + " " + str(hint_key))] = str(answer_keys)
self.WrongAnswers=[]
self.Used=[]
return feedback_data
def get_staff_feedback(self, index):
"""
This function is the alternative to get_feedback if the user is staff.
The method to determine whether or not the user is staff has not yet been implemented.
"""
# feedback_data is a dictionary of hints and corresponding answers
# The keys are the used hints, the values are the corresponding incorrect answer
# For flagged hints, the keys are used hints and the values are "flagged"
feedback_data = {}
@XBlock.json_handler @XBlock.json_handler
def get_ratings(self, data, suffix=''): def get_ratings(self, data, suffix=''):
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<span class='Thankyou'></span> <span class='Thankyou'></span>
</p> </p>
<div class="hintansarea"> <div class="feedback">
</div> </div>
......
...@@ -5,19 +5,22 @@ var issubmitting = 0; ...@@ -5,19 +5,22 @@ var issubmitting = 0;
var issubmittinghint = 0; var issubmittinghint = 0;
function CrowdXBlock(runtime, element){ function CrowdXBlock(runtime, element){
var WrongAnswer = []; $(".HintsToUse", element).text("");
var HintUsed = [];
var HintShown = [];
$("#answer").hide();
$(".problem").hide();
$("#feedback").hide();
var_element = String;
var_event_type = String;
var_data = String;
//$(".HintsToUse", element).text("Hints are enabled for this problem!");
clearvariables(); clearvariables();
//repeat counter is used to counteract a bug caused by switching units
//after switching units all logger.listen events would trigger multiple times
repeatcounter += 1; repeatcounter += 1;
console.debug(repeatcounter); //use to determine whether or not to initialize hint feedback
var hasReceivedHint = false;
var is_staff = false;
var check_staff = $('#staffstatus').val();
if(check_staff == 'staff view');
{
console.log(check_staff);
console.log("is_staff");
is_staff = true;
}
Logger.listen('seq_next', null, clearingvariables); Logger.listen('seq_next', null, clearingvariables);
Logger.listen('seq_goto', null, clearingvariables); Logger.listen('seq_goto', null, clearingvariables);
...@@ -26,22 +29,18 @@ function CrowdXBlock(runtime, element){ ...@@ -26,22 +29,18 @@ function CrowdXBlock(runtime, element){
} }
function clearvariables(data){ function clearvariables(data){
HintUsed = [];
WrongAnswer = [];
repeating = 0; repeating = 0;
} }
Logger.listen('problem_graded', null, dostuff); Logger.listen('problem_graded', null, get_event_data);
function dostuff(event_type, data, element){
//read the data from the problem_graded event here
function get_event_data(event_type, data, element){
repeating += 1; repeating += 1;
if(repeating != repeatcounter){ if(repeating != repeatcounter){
console.debug(repeating); console.debug(repeating);
}else{ }else{
$("#studentsubmit").val(''); check_correct(event_type, data, element);
var_element = element;
var_event_type = event_type;
var_data = data;
senddata(var_event_type, var_data, var_element);
} }
} }
...@@ -49,144 +48,118 @@ function CrowdXBlock(runtime, element){ ...@@ -49,144 +48,118 @@ function CrowdXBlock(runtime, element){
repeating = 0; repeating = 0;
}); });
function senddata(var_event_type, var_data, var_element){ function check_correct(var_event_type, var_data, var_element){
//check that problem wasn't correctly answered
if (var_data[1].search(/class="correct/) === -1){ if (var_data[1].search(/class="correct/) === -1){
$.ajax({ //that probably will be changed once i use response.search or something? $.ajax({
type: "POST", //if/when that is changed, remove checkreply and uncomment the else statement below type: "POST",
url: runtime.handlerUrl(element, 'get_hint'), url: runtime.handlerUrl(element, 'get_hint'),
data: JSON.stringify({"submittedanswer": var_data[0]}), //return student's incorrect answer here data: JSON.stringify({"submittedanswer": var_data[0]}),
//from var_data[1] check id (long thing) and get class (correct or incorrect) success: seehint
success: seehint });
}); hasReceivedHint = true;
}else{ }else if(hasReceivedHint == true){
$('.correct', element).show(); $('.correct', element).show();
$('.correct', element).text("You're correct! Please help us improve our hints by voting on them, or submit your own hint!"); $('.correct', element).text("You're correct! Please help us improve our hints by voting on them, or submit your own hint!");
$(".HintsToUse", element).text(" "); $(".HintsToUse", element).text(" ");
$.ajax({ //send empty data for ajax call because not having a data field causes error
type: "POST", $.ajax({
url: runtime.handlerUrl(element, 'get_feedback'), type: "POST",
data: JSON.stringify({"hello": "world"}), url: runtime.handlerUrl(element, 'get_feedback'),
success: getfeedback data: JSON.stringify(""),
});} success: getFeedback
} });
}else{
$.ajax({ $(".HintsToUse", element).text("");
type: "POST", }
url: runtime.handlerUrl(element, 'studiodata'),
data: JSON.stringify({"hello": "world"}),
success: studiodata
});
function studiodata(result){
$(".xblock-editor").append("confirm_working");
if($(".xblock-editor").length != 0){
$.each(result, function(index, value) {
console.debug(index);
$('.xblock-editor').append("<p id=\"" + value + "\"> The hint<b>" + " " + index + " " + "</b>was flagged for the submission<b>" + " " + value + "</b></p>");
$('#'+value).prepend("<input data-value=\"" + value + "\" id=\"" + index + "\" style=\"height:35px;padding-top: 3px;\" type=\"button\" class=\"flagbutton\" data-rate=\"dismiss\" value=\"Dismiss Hint\"><input data-value=\"" + value + "\" id=\"" + index + "\" style=\"height:35px; padding-top: 3px;\" type=\"button\" class=\"flagbutton\" data-rate=\"purge\" value=\"Purge Hint\">");
});
}
} }
$(document).on('click', '.flagbutton', function(){
answer_wrong = $(this).attr('id');
hint = $(this).attr('data-value');
rating = $(this).attr('data-rate');
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'moderate_hint'),
data: JSON.stringify({"answer_wrong":answer_wrong, "hint": hint, "rating":rating}),
});
});
function seehint(result){//use html to show these results somewhere i guess function seehint(result){
console.debug('seehint'); //show hint to student
HintUsed.push(result.HintsToUse);
$('.HintsToUse', element).text(result.HintsToUse); $('.HintsToUse', element).text(result.HintsToUse);
} }
function getfeedback(result){ function getFeedback(result){
$("#answer").show();
$(".problem").show();
$("#feedback").show();
$.each(result, function(index, value) { $.each(result, function(index, value) {
student_answer = value.replace(/\./g, 'ddeecciimmaallppooiinntt'); //data of student answer and hints are stored in the paragraphs/buttons
hint_used = index.replace(/\./g, 'ddeecciimmaallppooiinntt'); //so that when a button is clicked, the answer and hint can be sent to the python script
student_answer = student_answer.replace(/\:/g, 'ccoolloonn'); student_answer = value;
hint_used = hint_used.replace(/\:/g, 'ccoolloonn'); hint_used = index;
student_answer = student_answer.replace(/\;/g, 'sseemmiiccoolloonn'); if($(".submit"+student_answer).length == 0){
hint_used = hint_used.replace(/\;/g, 'sseemmiiccoolloonn'); $('.feedback', element).append("<p class=\"submit" + student_answer + "\"</p>");
student_answer = student_answer.replace(/\=/g, 'eeqquuaallss'); $(".submit"+student_answer, element).append("<b>Answer-specific hints for \b" + " " + student_answer + "<p><input id=\"submitbuttonfor" + student_answer + "\" style=\"float: right; float: top;\" type=\"button\" class=\"submitbutton\" value=\"Submit a hint\"><p class=\"showHintsFor" + student_answer + "\"> </p></div>");
hint_used = hint_used.replace(/\=/g, 'eeqquuaallss'); }
if($("#submit"+student_answer).length == 0){ if(hint_used.slice(0,22) != "There are no hints for"){
$('.hintansarea').append("<p id=\"submit" + student_answer + "\" class=\"hintsarea\"> </p>"); $('.showHintsFor'+student_answer, element).append(
$('#submit'+student_answer).append("<p> </p><b>Answer-specific hints for \b" + " " + student_answer + "<p> <p id=\"hintstoshow" + student_answer + "\"> </p></div>"); "<p \" class =\"votingFor" + hint_used + "\">" +
} "<div data-value=\"" + student_answer + "\" id=\"" + hint_used +"\" role=\"button\" class=\"upvote_hint\"" +
if(hint_used.slice(0,22) != "There are no hints for"){ "data-rate=\"1\" data-icon=\"arrow-u\" aria-label=\"upvote\"><b>↑</b></div>" +
$('#hintstoshow'+student_answer).append("<p \" id =\"thisparagraph" + hint_used + "\">" + "<div data-value=\"" + student_answer + "\" id=\"" + hint_used + "\" role=\"button\" class=\"upvote_hint\" data-rate=\"1\" data-icon=\"arrow-u\" aria-label=\"upvote\"><b>↑</b></div> <div class = \"" + hint_used + "rating\">" + hint_used + "</div> <div data-value=\"" + student_answer + "\" id=\"" + hint_used + "\" role=\"button\" class=\"downvote_hint\" data-rate=\"-1\" aria-label=\"downvote\"><b>↓</b></div> </p>"); "<div class = \"" + hint_used + "rating\">" + hint_used + "</div>" +
//<div data-value=\"" + student_answer + "\" id=\"" + hint_used + "\" role=\"button\" class=\"flag_hint\" data-rate=\"0\" aria-label=\"report\"><b>!</b></div> "<div data-value=\"" + student_answer + "\" id=\"" + hint_used + "\" role=\"button\" class=\"downvote_hint\"" +
$.ajax({ "data-rate=\"-1\" aria-label=\"downvote\"><b>↓</b>" +
type: "POST", "</div> </p>");
url: runtime.handlerUrl(element, 'get_ratings'), $.ajax({
data: JSON.stringify({"student_answer": student_answer, "hint_used": hint_used}), type: "POST",
success: show_ratings url: runtime.handlerUrl(element, 'get_ratings'),
}); data: JSON.stringify({"student_answer": student_answer, "hint_used": hint_used}),
HintShown.push(index); success: show_ratings
}else{ });
$('#hintstoshow'+student_answer).empty(); }else{
$('#hintstoshow'+student_answer).append("<p id=\"hintstoshow" + student_answer + "\"data-value=\"" + student_answer + "\"> <b>No hints exist in the database. (You received a default hint)</p> <p id=\"" + hint_used + "\"data-value=\"" + student_answer + "\" </p>"); $('.showHintsFor'+student_answer).empty();
} $('.showHintsFor'+student_answer).append("<p class=\".showHintsFor" + student_answer + "\"data-value=\"" + student_answer + "\"> <b>No hints exist in the database. (You received a default hint)</p> <p id=\"" + hint_used + "\"data-value=\"" + student_answer + "\" </p>");
}
}); });
} }
function show_ratings(result) { function show_ratings(result) {
$.each(result, function(index, value) { $.each(result, function(index, value) {
console.log(index) console.log(index);
$("."+index+"rating").prepend(value + " ");}) console.log(value);
$("."+index+"rating").append(value + " " + index);
})
} }
$(document).on('click', '.submitbutton', function(){ //upvote $(document).on('click', '.submitbutton', function(){ //upvote
issubmittinghint = 0; issubmittinghint = 0;
issubmitting += 1; issubmitting += 1;
if(issubmitting == repeatcounter){ if(issubmitting == repeatcounter){
id = this.id; id = this.id;
id = id.slice(15); id = id.slice(15);
//value = document.getElementById(id).getAttribute('data-value'); //value = document.getElementById(id).getAttribute('data-value');
$('.submitbutton').show(); $('.submitbutton').show();
$('.math').remove(); $('.math').remove();
$('#submit').remove(); $('#submit').remove();
$(this).hide(); $(this).hide();
$('#hintstoshow' + id).prepend("<p><input type=\"text\" name=\"studentinput\" id=\"" + id + "\" class=\"math\" size=\"40\"><input id=\"submit\" type=\"button\" data-is=\"" + id + "\" class=\"button\" value=\"Submit Hint\"> </p>"); $('.showHintsFor'+id, element).prepend("<p><input type=\"text\" name=\"studentinput\" id=\"" + id + "\" class=\"math\" size=\"40\"><input id=\"submit\" type=\"button\" data-is=\"" + id + "\" class=\"button\" value=\"Submit Hint\"> </p>");
}}) }
})
$(document).on('click', '#submit', function(){ $(document).on('click', '#submit', function(){
issubmittinghint += 1; issubmittinghint += 1;
if(issubmittinghint == repeatcounter){ if(issubmittinghint == repeatcounter){
if($('.math').val() != null){ if($('.math').val() != null){
var answerdata = String; var answerdata = String;
var valueid = String; issubmitting = 0;
issubmitting = 0; $('#submit').each(function(){
$('#submit').each(function(){ answerdata = $('.math').attr('id');
answerdata = $('.math').attr('id'); });
}); $('.submitbutton').show();
$('.submitbutton').show(); $.ajax({
$.ajax({ type: "POST",
type: "POST", url: runtime.handlerUrl(element, 'give_hint'),
url: runtime.handlerUrl(element, 'give_hint'), data: JSON.stringify({"submission": $('.math').val(), "answer": answerdata}), //give hin for first incorrect answer
data: JSON.stringify({"submission": $('.math').val(), "answer": answerdata}), //give hin for first incorrect answer //success: finish
//success: finish });
}); $("#answer").val('');
$("#answer").val(''); $(this).remove();
//data_value = document.getElementById(valueid).getAttribute('data-value'); $('.math').remove();
data_value = String('hintstoshow' + answerdata); document.getElementById("submitbuttonfor" + answerdata).remove();
$(this).remove(); $('#submitbuttonfor' + answerdata).remove();
$('.math').remove(); $('#'+answerdata).remove();
document.getElementById("submitbuttonfor" + answerdata).remove(); $('#submit'+answerdata).prepend('Thankyou for your hint!');
$('#submitbuttonfor' + answerdata).remove(); }
$('#'+answerdata).remove(); }
//value = document.getElementById(id).getAttribute('data-value'); })
//$('#hintstoshow' + value).prepend("<p> Thankyou! </p>");
$('#submit'+answerdata).prepend('Thankyou for your hint!');
}}})
$(document).on('click', '.upvote_hint', function(){ //upvote $(document).on('click', '.upvote_hint', function(){ //upvote
canhint = 0; canhint = 0;
...@@ -202,6 +175,7 @@ function CrowdXBlock(runtime, element){ ...@@ -202,6 +175,7 @@ function CrowdXBlock(runtime, element){
data: JSON.stringify({"student_rating": $(this).attr('data-rate'), "used_hint": $(this).attr('id'), "student_answer": $(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 success: finish
});}) });})
$(document).on('click', '.downvote_hint', function(){ //upvote $(document).on('click', '.downvote_hint', function(){ //upvote
canhint = 0; canhint = 0;
id = this.id; id = this.id;
...@@ -216,6 +190,7 @@ function CrowdXBlock(runtime, element){ ...@@ -216,6 +190,7 @@ function CrowdXBlock(runtime, element){
data: JSON.stringify({"student_rating": $(this).attr('data-rate'), "used_hint": $(this).attr('id'), "student_answer": $(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 success: finish
});}) });})
$(document).on('click', '.flag_hint', function(){ //upvote $(document).on('click', '.flag_hint', function(){ //upvote
canhint = 0; canhint = 0;
id = this.id; id = this.id;
...@@ -236,17 +211,13 @@ function CrowdXBlock(runtime, element){ ...@@ -236,17 +211,13 @@ function CrowdXBlock(runtime, element){
if(canhint == 0){ if(canhint == 0){
canhint = 1; canhint = 1;
$('.Thankyou', element).text("Thankyou for your help!"); $('.Thankyou', element).text("Thankyou for your help!");
idtouse = String('thisparagraph' + result.used_hint); idtouse = String('votingFor' + result.used_hint);
hint_rating = result.rating; hint_rating = result.rating;
if(result.rating == "zzeerroo"){ if(result.rating == "zzeerroo"){
hint_rating = 0; hint_rating = 0;
}if(result.rating == "thiswasflagged"){ }if(result.rating == "thiswasflagged"){
hint_rating = 999; hint_rating = 999;
} }
//idtouse = idtouse.replace('ddeecciimmaallppooiinntt', /\./g);
//idtouse = idtouse.replace('ccoolloonn', /\:/g);
//idtouse = idtouse.replace('sseemmiiccoolloonn', /\;/g);
//idtouse = idtouse.replace('eeqquuaallss', /\=/g);
$('p').each(function(){ $('p').each(function(){
if($(this).attr('id') == idtouse){ if($(this).attr('id') == idtouse){
if(hint_rating != "You have already voted on this hint!" && hint_rating != 999){ if(hint_rating != "You have already voted on this hint!" && hint_rating != 999){
...@@ -263,7 +234,32 @@ function CrowdXBlock(runtime, element){ ...@@ -263,7 +234,32 @@ function CrowdXBlock(runtime, element){
} }
});} });}
} }
}
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'studiodata'),
data: JSON.stringify(""),
success: studiodata
});
function studiodata(result){
if($(".xblock-editor").length != 0){
$.each(result, function(index, value) {
$('.xblock-editor').append("<p id=\"" + value + "\"> The hint<b>" + " " + index + " " + "</b>was flagged for the submission<b>" + " " + value + "</b></p>");
$('#'+value).prepend("<input data-value=\"" + value + "\" id=\"" + index + "\" style=\"height:35px;padding-top: 3px;\" type=\"button\" class=\"flagbutton\" data-rate=\"dismiss\" value=\"Dismiss Hint\"><input data-value=\"" + value + "\" id=\"" + index + "\" style=\"height:35px; padding-top: 3px;\" type=\"button\" class=\"flagbutton\" data-rate=\"purge\" value=\"Purge Hint\">");
});
}
}
$(document).on('click', '.flagbutton', function(){
answer_wrong = $(this).attr('id');
hint = $(this).attr('data-value');
rating = $(this).attr('data-rate');
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'moderate_hint'),
data: JSON.stringify({"answer_wrong":answer_wrong, "hint": hint, "rating":rating}),
});
});
}
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