Commit 73dc9e64 by Piotr Mitros

Accessible

parent ad47fb57
...@@ -106,9 +106,9 @@ class RateXBlock(XBlock): ...@@ -106,9 +106,9 @@ class RateXBlock(XBlock):
# Now, we render the RateXBlock. This may be redundant, since we # Now, we render the RateXBlock. This may be redundant, since we
# don't always show it. # don't always show it.
html = self.resource_string("static/html/rate.html") html = self.resource_string("static/html/rate.html")
scale_item = u'<span class="rate_likert_rating rate_rating_{i} {active}" title="{level}">{icon}</span>' scale_item = u'<input id="radio_{i}" type="radio" name="rate_scale" class="rate_radio" title="{level}" {active}><label for="radio_{i}" title="{level}">{icon}<span class="rate_sr_text">{level}</span></label></input>'
indexes = range(len(prompt['icons'])) indexes = range(len(prompt['icons']))
active_vote = [" rate_rating_active " if i == self.user_vote else "" for i in indexes] active_vote = ["checked" if i == self.user_vote else "" for i in indexes]
scale = u"".join(scale_item.format(level=level, icon=icon, i=i, active=active) for (level,icon,i,active) in zip(prompt['mouseovers'], prompt['icons'], indexes, active_vote)) scale = u"".join(scale_item.format(level=level, icon=icon, i=i, active=active) for (level,icon,i,active) in zip(prompt['mouseovers'], prompt['icons'], indexes, active_vote))
rendered = html.format(self=self, scale=scale, string_prompt = prompt['string'], likert_prompt = prompt['likert']) rendered = html.format(self=self, scale=scale, string_prompt = prompt['string'], likert_prompt = prompt['likert'])
......
...@@ -33,3 +33,28 @@ ...@@ -33,3 +33,28 @@
font-weight: bold; font-weight: bold;
background-color: blanchedalmond; background-color: blanchedalmond;
} }
.rate_block .rate_radio {
opacity:0;
width:0;
padding:0;
margin:0;
}
.rate_block .rate_sr_text{
opacity:0;
width:1px;
height:1px;
padding:0;
margin:0;
position:absolute;
clip:rect(1px,1px,1px,1px);
left:-10000px;
overflow:hidden;
}
.rate_block input[type="radio"]:checked + label{
background-color:yellow;
font-weight:bold;
}
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
<div class="rate_thank_you">Thank you!</div> <div class="rate_thank_you">Thank you!</div>
</div> </div>
<div class="rate_likert_header">{likert_prompt}</div> <div class="rate_likert_header">{likert_prompt}</div>
<div class="rate_likert_scale">{scale}</div> <div class="rate_likert_scale"> <form action="">{scale}</form></div>
</div> </div>
...@@ -16,19 +16,15 @@ function RateXBlock(runtime, element) { ...@@ -16,19 +16,15 @@ function RateXBlock(runtime, element) {
var vote_handler = runtime.handlerUrl(element, 'vote'); var vote_handler = runtime.handlerUrl(element, 'vote');
var feedback_handler = runtime.handlerUrl(element, 'feedback'); var feedback_handler = runtime.handlerUrl(element, 'feedback');
$('.rate_likert_rating', element).click(function(eventObject) { $('.rate_radio', element).change(function(eventObject) {
var vote_class = eventObject.currentTarget.className.split(' ').find(function f(x) { return x.startsWith("rate_rating_") } ) target_id = eventObject.target.id;
var vote = parseInt(vote_class.split('_')[2]); vote = parseInt(target_id.split('_')[1]);
$('.rate_rating_active', element).removeClass("rate_rating_active");
$('.'+vote_class, element).addClass("rate_rating_active");
Logger.log("edx.ratexblock.likert_rate", {"vote":vote})
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: vote_handler, url: vote_handler,
data: JSON.stringify({"vote": vote}), data: JSON.stringify({"vote": vote}),
}); });
Logger.log("edx.ratexblock.likert_rate", {"vote":vote})
}); });
$('.rate_string_area', element).change(function(eventObject) { $('.rate_string_area', element).change(function(eventObject) {
...@@ -44,13 +40,3 @@ function RateXBlock(runtime, element) { ...@@ -44,13 +40,3 @@ function RateXBlock(runtime, element) {
}); });
} }
/*
function updateCount(result) {
$('.count', element).text(result.count);
}
*/
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