Code review changes
i18n
This commit is contained in:
@@ -49,17 +49,6 @@ class StaffDebugPage(PageObject):
|
||||
def is_browser_on_page(self):
|
||||
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):
|
||||
"""
|
||||
This clicks on the reset attempts link with an optionally
|
||||
@@ -67,7 +56,7 @@ class StaffDebugPage(PageObject):
|
||||
"""
|
||||
if 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):
|
||||
"""
|
||||
@@ -75,7 +64,7 @@ class StaffDebugPage(PageObject):
|
||||
"""
|
||||
if 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
|
||||
def idash_msg(self):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('StaffDebugActions', function() {
|
||||
var loc = 'test_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() {
|
||||
it('defines url to courseware ajax entry point', function() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Build StaffDebug object
|
||||
var StaffDebug = (function(){
|
||||
|
||||
get_current_url = function() {
|
||||
@@ -6,7 +7,6 @@ var StaffDebug = (function(){
|
||||
|
||||
get_url = function(action){
|
||||
var pathname = this.get_current_url();
|
||||
console.log(pathname)
|
||||
var url = pathname.substr(0,pathname.indexOf('/courseware')) + '/' + action;
|
||||
return url;
|
||||
}
|
||||
@@ -20,10 +20,12 @@ var StaffDebug = (function(){
|
||||
}
|
||||
|
||||
do_idash_action = function(locname, idaction){
|
||||
var pdata = {'action': idaction,
|
||||
'problem_for_student': locname,
|
||||
'unique_student_identifier': get_user(locname)
|
||||
}
|
||||
var pdata = {
|
||||
'action': idaction,
|
||||
'problem_for_student': locname,
|
||||
'unique_student_identifier': get_user(locname)
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: get_url('instructor'),
|
||||
@@ -33,7 +35,18 @@ var StaffDebug = (function(){
|
||||
$("#result_" + locname).html( msg );
|
||||
},
|
||||
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'
|
||||
});
|
||||
@@ -47,11 +60,24 @@ var StaffDebug = (function(){
|
||||
do_idash_action(locname, "Delete student state for module");
|
||||
}
|
||||
|
||||
return {reset: reset,
|
||||
sdelete: sdelete,
|
||||
do_idash_action: do_idash_action,
|
||||
get_current_url: get_current_url,
|
||||
get_url: get_url,
|
||||
get_user: get_user
|
||||
}
|
||||
return {
|
||||
reset: reset,
|
||||
sdelete: sdelete,
|
||||
do_idash_action: do_idash_action,
|
||||
get_current_url: get_current_url,
|
||||
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}
|
||||
</header>
|
||||
|
||||
<hr />
|
||||
<h3>Actions</h3>
|
||||
<h3>${_('Actions')}</h3>
|
||||
<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}"/>
|
||||
</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 id="result_${location.name}"/>
|
||||
|
||||
Reference in New Issue
Block a user