Final ie8 fixes hopefully. Now renders correctly for staff. Moved the
debug fns from per problem to part of courseware w/ context info passed as parms. Known issues: ie8 complains that getlog is not defined if you click on QA and does not show the debug info popup.
This commit is contained in:
@@ -217,6 +217,7 @@ def index(request, course_id, chapter=None, section=None,
|
||||
'init': '',
|
||||
'content': '',
|
||||
'staff_access': staff_access,
|
||||
'xqa_server': settings.MITX_FEATURES.get('USE_XQA_SERVER','http://xqa:server@content-qa.mitx.mit.edu/xqa')
|
||||
}
|
||||
|
||||
chapter_descriptor = course.get_child_by_url_name(chapter)
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
<%static:js group='discussion'/>
|
||||
|
||||
<%include file="../discussion/_js_body_dependencies.html" />
|
||||
|
||||
% if staff_access:
|
||||
<%include file="xqa_interface.html"/>
|
||||
% endif
|
||||
|
||||
<!-- TODO: http://docs.jquery.com/Plugins/Validation -->
|
||||
<script type="text/javascript">
|
||||
|
||||
73
lms/templates/courseware/xqa_interface.html
Normal file
73
lms/templates/courseware/xqa_interface.html
Normal file
@@ -0,0 +1,73 @@
|
||||
<script type="text/javascript" src="/static/js/vendor/jquery.leanModal.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function setup_debug(element_id, edit_link, staff_context){
|
||||
$('#' + element_id + '_trig').leanModal();
|
||||
$('#' + element_id + '_xqa_log').leanModal();
|
||||
$('#' + element_id + '_xqa_form').submit(function () {sendlog(element_id, edit_link, staff_context);});
|
||||
}
|
||||
|
||||
function sendlog(element_id, edit_link, staff_context){
|
||||
|
||||
var xqaLog = {
|
||||
authkey: staff_context.xqa_key,
|
||||
location: staff_context.location,
|
||||
category : staff_context.category,
|
||||
'username' : staff_context.user.username,
|
||||
return : 'query',
|
||||
format : 'html',
|
||||
email : staff_context.user.email,
|
||||
tag:$('#' + element_id + '_xqa_tag').val(),
|
||||
entry: $('#' + element_id + '_xqa_entry').val()
|
||||
};
|
||||
|
||||
if (edit_link) xqaLog["giturl"] = edit_link;
|
||||
|
||||
$.ajax({
|
||||
url: '${xqa_server}/log',
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(xqaLog),
|
||||
crossDomain: true,
|
||||
dataType: 'jsonp',
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader ("Authorization", "Basic eHFhOmFnYXJ3YWw="); },
|
||||
timeout : 1000,
|
||||
success: function(result) {
|
||||
$('#' + element_id + '_xqa_log_data').html(result);
|
||||
},
|
||||
error: function() {
|
||||
alert('Error: cannot connect to XQA server');
|
||||
console.log('error!');
|
||||
}
|
||||
});
|
||||
return false;
|
||||
};
|
||||
|
||||
function getlog(element_id, staff_context){
|
||||
|
||||
var xqaQuery = {
|
||||
authkey: staff_context.xqa_key,
|
||||
location: staff_context.location,
|
||||
format: 'html'
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
url: '${xqa_server}/query',
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(xqaQuery),
|
||||
crossDomain: true,
|
||||
dataType: 'jsonp',
|
||||
timeout : 1000,
|
||||
success: function(result) {
|
||||
$('#' + element_id + '_xqa_log_data').html(result);
|
||||
},
|
||||
error: function() {
|
||||
alert('Error: cannot connect to XQA server');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
</script>
|
||||
@@ -1,6 +1,14 @@
|
||||
${module_content}
|
||||
%if edit_link:
|
||||
<div><a href="${edit_link}">Edit</a> / <a href="#${element_id}_xqa-modal" onclick="getlog_${element_id}()" id="${element_id}_xqa_log">QA</a></div>
|
||||
<div>
|
||||
<a href="${edit_link}">Edit</a> /
|
||||
<a href="#${element_id}_xqa-modal" onclick="javascript:getlog('${element_id}', {
|
||||
'location': '${location}',
|
||||
'xqa_key': '${xqa_key}',
|
||||
'category': '${category}',
|
||||
'user': '${user}'
|
||||
})" id="${element_id}_xqa_log">QA</a>
|
||||
</div>
|
||||
% endif
|
||||
<div><a href="#${element_id}_debug" id="${element_id}_trig">Staff Debug Info</a></div>
|
||||
|
||||
@@ -50,77 +58,19 @@ category = ${category | h}
|
||||
|
||||
<div id="${element_id}_setup"></div>
|
||||
|
||||
## leanModal needs to be included here otherwise this breaks when in a <vertical>
|
||||
<script type="text/javascript" src="/static/js/vendor/jquery.leanModal.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function setup_debug_${element_id}(){
|
||||
$('#${element_id}_trig').leanModal();
|
||||
$('#${element_id}_xqa_log').leanModal();
|
||||
$('#${element_id}_xqa_form').submit(sendlog_${element_id});
|
||||
}
|
||||
|
||||
function sendlog_${element_id}(){
|
||||
|
||||
var xqaLog = {authkey: '${xqa_key}',
|
||||
location: '${location}',
|
||||
%if edit_link:
|
||||
giturl: '${edit_link}',
|
||||
%endif
|
||||
category : '${category}',
|
||||
username : '${user.username}',
|
||||
return : 'query',
|
||||
format : 'html',
|
||||
email : '${user.email}',
|
||||
tag:$('#${element_id}_xqa_tag').val(),
|
||||
entry: $('#${element_id}_xqa_entry').val()};
|
||||
|
||||
$.ajax({
|
||||
url: '${xqa_server}/log',
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(xqaLog),
|
||||
crossDomain: true,
|
||||
dataType: 'jsonp',
|
||||
beforeSend: function (xhr) { xhr.setRequestHeader ("Authorization", "Basic eHFhOmFnYXJ3YWw="); },
|
||||
timeout : 1000,
|
||||
success: function(result) {
|
||||
$('#${element_id}_xqa_log_data').html(result);
|
||||
},
|
||||
error: function() {
|
||||
alert('Error: cannot connect to XQA server');
|
||||
console.log('error!');
|
||||
}
|
||||
});
|
||||
return false;
|
||||
};
|
||||
|
||||
setup_debug_${element_id}();
|
||||
|
||||
function getlog_${element_id}(){
|
||||
|
||||
var xqaQuery = {authkey: '${xqa_key}',
|
||||
location: '${location}',
|
||||
format: 'html'};
|
||||
|
||||
$.ajax({
|
||||
url: '${xqa_server}/query',
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(xqaQuery),
|
||||
crossDomain: true,
|
||||
dataType: 'jsonp',
|
||||
timeout : 1000,
|
||||
success: function(result) {
|
||||
$('#${element_id}_xqa_log_data').html(result);
|
||||
},
|
||||
error: function() {
|
||||
alert('Error: cannot connect to XQA server');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
// assumes courseware.html's loaded this method.
|
||||
setup_debug('${element_id}',
|
||||
%if edit_link:
|
||||
'${edit_link}',
|
||||
%else:
|
||||
null,
|
||||
%endif
|
||||
{
|
||||
'location': '${location}',
|
||||
'xqa_key': '${xqa_key}',
|
||||
'category': '${category}',
|
||||
'user': '${user}'
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user