Commit 2998a2e9 by Carson Gee

Code review changes

i18n
parent 57756344
...@@ -49,17 +49,6 @@ class StaffDebugPage(PageObject): ...@@ -49,17 +49,6 @@ class StaffDebugPage(PageObject):
def is_browser_on_page(self): def is_browser_on_page(self):
return self.q(css='section.staff-modal').present return self.q(css='section.staff-modal').present
def _click_link(self, link_text):
"""
Clicks on an action link based on text
"""
for link in self.q(css='section.staff-modal a').execute():
if link.text == link_text:
return link.click()
raise Exception('Could not find the {} link to click on.'.format(
link_text))
def reset_attempts(self, user=None): def reset_attempts(self, user=None):
""" """
This clicks on the reset attempts link with an optionally This clicks on the reset attempts link with an optionally
...@@ -67,7 +56,7 @@ class StaffDebugPage(PageObject): ...@@ -67,7 +56,7 @@ class StaffDebugPage(PageObject):
""" """
if user: if user:
self.q(css='input[id^=sd_fu_]').first.fill(user) self.q(css='input[id^=sd_fu_]').first.fill(user)
self._click_link('Reset Student Attempts') self.q(css='section.staff-modal a#staff-debug-reset').click()
def delete_state(self, user=None): def delete_state(self, user=None):
""" """
...@@ -75,7 +64,7 @@ class StaffDebugPage(PageObject): ...@@ -75,7 +64,7 @@ class StaffDebugPage(PageObject):
""" """
if user: if user:
self.q(css='input[id^=sd_fu_]').fill(user) self.q(css='input[id^=sd_fu_]').fill(user)
self._click_link('Delete Student State') self.q(css='section.staff-modal a#staff-debug-sdelete').click()
@property @property
def idash_msg(self): def idash_msg(self):
......
describe('StaffDebugActions', function() { describe('StaffDebugActions', function() {
var loc = 'test_loc'; var loc = 'test_loc';
var fixture_id = 'sd_fu_' + loc; var fixture_id = 'sd_fu_' + loc;
var fixture = $('<input id="' + fixture_id + '" placeholder="userman" />'); var fixture = $('<input>', { id: fixture_id, placeholder: "userman" });
describe('get_url ', function() { describe('get_url ', function() {
it('defines url to courseware ajax entry point', function() { it('defines url to courseware ajax entry point', function() {
......
// Build StaffDebug object
var StaffDebug = (function(){ var StaffDebug = (function(){
get_current_url = function() { get_current_url = function() {
...@@ -6,7 +7,6 @@ var StaffDebug = (function(){ ...@@ -6,7 +7,6 @@ var StaffDebug = (function(){
get_url = function(action){ get_url = function(action){
var pathname = this.get_current_url(); var pathname = this.get_current_url();
console.log(pathname)
var url = pathname.substr(0,pathname.indexOf('/courseware')) + '/' + action; var url = pathname.substr(0,pathname.indexOf('/courseware')) + '/' + action;
return url; return url;
} }
...@@ -20,10 +20,12 @@ var StaffDebug = (function(){ ...@@ -20,10 +20,12 @@ var StaffDebug = (function(){
} }
do_idash_action = function(locname, idaction){ do_idash_action = function(locname, idaction){
var pdata = {'action': idaction, var pdata = {
'problem_for_student': locname, 'action': idaction,
'unique_student_identifier': get_user(locname) 'problem_for_student': locname,
} 'unique_student_identifier': get_user(locname)
}
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: get_url('instructor'), url: get_url('instructor'),
...@@ -33,7 +35,18 @@ var StaffDebug = (function(){ ...@@ -33,7 +35,18 @@ var StaffDebug = (function(){
$("#result_" + locname).html( msg ); $("#result_" + locname).html( msg );
}, },
error: function(request, status, error) { error: function(request, status, error) {
$("#result_" + locname).html('<p id="idash_msg"><font color="red">' + gettext('Something has gone wrong with this request. The server replied with a status of: ') + error + '</font></p>'); var text = _.template(
gettext('Something has gone wrong with this request. \
The server replied with a status of: {error}'),
{error: error},
{interpolate: /\{(.+?)\}/g}
)
var html = _.template(
'<p id="idash_msg"><font color="red">{text}</font></p>',
{text: text},
{interpolate: /\{(.+?)\}/g}
)
$("#result_"+locname).html(html);
}, },
dataType: 'html' dataType: 'html'
}); });
...@@ -47,11 +60,24 @@ var StaffDebug = (function(){ ...@@ -47,11 +60,24 @@ var StaffDebug = (function(){
do_idash_action(locname, "Delete student state for module"); do_idash_action(locname, "Delete student state for module");
} }
return {reset: reset, return {
sdelete: sdelete, reset: reset,
do_idash_action: do_idash_action, sdelete: sdelete,
get_current_url: get_current_url, do_idash_action: do_idash_action,
get_url: get_url, get_current_url: get_current_url,
get_user: get_user get_url: get_url,
} get_user: get_user
}
})(); })();
// Register click handlers
$(document).ready(function() {
$('#staff-debug-reset').click(function() {
StaffDebug.reset($(this).data('location'));
return false;
});
$('#staff-debug-sdelete').click(function() {
StaffDebug.sdelete($(this).data('location'));
return false;
});
});
...@@ -55,14 +55,16 @@ ${block_content} ...@@ -55,14 +55,16 @@ ${block_content}
</header> </header>
<hr /> <hr />
<h3>Actions</h3> <h3>${_('Actions')}</h3>
<div> <div>
<label for="sd_fu_${location.name}">For User:</label> <label for="sd_fu_${location.name}">${_('For User')}:</label>
<input type="text" id="sd_fu_${location.name}" placeholder="${user.username}"/> <input type="text" id="sd_fu_${location.name}" placeholder="${user.username}"/>
</div> </div>
<div> <div>
[ <a href='javascript:StaffDebug.reset("${location.name}")'>${_('Reset Student Attempts')}</a> | [
<a href='javascript:StaffDebug.sdelete("${location.name}")'>${_('Delete Student State')}</a> <a href="#" id="staff-debug-reset" data-location="${location.name}">${_('Reset Student Attempts')}</a>
|
<a href="#" id="staff-debug-sdelete" data-location="${location.name}">${_('Delete Student State')}</a>
] ]
</div> </div>
<div id="result_${location.name}"/> <div id="result_${location.name}"/>
......
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