Commit a0ab195e by Sola

now have submission buttons that are specific to the incorrect answer to which…

now have submission buttons that are specific to the incorrect answer to which the student wants to submit a hint. i believe all is functional.
parent bd777f90
...@@ -48,6 +48,7 @@ class CrowdXBlock(XBlock): ...@@ -48,6 +48,7 @@ class CrowdXBlock(XBlock):
for key in self.HintsToUse: for key in self.HintsToUse:
if key not in self.Used: if key not in self.Used:
hintsarehere = 1 hintsarehere = 1
print("hints are here doe")
if hintsarehere == 0: if hintsarehere == 0:
print("PLSDONTHAPPENDOE") print("PLSDONTHAPPENDOE")
self.HintsToUse.update(self.DefaultHints) #Use DefaultHints if there aren't enough other hints self.HintsToUse.update(self.DefaultHints) #Use DefaultHints if there aren't enough other hints
...@@ -80,7 +81,7 @@ class CrowdXBlock(XBlock): ...@@ -80,7 +81,7 @@ class CrowdXBlock(XBlock):
@XBlock.json_handler #add 1 or -1 to rating of a hint @XBlock.json_handler #add 1 or -1 to rating of a hint
def rate_hint(self, data, suffix=''): def rate_hint(self, data, suffix=''):
ansnum = self.Used.index(str(data['ansnum'])) ansnum = self.Used.index(str(data['ansnum']))
print("ansnum is" + ansnum) print("ansnum is" + str(ansnum))
if self.Voted == 0: if self.Voted == 0:
for key in self.DefaultHints: for key in self.DefaultHints:
if key == self.Used[int(ansnum)]: #rating for hints in DefaultHints if key == self.Used[int(ansnum)]: #rating for hints in DefaultHints
...@@ -103,7 +104,9 @@ class CrowdXBlock(XBlock): ...@@ -103,7 +104,9 @@ class CrowdXBlock(XBlock):
def give_hint(self, data, suffix=''): #add student-made hint into hints def give_hint(self, data, suffix=''): #add student-made hint into hints
if self.Voted == 0: if self.Voted == 0:
for key in self.hints: for key in self.hints:
if str(key) == str(self.WrongAnswers[0]): print(str(key))
print("still working here")
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
tempdict = (ast.literal_eval(tempdict)) tempdict = (ast.literal_eval(tempdict))
......
...@@ -48,6 +48,7 @@ class CrowdXBlock(XBlock): ...@@ -48,6 +48,7 @@ class CrowdXBlock(XBlock):
for key in self.HintsToUse: for key in self.HintsToUse:
if key not in self.Used: if key not in self.Used:
hintsarehere = 1 hintsarehere = 1
print("hints are here doe")
if hintsarehere == 0: if hintsarehere == 0:
print("PLSDONTHAPPENDOE") print("PLSDONTHAPPENDOE")
self.HintsToUse.update(self.DefaultHints) #Use DefaultHints if there aren't enough other hints self.HintsToUse.update(self.DefaultHints) #Use DefaultHints if there aren't enough other hints
...@@ -80,7 +81,7 @@ class CrowdXBlock(XBlock): ...@@ -80,7 +81,7 @@ class CrowdXBlock(XBlock):
@XBlock.json_handler #add 1 or -1 to rating of a hint @XBlock.json_handler #add 1 or -1 to rating of a hint
def rate_hint(self, data, suffix=''): def rate_hint(self, data, suffix=''):
ansnum = self.Used.index(str(data['ansnum'])) ansnum = self.Used.index(str(data['ansnum']))
print ansnum print("ansnum is" + str(ansnum))
if self.Voted == 0: if self.Voted == 0:
for key in self.DefaultHints: for key in self.DefaultHints:
if key == self.Used[int(ansnum)]: #rating for hints in DefaultHints if key == self.Used[int(ansnum)]: #rating for hints in DefaultHints
...@@ -103,7 +104,9 @@ class CrowdXBlock(XBlock): ...@@ -103,7 +104,9 @@ class CrowdXBlock(XBlock):
def give_hint(self, data, suffix=''): #add student-made hint into hints def give_hint(self, data, suffix=''): #add student-made hint into hints
if self.Voted == 0: if self.Voted == 0:
for key in self.hints: for key in self.hints:
if str(key) == str(self.WrongAnswers[0]): print(str(key))
print("still working here")
if str(key) == self.WrongAnswer[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
tempdict = (ast.literal_eval(tempdict)) tempdict = (ast.literal_eval(tempdict))
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
</p> </p>
<span><br><span> Dummy Answer Input Here</span></span> <span><br><span> Dummy Answer Input Here</span></span>
<section id="studentinput" class="textinput"> <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"> <input id="studentanswer" type="button" class="button" value="Submit Answer">
</div> </div>
...@@ -30,10 +30,6 @@ ...@@ -30,10 +30,6 @@
<input type="hidden" name="problem_id" value="Numerical Input"> <input type="hidden" name="problem_id" value="Numerical Input">
<section class="problem"> <section class="problem">
<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" class="button" value="Submit Hint">
</div></section></span> </div></section></span>
</section> </section>
......
...@@ -15,10 +15,9 @@ ...@@ -15,10 +15,9 @@
<span class='Thankyou'></span> <span class='Thankyou'></span>
</p> </p>
<script id="feedback"> <div class="hintansarea">
var hintused = []
var wronganswer = [] </div>
</script>
<p> <p>
<input id="caus" type="button" class="button" value="clearAllUserState"> <input id="caus" type="button" class="button" value="clearAllUserState">
...@@ -31,10 +30,6 @@ var wronganswer = [] ...@@ -31,10 +30,6 @@ var wronganswer = []
<input type="hidden" name="problem_id" value="Numerical Input"> <input type="hidden" name="problem_id" value="Numerical Input">
<section class="problem"> <section class="problem">
<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" class="button" value="Submit Hint">
</div></section></span> </div></section></span>
</section> </section>
......
...@@ -30,25 +30,32 @@ function CrowdXBlock(runtime, element){ ...@@ -30,25 +30,32 @@ function CrowdXBlock(runtime, element){
$("#feedback").show(); $("#feedback").show();
$.each(result, function(index, value) { $.each(result, function(index, value) {
console.log( index + ": " + value ); console.log( index + ": " + value );
$('.hintansarea').append("<p> For your incorrect answer of:" + " " + value + "</p> <p> You received the hint:" + " " + index + " <input id\"" + index + "\" type=\"button\" class=\"hintbutton\" value=\"Upvote this Hint\"> </p>"); $('.hintansarea').append("<p id=\"submit" + index + "\"> For your incorrect answer of:" + " " + value + "</p> <p> You received the hint:" + " " + index + " <input id=\"" + index + "\" type=\"button\" class=\"hintbutton\" value=\"Upvote this Hint\"> </p><p> <input id=\"" + index + "\" type=\"button\" class=\"submitbutton\" value=\"Submit a hint for this problem\">");
}); });
}; };
$(document).on('click', '.hintbutton', function(){ //upvote $(document).on('click', '.hintbutton', function(){ //upvote
console.log("please show me something"); console.log("the first id" + this.id);
id = this.id; id = this.id;
console.log($(this).id()); console.log($(this).attr('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')}), data: JSON.stringify({"rating": 1, "ansnum": $(this).attr('id')}),
success: finish success: finish
});}) });})
$('#submit', element).click(function(eventObject) { $(document).on('click', '.submitbutton', function(){ //upvote
console.log("submitbutton hit");
id = this.id;
console.log("this id " + $(this).attr('id'));
$('#submit' + id).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({ $.ajax({
type: "POST", type: "POST",
url: runtime.handlerUrl(element, 'give_hint'), url: runtime.handlerUrl(element, 'give_hint'),
data: JSON.stringify({"submission": $('#answer').val()}), //give hin for first incorrect answer data: JSON.stringify({"submission": $('.math').val(), "id": $(".math").attr('id')}), //give hin for first incorrect answer
success: finish success: finish
}); });
$("#answer").val('');}) $("#answer").val('');})
...@@ -64,28 +71,16 @@ function CrowdXBlock(runtime, element){ ...@@ -64,28 +71,16 @@ function CrowdXBlock(runtime, element){
$("#studentsubmit").val(''); $("#studentsubmit").val('');
$("#answer").val('');}) $("#answer").val('');})
function finish(){ function finish(){
$("#pair0").hide(); $(".hintbutton").hide();
$("#pair3").hide();
$("#pair2").hide();
$("#pair1").hide();
$('.Thankyou', element).text("Thankyou for your help!"); $('.Thankyou', element).text("Thankyou for your help!");
$('.correct', element).hide(); $('.correct', element).hide();
$(".hintansarea").hide();
} }
function clearstates(){ function clearstates(){
$("#pair0").hide(); $(".hintansarea").hide();
$("#pair3").hide(); $(".hintbutton").hide();
$("#pair2").hide();
$("#pair1").hide();
$("#answer").hide(); $("#answer").hide();
$(".problem").hide(); $(".problem").hide();
$('.WrongAnswer0', element).text();
$('.HintUsed0', element).text();
$('.WrongAnswer1', element).text();
$('.HintUsed1', element).text();
$('.WrongAnswer2', element).text();
$('.HintUsed2', element).text();
$('.WrongAnswer3', element).text();
$('.HintUsed3', element).text();
} }
function checkreply(result){ function checkreply(result){
......
...@@ -30,25 +30,32 @@ function CrowdXBlock(runtime, element){ ...@@ -30,25 +30,32 @@ function CrowdXBlock(runtime, element){
$("#feedback").show(); $("#feedback").show();
$.each(result, function(index, value) { $.each(result, function(index, value) {
console.log( index + ": " + value ); console.log( index + ": " + value );
$('.hintansarea').append("<p> For your incorrect answer of:" + " " + value + "</p> <p> You received the hint:" + " " + index + " <input id\"" + index + "\" type=\"button\" class=\"hintbutton\" value=\"Upvote this Hint\"> </p>"); $('.hintansarea').append("<p id=\"submit" + index + "\"> For your incorrect answer of:" + " " + value + "</p> <p> You received the hint:" + " " + index + " <input id=\"" + index + "\" type=\"button\" class=\"hintbutton\" value=\"Upvote this Hint\"> </p><p> <input id=\"" + index + "\" type=\"button\" class=\"submitbutton\" value=\"Submit a hint for this problem\">");
}); });
}; };
$(document).on('click', '.hintbutton', function(){ //upvote $(document).on('click', '.hintbutton', function(){ //upvote
console.log("please show me something"); console.log("the first id" + this.id);
id = this.id; id = this.id;
console.log($(this).attr('value')); console.log($(this).attr('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')}), data: JSON.stringify({"rating": 1, "ansnum": $(this).attr('id')}),
success: finish success: finish
});}) });})
$('#submit', element).click(function(eventObject) { $(document).on('click', '.submitbutton', function(){ //upvote
console.log("submitbutton hit");
id = this.id;
console.log("this id " + $(this).attr('id'));
$('#submit' + id).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({ $.ajax({
type: "POST", type: "POST",
url: runtime.handlerUrl(element, 'give_hint'), url: runtime.handlerUrl(element, 'give_hint'),
data: JSON.stringify({"submission": $('#answer').val()}), //give hin for first incorrect answer data: JSON.stringify({"submission": $('#answer').val(), "id": $(".math").attr('id')}), //give hin for first incorrect answer
success: finish success: finish
}); });
$("#answer").val('');}) $("#answer").val('');})
...@@ -64,28 +71,16 @@ function CrowdXBlock(runtime, element){ ...@@ -64,28 +71,16 @@ function CrowdXBlock(runtime, element){
$("#studentsubmit").val(''); $("#studentsubmit").val('');
$("#answer").val('');}) $("#answer").val('');})
function finish(){ function finish(){
$("#pair0").hide(); $(".hintbutton").hide();
$("#pair3").hide();
$("#pair2").hide();
$("#pair1").hide();
$('.Thankyou', element).text("Thankyou for your help!"); $('.Thankyou', element).text("Thankyou for your help!");
$('.correct', element).hide(); $('.correct', element).hide();
$(".hintansarea").hide();
} }
function clearstates(){ function clearstates(){
$("#pair0").hide(); $(".hintansarea").hide();
$("#pair3").hide(); $(".hintbutton").hide();
$("#pair2").hide();
$("#pair1").hide();
$("#answer").hide(); $("#answer").hide();
$(".problem").hide(); $(".problem").hide();
$('.WrongAnswer0', element).text();
$('.HintUsed0', element).text();
$('.WrongAnswer1', element).text();
$('.HintUsed1', element).text();
$('.WrongAnswer2', element).text();
$('.HintUsed2', element).text();
$('.WrongAnswer3', element).text();
$('.HintUsed3', element).text();
} }
function checkreply(result){ function checkreply(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