Commit 7f4bb63d by Don Mitchell

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.
parent 8089be33
...@@ -217,6 +217,7 @@ def index(request, course_id, chapter=None, section=None, ...@@ -217,6 +217,7 @@ def index(request, course_id, chapter=None, section=None,
'init': '', 'init': '',
'content': '', 'content': '',
'staff_access': staff_access, '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) chapter_descriptor = course.get_child_by_url_name(chapter)
......
...@@ -25,7 +25,9 @@ ...@@ -25,7 +25,9 @@
<%static:js group='discussion'/> <%static:js group='discussion'/>
<%include file="../discussion/_js_body_dependencies.html" /> <%include file="../discussion/_js_body_dependencies.html" />
% if staff_access:
<%include file="xqa_interface.html"/>
% endif
<!-- TODO: http://docs.jquery.com/Plugins/Validation --> <!-- TODO: http://docs.jquery.com/Plugins/Validation -->
<script type="text/javascript"> <script type="text/javascript">
......
<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>
\ No newline at end of file
${module_content} ${module_content}
%if edit_link: %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 % endif
<div><a href="#${element_id}_debug" id="${element_id}_trig">Staff Debug Info</a></div> <div><a href="#${element_id}_debug" id="${element_id}_trig">Staff Debug Info</a></div>
...@@ -50,77 +58,19 @@ category = ${category | h} ...@@ -50,77 +58,19 @@ category = ${category | h}
<div id="${element_id}_setup"></div> <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"> <script type="text/javascript">
// assumes courseware.html's loaded this method.
function setup_debug_${element_id}(){ 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: %if edit_link:
giturl: '${edit_link}', '${edit_link}',
%else:
null,
%endif %endif
category : '${category}', {
username : '${user.username}', 'location': '${location}',
return : 'query', 'xqa_key': '${xqa_key}',
format : 'html', 'category': '${category}',
email : '${user.email}', 'user': '${user}'
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');
}
}); });
};
</script> </script>
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