Commit b933c8b3 by Sola Committed by Piotr Mitros

fixed variabl naming and staff feedback

parent dfada058
...@@ -41,7 +41,7 @@ class CrowdXBlock(XBlock): ...@@ -41,7 +41,7 @@ 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={"answer2": "THis is a hint that should be flagged"}, 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.
...@@ -51,7 +51,6 @@ class CrowdXBlock(XBlock): ...@@ -51,7 +51,6 @@ class CrowdXBlock(XBlock):
# will be shown. The method to actually determine whether or not the user is staff is not currently implemented. # 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 # TODO: make this into a boolean instead of a dict
isStaff = Dict(default={'isStaff': 'true'}, scope=Scope.user_state_summary) isStaff = Dict(default={'isStaff': 'true'}, scope=Scope.user_state_summary)
HintsToUse = Dict({}, scope=Scope.user_state)
def student_view(self, context=None): def student_view(self, context=None):
""" """
...@@ -197,22 +196,20 @@ class CrowdXBlock(XBlock): ...@@ -197,22 +196,20 @@ class CrowdXBlock(XBlock):
# corresponding incorrect answer # corresponding incorrect answer
feedback_data = {} feedback_data = {}
number_of_hints = 0 number_of_hints = 0
if len(self.WrongAnswers) == 0: # TODO: possibly simply check here whether or not user is staff
if self.isStaff['isStaff'] == 'false': if self.isStaff['isStaff'] == 'true':
return
elif self.isStaff['isStaff'] == 'true':
for answer_keys in self.hint_database: for answer_keys in self.hint_database:
print str(answer_keys)
if str(len(self.hint_database[str(answer_keys)])) != str(0): if str(len(self.hint_database[str(answer_keys)])) != str(0):
hint_key = self.hint_database[str(answer_keys)].keys() for hints in self.hint_database[str(answer_keys)]:
for hints in hint_key: for flagged_hints in self.Flagged:
print str(hints) if str(hints) != self.Flagged[flagged_hints]:
if str(hints) not in self.Flagged.keys(): feedback_data[str(hints)] = str(answer_keys)
feedback_data[str(hints)] = str(answer_keys) else:
else: feedback_data[str(hints)] = str("Flagged")
feedback_data[str(hints)] = str("Flagged Hints")
else: else:
feedback_data[str("There are no hints for" + " " + str(answer_keys))] = str(answer_keys) feedback_data[str("There are no hints for" + " " + str(answer_keys))] = str(answer_keys)
elif len(self.WrongAnswers) == 0:
return
else: else:
for index in range(0, len(self.Used)): for index in range(0, len(self.Used)):
# each index is a hint that was used, in order of usage # each index is a hint that was used, in order of usage
......
<div class="crowdxblock_block"> <!--most stuff just for testing purposes--> <div class="crowdxblock_block"> <!--most stuff just for testing purposes-->
<p> <span class='HintsToUse'>{self.HintsToUse}</span> <p> <span class='HintsToUse'></span>
</p> </p>
</div> </div>
......
...@@ -23,6 +23,15 @@ function CrowdXBlock(runtime, element){ ...@@ -23,6 +23,15 @@ function CrowdXBlock(runtime, element){
repeating = 0; repeating = 0;
} }
function logError(details) {
$.ajax({
type: 'POST',
url: '/home/sola/crowdxblock',
data: JSON.stringify({context: navigator.userAgent, details: details}),
contentType: 'application/json; charset=utf-8'
});
}
Logger.listen('problem_graded', null, get_event_data); Logger.listen('problem_graded', null, get_event_data);
//read the data from the problem_graded event here //read the data from the problem_graded event here
...@@ -57,6 +66,8 @@ function CrowdXBlock(runtime, element){ ...@@ -57,6 +66,8 @@ function CrowdXBlock(runtime, element){
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: runtime.handlerUrl(element, 'get_feedback'), url: runtime.handlerUrl(element, 'get_feedback'),
//possibly send here if user is staff?
//doing so would be helpful to set up a "flagged" seciton for hints
data: JSON.stringify(""), data: JSON.stringify(""),
success: getFeedback success: getFeedback
}); });
...@@ -78,6 +89,8 @@ function CrowdXBlock(runtime, element){ ...@@ -78,6 +89,8 @@ function CrowdXBlock(runtime, element){
$('.feedback', element).append("<p class=\"submit" + student_answer + "\"</p>"); $('.feedback', element).append("<p class=\"submit" + student_answer + "\"</p>");
$(".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>"); $(".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>");
} }
//get_feedback will send "There are no hints for" + student_answer if no hints exist
//slice to determine this
if(hint_used.slice(0,22) != "There are no hints for"){ if(hint_used.slice(0,22) != "There are no hints for"){
$('.showHintsFor'+student_answer, element).append( $('.showHintsFor'+student_answer, element).append(
"<p \" class =\"votingFor" + hint_used + "\">" + "<p \" class =\"votingFor" + hint_used + "\">" +
...@@ -113,6 +126,9 @@ function CrowdXBlock(runtime, element){ ...@@ -113,6 +126,9 @@ function CrowdXBlock(runtime, element){
issubmitting += 1; issubmitting += 1;
if(issubmitting == repeatcounter){ if(issubmitting == repeatcounter){
id = this.id; id = this.id;
//the id of the button is "submitbuttonfor"+student_answer
//slice to determine which answer for which a submission is being made
//this should be made more dynamic
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();
...@@ -153,47 +169,50 @@ function CrowdXBlock(runtime, element){ ...@@ -153,47 +169,50 @@ function CrowdXBlock(runtime, element){
$(document).on('click', '.upvote_hint', function(){ //upvote $(document).on('click', '.upvote_hint', function(){ //upvote
canhint = 0; canhint = 0;
id = this.id; id = this.id;
$(this).hide();
$('.hintbutton').each(function(){ $('.hintbutton').each(function(){
if($(this).attr('id') == String(id)){ if($(this).attr('id') == String(id)){
$(this).hide();} $(this).hide();
}
}); });
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'), url: runtime.handlerUrl(element, 'rate_hint'),
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;
$(this).hide();
$('.hintbutton').each(function(){ $('.hintbutton').each(function(){
if($(this).attr('id') == String(id)){ if($(this).attr('id') == String(id)){
$(this).hide();} $(this).hide();
}
}); });
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'), url: runtime.handlerUrl(element, 'rate_hint'),
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;
$(this).hide();
$('.hintbutton').each(function(){ $('.hintbutton').each(function(){
if($(this).attr('id') == String(id)){ if($(this).attr('id') == String(id)){
$(this).hide();} $(this).hide();
}
}); });
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'), url: runtime.handlerUrl(element, 'rate_hint'),
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
});}) });
})
function finish(result){ function finish(result){
......
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