Commit 365d259b by Sola

hinter now provides hints based on the mistake made for each dummy answer…

hinter now provides hints based on the mistake made for each dummy answer submission. After correct answer event takes place the incorrect answers and the hints provided for each one appear (up to 4 currently). Clicking on their orange box area will add 1 to the hint's rating for the respective answer, or you can submit your own hint (which will default to being under the first incorrect answer). Effectively you can only vote once, although it's not programmed to necessarily be so. sorry for long commit comment.
parent ca933c70
......@@ -36,11 +36,10 @@ class CrowdXBlock(XBlock):
answer = data["submittedanswer"]
if data["submittedanswer"] not in self.WrongAnswers:
self.WrongAnswers.append(data["submittedanswer"]) #add user's incorrect answer to WrongAnswers
if data["submittedanswer"] not in self.hints:
if str(data["submittedanswer"]) not in self.hints:
self.hints[data["submittedanswer"]] = {} #add user's incorrect answer to WrongAnswers
for key in self.hints:
try:
print("key" + str(key))
temphints = str(self.hints[str(key)[0]]) #perhaps a better way to do this exists, but for now this works
if str(key) == str(data["submittedanswer"]):
self.HintsToUse = {}
......@@ -54,7 +53,6 @@ class CrowdXBlock(XBlock):
# self.HintsToUse = self.DefaultHints.copy()
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
print self.HintsToUse
return {'HintsToUse': max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0]}
else:
NotUsed = random.choice(self.HintsToUse.keys())
......@@ -62,7 +60,6 @@ class CrowdXBlock(XBlock):
while NotUsed in self.Used:
NotUsed = random.choice(self.HintsToUse.keys()) #Choose random hint that hasn't already been Used
self.Used.append(NotUsed)
print self.HintsToUse
return {'HintsToUse': NotUsed} #note to self dont let python get into endless notused loop
@XBlock.json_handler
......@@ -83,30 +80,27 @@ class CrowdXBlock(XBlock):
for key in self.hints:
tempdict = str(self.hints[str(key)[0]]) #rate hint that is in hints
tempdict = (ast.literal_eval(tempdict))
if key == self.WrongAnswers[data['ansnum']]: #ansnum will the the answer/hint pair that is selected
tempdict[self.Used[data['ansnum']]] += int(data["rating"])
self.hints[str(key)[0]] = tempdict
if str(key) == str(self.WrongAnswers[data['ansnum']]): #ansnum will the the answer/hint pair that is selected
tempdict[self.Used[int(data['ansnum'])]] += int(data["rating"])
self.hints[str(key)] = tempdict
print("TESTING AGAIN HI")
print("hints are " + str(self.hints[str(key)]))
print("otherstuff " + str(self.hints))
for key in self.DefaultHints:
if key == self.Used[data['ansnum']]: #rating for hints in DefaultHints
self.DefaultHints[key] += int(data["rating"])
return {'wngans': self.WrongAnswers[data["ansnum"]], 'hntusd': self.Used[data["ansnum"]]}#
@XBlock.json_handler
def get_data(self, data, suffix=''): #pass hint/answer text to js to see in html
return {'wngans': self.WrongAnswers[data["ansnum"]], 'hntusd': self.Used[data["ansnum"]]}
if key == self.Used[int(data['ansnum'])]: #rating for hints in DefaultHints
self.DefaultHints[str(key)] += int(data["rating"])
@XBlock.json_handler
def give_hint(self, data, suffix=''): #add student-made hint into hints
for key in self.hints:
if key == self.WrongAnswers[data['ansnum']]:
for y in self.hints[self.WrongAnswers[data['ansnum']]]:
if y == data['submission']: #if the exact hint already exists, +1 rate
self.hints[self.WrongAnswers[data['ansnum']][y]] += int(data["rating"])
return {'wngans': self.WrongAnswers[data["ansnum"]], 'hntusd': self.Used[data["ansnum"]]}
else:
self.hints[key[data['submission']]] = 0 #add with default rating of 0
return {'wngans': self.WrongAnswers[data["ansnum"]], 'hntusd': self.Used[data["ansnum"]]}
return {'wngans': self.WrongAnswers[data["ansnum"]], 'hntusd': self.Used[data["ansnum"]]}
for key in self.hints:
if str(key) == str(self.WrongAnswers[0]):
if str(data['submission']) not in self.hints[str(key)]:
tempdict = str(self.hints[str(key)[0]]) #rate hint that is in hints
tempdict = (ast.literal_eval(tempdict))
tempdict.update({data['submission']: 0})
self.hints[str(key)] = tempdict
else:
self.hints[str(key)[str(data['submission'])]] += 1
@staticmethod
def workbench_scenarios():
......
import pkg_resources
import logging
import operator
import random
import ast
from xblock.core import XBlock
from xblock.fields import Scope, Integer, Boolean, String, Dict, List
......@@ -13,7 +13,7 @@ log = logging.getLogger(__name__)
#get_hint and get_feedback are in
class CrowdXBlock(XBlock):
hints = Dict(default={}, scope=Scope.content) #All hints. sorted by type of mistake. type_of_incorrect_answer{"hint":rating, "hint":rating}
hints = Dict(default={"1": {"hint1":10, "hint2":0, "hint3":0, "hint4":0}, "2": {"hint12":10, "hint22":0, "hints32":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={"hint": 100, "hinttwo": 10, "hintthree": 0, "hintasdf": 50, "aas;dklfj?": 1000, "SuperDuperBestHint": 10000}, scope=Scope.content) #Default hints in case no incorrect answers in hints match the user's mistake
......@@ -36,17 +36,22 @@ class CrowdXBlock(XBlock):
answer = data["submittedanswer"]
if data["submittedanswer"] not in self.WrongAnswers:
self.WrongAnswers.append(data["submittedanswer"]) #add user's incorrect answer to WrongAnswers
if data["submittedanswer"] not in self.hints:
self.hints[data["submittedanswer"]] = Dict{} #add user's incorrect answer to WrongAnswers
if str(data["submittedanswer"]) not in self.hints:
self.hints[data["submittedanswer"]] = {} #add user's incorrect answer to WrongAnswers
for key in self.hints:
if key == data["submittedanswer"]:
for y in self.hints[key]:
self.HintsToUse[y] += self.hints[key[y]] #If the user's incorrect answre has precedence in hints, add hints listed under
if len(self.HintsToUse) < 2: #incorrect answer to HintsToUse
try:
temphints = str(self.hints[str(key)[0]]) #perhaps a better way to do this exists, but for now this works
if str(key) == str(data["submittedanswer"]):
self.HintsToUse = {}
self.HintsToUse.update(ast.literal_eval(temphints))
except:
self.HintsToUse = {}
self.HintsToUse.update(self.DefaultHints)
if len(self.HintsToUse) <= 2: #incorrect answer to HintsToUse
self.HintsToUse.update(self.DefaultHints) #Use DefaultHints if there aren't enough other hints
else:
self.HintsToUse = self.DefaultHints.copy()
if len(self.WrongAnswers) == 1:
#else:
# self.HintsToUse = self.DefaultHints.copy()
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
return {'HintsToUse': max(self.HintsToUse.iteritems(), key=operator.itemgetter(1))[0]}
else:
......@@ -58,40 +63,44 @@ class CrowdXBlock(XBlock):
return {'HintsToUse': NotUsed} #note to self dont let python get into endless notused loop
@XBlock.json_handler
def get_feedback(self, data, suffix=''): #feedback, either rating or making a hint, starts here
def get_feedback(self, data, suffix=''): #start feedback, sent hint/answer data
feedbackdict = {}
if len(self.WrongAnswers) == 0:
return #Do nothing if no mistakes were made
else: #lenth of Used will be used to dictate flow of feedback
return {'lenused': int(len(self.Used))}
for i in range(0, len(self.Used)):
ans = str('wngans' + str(i))
hnt = str('hntusd' + str(i))
feedbackdict[ans] = str(self.WrongAnswers[i])
feedbackdict[hnt] = str(self.Used[i])
return feedbackdict
@XBlock.json_handler #add 1 or -1 to rating of a hint
def rate_hint(self, data, suffix=''):
for key in self.hints: #rating for hints in hints dictionary
if key == self.WrongAnswers[data['ansnum']]:
for y in self.hints[self.WrongAnswers[data['ansnum']]]: #ansnum represents which hint/
if y == self.Used[data['ansnum']]: #answer pair is being rated
self.hints[self.WrongAnswers[data['ansnum']][y]] += int(data["rating"])#0 is first hint/answer
for key in self.hints:
tempdict = str(self.hints[str(key)[0]]) #rate hint that is in hints
tempdict = (ast.literal_eval(tempdict))
if str(key) == str(self.WrongAnswers[data['ansnum']]): #ansnum will the the answer/hint pair that is selected
tempdict[self.Used[int(data['ansnum'])]] += int(data["rating"])
self.hints[str(key)] = tempdict
print("TESTING AGAIN HI")
print("hints are " + self.hints[str(key)])
print("otherstuff " + self.hints)
for key in self.DefaultHints:
if key == self.Used[data['ansnum']]: #rating for hints in DefaultHints
self.DefaultHints[key] += int(data["rating"])
return {'wngans': self.WrongAnswers[data["ansnum"]], 'hntusd': self.Used[data["ansnum"]]}#
@XBlock.json_handler
def get_data(self, data, suffix=''): #pass hint/answer text to js to see in html
return {'wngans': self.WrongAnswers[data["ansnum"]], 'hntusd': self.Used[data["ansnum"]]}
if key == self.Used[int(data['ansnum'])]: #rating for hints in DefaultHints
self.DefaultHints[str(key)] += int(data["rating"])
@XBlock.json_handler
def give_hint(self, data, suffix=''): #add student-made hint into hints
for key in self.hints:
if key == self.WrongAnswers[data['ansnum']]:
for y in self.hints[self.WrongAnswers[data['ansnum']]]:
if y == data['submission']: #if the exact hint already exists, +1 rate
self.hints[self.WrongAnswers[data['ansnum']][y]] += int(data["rating"])
return {'wngans': self.WrongAnswers[data["ansnum"]], 'hntusd': self.Used[data["ansnum"]]}
else:
self.hints[key[data['submission']]] = 0 #add with default rating of 0
return {'wngans': self.WrongAnswers[data["ansnum"]], 'hntusd': self.Used[data["ansnum"]]}
return {'wngans': self.WrongAnswers[data["ansnum"]], 'hntusd': self.Used[data["ansnum"]]}
for key in self.hints:
if str(key) == str(self.WrongAnswers[0]):
if str(data['submission']) not in self.hints[str(key)]:
tempdict = str(self.hints[str(key)[0]]) #rate hint that is in hints
tempdict = (ast.literal_eval(tempdict))
tempdict.update({data['submission']: 0})
self.hints[str(key)] = tempdict
else:
self.hints[str(key)[str(data['submission'])]] += 1
@staticmethod
def workbench_scenarios():
......@@ -103,3 +112,9 @@ class CrowdXBlock(XBlock):
</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]))'''
......@@ -14,20 +14,37 @@
<p>
<span class='Thankyou'></span>
</p>
<div id="pair0" style="background-color:#FFA500;height:60px;width:400px"> <p>
<span class='WrongAnswer0'></span>
</p>
<p>
<span class='HintUsed0'></span>
</p> </div>
<div id="pair1" style="background-color:#FFA500;height:60px;width:400px"><p>
<span class='WrongAnswer1'></span>
</p>
<p>
<span class='WrongAnswer'></span>
<span class='HintUsed1'></span>
</p> </div>
<div id="pair2" style="background-color:#FFA500;height:60px;width:400px"><p>
<span class='WrongAnswer2'></span>
</p>
<p>
<span class='HintUsed'></span>
<span class='HintUsed2'></span>
</p> </div>
<div id="pair3" style="background-color:#FFA500;height:60px;width:400px"><p>
<span class='WrongAnswer3'></span>
</p>
<p>
<span class='HintUsed3'></span>
</p> </div>
<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">
<input id="upvote" type="button" value="Upvote">
<input id="downvote" type="button" value="Downvote">
<section class="problem">
<span><br><span> Enter and submit your own hint!</span></span>
<section id="studentinput" class="textinput">
......
......@@ -14,12 +14,31 @@
<p>
<span class='Thankyou'></span>
</p>
<div id="pair0" style="background-color:#FFA500;height:60px;width:400px"> <p>
<span class='WrongAnswer0'></span>
</p>
<p>
<span class='HintUsed0'></span>
</p> </div>
<div id="pair1" style="background-color:#FFA500;height:60px;width:400px"><p>
<span class='WrongAnswer1'></span>
</p>
<p>
<span class='WrongAnswer'></span>
<span class='HintUsed1'></span>
</p> </div>
<div id="pair2" style="background-color:#FFA500;height:60px;width:400px"><p>
<span class='WrongAnswer2'></span>
</p>
<p>
<span class='HintUsed'></span>
<span class='HintUsed2'></span>
</p> </div>
<div id="pair3" style="background-color:#FFA500;height:60px;width:400px"><p>
<span class='WrongAnswer3'></span>
</p>
<p>
<span class='HintUsed3'></span>
</p> </div>
<section class="solution-span"><span id="solution_i4x-Me-19_002-problem-Numerical_Input_solution_1"></span></section></div>
......@@ -29,7 +48,7 @@
<input id="upvote" type="button" value="Upvote">
<input id="downvote" type="button" value="Downvote">
<section class="problem">
<span><br><span> I'm sure something will go here.</span></span>
<span><br><span> Enter and submit your own hint!</span></span>
<section id="studentinput" class="textinput">
<input type="text" name="studentinput" id="answer" class="math" size="40">
<input id="submit" type="button" value="Submit Hint">
......
/*
function updateCount(result) {
$('.count', element).text(result.count);
}
function checktheanswer(result) {
// capture the information from server and render your screen to show the submission result
$('.studentanswer', element).text(result.studentanswer);
}
var handlerUrl = runtime.handlerUrl(element, 'increment_count');
var handlerUrlcheck = runtime.handlerUrl(element, 'checkanswer');
$('#check').click(function(eventObject) {
capture what the user types
$.ajax({
type: "POST",
url: handlerUrlcheck,
data: JSON.stringify({"submittedanswer": $('#answer').val()}),
success: checktheanswer
});
$.ajax({
type: "POST",
url: handlerUrl,
data: JSON.stringify({"hello": "world"}), // pass what user types to server
success: updateCount
});
});
*/
//my coding attemps start here i guess
/*this.url = this.el.data('url');
Logger.listen('problem_graded', this.el.data('child-id'), this.capture_problem);
......@@ -46,12 +15,25 @@ function CrowdXBlock(runtime, element){
var whichanswer = 0.0;
var WrongAnswer = [];
var HintUsed = [];
$("#pair0").hide();
$("#pair3").hide();
$("#pair2").hide();
$("#pair1").hide();
function seehint(result){//use html to show these results somewhere i guess
$('.HintsToUse', element).text(result.HintsToUse); //text(result.self.hints?)
}
function getfeedback(result){
if(result.wngans0 != undefined){
$("#pair0").show();
}if(result.wngans1 != undefined){
$("#pair1").show();
}if(result.wngans2 != undefined){
$("#pair2").show();
}if(result.wngans3 != undefined){
$("#pair3").show();
}
$('.WrongAnswer0', element).text("For your incorrect answer of: " + result.wngans0);
$('.HintUsed0', element).text("You recieved the hint: " + result.hntusd0);
$('.WrongAnswer1', element).text("For your incorrect answer of: " + result.wngans1);
......@@ -63,53 +45,50 @@ function CrowdXBlock(runtime, element){
}
function morefeedback(result){
if(whichanswer != (howmany - 1)){
whichanswer += 1;
}
console.log(howmany);
console.log(whichanswer);
$('.WrongAnswer', element).text("For your incorrect answer of: " + result.wngans);
$('.HintUsed', element).text("You recieved the hint: " + result.hntusd);
$('.Thankyou', element).text("Thankyou for your help!");
}
$('#upvote', element).click(function(eventObject) {
if(whichanswer != howmany){
$('#pair0', element).click(function(eventObject) { //upvote pair0
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'),
data: JSON.stringify({"rating": 1, "ansnum": 0}),
success: finish
});})
$('#pair1', element).click(function(eventObject) { //upvote pair0
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'),
data: JSON.stringify({"rating": 1, "ansnum": whichanswer}), //return answer data to py /*answers*/
success: morefeedback
});} else{
$('.WrongAnswer', element).text();
$('.HintUsed', element).text();
$('.Thankyou', element).text("You're all done.");}
})
$('#downvote', element).click(function(eventObject) {
if(whichanswer != howmany){
data: JSON.stringify({"rating": 1, "ansnum": 1}),
success: finish
});})
$('#pair2', element).click(function(eventObject) { //upvote pair0
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'),
data: JSON.stringify({"rating": -1, "ansnum": whichanswer}), //return answer data to py /*answers*/
success: morefeedback
});} else{
$('.WrongAnswer', element).text();
$('.HintUsed', element).text();
$('.Thankyou', element).text("You're all done.");}
})
data: JSON.stringify({"rating": 1, "ansnum": 2}),
success: finish
});})
$('#pair3', element).click(function(eventObject) { //upvote pair0
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'),
data: JSON.stringify({"rating": 1, "ansnum": 3}),
success: finish
});})
$('#submit', element).click(function(eventObject) {
if(whichanswer != howmany){
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'give_hint'),
data: JSON.stringify({"submission": $('#answer').val(), "ansnum": whichanswer}), //return answer data to py /*answers*/
success: morefeedback
});} else{
$('.WrongAnswer', element).text();
$('.HintUsed', element).text();
$('.Thankyou', element).text("You're all done.");}
})
data: JSON.stringify({"submission": $('#answer').val()}), //give hin for first incorrect answer
success: finish
});})
function finish(){
$("#pair0").hide();
$("#pair3").hide();
$("#pair2").hide();
$("#pair1").hide();
$('.Thankyou', element).text("Thankyou for your help!");
$('.correct', element).hide();
}
$('p', element).click(function(eventObject) { //for test
a += 1
......@@ -121,7 +100,7 @@ function CrowdXBlock(runtime, element){
success: seehint
});
} else { //answer is correct
$('.correct', element).text("You're correct.");
$('.correct', element).text("You're correct! Please choose the best hint, or provide us with one of your own!");
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'get_feedback'),
......
/*
function updateCount(result) {
$('.count', element).text(result.count);
}
function checktheanswer(result) {
// capture the information from server and render your screen to show the submission result
$('.studentanswer', element).text(result.studentanswer);
}
var handlerUrl = runtime.handlerUrl(element, 'increment_count');
var handlerUrlcheck = runtime.handlerUrl(element, 'checkanswer');
$('#check').click(function(eventObject) {
capture what the user types
$.ajax({
type: "POST",
url: handlerUrlcheck,
data: JSON.stringify({"submittedanswer": $('#answer').val()}),
success: checktheanswer
});
$.ajax({
type: "POST",
url: handlerUrl,
data: JSON.stringify({"hello": "world"}), // pass what user types to server
success: updateCount
});
});
*/
//my coding attemps start here i guess
/*this.url = this.el.data('url');
Logger.listen('problem_graded', this.el.data('child-id'), this.capture_problem);
......@@ -46,73 +15,84 @@ function CrowdXBlock(runtime, element){
var whichanswer = 0.0;
var WrongAnswer = [];
var HintUsed = [];
$("#pair0").hide();
$("#pair3").hide();
$("#pair2").hide();
$("#pair1").hide();
function seehint(result){//use html to show these results somewhere i guess
$('.HintsToUse', element).text(result.HintsToUse); //text(result.self.hints?)
}
function getfeedback(result){
howmany = result;
console.log(howmany);
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'get_data'),
data: JSON.stringify({"ansnum": whichanswer}),
success: morefeedback
});
if(result.wngans0 != undefined){
$("#pair0").show();
}if(result.wngans1 != undefined){
$("#pair1").show();
}if(result.wngans2 != undefined){
$("#pair2").show();
}if(result.wngans3 != undefined){
$("#pair3").show();
}
$('.WrongAnswer0', element).text("For your incorrect answer of: " + result.wngans0);
$('.HintUsed0', element).text("You recieved the hint: " + result.hntusd0);
$('.WrongAnswer1', element).text("For your incorrect answer of: " + result.wngans1);
$('.HintUsed1', element).text("You recieved the hint: " + result.hntusd1);
$('.WrongAnswer2', element).text("For your incorrect answer of: " + result.wngans2);
$('.HintUsed2', element).text("You recieved the hint: " + result.hntusd2);
$('.WrongAnswer3', element).text("For your incorrect answer of: " + result.wngans3);
$('.HintUsed3', element).text("You recieved the hint: " + result.hntusd3);
}
function morefeedback(result){
if(whichanswer != (howmany - 1){
whichanswer += 1;
}
console.log(howmany);
console.log(whichanswer);
$('.WrongAnswer', element).text("For your incorrect answer of: " + result.wngans);
$('.HintUsed', element).text("You recieved the hint: " + result.hntusd);
$('.Thankyou', element).text("Thankyou for your help!");
}
$('#upvote', element).click(function(eventObject) {
if(whichanswer != howmany){
$('#pair0', element).click(function(eventObject) { //upvote pair0
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'),
data: JSON.stringify({"rating": 1, "ansnum": whichanswer}), //return answer data to py /*answers*/
success: morefeedback
});} else{
$('.WrongAnswer', element).text();
$('.HintUsed', element).text();
$('.Thankyou', element).text("You're all done.");}
})
$('#downvote', element).click(function(eventObject) {
if(whichanswer != howmany){
data: JSON.stringify({"rating": 1, "ansnum": 0}),
success: finish
});})
$('#pair1', element).click(function(eventObject) { //upvote pair0
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'),
data: JSON.stringify({"rating": -1, "ansnum": whichanswer}), //return answer data to py /*answers*/
success: morefeedback
});} else{
$('.WrongAnswer', element).text();
$('.HintUsed', element).text();
$('.Thankyou', element).text("You're all done.");}
})
data: JSON.stringify({"rating": 1, "ansnum": 1}),
success: finish
});})
$('#pair2', element).click(function(eventObject) { //upvote pair0
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'),
data: JSON.stringify({"rating": 1, "ansnum": 2}),
success: finish
});})
$('#pair3', element).click(function(eventObject) { //upvote pair0
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'rate_hint'),
data: JSON.stringify({"rating": 1, "ansnum": 3}),
success: finish
});})
$('#submit', element).click(function(eventObject) {
if(whichanswer != howmany){
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'give_hint'),
data: JSON.stringify({"submission": $('#answer').val(), "ansnum": whichanswer}), //return answer data to py /*answers*/
success: morefeedback
});} else{
$('.WrongAnswer', element).text();
$('.HintUsed', element).text();
$('.Thankyou', element).text("You're all done.");}
})
data: JSON.stringify({"submission": $('#answer').val(), "ansnum": 0}), //give hin for first incorrect answer
success: finish
});})
function finish(){
$("#pair0").hide();
$("#pair3").hide();
$("#pair2").hide();
$("#pair1").hide();
$('.Thankyou', element).text("Thankyou for your help!");
$('.correct', element).hide();
}
$('p', element).click(function(eventObject) { //for test
a += 1
if (a != 5) { //when answer is incorrect /*response.search(/class="correct/) === -1*/
if (a != 4) { //when answer is incorrect /*response.search(/class="correct/) === -1*/
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'get_hint'),
......@@ -120,7 +100,7 @@ function CrowdXBlock(runtime, element){
success: seehint
});
} else { //answer is correct
$('.correct', element).text("You're correct.");
$('.correct', element).text("You're correct! Please choose the best hint, or provide us with one of your own!");
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'get_feedback'),
......
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