Fixed staff debug on instructor page
added unit test js fixed test js updated test commetn updated xss
This commit is contained in:
@@ -250,6 +250,7 @@ def instructor_dashboard_2(request, course_id):
|
||||
'generate_bulk_certificate_exceptions_url': generate_bulk_certificate_exceptions_url,
|
||||
'certificate_exception_view_url': certificate_exception_view_url,
|
||||
'certificate_invalidation_view_url': certificate_invalidation_view_url,
|
||||
'xqa_server': settings.FEATURES.get('XQA_SERVER', "http://your_xqa_server.com"),
|
||||
}
|
||||
|
||||
return render_to_response('instructor/instructor_dashboard_2/instructor_dashboard_2.html', context)
|
||||
|
||||
@@ -31,6 +31,15 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
describe('getURL ', function() {
|
||||
it('defines that getCurrentUrl works on instructor page as expected', function() {
|
||||
spyOn(StaffDebug, 'getCurrentUrl')
|
||||
.and.returnValue('/courses/edx_demo_course/instructor#view-open_response_assessment');
|
||||
expect(StaffDebug.getURL('rescore_problem'))
|
||||
.toBe('/courses/edx_demo_course/instructor/api/rescore_problem');
|
||||
});
|
||||
});
|
||||
|
||||
describe('sanitizeString', function() {
|
||||
it('escapes escapable characters in a string', function() {
|
||||
expect(StaffDebug.sanitizeString('.*+?^:${}()|]['))
|
||||
|
||||
@@ -4,7 +4,11 @@ var StaffDebug = (function() {
|
||||
/* global getCurrentUrl:true */
|
||||
var getURL = function(action) {
|
||||
var pathname = this.getCurrentUrl();
|
||||
return pathname.substr(0, pathname.indexOf('/courseware')) + '/instructor/api/' + action;
|
||||
var index = pathname.indexOf('/courseware');
|
||||
if (index <= 0) {
|
||||
index = pathname.indexOf('/', '/courses/'.length);
|
||||
}
|
||||
return pathname.substr(0, index) + '/instructor/api/' + action;
|
||||
};
|
||||
|
||||
var sanitizeString = function(string) {
|
||||
@@ -48,7 +52,10 @@ var StaffDebug = (function() {
|
||||
var html = _.template('<p id="idash_msg" class="success">{text}</p>', {interpolate: /\{(.+?)\}/g})(
|
||||
{text: text}
|
||||
);
|
||||
$('#result_' + sanitizeString(action.locationName)).html(html);
|
||||
edx.HtmlUtils.setHtml(
|
||||
$('#result_' + sanitizeString(action.locationName)),
|
||||
edx.HtmlUtils.HTML(html)
|
||||
);
|
||||
},
|
||||
error: function(request, status, error) {
|
||||
var responseJSON;
|
||||
@@ -66,7 +73,10 @@ var StaffDebug = (function() {
|
||||
var html = _.template('<p id="idash_msg" class="error">{text}</p>', {interpolate: /\{(.+?)\}/g})(
|
||||
{text: text}
|
||||
);
|
||||
$('#result_' + sanitizeString(action.locationName)).html(html);
|
||||
edx.HtmlUtils.setHtml(
|
||||
$('#result_' + sanitizeString(action.locationName)),
|
||||
edx.HtmlUtils.HTML(html)
|
||||
);
|
||||
},
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
@@ -2905,3 +2905,40 @@ input[name="subject"] {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div.staff_info {
|
||||
display: none;
|
||||
|
||||
@include clearfix();
|
||||
|
||||
white-space: pre-wrap;
|
||||
border-top: 1px solid $gray-l3;
|
||||
padding-top: lh();
|
||||
margin-top: lh();
|
||||
line-height: lh();
|
||||
font-family: Consolas, "Lucida Console", Monaco, "Courier New", Courier, monospace;
|
||||
|
||||
// Debugging content is always in English, therefore it's never RTL
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.xqa-modal,
|
||||
.staff-modal,
|
||||
.history-modal {
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
left: left(20%);
|
||||
overflow: auto;
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.staff_actions {
|
||||
p.error {
|
||||
color: theme-color("danger");
|
||||
}
|
||||
|
||||
p.success {
|
||||
color: theme-color("success");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ function setup_debug(element_id, edit_link, staff_context){
|
||||
var username = $("#" + element_id + "_history_student_username").val();
|
||||
var location = $("#" + element_id + "_history_location").val();
|
||||
// xss-lint: disable=mako-invalid-js-filter
|
||||
$("#" + element_id + "_history_text").load('/courses/' + "${six.text_type(course.id) | u}" +
|
||||
$("#" + element_id + "_history_text").load('/courses/' + "${six.text_type(getattr(course,'id','')) | u}" +
|
||||
"/submission_history/" + username + "/" + location);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<%page args="section_data" expression_filter="h"/>
|
||||
<%! from openedx.core.djangolib.markup import HTML %>
|
||||
|
||||
<%include file="/courseware/xqa_interface.html/"/>
|
||||
|
||||
<section class="open-response-assessment">
|
||||
${HTML(section_data['fragment'].body_html())}
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user