Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
6212507b
Commit
6212507b
authored
Nov 06, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1008 from MITx/ie8patch
merge to master
parents
f6a56a19
7f4bb63d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
172 additions
and
137 deletions
+172
-137
common/djangoapps/pipeline_mako/templates/static_content.html
+1
-2
common/lib/xmodule/xmodule/js/src/capa/schematic.js
+71
-62
lms/djangoapps/courseware/views.py
+1
-0
lms/templates/courseware/courseware.html
+3
-1
lms/templates/courseware/xqa_interface.html
+74
-0
lms/templates/staff_problem_info.html
+22
-72
No files found.
common/djangoapps/pipeline_mako/templates/static_content.html
View file @
6212507b
...
...
@@ -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:
...
...
common/lib/xmodule/xmodule/js/src/capa/schematic.js
View file @
6212507b
...
...
@@ -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,23 +3339,28 @@ schematic = (function() {
}
// add method to canvas to compute relative coords for event
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
}
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -3718,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
.
getElementsByClassName
(
'
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...
...
...
@@ -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
)
{
...
...
lms/djangoapps/courseware/views.py
View file @
6212507b
...
...
@@ -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
)
...
...
lms/templates/courseware/courseware.html
View file @
6212507b
...
...
@@ -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"
>
...
...
lms/templates/courseware/xqa_interface.html
0 → 100644
View file @
6212507b
<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
lms/templates/staff_problem_info.html
View file @
6212507b
${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
});
}
setup_debug_$
{
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
;
};
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>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment