Commit 567084e1 by Piotr Mitros

Code review nits

parent 5dcb7597
...@@ -50,8 +50,8 @@ class RateXBlock(XBlock): ...@@ -50,8 +50,8 @@ class RateXBlock(XBlock):
# exposed in the UX. If the prompt is missing any portions, we # exposed in the UX. If the prompt is missing any portions, we
# will default to the ones in default_prompt. # will default to the ones in default_prompt.
prompts = List( prompts = List(
default=[{'freeform': "What could be improved to make this section more clear?", default=[{'freeform': "Please provide us feedback on this section",
'likert': "Was this section clear or confusing?"}], 'likert': "Please rate your overall experience with this section"}],
scope=Scope.settings, scope=Scope.settings,
help="Freeform user prompt", help="Freeform user prompt",
xml_node=True xml_node=True
...@@ -111,14 +111,13 @@ class RateXBlock(XBlock): ...@@ -111,14 +111,13 @@ class RateXBlock(XBlock):
The primary view of the RateXBlock, shown to students The primary view of the RateXBlock, shown to students
when viewing courses. when viewing courses.
""" """
if self.prompt_choice < 0 or self.prompt_choice >= len(self.prompts):
self.prompt_choice = random.randint(0, len(self.prompts) - 1)
prompt = self.get_prompt(self.prompt_choice)
# Figure out which prompt we show. We set self.prompt_choice to # Figure out which prompt we show. We set self.prompt_choice to
# the index of the prompt. We set it if it is out of range (either # the index of the prompt. We set it if it is out of range (either
# uninitiailized, or incorrect due to changing list length). Then, # uninitiailized, or incorrect due to changing list length). Then,
# we grab the prompt, prepopulated with defaults. # we grab the prompt, prepopulated with defaults.
if self.prompt_choice < 0 or self.prompt_choice >= len(self.prompts):
self.prompt_choice = random.randint(0, len(self.prompts) - 1)
prompt = self.get_prompt(self.prompt_choice)
# 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.
...@@ -162,10 +161,10 @@ class RateXBlock(XBlock): ...@@ -162,10 +161,10 @@ class RateXBlock(XBlock):
""" """
Create a fragment used to display the edit view in the Studio. Create a fragment used to display the edit view in the Studio.
""" """
html_str = pkg_resources.resource_string(__name__, "static/html/studio_view.html") html_str = self.resource_string("static/html/studio_view.html")
prompt = self.get_prompt(0) prompt = self.get_prompt(0)
frag = Fragment(unicode(html_str).format(**prompt)) frag = Fragment(unicode(html_str).format(**prompt))
js_str = pkg_resources.resource_string(__name__, "static/js/src/studio.js") js_str = self.resource_string("static/js/src/studio.js")
frag.add_javascript(unicode(js_str)) frag.add_javascript(unicode(js_str))
frag.initialize_js('RateBlock') frag.initialize_js('RateBlock')
return frag return frag
......
...@@ -29,32 +29,19 @@ function RateXBlock(runtime, element) { ...@@ -29,32 +29,19 @@ function RateXBlock(runtime, element) {
type: "POST", type: "POST",
url: feedback_handler, url: feedback_handler,
data: JSON.stringify(feedback), data: JSON.stringify(feedback),
success: function(data) {console.log(data.response); $('.rate_thank_you', element).text(data.response);} success: function(data) {$('.rate_thank_you', element).text(data.response);}
}); });
}); });
$('.rate_radio', element).change(function(eventObject) { $('.rate_radio', element).change(function(eventObject) {
target_id = eventObject.target.id; target_id = eventObject.target.id;
vote = parseInt(target_id.split('_')[1]); vote = parseInt(target_id.split('_')[1]);
/*$.ajax({
type: "POST",
url: feedback_handler,
data: JSON.stringify({"vote": vote}),
});*/
Logger.log("edx.ratexblock.likert_rate", {"vote":vote}) Logger.log("edx.ratexblock.likert_rate", {"vote":vote})
}); });
$('.rate_freeform_area', element).change(function(eventObject) { $('.rate_freeform_area', element).change(function(eventObject) {
var freeform = eventObject.currentTarget.value; var freeform = eventObject.currentTarget.value;
Logger.log("edx.ratexblock.freeform_feedback", {"freeform":freeform}) Logger.log("edx.ratexblock.freeform_feedback", {"freeform":freeform})
/*
$('.rate_thank_you', element).css('visibility','hidden');
$.ajax({
type: "POST",
url: feedback_handler,
data: JSON.stringify({"freeform": freeform}),
success: function() {$('.rate_thank_you', element).css('visibility','visible')},
});*/
}); });
} }
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