Commit 50af0024 by solashirai

basic fixes

parent f486755d
...@@ -171,7 +171,7 @@ class CrowdsourceHinter(XBlock): ...@@ -171,7 +171,7 @@ class CrowdsourceHinter(XBlock):
rating_dict = {} rating_dict = {}
for hint in self.hint_database[answer]: for hint in self.hint_database[answer]:
rating_dict.update({hint: (self.hint_database[answer][hint]["upvotes"] - self.hint_database[answer][hint]["downvotes"])}) rating_dict.update({hint: (self.hint_database[answer][hint]["upvotes"] - self.hint_database[answer][hint]["downvotes"])})
self.hint_database[answer].remove(min(rating_dict, rating_dict.get)) del self.hint_database[answer][(min(rating_dict, key=rating_dict.get))]
def compare_ratings(self, answer, hint, best): def compare_ratings(self, answer, hint, best):
...@@ -179,7 +179,7 @@ class CrowdsourceHinter(XBlock): ...@@ -179,7 +179,7 @@ class CrowdsourceHinter(XBlock):
Determine if the rating of a hint is better than the current Determine if the rating of a hint is better than the current
"best" hint. "best" hint.
""" """
return (self.hint_database[answer][hint]["upvotes"] - self.hint_database[answer][hint]["downvotes"]) > (self.hint_database[answer][best_hint]["upvotes"] - self.hint_database[answer][best_hint]["downvotes"]) return (self.hint_database[answer][hint]["upvotes"] - self.hint_database[answer][hint]["downvotes"]) > (self.hint_database[answer][best]["upvotes"] - self.hint_database[answer][best]["downvotes"])
@XBlock.json_handler @XBlock.json_handler
def get_hint(self, data, suffix=''): def get_hint(self, data, suffix=''):
...@@ -198,10 +198,6 @@ class CrowdsourceHinter(XBlock): ...@@ -198,10 +198,6 @@ class CrowdsourceHinter(XBlock):
'HintCategory': Either a string for the type of hint, or False 'HintCategory': Either a string for the type of hint, or False
if no hints if no hints
""" """
# We will remove excess hints at this point so that issues
# won't arise later due to a hint being removed
# (e.x. upvoting a hint that has been removed)
self.limit_hint_storage
# Populate hint_database with hints from initial_hints if # Populate hint_database with hints from initial_hints if
# there are no hints in hint_database. This probably will # there are no hints in hint_database. This probably will
# occur only on the very first run of a unit containing this # occur only on the very first run of a unit containing this
...@@ -215,6 +211,13 @@ class CrowdsourceHinter(XBlock): ...@@ -215,6 +211,13 @@ class CrowdsourceHinter(XBlock):
if hints not in self.hint_database[answers]: if hints not in self.hint_database[answers]:
self.hint_database[answers].update({hints: {"upvotes": 0, "downvotes": 0}}) self.hint_database[answers].update({hints: {"upvotes": 0, "downvotes": 0}})
# We will remove excess hints at this point so that issues
# won't arise later due to a hint being removed
# (e.x. upvoting a hint that has been removed)
# Initial hints will have the opportunity to be added back
# into hint_database if the other hints have bad ratings.
self.limit_hint_storage()
answer = self.extract_student_answers(data["submittedanswer"]) answer = self.extract_student_answers(data["submittedanswer"])
# HACK: For now, we assume just one submission, a string, and # HACK: For now, we assume just one submission, a string, and
...@@ -232,7 +235,7 @@ class CrowdsourceHinter(XBlock): ...@@ -232,7 +235,7 @@ class CrowdsourceHinter(XBlock):
if self.hints_available(answer): if self.hints_available(answer):
for hint in self.hint_database[answer]: for hint in self.hint_database[answer]:
if hint not in self.reported_hints.keys(): if hint not in self.reported_hints.keys():
# if best_hint hasn't been set yet or the rating of hints is greater than the rating of best_hint # if best_hint hasn't been set yet or if a hint's rating is greater than the rating of best_hint
if best_hint == "" or self.compare_ratings(answer, hint, best_hint): if best_hint == "" or self.compare_ratings(answer, hint, best_hint):
best_hint = hint best_hint = hint
self.used.append(best_hint) self.used.append(best_hint)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
Generic Hints: <textarea type="text" class="csh_generic_hints" value = "{{generic}}"/> Generic Hints: <textarea type="text" class="csh_generic_hints" value = "{{generic}}"/>
</p> </p>
<p> <p>
Initial hints should be a python dictionary, in the following format - {"mistake1": {"hint1": {"upvotes": 0, "downvotes": 0}}, "mistake2": {"hint2": {"upvotes": 0, "downvotes": 0}}}. Upvotes and downvotes can be set to desired values for varying results (e.x. set high downvotes to make new student-made hints have priority over your initial hint). Initial hints should be a python dictionary, with incorrect answers as keys and a list of hints as values. e.x. {"mistake1": ["hint1", "hint2"], "mistake2": ["hint"]}.
</p> </p>
<p> <p>
Initial Hints: <textarea type="text" class="csh_initial_hints" value = "{{initial}}"/> Initial Hints: <textarea type="text" class="csh_initial_hints" value = "{{initial}}"/>
......
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