Commit 7bedbdff by Sola Committed by Piotr Mitros

submit hint input appears correctly, default hints no longer show up for answers…

submit hint input appears correctly, default hints no longer show up for answers that don't have hints, all hints for answer show up (limit later)
parent 20d3c860
...@@ -13,7 +13,7 @@ log = logging.getLogger(__name__) ...@@ -13,7 +13,7 @@ log = logging.getLogger(__name__)
#get_hint and get_feedback are in #get_hint and get_feedback are in
class CrowdXBlock(XBlock): class CrowdXBlock(XBlock):
correctanswer = String(default="2.0", scope=Scope.content) #should be irrelevant for completed version correctanswer = String(default="2.0", scope=Scope.content) #should be irrelevant for completed version
hints = Dict(default={"2": {"Keep significant figures in mind.":1, "So close yet so far.":0, "Try adding a .0.":0}, "8.6": {"You might have added all of the horizontal forces together to equal a total of 21 for the horizontal component of this object's force. The two forces are facing opposite direction, so you need to subtract them.":1, "Try 12-9 for the total horizontal force.":0}, "1.2": {"Did you remember to add in the vertical component of force for this object?":0}}, scope=Scope.content) hints = Dict(default={"2": {"another 2 hint":0, "yet another 2 hint":0,"Keep significant figures in mind.":1, "So close yet so far.":0, "Try adding a .0.":0}, "8.6": {"You might have added all of the horizontal forces together to equal a total of 21 for the horizontal component of this object's force. The two forces are facing opposite direction, so you need to subtract them.":1, "Try 12-9 for the total horizontal force.":0}, "1.2": {"Did you remember to add in the vertical component of force for this object?":0}}, scope=Scope.content)
#All hints. sorted by type of mistake. type_of_incorrect_answer{"hint":rating, "hint":rating} #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 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 WrongAnswers = List(default=[], scope=Scope.user_state) #List of mistakes made by user
...@@ -54,7 +54,6 @@ class CrowdXBlock(XBlock): ...@@ -54,7 +54,6 @@ class CrowdXBlock(XBlock):
self.hints[str(data["submittedanswer"])] = {} #add user's incorrect answer to WrongAnswers self.hints[str(data["submittedanswer"])] = {} #add user's incorrect answer to WrongAnswers
self.HintsToUse = {} self.HintsToUse = {}
self.HintsToUse.update(self.DefaultHints) self.HintsToUse.update(self.DefaultHints)
print str(self.hints)
if max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0] not in self.Used: if max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0] not in self.Used:
self.Used.append(max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0]) #Highest rated hint is shown first self.Used.append(max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0]) #Highest rated hint is shown first
return {'HintsToUse': max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0]} return {'HintsToUse': max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0]}
...@@ -63,8 +62,16 @@ class CrowdXBlock(XBlock): ...@@ -63,8 +62,16 @@ class CrowdXBlock(XBlock):
if len(self.HintsToUse) > len(self.Used): if len(self.HintsToUse) > len(self.Used):
while NotUsed in self.Used: while NotUsed in self.Used:
NotUsed = random.choice(self.HintsToUse.keys()) #Choose random hint that hasn't already been Used NotUsed = random.choice(self.HintsToUse.keys()) #Choose random hint that hasn't already been Used
elif len(self.Used) > 0: else:
return {'HintsToUse': "Sorry, there are no more hints for this answer."} usedef = 0
for h in self.HintsToUse:
if str(h) not in self.Used:
NotUsed = h
usedef = 1
if usedef == 0:
self.Used.append(str("There are no hints for" + " " + data["submittedanswer"]))
print str(self.Used)
return {'HintsToUse': "Sorry, there are no more hints for this answer."}
self.Used.append(NotUsed) self.Used.append(NotUsed)
return {'HintsToUse': NotUsed} #note to self dont let python get into endless notused loop return {'HintsToUse': NotUsed} #note to self dont let python get into endless notused loop
...@@ -78,34 +85,23 @@ class CrowdXBlock(XBlock): ...@@ -78,34 +85,23 @@ class CrowdXBlock(XBlock):
for i in range(0, len(self.Used)): for i in range(0, len(self.Used)):
ans = str('wngans' + str(i)) ans = str('wngans' + str(i))
hnt = str('hntusd' + str(i)) hnt = str('hntusd' + str(i))
feedbackdict[str(self.Used[i])] = str(self.WrongAnswers[i]) for keys in self.hints:
if str(self.Used[i]) in self.hints[str(keys)]:
feedbackdict[str(self.Used[i])] = str(self.WrongAnswers[i])
feedbacklist.append(str(self.Used[i])) feedbacklist.append(str(self.Used[i]))
for key in self.hints: for key in self.hints:
if str(key) == str(self.WrongAnswers[i]): if str(key) == str(self.WrongAnswers[i]):
if len(self.hints[str(key)]) > 2: if len(self.hints[str(key)]) != 0:
thiskeycount = 0 for nextkey in self.hints[str(key)]:
while thiskeycount < 2: feedbackdict[str(nextkey)] = str(self.WrongAnswers[i])
nextkey = random.choice(self.hints[key].keys()) self.WrongAnswers.append(str(self.WrongAnswers[i]))
if str(nextkey) not in feedbacklist: self.Used.append(str(nextkey))
thiskeycount += 1
feedbacklist.append(str(nextkey))
feedbackdict[str(nextkey)] = str(self.WrongAnswers[i])
print(str(nextkey))
if thiskeycount == 2:
feedbacklist = []
else: else:
thiskeycount = 0 feedbackdict[str("There are no hints for" + " " + str(self.WrongAnswers[i]))] = str(self.WrongAnswers[i])
while thiskeycount < 2: self.WrongAnswers.append(str(self.WrongAnswers[i]))
nextkey = random.choice(self.DefaultHints.keys()) self.Used.append(str("There are no hints for" + " " + str(self.WrongAnswers[i])))
if str(nextkey) not in feedbacklist: print("used is " + str(self.Used))
thiskeycount += 1 print(str(feedbackdict))
feedbacklist.append(str(nextkey))
feedbackdict[str(nextkey)] = str(self.WrongAnswers[i])
if thiskeycount == 2:
feedbacklist = []
if str(self.WrongAnswers[i]) not in self.hints:
feedbackdict[str(random.choice(self.DefaultHints.keys()))] = str(self.WrongAnswers[i])
print("feedbackdict is: " + str(feedbackdict))
return feedbackdict return feedbackdict
@XBlock.json_handler #add 1 or -1 to rating of a hint @XBlock.json_handler #add 1 or -1 to rating of a hint
...@@ -114,6 +110,7 @@ class CrowdXBlock(XBlock): ...@@ -114,6 +110,7 @@ class CrowdXBlock(XBlock):
data['ansnum'] = data['ansnum'].replace('qquueessttiioonnmmaarrkk', '?') data['ansnum'] = data['ansnum'].replace('qquueessttiioonnmmaarrkk', '?')
for usdkey in self.Used: for usdkey in self.Used:
if str(usdkey) == str(data['ansnum']): if str(usdkey) == str(data['ansnum']):
print str(self.Used)
ansnum = self.Used.index(str(data['ansnum'])) ansnum = self.Used.index(str(data['ansnum']))
if self.Voted == 0: if self.Voted == 0:
for key in self.DefaultHints: for key in self.DefaultHints:
...@@ -147,6 +144,8 @@ class CrowdXBlock(XBlock): ...@@ -147,6 +144,8 @@ class CrowdXBlock(XBlock):
data['id'] = data['id'].replace('ddeecciimmaallppooiinntt', '.') data['id'] = data['id'].replace('ddeecciimmaallppooiinntt', '.')
if self.Voted == 0: if self.Voted == 0:
for key in self.hints: for key in self.hints:
print(str(self.Used))
print(str(self.Used.index(str(data['id']))))
if str(key) == self.WrongAnswers[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)]: if str(data['submission']) not in self.hints[str(key)]:
tempdict = str(self.hints[str(key)]) #rate hint that is in hints tempdict = str(self.hints[str(key)]) #rate hint that is in hints
...@@ -154,7 +153,6 @@ class CrowdXBlock(XBlock): ...@@ -154,7 +153,6 @@ class CrowdXBlock(XBlock):
tempdict.update({data['submission']: 0}) tempdict.update({data['submission']: 0})
self.hints[str(key)] = tempdict self.hints[str(key)] = tempdict
self.Voted = 1 self.Voted = 1
print ('this went through fine')
return return
else: else:
ansnum = self.Used.index(data['submission']) ansnum = self.Used.index(data['submission'])
...@@ -188,9 +186,4 @@ class CrowdXBlock(XBlock): ...@@ -188,9 +186,4 @@ class CrowdXBlock(XBlock):
</vertical_demo> </vertical_demo>
"""), """),
] ]
'''
print ("answer" + str(data["submittedanswer"]))
for keys in self.hints[key]:
print ("other key" + y)
self.HintsToUse[keys] = self.hints[key[keys]] #If the user's incorrect answre has precedence in hints, add hints listed under
print("hintstouse: " + str(self.HintsToUse[keys]))'''
...@@ -13,7 +13,7 @@ log = logging.getLogger(__name__) ...@@ -13,7 +13,7 @@ log = logging.getLogger(__name__)
#get_hint and get_feedback are in #get_hint and get_feedback are in
class CrowdXBlock(XBlock): class CrowdXBlock(XBlock):
correctanswer = String(default="2.0", scope=Scope.content) #should be irrelevant for completed version correctanswer = String(default="2.0", scope=Scope.content) #should be irrelevant for completed version
hints = Dict(default={"2": {"Keep significant figures in mind.":1, "So close yet so far.":0, "Try adding a .0.":0}, "8.6": {"You might have added all of the horizontal forces together to equal a total of 21 for the horizontal component of this object's force. The two forces are facing opposite direction, so you need to subtract them.":1, "Try 12-9 for the total horizontal force.":0}, "1.2": {"Did you remember to add in the vertical component of force for this object?":0}}, scope=Scope.content) hints = Dict(default={"2": {"another 2 hint":0, "yet another 2 hint":0,"Keep significant figures in mind.":1, "So close yet so far.":0, "Try adding a .0.":0}, "8.6": {"You might have added all of the horizontal forces together to equal a total of 21 for the horizontal component of this object's force. The two forces are facing opposite direction, so you need to subtract them.":1, "Try 12-9 for the total horizontal force.":0}, "1.2": {"Did you remember to add in the vertical component of force for this object?":0}}, scope=Scope.content)
#All hints. sorted by type of mistake. type_of_incorrect_answer{"hint":rating, "hint":rating} #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 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 WrongAnswers = List(default=[], scope=Scope.user_state) #List of mistakes made by user
...@@ -54,7 +54,6 @@ class CrowdXBlock(XBlock): ...@@ -54,7 +54,6 @@ class CrowdXBlock(XBlock):
self.hints[str(data["submittedanswer"])] = {} #add user's incorrect answer to WrongAnswers self.hints[str(data["submittedanswer"])] = {} #add user's incorrect answer to WrongAnswers
self.HintsToUse = {} self.HintsToUse = {}
self.HintsToUse.update(self.DefaultHints) self.HintsToUse.update(self.DefaultHints)
print str(self.hints)
if max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0] not in self.Used: if max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0] not in self.Used:
self.Used.append(max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0]) #Highest rated hint is shown first self.Used.append(max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0]) #Highest rated hint is shown first
return {'HintsToUse': max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0]} return {'HintsToUse': max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0]}
...@@ -63,8 +62,16 @@ class CrowdXBlock(XBlock): ...@@ -63,8 +62,16 @@ class CrowdXBlock(XBlock):
if len(self.HintsToUse) > len(self.Used): if len(self.HintsToUse) > len(self.Used):
while NotUsed in self.Used: while NotUsed in self.Used:
NotUsed = random.choice(self.HintsToUse.keys()) #Choose random hint that hasn't already been Used NotUsed = random.choice(self.HintsToUse.keys()) #Choose random hint that hasn't already been Used
elif len(self.Used) > 0: else:
return {'HintsToUse': "Sorry, there are no more hints."} usedef = 0
for h in self.HintsToUse:
if str(h) not in self.Used:
NotUsed = h
usedef = 1
if usedef == 0:
self.Used.append(str("There are no hints for" + " " + data["submittedanswer"]))
print str(self.Used)
return {'HintsToUse': "Sorry, there are no more hints for this answer."}
self.Used.append(NotUsed) self.Used.append(NotUsed)
return {'HintsToUse': NotUsed} #note to self dont let python get into endless notused loop return {'HintsToUse': NotUsed} #note to self dont let python get into endless notused loop
...@@ -78,34 +85,22 @@ class CrowdXBlock(XBlock): ...@@ -78,34 +85,22 @@ class CrowdXBlock(XBlock):
for i in range(0, len(self.Used)): for i in range(0, len(self.Used)):
ans = str('wngans' + str(i)) ans = str('wngans' + str(i))
hnt = str('hntusd' + str(i)) hnt = str('hntusd' + str(i))
feedbackdict[str(self.Used[i])] = str(self.WrongAnswers[i]) for keys in self.hints:
if str(self.Used[i]) in self.hints[str(keys)]:
feedbackdict[str(self.Used[i])] = str(self.WrongAnswers[i])
feedbacklist.append(str(self.Used[i])) feedbacklist.append(str(self.Used[i]))
for key in self.hints: for key in self.hints:
if str(key) == str(self.WrongAnswers[i]): if str(key) == str(self.WrongAnswers[i]):
if len(self.hints[str(key)]) > 2: if len(self.hints[str(key)]) != 0:
thiskeycount = 0 for nextkey in self.hints[str(key)]:
while thiskeycount < 2: feedbackdict[str(nextkey)] = str(self.WrongAnswers[i])
nextkey = random.choice(self.hints[key].keys()) self.WrongAnswers.append(str(self.WrongAnswers[i]))
if str(nextkey) not in feedbacklist: self.Used.append(str(nextkey))
thiskeycount += 1
feedbacklist.append(str(nextkey))
feedbackdict[str(nextkey)] = str(self.WrongAnswers[i])
print(str(nextkey))
if thiskeycount == 2:
feedbacklist = []
else: else:
thiskeycount = 0 feedbackdict[str("There are no hints for" + " " + str(self.WrongAnswers[i]))] = str(self.WrongAnswers[i])
while thiskeycount < 2: self.WrongAnswers.append(str(self.WrongAnswers[i]))
nextkey = random.choice(self.DefaultHints.keys()) print("used is " + str(self.Used))
if str(nextkey) not in feedbacklist: print(str(feedbackdict))
thiskeycount += 1
feedbacklist.append(str(nextkey))
feedbackdict[str(nextkey)] = str(self.WrongAnswers[i])
if thiskeycount == 2:
feedbacklist = []
if str(self.WrongAnswers[i]) not in self.hints:
feedbackdict[str(random.choice(self.DefaultHints.keys()))] = str(self.WrongAnswers[i])
print("feedbackdict is: " + str(feedbackdict))
return feedbackdict return feedbackdict
@XBlock.json_handler #add 1 or -1 to rating of a hint @XBlock.json_handler #add 1 or -1 to rating of a hint
...@@ -114,6 +109,7 @@ class CrowdXBlock(XBlock): ...@@ -114,6 +109,7 @@ class CrowdXBlock(XBlock):
data['ansnum'] = data['ansnum'].replace('qquueessttiioonnmmaarrkk', '?') data['ansnum'] = data['ansnum'].replace('qquueessttiioonnmmaarrkk', '?')
for usdkey in self.Used: for usdkey in self.Used:
if str(usdkey) == str(data['ansnum']): if str(usdkey) == str(data['ansnum']):
print str(self.Used)
ansnum = self.Used.index(str(data['ansnum'])) ansnum = self.Used.index(str(data['ansnum']))
if self.Voted == 0: if self.Voted == 0:
for key in self.DefaultHints: for key in self.DefaultHints:
...@@ -147,6 +143,8 @@ class CrowdXBlock(XBlock): ...@@ -147,6 +143,8 @@ class CrowdXBlock(XBlock):
data['id'] = data['id'].replace('ddeecciimmaallppooiinntt', '.') data['id'] = data['id'].replace('ddeecciimmaallppooiinntt', '.')
if self.Voted == 0: if self.Voted == 0:
for key in self.hints: for key in self.hints:
print(str(self.Used))
print(str(self.Used.index(str(data['id']))))
if str(key) == self.WrongAnswers[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)]: if str(data['submission']) not in self.hints[str(key)]:
tempdict = str(self.hints[str(key)]) #rate hint that is in hints tempdict = str(self.hints[str(key)]) #rate hint that is in hints
...@@ -154,7 +152,6 @@ class CrowdXBlock(XBlock): ...@@ -154,7 +152,6 @@ class CrowdXBlock(XBlock):
tempdict.update({data['submission']: 0}) tempdict.update({data['submission']: 0})
self.hints[str(key)] = tempdict self.hints[str(key)] = tempdict
self.Voted = 1 self.Voted = 1
print ('this went through fine')
return return
else: else:
ansnum = self.Used.index(data['submission']) ansnum = self.Used.index(data['submission'])
...@@ -188,9 +185,4 @@ class CrowdXBlock(XBlock): ...@@ -188,9 +185,4 @@ class CrowdXBlock(XBlock):
</vertical_demo> </vertical_demo>
"""), """),
] ]
'''
print ("answer" + str(data["submittedanswer"]))
for keys in self.hints[key]:
print ("other key" + y)
self.HintsToUse[keys] = self.hints[key[keys]] #If the user's incorrect answre has precedence in hints, add hints listed under
print("hintstouse: " + str(self.HintsToUse[keys]))'''
...@@ -27,36 +27,25 @@ function CrowdXBlock(runtime, element){ ...@@ -27,36 +27,25 @@ function CrowdXBlock(runtime, element){
$.each(result, function(index, value) { $.each(result, function(index, value) {
valueid = value.replace(/\./g, 'ddeecciimmaallppooiinntt'); valueid = value.replace(/\./g, 'ddeecciimmaallppooiinntt');
indexid = index.replace(/\./g, 'ddeecciimmaallppooiinntt'); indexid = index.replace(/\./g, 'ddeecciimmaallppooiinntt');
// valueid = valueid.replace(/\?/g, 'qquueessttiioonnmmaarrkk');
// indexid = indexid.replace(/\?/g, 'qquueessttiioonnmmaarrkk');
console.log("the type of value is" + ' '+ typeof(value));
if($("#submit"+valueid).length == 0){ if($("#submit"+valueid).length == 0){
console.log("#submit"+value); $('.hintansarea').append("<p id=\"submit" + valueid + "\" class=\"hintsarea\"> </p>");
$('.hintansarea').append("<p id=\"submit" + valueid + "\" class=\"hintsarea\"> </p>"); $('#submit'+valueid).append("For your incorrect answer of:" + " " + value + " <p id=\"hintstoshow" + valueid + "\"> The following hints exist: </p><p> <input id=\"" + indexid + "\" type=\"button\" class=\"submitbutton\" value=\"Submit a hint for this problem\">");
console.log('hintsarea made for ' + value); }
$('#submit'+valueid).append("For your incorrect answer of:" + " " + value + " <p id=\"hintstoshow" + valueid + "\"> The following hints exist: </p><p> <input id=\"" + indexid + "\" type=\"button\" class=\"submitbutton\" value=\"Submit a hint for this problem\">"); if(indexid.slice(0,22) != "There are no hints for"){
} $('#hintstoshow'+valueid).append("<p>" + index + "<input data-value=\"" + valueid + "\" id=\"" + indexid + "\" type=\"button\" class=\"hintbutton\" value=\"Upvote this Hint\"></p>");
console.log('indexid' + indexid); }else{
$('#hintstoshow'+valueid).append("<p>" + index + "<input data-value=\"" + valueid + "\" id=\"" + indexid + "\" type=\"button\" class=\"hintbutton\" value=\"Upvote this Hint\"></p>"); $('#hintstoshow'+valueid).empty();
console.log('valueid' + valueid); $('#hintstoshow'+valueid).append("<p id=\"hintstoshow" + valueid + "\"> No hints exist in the database.</p> <p data-value=\"" + valueid + "\" id=\"" + indexid + "\"</p>");
console.log("the value is " + value); }
}); });
} }
$(document).on('click', '.submitbutton', function(){ //upvote $(document).on('click', '.submitbutton', function(){ //upvote
console.log("submitbutton hit");
console.log(this.id);
id = this.id; id = this.id;
value = $('#'+id).attr('data-value'); value = document.getElementById(this.id).getAttribute('data-value');
// console.log($('#'+id).attr('data-value')); $(this).hide();
// valueid = $('#'+id).attr('data-value').replace(/\./g, 'ddeecciimmaallppooiinntt'); $('#submit' + value).append("<p><input type=\"text\" name=\"studentinput\" id=\"" + id + "\" class=\"math\" size=\"40\"><<input id=\"submit\" type=\"button\" class=\"button\" value=\"Submit Hint\"> </p>");})
// indexid = index.replace(/\./g, 'ddeecciimmaallppooiinntt');
// valueid = valueid.replace(/\?/g, 'qquueessttiioonnmmaarrkk');
// indexid = indexid.replace(/\?/g, 'qquueessttiioonnmmaarrkk');
console.log("this id " + $(this).attr('id'));
$('#submit' + valueid).append("<p><input type=\"text\" name=\"studentinput\" id=\"" + id + "\" class=\"math\" size=\"40\"><<input id=\"submit\" type=\"button\" class=\"button\" value=\"Submit Hint\"> </p>");})
$(document).on('click', '#submit', function(){ $(document).on('click', '#submit', function(){
console.log('submitid' + ' ' + '#submit' + valueid);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: runtime.handlerUrl(element, 'give_hint'), url: runtime.handlerUrl(element, 'give_hint'),
...@@ -67,30 +56,12 @@ function CrowdXBlock(runtime, element){ ...@@ -67,30 +56,12 @@ function CrowdXBlock(runtime, element){
$(document).on('click', '.hintbutton', function(){ //upvote $(document).on('click', '.hintbutton', function(){ //upvote
id = this.id; id = this.id;
console.log("the first id" + this.id);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'), url: runtime.handlerUrl(element, 'rate_hint'),
data: JSON.stringify({"rating": 1, "ansnum": $(this).attr('id'), "value": $(this).attr('data-value')}), data: JSON.stringify({"rating": 1, "ansnum": $(this).attr('id'), "value": $(this).attr('data-value')}),
success: finish success: finish
});}) });})
$(document).on('click', '.submitbutton', function(){ //upvote
console.log("submitbutton hit");
id = $(this).attr('id');
value = $('#'+id).attr('data-value');
console.log("this id " + $(this).attr('id'));
console.log('#submit' + value);
$('#submit' + value).append("<p><input type=\"text\" name=\"studentinput\" id=\"" + id + "\" class=\"math\" size=\"40\"><<input id=\"submit\" type=\"button\" class=\"button\" value=\"Submit Hint\"> </p>");})
$(document).on('click', '#submit', function(){
console.log("the other id thing" + this.id);
console.log("thisthing" + $(".math").attr('id'));
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'give_hint'),
data: JSON.stringify({"submission": $('.math').val(), "id": $(".math").attr('id')}), //give hin for first incorrect answer
success: finish
});
$("#answer").val('');})
$('#caus', element).click(function(eventObject) { $('#caus', element).click(function(eventObject) {
console.debug("ca working this is edited"); console.debug("ca working this is edited");
...@@ -128,7 +99,6 @@ function CrowdXBlock(runtime, element){ ...@@ -128,7 +99,6 @@ function CrowdXBlock(runtime, element){
success: getfeedback success: getfeedback
}); });
}else{ }else{
console.debug("nay");
seehint(result) seehint(result)
} }
} }
......
...@@ -27,37 +27,25 @@ function CrowdXBlock(runtime, element){ ...@@ -27,37 +27,25 @@ function CrowdXBlock(runtime, element){
$.each(result, function(index, value) { $.each(result, function(index, value) {
valueid = value.replace(/\./g, 'ddeecciimmaallppooiinntt'); valueid = value.replace(/\./g, 'ddeecciimmaallppooiinntt');
indexid = index.replace(/\./g, 'ddeecciimmaallppooiinntt'); indexid = index.replace(/\./g, 'ddeecciimmaallppooiinntt');
// valueid = valueid.replace(/\?/g, 'qquueessttiioonnmmaarrkk');
// indexid = indexid.replace(/\?/g, 'qquueessttiioonnmmaarrkk');
console.log("the type of value is" + ' '+ typeof(value));
if($("#submit"+valueid).length == 0){ if($("#submit"+valueid).length == 0){
console.log("#submit"+value); $('.hintansarea').append("<p id=\"submit" + valueid + "\" class=\"hintsarea\"> </p>");
$('.hintansarea').append("<p id=\"submit" + valueid + "\" class=\"hintsarea\"> </p>"); $('#submit'+valueid).append("For your incorrect answer of:" + " " + value + " <p id=\"hintstoshow" + valueid + "\"> The following hints exist: </p><p> <input id=\"" + indexid + "\" type=\"button\" class=\"submitbutton\" value=\"Submit a hint for this problem\">");
console.log('hintsarea made for ' + value); }
$('#submit'+valueid).append("For your incorrect answer of:" + " " + value + " <p id=\"hintstoshow" + valueid + "\"> The following hints exist: </p><p> <input id=\"" + indexid + "\" type=\"button\" class=\"submitbutton\" value=\"Submit a hint for this problem\">"); if(indexid.slice(0,22) != "There are no hints for"){
} $('#hintstoshow'+valueid).append("<p>" + index + "<input data-value=\"" + valueid + "\" id=\"" + indexid + "\" type=\"button\" class=\"hintbutton\" value=\"Upvote this Hint\"></p>");
console.log('indexid' + indexid); }else{
$('#hintstoshow'+valueid).append("<p>" + index + "<input data-value=\"" + valueid + "\" id=\"" + indexid + "\" type=\"button\" class=\"hintbutton\" value=\"Upvote this Hint\"></p>"); $('#hintstoshow'+valueid).empty();
console.log('valueid' + valueid); $('#hintstoshow'+valueid).append("<p id=\"hintstoshow" + valueid + "\"> No hints exist in the database. <p data-value=\"" + valueid + "\" id=\"" + indexid + "\"</p></p>");
console.log("the value is " + value); }
}); });
} }
$(document).on('click', '.submitbutton', function(){ //upvote $(document).on('click', '.submitbutton', function(){ //upvote
console.log("submitbutton hit");
console.log(this.id);
id = this.id; id = this.id;
value = $('#'+id).attr('data-value'); value = document.getElementById(this.id).getAttribute('data-value');
// console.log($('#'+id).attr('data-value')); $(this).hide();
// valueid = $('#'+id).attr('data-value').replace(/\./g, 'ddeecciimmaallppooiinntt'); $('#submit' + value).append("<p><input type=\"text\" name=\"studentinput\" id=\"" + id + "\" class=\"math\" size=\"40\"><<input id=\"submit\" type=\"button\" class=\"button\" value=\"Submit Hint\"> </p>");})
// indexid = index.replace(/\./g, 'ddeecciimmaallppooiinntt');
// valueid = valueid.replace(/\?/g, 'qquueessttiioonnmmaarrkk');
// indexid = indexid.replace(/\?/g, 'qquueessttiioonnmmaarrkk');
console.log("this id " + $(this).attr('id'));
$('#submit' + valueid).append("<p><input type=\"text\" name=\"studentinput\" id=\"" + id + "\" class=\"math\" size=\"40\"><<input id=\"submit\" type=\"button\" class=\"button\" value=\"Submit Hint\"> </p>");})
$(document).on('click', '#submit', function(){ $(document).on('click', '#submit', function(){
console.log("the other id thing" + this.id);
console.log("thisthing" + $(".math").attr('id'));
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: runtime.handlerUrl(element, 'give_hint'), url: runtime.handlerUrl(element, 'give_hint'),
...@@ -68,30 +56,12 @@ function CrowdXBlock(runtime, element){ ...@@ -68,30 +56,12 @@ function CrowdXBlock(runtime, element){
$(document).on('click', '.hintbutton', function(){ //upvote $(document).on('click', '.hintbutton', function(){ //upvote
id = this.id; id = this.id;
console.log("the first id" + this.id);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'), url: runtime.handlerUrl(element, 'rate_hint'),
data: JSON.stringify({"rating": 1, "ansnum": $(this).attr('id'), "value": $(this).attr('data-value')}), data: JSON.stringify({"rating": 1, "ansnum": $(this).attr('id'), "value": $(this).attr('data-value')}),
success: finish success: finish
});}) });})
$(document).on('click', '.submitbutton', function(){ //upvote
console.log("submitbutton hit");
id = $(this).attr('id');
value = $('#'+id).attr('data-value');
console.log("this id " + $(this).attr('id'));
console.log('#submit' + value);
$('#submit' + value).append("<p><input type=\"text\" name=\"studentinput\" id=\"" + id + "\" class=\"math\" size=\"40\"><<input id=\"submit\" type=\"button\" class=\"button\" value=\"Submit Hint\"> </p>");})
$(document).on('click', '#submit', function(){
console.log("the other id thing" + this.id);
console.log("thisthing" + $(".math").attr('id'));
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'give_hint'),
data: JSON.stringify({"submission": $('.math').val(), "id": $(".math").attr('id')}), //give hin for first incorrect answer
success: finish
});
$("#answer").val('');})
$('#caus', element).click(function(eventObject) { $('#caus', element).click(function(eventObject) {
console.debug("ca working this is edited"); console.debug("ca working this is edited");
...@@ -129,7 +99,6 @@ function CrowdXBlock(runtime, element){ ...@@ -129,7 +99,6 @@ function CrowdXBlock(runtime, element){
success: getfeedback success: getfeedback
}); });
}else{ }else{
console.debug("nay");
seehint(result) seehint(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