Commit eb858773 by Sola

my computer will now not blow up after trying to get more hints than are available.

parent a0ab195e
......@@ -13,7 +13,8 @@ log = logging.getLogger(__name__)
#get_hint and get_feedback are in
class CrowdXBlock(XBlock):
correctanswer = String(default="42", scope=Scope.content) #should be irrelevant for completed version
hints = Dict(default={"2": {"hint1for2":0, "hint2for2":0, "hints3for22":0}, "1": {"hint1for1":0, "hint2for1":0, "hint3for1":0}, "3": {"hint1for3":0, "hint2for3":0, "hint3for3":0}}, scope=Scope.content) #All hints. sorted by type of mistake. type_of_incorrect_answer{"hint":rating, "hint":rating}
hints = Dict(default={"2": {"hint1for2":0, "hint2for2":0, "hint3for2":0}, "1": {"hint1for1":0, "hint2for1":0, "hint3for1":0}, "3": {"hint1for3":0, "hint2for3":0, "hint3for3":0}}, scope=Scope.content)
#All hints. sorted by type of mistake. type_of_incorrect_answer{"hint":rating, "hint":rating}
HintsToUse = Dict(default={}, scope=Scope.user_state) #Dict of hints to provide user
WrongAnswers = List(default=[], scope=Scope.user_state) #List of mistakes made by user
DefaultHints = Dict(default={"defaulthint1": 0, "defaulthint2": 0, "defaulthint3": 0, "defaulthint4": 0, "defaulthint5": 0, "bestdefaulthint": 3}, scope=Scope.content) #Default hints in case no incorrect answers in hints match the user's mistake
......@@ -59,9 +60,13 @@ class CrowdXBlock(XBlock):
return {'HintsToUse': max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0]}
else:
NotUsed = random.choice(self.HintsToUse.keys())
if len(NotUsed) != len(self.Used):
print(len(self.HintsToUse) + len(self.Used))
if len(self.HintsToUse) != len(self.Used):
print(len(self.HintsToUse) + len(self.Used))
while NotUsed in self.Used:
NotUsed = random.choice(self.HintsToUse.keys()) #Choose random hint that hasn't already been Used
elif len(self.Used) > 0:
return
self.Used.append(NotUsed)
return {'HintsToUse': NotUsed} #note to self dont let python get into endless notused loop
......
......@@ -13,7 +13,8 @@ log = logging.getLogger(__name__)
#get_hint and get_feedback are in
class CrowdXBlock(XBlock):
correctanswer = String(default="42", scope=Scope.content) #should be irrelevant for completed version
hints = Dict(default={"2": {"hint1for2":0, "hint2for2":0, "hints3for22":0}, "1": {"hint1for1":0, "hint2for1":0, "hint3for1":0}, "3": {"hint1for3":0, "hint2for3":0, "hint3for3":0}}, scope=Scope.content) #All hints. sorted by type of mistake. type_of_incorrect_answer{"hint":rating, "hint":rating}
hints = Dict(default={"2": {"hint1for2":0, "hint2for2":0, "hint3for2":0}, "1": {"hint1for1":0, "hint2for1":0, "hint3for1":0}, "3": {"hint1for3":0, "hint2for3":0, "hint3for3":0}}, scope=Scope.content)
#All hints. sorted by type of mistake. type_of_incorrect_answer{"hint":rating, "hint":rating}
HintsToUse = Dict(default={}, scope=Scope.user_state) #Dict of hints to provide user
WrongAnswers = List(default=[], scope=Scope.user_state) #List of mistakes made by user
DefaultHints = Dict(default={"defaulthint1": 0, "defaulthint2": 0, "defaulthint3": 0, "defaulthint4": 0, "defaulthint5": 0, "bestdefaulthint": 3}, scope=Scope.content) #Default hints in case no incorrect answers in hints match the user's mistake
......@@ -59,9 +60,13 @@ class CrowdXBlock(XBlock):
return {'HintsToUse': max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0]}
else:
NotUsed = random.choice(self.HintsToUse.keys())
if len(NotUsed) != len(self.Used):
print(len(self.HintsToUse) + len(self.Used))
if len(self.HintsToUse) != len(self.Used):
print(len(self.HintsToUse) + len(self.Used))
while NotUsed in self.Used:
NotUsed = random.choice(self.HintsToUse.keys()) #Choose random hint that hasn't already been Used
elif len(self.Used) > 0:
return
self.Used.append(NotUsed)
return {'HintsToUse': NotUsed} #note to self dont let python get into endless notused loop
......@@ -106,7 +111,7 @@ class CrowdXBlock(XBlock):
for key in self.hints:
print(str(key))
print("still working here")
if str(key) == self.WrongAnswer[self.Used.index(str(data['id']))]:
if str(key) == self.WrongAnswers[self.Used.index(str(data['id']))]:
if str(data['submission']) not in self.hints[str(key)]:
tempdict = str(self.hints[str(key)]) #rate hint that is in hints
tempdict = (ast.literal_eval(tempdict))
......
......@@ -23,9 +23,6 @@
<input id="caus" type="button" class="button" value="clearAllUserState">
</p>
<section class="solution-span"><span id="solution_i4x-Me-19_002-problem-Numerical_Input_solution_1"></span></section></div>
<section class="action">
<input type="hidden" name="problem_id" value="Numerical Input">
......
......@@ -4,7 +4,7 @@
</p>
<span><br><span> Dummy Answer Input Here</span></span>
<section id="studentinput" class="textinput">
<input type="text" name="studentanswer" id="studentsubmit" class="math" size="40">
<input type="text" name="studentanswer" id="studentsubmit" class="notmath" size="40">
<input id="studentanswer" type="button" class="button" value="Submit Answer">
</div>
......
......@@ -71,21 +71,23 @@ function CrowdXBlock(runtime, element){
$("#studentsubmit").val('');
$("#answer").val('');})
function finish(){
$(".hintbutton").hide();
$('.Thankyou', element).text("Thankyou for your help!");
$('.correct', element).hide();
$(".hintansarea").hide();
$( ".hintansarea" ).empty();
}
function clearstates(){
$(".hintansarea").hide();
$(".hintbutton").hide();
$('.Thankyou', element).text();
$('.correct', element).hide();
$( ".hintansarea" ).empty();
$("#answer").hide();
$(".problem").hide();
}
function checkreply(result){
if(result.correct == 1){
console.debug("yay");
$('.correct', element).show();
$('.correct', element).text("You're correct! Please choose the best hint, or provide us with one of your own!");
$.ajax({
type: "POST",
......
......@@ -55,7 +55,7 @@ function CrowdXBlock(runtime, element){
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'give_hint'),
data: JSON.stringify({"submission": $('#answer').val(), "id": $(".math").attr('id')}), //give hin for first incorrect answer
data: JSON.stringify({"submission": $('.math').val(), "id": $(".math").attr('id')}), //give hin for first incorrect answer
success: finish
});
$("#answer").val('');})
......@@ -71,14 +71,14 @@ function CrowdXBlock(runtime, element){
$("#studentsubmit").val('');
$("#answer").val('');})
function finish(){
$(".hintbutton").hide();
$('.Thankyou', element).text("Thankyou for your help!");
$('.correct', element).hide();
$(".hintansarea").hide();
$( ".hintansarea" ).empty();
}
function clearstates(){
$(".hintansarea").hide();
$(".hintbutton").hide();
$('.Thankyou', element).text();
$('.correct', element).hide();
$( ".hintansarea" ).empty();
$("#answer").hide();
$(".problem").hide();
}
......@@ -86,6 +86,7 @@ function CrowdXBlock(runtime, element){
function checkreply(result){
if(result.correct == 1){
console.debug("yay");
$('.correct', element).show();
$('.correct', element).text("You're correct! Please choose the best hint, or provide us with one of your own!");
$.ajax({
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