From 9cb2fbdd2fad6a553342776a535d1bd74aea6197 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Wed, 31 Oct 2012 16:26:11 -0400 Subject: [PATCH 1/6] Remove newline from javascript source tags --- common/djangoapps/pipeline_mako/templates/static_content.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/djangoapps/pipeline_mako/templates/static_content.html b/common/djangoapps/pipeline_mako/templates/static_content.html index c153da22fe..302d4d7aa5 100644 --- a/common/djangoapps/pipeline_mako/templates/static_content.html +++ b/common/djangoapps/pipeline_mako/templates/static_content.html @@ -3,8 +3,7 @@ from staticfiles.storage import staticfiles_storage from pipeline_mako import compressed_css, compressed_js %> -<%def name='url(file)'> -<% +<%def name='url(file)'><% try: url = staticfiles_storage.url(file) except: From 6bbe82b697e30fb8852e87db15afa6711a4c7679 Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Wed, 31 Oct 2012 17:05:46 -0400 Subject: [PATCH 2/6] Make work w/ ie8. Still complains that HTMLCanvasElement is undefined but doesn't try to manipulate it. --- common/lib/xmodule/xmodule/js/src/capa/schematic.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/capa/schematic.js b/common/lib/xmodule/xmodule/js/src/capa/schematic.js index b01f6e12e8..8fb6769342 100644 --- a/common/lib/xmodule/xmodule/js/src/capa/schematic.js +++ b/common/lib/xmodule/xmodule/js/src/capa/schematic.js @@ -1995,7 +1995,7 @@ cktsim = (function() { // set up each schematic entry widget function update_schematics() { // set up each schematic on the page - var schematics = document.getElementsByClassName('schematic'); + var schematics = $('.schematic'); for (var i = 0; i < schematics.length; ++i) if (schematics[i].getAttribute("loaded") != "true") { try { @@ -2036,7 +2036,7 @@ function add_schematic_handler(other_onload) { // ask each schematic input widget to update its value field for submission function prepare_schematics() { - var schematics = document.getElementsByClassName('schematic'); + var schematics = $('.schematic'); for (var i = schematics.length - 1; i >= 0; i--) schematics[i].schematic.update_value(); } @@ -3339,7 +3339,7 @@ schematic = (function() { } // add method to canvas to compute relative coords for event - HTMLCanvasElement.prototype.relMouseCoords = function(event){ + if (HTMLCanvasElement) HTMLCanvasElement.prototype.relMouseCoords = function(event){ // run up the DOM tree to figure out coords for top,left of canvas var totalOffsetX = 0; var totalOffsetY = 0; @@ -3718,7 +3718,7 @@ schematic = (function() { // look for property input fields in the content and give // them a keypress listener that interprets ENTER as // clicking OK. - var plist = content.getElementsByClassName('property'); + var plist = $(content).find('.property'); for (var i = plist.length - 1; i >= 0; --i) { var field = plist[i]; field.dialog = dialog; // help event handler find us... From 2b5e55b6623af972b7b403a4e82d6771759ce2c8 Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Wed, 31 Oct 2012 17:29:19 -0400 Subject: [PATCH 3/6] Use try/catch to detect undefined globals for canvas --- .../xmodule/xmodule/js/src/capa/schematic.js | 127 ++++++++++-------- 1 file changed, 68 insertions(+), 59 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/capa/schematic.js b/common/lib/xmodule/xmodule/js/src/capa/schematic.js index 8fb6769342..d2602d8ac3 100644 --- a/common/lib/xmodule/xmodule/js/src/capa/schematic.js +++ b/common/lib/xmodule/xmodule/js/src/capa/schematic.js @@ -3339,23 +3339,28 @@ schematic = (function() { } // add method to canvas to compute relative coords for event - if (HTMLCanvasElement) HTMLCanvasElement.prototype.relMouseCoords = function(event){ - // run up the DOM tree to figure out coords for top,left of canvas - var totalOffsetX = 0; - var totalOffsetY = 0; - var currentElement = this; - do { - totalOffsetX += currentElement.offsetLeft; - totalOffsetY += currentElement.offsetTop; - } - while (currentElement = currentElement.offsetParent); - - // now compute relative position of click within the canvas - this.mouse_x = event.pageX - totalOffsetX; - this.mouse_y = event.pageY - totalOffsetY; - - this.page_x = event.pageX; - this.page_y = event.pageY; + try { + if (HTMLCanvasElement) + HTMLCanvasElement.prototype.relMouseCoords = function(event){ + // run up the DOM tree to figure out coords for top,left of canvas + var totalOffsetX = 0; + var totalOffsetY = 0; + var currentElement = this; + do { + totalOffsetX += currentElement.offsetLeft; + totalOffsetY += currentElement.offsetTop; + } + while (currentElement = currentElement.offsetParent); + + // now compute relative position of click within the canvas + this.mouse_x = event.pageX - totalOffsetX; + this.mouse_y = event.pageY - totalOffsetY; + + this.page_x = event.pageX; + this.page_y = event.pageY; + } + } + catch (err) { // ignore } /////////////////////////////////////////////////////////////////////////////// @@ -4091,48 +4096,52 @@ schematic = (function() { // add dashed lines! // from http://davidowens.wordpress.com/2010/09/07/html-5-canvas-and-dashed-lines/ - CanvasRenderingContext2D.prototype.dashedLineTo = function(fromX, fromY, toX, toY, pattern) { - // Our growth rate for our line can be one of the following: - // (+,+), (+,-), (-,+), (-,-) - // Because of this, our algorithm needs to understand if the x-coord and - // y-coord should be getting smaller or larger and properly cap the values - // based on (x,y). - var lt = function (a, b) { return a <= b; }; - var gt = function (a, b) { return a >= b; }; - var capmin = function (a, b) { return Math.min(a, b); }; - var capmax = function (a, b) { return Math.max(a, b); }; - - var checkX = { thereYet: gt, cap: capmin }; - var checkY = { thereYet: gt, cap: capmin }; - - if (fromY - toY > 0) { - checkY.thereYet = lt; - checkY.cap = capmax; - } - if (fromX - toX > 0) { - checkX.thereYet = lt; - checkX.cap = capmax; - } - - this.moveTo(fromX, fromY); - var offsetX = fromX; - var offsetY = fromY; - var idx = 0, dash = true; - while (!(checkX.thereYet(offsetX, toX) && checkY.thereYet(offsetY, toY))) { - var ang = Math.atan2(toY - fromY, toX - fromX); - var len = pattern[idx]; - - offsetX = checkX.cap(toX, offsetX + (Math.cos(ang) * len)); - offsetY = checkY.cap(toY, offsetY + (Math.sin(ang) * len)); - - if (dash) this.lineTo(offsetX, offsetY); - else this.moveTo(offsetX, offsetY); - - idx = (idx + 1) % pattern.length; - dash = !dash; - } - }; - + try { + if (CanvasRenderingContext2D) + CanvasRenderingContext2D.prototype.dashedLineTo = function(fromX, fromY, toX, toY, pattern) { + // Our growth rate for our line can be one of the following: + // (+,+), (+,-), (-,+), (-,-) + // Because of this, our algorithm needs to understand if the x-coord and + // y-coord should be getting smaller or larger and properly cap the values + // based on (x,y). + var lt = function (a, b) { return a <= b; }; + var gt = function (a, b) { return a >= b; }; + var capmin = function (a, b) { return Math.min(a, b); }; + var capmax = function (a, b) { return Math.max(a, b); }; + + var checkX = { thereYet: gt, cap: capmin }; + var checkY = { thereYet: gt, cap: capmin }; + + if (fromY - toY > 0) { + checkY.thereYet = lt; + checkY.cap = capmax; + } + if (fromX - toX > 0) { + checkX.thereYet = lt; + checkX.cap = capmax; + } + + this.moveTo(fromX, fromY); + var offsetX = fromX; + var offsetY = fromY; + var idx = 0, dash = true; + while (!(checkX.thereYet(offsetX, toX) && checkY.thereYet(offsetY, toY))) { + var ang = Math.atan2(toY - fromY, toX - fromX); + var len = pattern[idx]; + + offsetX = checkX.cap(toX, offsetX + (Math.cos(ang) * len)); + offsetY = checkY.cap(toY, offsetY + (Math.sin(ang) * len)); + + if (dash) this.lineTo(offsetX, offsetY); + else this.moveTo(offsetX, offsetY); + + idx = (idx + 1) % pattern.length; + dash = !dash; + } + }; + } + catch (err) { //noop + } // given a range of values, return a new range [vmin',vmax'] where the limits // have been chosen "nicely". Taken from matplotlib.ticker.LinearLocator function view_limits(vmin,vmax) { From afabb4ab1612f63734de62176a8262553c03b5f3 Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Fri, 2 Nov 2012 14:25:25 -0400 Subject: [PATCH 4/6] Don't call fn before defined. [ie8 is only browser which seems to care.] --- lms/templates/staff_problem_info.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/templates/staff_problem_info.html b/lms/templates/staff_problem_info.html index 6d9d1a3a30..9d51a119c6 100644 --- a/lms/templates/staff_problem_info.html +++ b/lms/templates/staff_problem_info.html @@ -61,8 +61,6 @@ function setup_debug_${element_id}(){ $('#${element_id}_xqa_form').submit(sendlog_${element_id}); } -setup_debug_${element_id}(); - function sendlog_${element_id}(){ var xqaLog = {authkey: '${xqa_key}', @@ -97,6 +95,8 @@ function sendlog_${element_id}(){ }); return false; }; + +setup_debug_${element_id}(); function getlog_${element_id}(){ From 8089be33540bcd7c3473a5cfdf11f1ff8d240768 Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Fri, 2 Nov 2012 15:31:02 -0400 Subject: [PATCH 5/6] Minor stylistic change on jQuery pattern. --- common/lib/xmodule/xmodule/js/src/capa/schematic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/xmodule/xmodule/js/src/capa/schematic.js b/common/lib/xmodule/xmodule/js/src/capa/schematic.js index d2602d8ac3..e65b0ecad6 100644 --- a/common/lib/xmodule/xmodule/js/src/capa/schematic.js +++ b/common/lib/xmodule/xmodule/js/src/capa/schematic.js @@ -3723,7 +3723,7 @@ schematic = (function() { // look for property input fields in the content and give // them a keypress listener that interprets ENTER as // clicking OK. - var plist = $(content).find('.property'); + var plist = content.$('.property'); for (var i = plist.length - 1; i >= 0; --i) { var field = plist[i]; field.dialog = dialog; // help event handler find us... From 7f4bb63dff596ebd8ded0afa48a31c03196cc17c Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Mon, 5 Nov 2012 13:55:09 -0500 Subject: [PATCH 6/6] 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. --- lms/djangoapps/courseware/views.py | 1 + lms/templates/courseware/courseware.html | 4 +- lms/templates/courseware/xqa_interface.html | 73 ++++++++++++++++ lms/templates/staff_problem_info.html | 94 +++++---------------- 4 files changed, 99 insertions(+), 73 deletions(-) create mode 100644 lms/templates/courseware/xqa_interface.html diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index 58bd6924af..d8def76473 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -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) diff --git a/lms/templates/courseware/courseware.html b/lms/templates/courseware/courseware.html index 62af7d6f82..1ea3df1b5a 100644 --- a/lms/templates/courseware/courseware.html +++ b/lms/templates/courseware/courseware.html @@ -25,7 +25,9 @@ <%static:js group='discussion'/> <%include file="../discussion/_js_body_dependencies.html" /> - + % if staff_access: + <%include file="xqa_interface.html"/> + % endif + \ No newline at end of file diff --git a/lms/templates/staff_problem_info.html b/lms/templates/staff_problem_info.html index 9d51a119c6..0f1893ee4f 100644 --- a/lms/templates/staff_problem_info.html +++ b/lms/templates/staff_problem_info.html @@ -1,6 +1,14 @@ ${module_content} %if edit_link: - +
+ Edit / + QA +
% endif @@ -50,77 +58,19 @@ category = ${category | h}
-## leanModal needs to be included here otherwise this breaks when in a - -