Commit 0be2bc41 by solashirai Committed by Piotr Mitros

changed "flagged" to "reported"

parent 6930813b
...@@ -51,19 +51,19 @@ class CrowdsourceHinter(XBlock): ...@@ -51,19 +51,19 @@ class CrowdsourceHinter(XBlock):
# i believe this will also prevent students from voting again on a particular hint if they were to return to # i believe this will also prevent students from voting again on a particular hint if they were to return to
# a particular problem later # a particular problem later
Voted = List(default=[], scope=Scope.user_state) Voted = List(default=[], scope=Scope.user_state)
# This is a dictionary of hints that have been flagged. the values represent the incorrect answer submission, and the # This is a dictionary of hints that have been reported. the values represent the incorrect answer submission, and the
# keys are the hints the corresponding hints. hints with identical text for differing answers will all not show up for the # keys are the hints the corresponding hints. hints with identical text for differing answers will all not show up for the
# student. # student.
# #
# Example: {"desk": "You're completely wrong, the answer is supposed to be computer."} # Example: {"desk": "You're completely wrong, the answer is supposed to be computer."}
Flagged = Dict(default={}, scope=Scope.user_state_summary) Reported = Dict(default={}, 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.
show_best = Boolean(default = True, scope=Scope.user_state_summary) show_best = Boolean(default = True, scope=Scope.user_state_summary)
# This String represents the xblock element for which the hinter is running. It is necessary to manually # This String represents the xblock element for which the hinter is running. It is necessary to manually
# set this value in the XML file under the format "hinting_element": "i4x://edX/DemoX/problem/Text_Input" . # set this value in the XML file under the format "hinting_element": "i4x://edX/DemoX/problem/Text_Input" .
# Without properly setting this String, the hinter will not correctly be able to use the Logger listen for problem_graded. # Setting the element in the XML file is critical for the hinter to work.
Element = String(default="", scope=Scope.content) Element = String(default="", scope=Scope.content)
def student_view(self, context=None): def student_view(self, context=None):
...@@ -156,19 +156,20 @@ class CrowdsourceHinter(XBlock): ...@@ -156,19 +156,20 @@ class CrowdsourceHinter(XBlock):
if self.show_best: if self.show_best:
# if set to show best, only the best hint will be shown. Different hints will not be shown # if set to show best, only the best hint will be shown. Different hints will not be shown
# for multiple submissions/hint requests # for multiple submissions/hint requests
if best_hint not in self.Flagged.keys(): # currently set by default to True
if best_hint not in self.Reported.keys():
self.Used.append(best_hint) self.Used.append(best_hint)
return {'HintsToUse': best_hint, "StudentAnswer": answer} return {'HintsToUse': best_hint, "StudentAnswer": answer}
if best_hint not in self.Used: if best_hint not in self.Used:
# choose highest rated hint for the incorrect answer # choose highest rated hint for the incorrect answer
if best_hint not in self.Flagged.keys(): if best_hint not in self.Reported.keys():
self.Used.append(best_hint) self.Used.append(best_hint)
return {'HintsToUse': best_hint, "StudentAnswer": answer} return {'HintsToUse': best_hint, "StudentAnswer": answer}
# choose another random hint for the answer. # choose another random hint for the answer.
temporary_hints_list = [] temporary_hints_list = []
for hint_keys in self.hint_database[str(answer)]: for hint_keys in self.hint_database[str(answer)]:
if hint_keys not in self.Used: if hint_keys not in self.Used:
if hint_keys not in self.Flagged: if hint_keys not in self.Reported:
temporary_hints_list.append(str(hint_keys)) temporary_hints_list.append(str(hint_keys))
not_used = random.choice(temporary_hints_list) not_used = random.choice(temporary_hints_list)
self.Used.append(not_used) self.Used.append(not_used)
...@@ -193,7 +194,7 @@ class CrowdsourceHinter(XBlock): ...@@ -193,7 +194,7 @@ class CrowdsourceHinter(XBlock):
Returns 0 if no hints to show exist Returns 0 if no hints to show exist
""" """
isflagged = [] isreported = []
isused = 0 isused = 0
self.WrongAnswers.append(str(answer)) # add the student's input to the temporary list self.WrongAnswers.append(str(answer)) # add the student's input to the temporary list
if str(answer) not in self.hint_database: if str(answer) not in self.hint_database:
...@@ -201,13 +202,13 @@ class CrowdsourceHinter(XBlock): ...@@ -201,13 +202,13 @@ class CrowdsourceHinter(XBlock):
self.hint_database[str(answer)] = {} self.hint_database[str(answer)] = {}
return str(0) return str(0)
for hint_keys in self.hint_database[str(answer)]: for hint_keys in self.hint_database[str(answer)]:
for flagged_keys in self.Flagged: for reported_keys in self.Reported:
if hint_keys == flagged_keys: if hint_keys == reported_keys:
isflagged.append(hint_keys) isreported.append(hint_keys)
if str(hint_keys) in self.Used: if str(hint_keys) in self.Used:
if self.show_best is False: if self.show_best is False:
isused += 1 isused += 1
if (len(self.hint_database[str(answer)]) - len(isflagged) - isused) > 0: if (len(self.hint_database[str(answer)]) - len(isreported) - isused) > 0:
return str(1) return str(1)
else: else:
return str(0) return str(0)
...@@ -229,13 +230,13 @@ class CrowdsourceHinter(XBlock): ...@@ -229,13 +230,13 @@ class CrowdsourceHinter(XBlock):
# corresponding incorrect answer # corresponding incorrect answer
feedback_data = {} feedback_data = {}
if data['isStaff'] == 'true': if data['isStaff'] == 'true':
if len(self.Flagged) != 0: if len(self.Reported) != 0:
for answer_keys in self.hint_database: for answer_keys in self.hint_database:
if str(len(self.hint_database[str(answer_keys)])) != str(0): if str(len(self.hint_database[str(answer_keys)])) != str(0):
for hints in self.hint_database[str(answer_keys)]: for hints in self.hint_database[str(answer_keys)]:
for flagged_hints in self.Flagged: for reported_hints in self.Reported:
if str(hints) == flagged_hints: if str(hints) == reported_hints:
feedback_data[str(hints)] = str("Flagged") feedback_data[str(hints)] = str("Reported")
if len(self.WrongAnswers) == 0: if len(self.WrongAnswers) == 0:
return return
else: else:
...@@ -248,7 +249,7 @@ class CrowdsourceHinter(XBlock): ...@@ -248,7 +249,7 @@ class CrowdsourceHinter(XBlock):
self.Used=[] self.Used=[]
return feedback_data return feedback_data
else: else:
# if the student's answer had no hints (or all the hints were flagged and unavailable) return None # if the student's answer had no hints (or all the hints were reported and unavailable) return None
feedback_data[None] = str(self.WrongAnswers[index]) feedback_data[None] = str(self.WrongAnswers[index])
self.WrongAnswers=[] self.WrongAnswers=[]
self.Used=[] self.Used=[]
...@@ -277,9 +278,9 @@ class CrowdsourceHinter(XBlock): ...@@ -277,9 +278,9 @@ class CrowdsourceHinter(XBlock):
hint_rating: the rating of the hint as well as data on what the hint in question is hint_rating: the rating of the hint as well as data on what the hint in question is
""" """
hint_rating = {} hint_rating = {}
if data['student_answer'] == 'Flagged': if data['student_answer'] == 'Reported':
hint_rating['rating'] = 0 hint_rating['rating'] = 0
hint_rating['student_ansxwer'] = 'Flagged' hint_rating['student_ansxwer'] = 'Reported'
hint_rating['hint'] = data['hint'] hint_rating['hint'] = data['hint']
return hint_rating return hint_rating
hint_rating['rating'] = self.hint_database[data['student_answer']][data['hint']] hint_rating['rating'] = self.hint_database[data['student_answer']][data['hint']]
...@@ -292,7 +293,7 @@ class CrowdsourceHinter(XBlock): ...@@ -292,7 +293,7 @@ class CrowdsourceHinter(XBlock):
""" """
Used to facilitate hint rating by students. Used to facilitate hint rating by students.
Hint ratings in hint_database are updated and the resulting hint rating (or flagged status) is returned to JS. Hint ratings in hint_database are updated and the resulting hint rating (or reported status) is returned to JS.
Args: Args:
data['student_answer']: The incorrect answer that corresponds to the hint that is being voted on data['student_answer']: The incorrect answer that corresponds to the hint that is being voted on
...@@ -305,21 +306,21 @@ class CrowdsourceHinter(XBlock): ...@@ -305,21 +306,21 @@ class CrowdsourceHinter(XBlock):
answer_data = data['student_answer'] answer_data = data['student_answer']
data_rating = data['student_rating'] data_rating = data['student_rating']
data_hint = data['hint'] data_hint = data['hint']
if data['student_rating'] == 'unflag': if data['student_rating'] == 'unreport':
for flagged_hints in self.Flagged: for reporteded_hints in self.Reported:
if flagged_hints == data_hint: if reported_hints == data_hint:
self.Flagged.pop(data_hint, None) self.Reported.pop(data_hint, None)
return {'rating': 'unflagged'} return {'rating': 'unreported'}
if data['student_rating'] == 'remove': if data['student_rating'] == 'remove':
for flagged_hints in self.Flagged: for reported_hints in self.Reported:
if data_hint == flagged_hints: if data_hint == reported_hints:
self.hint_database[self.Flagged[data_hint]].pop(data_hint, None) self.hint_database[self.Reported[data_hint]].pop(data_hint, None)
self.Flagged.pop(data_hint, None) self.Reported.pop(data_hint, None)
return {'rating': 'removed'} return {'rating': 'removed'}
if data['student_rating'] == 'flag': if data['student_rating'] == 'report':
# add hint to Flagged dictionary # add hint to Reported dictionary
self.Flagged[str(data_hint)] = answer_data self.Reported[str(data_hint)] = answer_data
return {"rating": 'flagged', 'hint': data_hint} return {"rating": 'reported', 'hint': data_hint}
if str(data_hint) not in self.Voted: if str(data_hint) not in self.Voted:
self.Voted.append(str(data_hint)) # add data to Voted to prevent multiple votes self.Voted.append(str(data_hint)) # add data to Voted to prevent multiple votes
rating = self.change_rating(data_hint, data_rating, answer_data) # change hint rating rating = self.change_rating(data_hint, data_rating, answer_data) # change hint rating
...@@ -351,7 +352,7 @@ class CrowdsourceHinter(XBlock): ...@@ -351,7 +352,7 @@ class CrowdsourceHinter(XBlock):
self.hint_database[str(answer_data)][str(data_hint)] -= 1 self.hint_database[str(answer_data)][str(data_hint)] -= 1
@XBlock.json_handler @XBlock.json_handler
def give_hint(self, data, suffix=''): def add_new_hint(self, data, suffix=''):
""" """
This function adds a new hint submitted by the student into the hint_database. This function adds a new hint submitted by the student into the hint_database.
...@@ -375,10 +376,10 @@ class CrowdsourceHinter(XBlock): ...@@ -375,10 +376,10 @@ class CrowdsourceHinter(XBlock):
@XBlock.json_handler @XBlock.json_handler
def studiodata(self, data, suffix=''): def studiodata(self, data, suffix=''):
""" """
This function serves to return the dictionary of flagged hints to JS. This is intended for use in This function serves to return the dictionary of reported hints to JS. This is intended for use in
the studio_view, which is under construction at the moment the studio_view, which is under construction at the moment
""" """
return self.Flagged return self.Reported
@staticmethod @staticmethod
def workbench_scenarios(): def workbench_scenarios():
...@@ -388,7 +389,7 @@ class CrowdsourceHinter(XBlock): ...@@ -388,7 +389,7 @@ class CrowdsourceHinter(XBlock):
""" """
<verticaldemo> <verticaldemo>
<crowdsourcehinter> <crowdsourcehinter>
{"initial_hint_answer": "michigann", "initial_hint_text": "you have an extra n", "generic_hint": "make sure to check your spelling"} {"generic_hints": "Make sure to check for basic mistakes like typos", "initial_hints": {"michiganp": {"remove the p at the end", 0}, "michigann": {"too many Ns on there": 0}}, "hinting_element": "i4x://edX/DemoX/problem/Text_Input"}
</crowdsourcehinter> </crowdsourcehinter>
</verticaldemo> </verticaldemo>
""" """
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
align-self: flex-end; align-self: flex-end;
} }
div[data-rate="flag"]{ div[data-rate="report"]{
font-weight: bold; font-weight: bold;
} }
...@@ -69,15 +69,15 @@ div[data-rate="downvote"] { ...@@ -69,15 +69,15 @@ div[data-rate="downvote"] {
font-weight: bold; font-weight: bold;
} }
.csh_flagged_hints { .csh_reported_hints {
background-color: red; background-color: red;
} }
.crowdsourcehinter_block .csh_flagged_hints { .crowdsourcehinter_block .csh_reported_hints {
visibility: hidden; visibility: hidden;
display: none; display: none;
} }
.crowdsourcehinter_block_is_staff .csh_flagged_hints { .crowdsourcehinter_block_is_staff .csh_reported_hints {
visibility: visible; visibility: visible;
} }
......
...@@ -10,17 +10,17 @@ ...@@ -10,17 +10,17 @@
<div role="button" class="csh_rate_hint" data-rate="downvote"> <div role="button" class="csh_rate_hint" data-rate="downvote">
<b>Rate as Unhelpful</b> <b>Rate as Unhelpful</b>
</div> </div>
<div role="button" class="csh_rate_hint" data-rate="flag" data-icon="flag" title="Report this hint."> <div role="button" class="csh_rate_hint" data-rate="report" data-icon="report" title="Report this hint.">
<b></b> <b></b>
</div> </div>
</div> </div>
</div> </div>
</script> </script>
<script type="x-tmpl/mustache" id="show_flagged_feedback"> <script type="x-tmpl/mustache" id="show_reported_feedback">
<div class="csh_hint_value" value ="{{hint}}"> <div class="csh_hint_value" value ="{{hint}}">
<div class="csh_hint">{{hint}}</div> <div class="csh_hint">{{hint}}</div>
<div role="button" class="csh_staff_rate" data-rate="unflag" aria-label="unflag"> <div role="button" class="csh_staff_rate" data-rate="unreport" aria-label="unreport">
<u><b>Return hint for use in the hinter</b></u> <u><b>Return hint for use in the hinter</b></u>
</div> </div>
<div role="button" class="csh_staff_rate" data-rate="remove" aria-label="remove"> <div role="button" class="csh_staff_rate" data-rate="remove" aria-label="remove">
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
<div role="button" class="csh_rate_hint" data-rate="downvote" title="This hint was not very helpful."> <div role="button" class="csh_rate_hint" data-rate="downvote" title="This hint was not very helpful.">
<b>-</b> <b>-</b>
</div> </div>
<div role="button" class="csh_rate_hint" data-rate="flag" title="Report this hint"> <div role="button" class="csh_rate_hint" data-rate="report" title="Report this hint">
<b></b> <b></b>
</div> </div>
</div> </div>
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
<span class='Thankyou'></span> <span class='Thankyou'></span>
</p> </p>
<div class="csh_feedback"> <div class="csh_feedback">
<div class="csh_flagged_hints"> <div class="csh_reported_hints">
<span>moderate reported hints</span> <span>moderate reported hints</span>
</div> </div>
</div> </div>
......
...@@ -80,7 +80,7 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -80,7 +80,7 @@ function CrowdsourceHinter(runtime, element, data){
function showHintFeedback(hint, student_answer){ function showHintFeedback(hint, student_answer){
//Append answer-specific hints for each student answer during the feedback stage. //Append answer-specific hints for each student answer during the feedback stage.
//This appended div includes upvote/downvote/flagging buttons, the hint, and the hint's rating //This appended div includes upvote/downvote/reporting buttons, the hint, and the hint's rating
$(".csh_student_answer", element).each(function(){ $(".csh_student_answer", element).each(function(){
if ($(this).find('.csh_answer_text').attr('answer') == student_answer){ if ($(this).find('.csh_answer_text').attr('answer') == student_answer){
var html = ""; var html = "";
...@@ -100,17 +100,17 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -100,17 +100,17 @@ function CrowdsourceHinter(runtime, element, data){
}); });
} }
function showFlaggedFeedback(result){ function showReportedFeedback(result){
//For staff use, shows hints that have been flagged by students and allows for the hints' unflagging/removal. //For staff use, shows hints that have been reporteded by students and allows for the hints' unreporting/removal.
var html = ""; var html = "";
$(function(){ $(function(){
var template = $('#show_flagged_feedback').html(); var template = $('#show_reported_feedback').html();
var data = { var data = {
hint: result hint: result
}; };
html = Mustache.render(template, data); html = Mustache.render(template, data);
}); });
$(".csh_flagged_hints", element).append(html); $(".csh_reported_hints", element).append(html);
} }
function setStudentAnswers(student_answers){ function setStudentAnswers(student_answers){
...@@ -131,15 +131,15 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -131,15 +131,15 @@ function CrowdsourceHinter(runtime, element, data){
if(isStaff){ if(isStaff){
$('.crowdsourcehinter_block', element).attr('class', 'crowdsourcehinter_block_is_staff'); $('.crowdsourcehinter_block', element).attr('class', 'crowdsourcehinter_block_is_staff');
$.each(result, function(index, value) { $.each(result, function(index, value) {
if(value == "Flagged") { if(value == "Reported") {
//index represents the flagged hint's text //index represents the reported hint's text
showFlaggedFeedback(index); showReportedFeedback(index);
} }
}); });
} }
if(!isShowingHintFeedback){ if(!isShowingHintFeedback){
$.each(result, function(index, value) { $.each(result, function(index, value) {
if(value != "Flagged"){ if(value != "Reported"){
setStudentAnswers(value); setStudentAnswers(value);
student_answer = value; student_answer = value;
hint = index; hint = index;
...@@ -160,7 +160,7 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -160,7 +160,7 @@ function CrowdsourceHinter(runtime, element, data){
} }
}); });
} }
//flagged hints have their corresponding answer set to "Flagged" //reported hints have their corresponding answer set to "Reported"
else{ else{
showHintFeedback(hint, student_answer); showHintFeedback(hint, student_answer);
} }
...@@ -201,7 +201,7 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -201,7 +201,7 @@ function CrowdsourceHinter(runtime, element, data){
$('.csh_submitbutton', element).show(); $('.csh_submitbutton', element).show();
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: runtime.handlerUrl(element, 'give_hint'), url: runtime.handlerUrl(element, 'add_new_hint'),
data: JSON.stringify({"submission": newhint, "answer": answerdata}), data: JSON.stringify({"submission": newhint, "answer": answerdata}),
success: function(result){ success: function(result){
$.ajax({ $.ajax({
...@@ -218,8 +218,8 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -218,8 +218,8 @@ function CrowdsourceHinter(runtime, element, data){
}) })
$(element).on('click', '.csh_rate_hint', function(){ $(element).on('click', '.csh_rate_hint', function(){
if ($(this).attr('data-rate') == "flag"){ if ($(this).attr('data-rate') == "report"){
alert("This hint has been flagged for review."); alert("This hint has been reported for review.");
} }
hint = $('.csh_HintsToUse', element).attr('hint_received'); hint = $('.csh_HintsToUse', element).attr('hint_received');
student_answer = $('.csh_HintsToUse', element).attr('student_answer'); student_answer = $('.csh_HintsToUse', element).attr('student_answer');
...@@ -233,10 +233,10 @@ function CrowdsourceHinter(runtime, element, data){ ...@@ -233,10 +233,10 @@ function CrowdsourceHinter(runtime, element, data){
}); });
$(element).on('click', '.csh_staff_rate', function(){ $(element).on('click', '.csh_staff_rate', function(){
//Staff ratings are the removal or unflagging of flagged hints from the database. The attribute 'data-rate' is used //Staff ratings are the removal or unreporting of reported hints from the database. The attribute 'data-rate' is used
//to determine whether to unflag or delete the hint. //to determine whether to unreport or delete the hint.
hint = $(this).parent().find(".csh_hint").text(); hint = $(this).parent().find(".csh_hint").text();
student_answer = "Flagged"; student_answer = "Reported";
Logger.log('crowd_hinter.staff_rate_hint.click.event', {"hint": hint, "student_answer": student_answer, "rating": $(this).attr('data-rate')}); Logger.log('crowd_hinter.staff_rate_hint.click.event', {"hint": hint, "student_answer": student_answer, "rating": $(this).attr('data-rate')});
$.ajax({ $.ajax({
type: "POST", type: "POST",
......
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