This is the Crowd Sourced Hinter XBlock. The Crowd Sourced Hinter provides students
with hints when they incorrectly answer a numerical-or text-input problem. Additionally,
the hints that are provided to students are student-made hints.
This XBlock is still under construction. Functionalities to set default hints, properly moderate flagged hints, and lots of improvements to user interface are to be done soon.
To bring the crowd sourced hinter into a demo course:
First, follow https://github.com/edx/edx-platform/blob/master/docs/en_us/developers/source/xblocks.rst#testing for general xblock creation.
The name of the module will be "crowdxblock" in advanced settings.
After creating a new unit, add the crowdsourcedhinter xblock just like any other custom xblock. The name of the crowd sourced hinter may not show up for some reason, but an empty space where its name should be will be clickable.
Testing the functionality of the crowd sourced hinter works best when switching between different users and answering the same problem within a unit.
After a student incorrectly answers a problem, a hint will be provided. This hint will either be a default hint or a hint that has been submitted specifically for that incorrect answer (if such a hint has previously been submitted). If multiple hints exist for a single incorrect answer, the current system will choose the highest rated hint to show the student.
After a student has correctly answered the problem, they can give feedback on hints. Students can upvote, downvote, or flag the hint that they recieved for each aswer as well as 2 other hints that exist for that aswer (if these exist). Students also can submit new hints for their answer.
correctanswer=String(default="2.0",scope=Scope.content)#should be irrelevant for completed version
"""
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)
This is the Crowd Sourced Hinter XBlock. This Xblock seeks to provide students with hints
#All hints. sorted by type of mistake. type_of_incorrect_answer{"hint":rating, "hint":rating}
that specifically address their mistake. Additionally, the hints that this Xblock shows
HintsToUse=Dict(default={},scope=Scope.user_state)#Dict of hints to provide user
are created by the students themselves. This doc string will probably be edited later.
WrongAnswers=List(default=[],scope=Scope.user_state)#List of mistakes made by user
"""
DefaultHints=Dict(default={"Start with the equation F=ma":2,"This object has horizontal and vertical components of force. Solve for the total force in each direction, then compare it to the final acceleration":1,"A small example: If an object has a force of 10N applied to it in an upward direction and it's acceleration is 1m/s^2, the mass of that object is 10.0 kg. F=ma, 10N=m*(1m/s^2), m=10/1, m=10.":1},scope=Scope.content)#Default hints in case no incorrect answers in hints match the user's mistake
from xblock.fields import Scope, Integer, Boolean, String, Dict, List
from xblock.fields import Scope, Dict, List
from xblock.fragment import Fragment
from xblock.fragment import Fragment
log = logging.getLogger(__name__)
log = logging.getLogger(__name__)
#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
"""
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)
This is the Crowd Sourced Hinter XBlock. This Xblock seeks to provide students with hints
#All hints. sorted by type of mistake. type_of_incorrect_answer{"hint":rating, "hint":rating}
that specifically address their mistake. Additionally, the hints that this Xblock shows
HintsToUse = Dict(default={}, scope=Scope.user_state) #Dict of hints to provide user
are created by the students themselves. This doc string will probably be edited later.
WrongAnswers = List(default=[], scope=Scope.user_state) #List of mistakes made by user
"""
DefaultHints = Dict(default={"Start with the equation F=ma":2, "This object has horizontal and vertical components of force. Solve for the total force in each direction, then compare it to the final acceleration":1, "A small example: If an object has a force of 10N applied to it in an upward direction and it's acceleration is 1m/s^2, the mass of that object is 10.0 kg. F=ma, 10N=m*(1m/s^2), m=10/1, m=10.":1}, scope=Scope.content) #Default hints in case no incorrect answers in hints match the user's mistake
$('#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\">");
$('#submit'+valueid).append("<p> </p><b>Incorrect Answer: \b"+" "+value+"<p> <input id=\"submitbuttonfor"+indexid+"\" style=\"float: right; float: top;\" type=\"button\" class=\"submitbutton\" value=\"Submit a hint\"> <p id=\"hintstoshow"+valueid+"\"> <b><u>Hints in the Data Base:</u>\b </p></div>");
}
}
if(indexid.slice(0,22)!="There are no hints for"){
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>");
$('#hintstoshow'+valueid).append("<p id=\"hintstoshow"+valueid+"\"> No hints exist in the database.</p> <p data-value=\""+valueid+"\" id=\""+indexid+"\"</p>");
console.log('index id is:'+indexid);
$('#hintstoshow'+valueid).append("<p style = \"color: blue;\" id=\"hintstoshow"+valueid+"\"data-value=\""+valueid+"\"> <b>No hints exist in the database. (You received a default hint)</p> <p id=\""+indexid+"\"data-value=\""+valueid+"\" </p>");
$.ajax({ //that probably will be changed once i use response.search or something?
type: "POST", //if/when that is changed, remove checkreply and uncomment the else statement below
url: runtime.handlerUrl(element, 'get_hint'),
data: JSON.stringify({"submittedanswer": vard[0]}), //return student's incorrect answer here
//from vard[1] check id (long thing) and get class (correct or incorrect)
success: seehint
});
}else{
$('.correct', element).show();
$('.correct', element).text("You're correct! Please help us improve our hints by voting on them, or submit your own hint!");
$(".HintsToUse", element).text(" ");
console.debug("this should also only show up once...");
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'get_feedback'),
data: JSON.stringify({"hello": "world"}),
success: getfeedback
});}
}
$.ajax({
type: "POST",
url: runtime.handlerUrl(element, 'studiodata'),
data: JSON.stringify({"hello": "world"}),
success: studiodata
});
function studiodata(result){
$(".xblock-editor").append("confirm_working");
if($(".xblock-editor").length != 0){
$.each(result, function(index, value) {
console.debug(index);
$('.xblock-editor').append("<p id=\"" + value + "\"> The hint<b>" + " " + index + " " + "</b>was flagged for the submission<b>" + " " + value + "</b></p>");
$('#'+value).prepend("<input data-value=\"" + value + "\" id=\"" + index + "\" style=\"height:35px;padding-top: 3px;\" type=\"button\" class=\"flagbutton\" data-rate=\"dismiss\" value=\"Dismiss Hint\"><input data-value=\"" + value + "\" id=\"" + index + "\" style=\"height:35px; padding-top: 3px;\" type=\"button\" class=\"flagbutton\" data-rate=\"purge\" value=\"Purge Hint\">");
$('#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\">");
$('#submit'+valueid).append("<p> </p><b>Incorrect Answer: \b" + " " + value + "<p> <input id=\"submitbuttonfor" + indexid + "\" style=\"float: right; float: top;\" type=\"button\" class=\"submitbutton\" value=\"Submit a hint\"> <p id=\"hintstoshow" + valueid + "\"> <b><u>Hints in the Data Base:</u>\b </p></div>");
}
}
if(indexid.slice(0,22) != "There are no hints for"){
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>");