Commit 6212507b by Calen Pennington

Merge pull request #1008 from MITx/ie8patch

merge to master
parents f6a56a19 7f4bb63d
...@@ -3,8 +3,7 @@ from staticfiles.storage import staticfiles_storage ...@@ -3,8 +3,7 @@ from staticfiles.storage import staticfiles_storage
from pipeline_mako import compressed_css, compressed_js from pipeline_mako import compressed_css, compressed_js
%> %>
<%def name='url(file)'> <%def name='url(file)'><%
<%
try: try:
url = staticfiles_storage.url(file) url = staticfiles_storage.url(file)
except: except:
......
...@@ -1995,7 +1995,7 @@ cktsim = (function() { ...@@ -1995,7 +1995,7 @@ cktsim = (function() {
// set up each schematic entry widget // set up each schematic entry widget
function update_schematics() { function update_schematics() {
// set up each schematic on the page // set up each schematic on the page
var schematics = document.getElementsByClassName('schematic'); var schematics = $('.schematic');
for (var i = 0; i < schematics.length; ++i) for (var i = 0; i < schematics.length; ++i)
if (schematics[i].getAttribute("loaded") != "true") { if (schematics[i].getAttribute("loaded") != "true") {
try { try {
...@@ -2036,7 +2036,7 @@ function add_schematic_handler(other_onload) { ...@@ -2036,7 +2036,7 @@ function add_schematic_handler(other_onload) {
// ask each schematic input widget to update its value field for submission // ask each schematic input widget to update its value field for submission
function prepare_schematics() { function prepare_schematics() {
var schematics = document.getElementsByClassName('schematic'); var schematics = $('.schematic');
for (var i = schematics.length - 1; i >= 0; i--) for (var i = schematics.length - 1; i >= 0; i--)
schematics[i].schematic.update_value(); schematics[i].schematic.update_value();
} }
...@@ -3339,6 +3339,8 @@ schematic = (function() { ...@@ -3339,6 +3339,8 @@ schematic = (function() {
} }
// add method to canvas to compute relative coords for event // add method to canvas to compute relative coords for event
try {
if (HTMLCanvasElement)
HTMLCanvasElement.prototype.relMouseCoords = function(event){ HTMLCanvasElement.prototype.relMouseCoords = function(event){
// run up the DOM tree to figure out coords for top,left of canvas // run up the DOM tree to figure out coords for top,left of canvas
var totalOffsetX = 0; var totalOffsetX = 0;
...@@ -3357,6 +3359,9 @@ schematic = (function() { ...@@ -3357,6 +3359,9 @@ schematic = (function() {
this.page_x = event.pageX; this.page_x = event.pageX;
this.page_y = event.pageY; this.page_y = event.pageY;
} }
}
catch (err) { // ignore
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
...@@ -3718,7 +3723,7 @@ schematic = (function() { ...@@ -3718,7 +3723,7 @@ schematic = (function() {
// look for property input fields in the content and give // look for property input fields in the content and give
// them a keypress listener that interprets ENTER as // them a keypress listener that interprets ENTER as
// clicking OK. // clicking OK.
var plist = content.getElementsByClassName('property'); var plist = content.$('.property');
for (var i = plist.length - 1; i >= 0; --i) { for (var i = plist.length - 1; i >= 0; --i) {
var field = plist[i]; var field = plist[i];
field.dialog = dialog; // help event handler find us... field.dialog = dialog; // help event handler find us...
...@@ -4091,6 +4096,8 @@ schematic = (function() { ...@@ -4091,6 +4096,8 @@ schematic = (function() {
// add dashed lines! // add dashed lines!
// from http://davidowens.wordpress.com/2010/09/07/html-5-canvas-and-dashed-lines/ // from http://davidowens.wordpress.com/2010/09/07/html-5-canvas-and-dashed-lines/
try {
if (CanvasRenderingContext2D)
CanvasRenderingContext2D.prototype.dashedLineTo = function(fromX, fromY, toX, toY, pattern) { CanvasRenderingContext2D.prototype.dashedLineTo = function(fromX, fromY, toX, toY, pattern) {
// Our growth rate for our line can be one of the following: // Our growth rate for our line can be one of the following:
// (+,+), (+,-), (-,+), (-,-) // (+,+), (+,-), (-,+), (-,-)
...@@ -4132,7 +4139,9 @@ schematic = (function() { ...@@ -4132,7 +4139,9 @@ schematic = (function() {
dash = !dash; dash = !dash;
} }
}; };
}
catch (err) { //noop
}
// given a range of values, return a new range [vmin',vmax'] where the limits // given a range of values, return a new range [vmin',vmax'] where the limits
// have been chosen "nicely". Taken from matplotlib.ticker.LinearLocator // have been chosen "nicely". Taken from matplotlib.ticker.LinearLocator
function view_limits(vmin,vmax) { function view_limits(vmin,vmax) {
......
...@@ -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});
}
setup_debug_${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;
};
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