Commit b933c8b3 by Sola Committed by Piotr Mitros

fixed variabl naming and staff feedback

parent dfada058
......@@ -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
# 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
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
# 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.
......@@ -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.
# TODO: make this into a boolean instead of a dict
isStaff = Dict(default={'isStaff': 'true'}, scope=Scope.user_state_summary)
HintsToUse = Dict({}, scope=Scope.user_state)
def student_view(self, context=None):
"""
......@@ -197,22 +196,20 @@ class CrowdXBlock(XBlock):
# corresponding incorrect answer
feedback_data = {}
number_of_hints = 0
if len(self.WrongAnswers) == 0:
if self.isStaff['isStaff'] == 'false':
return
elif self.isStaff['isStaff'] == 'true':
# TODO: possibly simply check here whether or not user is staff
if self.isStaff['isStaff'] == 'true':
for answer_keys in self.hint_database:
print str(answer_keys)
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:
print str(hints)
if str(hints) not in self.Flagged.keys():
feedback_data[str(hints)] = str(answer_keys)
else:
feedback_data[str(hints)] = str("Flagged Hints")
for hints in self.hint_database[str(answer_keys)]:
for flagged_hints in self.Flagged:
if str(hints) != self.Flagged[flagged_hints]:
feedback_data[str(hints)] = str(answer_keys)
else:
feedback_data[str(hints)] = str("Flagged")
else:
feedback_data[str("There are no hints for" + " " + str(answer_keys))] = str(answer_keys)
elif len(self.WrongAnswers) == 0:
return
else:
for index in range(0, len(self.Used)):
# each index is a hint that was used, in order of usage
......
<div class="crowdxblock_block"> <!--most stuff just for testing purposes-->
<p> <span class='HintsToUse'>{self.HintsToUse}</span>
<p> <span class='HintsToUse'></span>
</p>
</div>
......
......@@ -23,6 +23,15 @@ function CrowdXBlock(runtime, element){
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);
//read the data from the problem_graded event here
......@@ -57,6 +66,8 @@ function CrowdXBlock(runtime, element){
$.ajax({
type: "POST",
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(""),
success: getFeedback
});
......@@ -78,6 +89,8 @@ function CrowdXBlock(runtime, element){
$('.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>");
}
//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"){
$('.showHintsFor'+student_answer, element).append(
"<p \" class =\"votingFor" + hint_used + "\">" +
......@@ -113,6 +126,9 @@ function CrowdXBlock(runtime, element){
issubmitting += 1;
if(issubmitting == repeatcounter){
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);
//value = document.getElementById(id).getAttribute('data-value');
$('.submitbutton').show();
......@@ -153,47 +169,50 @@ function CrowdXBlock(runtime, element){
$(document).on('click', '.upvote_hint', function(){ //upvote
canhint = 0;
id = this.id;
$(this).hide();
$('.hintbutton').each(function(){
if($(this).attr('id') == String(id)){
$(this).hide();}
if($(this).attr('id') == String(id)){
$(this).hide();
}
});
$.ajax({
type: "POST",
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')}),
success: finish
});})
});
})
$(document).on('click', '.downvote_hint', function(){ //upvote
canhint = 0;
id = this.id;
$(this).hide();
$('.hintbutton').each(function(){
if($(this).attr('id') == String(id)){
$(this).hide();}
if($(this).attr('id') == String(id)){
$(this).hide();
}
});
$.ajax({
type: "POST",
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')}),
success: finish
});})
});
})
$(document).on('click', '.flag_hint', function(){ //upvote
canhint = 0;
id = this.id;
$(this).hide();
$('.hintbutton').each(function(){
if($(this).attr('id') == String(id)){
$(this).hide();}
if($(this).attr('id') == String(id)){
$(this).hide();
}
});
$.ajax({
type: "POST",
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')}),
success: finish
});})
});
})
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