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
67463da0
Commit
67463da0
authored
Oct 02, 2013
by
Valera Rozuvan
Committed by
polesye
Oct 14, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated Jasmine tests as per Anton's and Alex's suggestions.
parent
a03c5be6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
69 additions
and
182 deletions
+69
-182
common/lib/xmodule/xmodule/js/fixtures/lti.html
+1
-3
common/lib/xmodule/xmodule/js/fixtures/lti_iframe_url_default.html
+0
-36
common/lib/xmodule/xmodule/js/fixtures/lti_iframe_url_new.html
+0
-37
common/lib/xmodule/xmodule/js/fixtures/lti_newpage_url_default.html
+0
-36
common/lib/xmodule/xmodule/js/fixtures/lti_newpage_url_empty.html
+0
-36
common/lib/xmodule/xmodule/js/spec/lti/constructor.js
+44
-12
common/lib/xmodule/xmodule/js/src/lti/lti.js
+24
-22
No files found.
common/lib/xmodule/xmodule/js/fixtures/lti
_newpage_url_new
.html
→
common/lib/xmodule/xmodule/js/fixtures/lti.html
View file @
67463da0
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<div
id=
"lti_id"
class=
"lti"
data-open_in_a_new_page=
"true"
>
<div
id=
"lti_id"
class=
"lti"
data-open_in_a_new_page=
"true"
>
<form
<form
action=
"
http://www.example.com/some_book
"
action=
""
name=
"ltiLaunchForm"
name=
"ltiLaunchForm"
class=
"ltiLaunchForm"
class=
"ltiLaunchForm"
method=
"post"
method=
"post"
...
@@ -27,7 +27,5 @@
...
@@ -27,7 +27,5 @@
<input
type=
"submit"
value=
"Press to Launch"
/>
<input
type=
"submit"
value=
"Press to Launch"
/>
</form>
</form>
<a
href=
"#"
class=
'link_lti_new_window'
>
Click to view LTI in new window
</a>
</div>
</div>
</div>
</div>
common/lib/xmodule/xmodule/js/fixtures/lti_iframe_url_default.html
deleted
100644 → 0
View file @
a03c5be6
<div
class=
"lti-wrapper"
>
<div
id=
"lti_id"
class=
"lti"
data-open_in_a_new_page=
"false"
>
<form
action=
"http://www.example.com"
name=
"ltiLaunchForm"
class=
"ltiLaunchForm"
method=
"post"
target=
"ltiLaunchFrame"
enctype=
"application/x-www-form-urlencoded"
>
<input
name=
"launch_presentation_return_url"
value=
""
/>
<input
name=
"lti_version"
value=
"LTI-1p0"
/>
<input
name=
"user_id"
value=
"student"
/>
<input
name=
"oauth_nonce"
value=
"28347958723982798572"
/>
<input
name=
"oauth_timestamp"
value=
"2389479832"
/>
<input
name=
"oauth_consumer_key"
value=
""
/>
<input
name=
"lis_result_sourcedid"
value=
""
/>
<input
name=
"oauth_signature_method"
value=
"HMAC-SHA1"
/>
<input
name=
"oauth_version"
value=
"1.0"
/>
<input
name=
"role"
value=
"student"
/>
<input
name=
"lis_outcome_service_url"
value=
""
/>
<input
name=
"oauth_signature"
value=
"89ru3289r3ry283y3r82ryr38yr"
/>
<input
name=
"lti_message_type"
value=
"basic-lti-launch-request"
/>
<input
name=
"oauth_callback"
value=
"about:blank"
/>
<input
type=
"submit"
value=
"Press to Launch"
/>
</form>
<h3
class=
"error_message"
>
Please provide launch_url. Click "Edit", and fill in the
required fields.
</h3>
</div>
</div>
common/lib/xmodule/xmodule/js/fixtures/lti_iframe_url_new.html
deleted
100644 → 0
View file @
a03c5be6
<div
class=
"lti-wrapper"
>
<div
id=
"lti_id"
class=
"lti"
data-open_in_a_new_page=
"false"
>
<form
action=
"http://www.example.com/some_book"
name=
"ltiLaunchForm"
class=
"ltiLaunchForm"
method=
"post"
target=
"ltiLaunchFrame"
enctype=
"application/x-www-form-urlencoded"
>
<input
name=
"launch_presentation_return_url"
value=
""
/>
<input
name=
"lti_version"
value=
"LTI-1p0"
/>
<input
name=
"user_id"
value=
"student"
/>
<input
name=
"oauth_nonce"
value=
"28347958723982798572"
/>
<input
name=
"oauth_timestamp"
value=
"2389479832"
/>
<input
name=
"oauth_consumer_key"
value=
""
/>
<input
name=
"lis_result_sourcedid"
value=
""
/>
<input
name=
"oauth_signature_method"
value=
"HMAC-SHA1"
/>
<input
name=
"oauth_version"
value=
"1.0"
/>
<input
name=
"role"
value=
"student"
/>
<input
name=
"lis_outcome_service_url"
value=
""
/>
<input
name=
"oauth_signature"
value=
"89ru3289r3ry283y3r82ryr38yr"
/>
<input
name=
"lti_message_type"
value=
"basic-lti-launch-request"
/>
<input
name=
"oauth_callback"
value=
"about:blank"
/>
<input
type=
"submit"
value=
"Press to Launch"
/>
</form>
<iframe
name=
"ltiLaunchFrame"
class=
"ltiLaunchFrame"
src=
""
></iframe>
</div>
</div>
common/lib/xmodule/xmodule/js/fixtures/lti_newpage_url_default.html
deleted
100644 → 0
View file @
a03c5be6
<div
class=
"lti-wrapper"
>
<div
id=
"lti_id"
class=
"lti"
data-open_in_a_new_page=
"true"
>
<form
action=
"http://www.example.com"
name=
"ltiLaunchForm"
class=
"ltiLaunchForm"
method=
"post"
target=
"_blank"
enctype=
"application/x-www-form-urlencoded"
>
<input
name=
"launch_presentation_return_url"
value=
""
/>
<input
name=
"lti_version"
value=
"LTI-1p0"
/>
<input
name=
"user_id"
value=
"student"
/>
<input
name=
"oauth_nonce"
value=
"28347958723982798572"
/>
<input
name=
"oauth_timestamp"
value=
"2389479832"
/>
<input
name=
"oauth_consumer_key"
value=
""
/>
<input
name=
"lis_result_sourcedid"
value=
""
/>
<input
name=
"oauth_signature_method"
value=
"HMAC-SHA1"
/>
<input
name=
"oauth_version"
value=
"1.0"
/>
<input
name=
"role"
value=
"student"
/>
<input
name=
"lis_outcome_service_url"
value=
""
/>
<input
name=
"oauth_signature"
value=
"89ru3289r3ry283y3r82ryr38yr"
/>
<input
name=
"lti_message_type"
value=
"basic-lti-launch-request"
/>
<input
name=
"oauth_callback"
value=
"about:blank"
/>
<input
type=
"submit"
value=
"Press to Launch"
/>
</form>
<h3
class=
"error_message"
>
Please provide launch_url. Click "Edit", and fill in the
required fields.
</h3>
</div>
</div>
common/lib/xmodule/xmodule/js/fixtures/lti_newpage_url_empty.html
deleted
100644 → 0
View file @
a03c5be6
<div
class=
"lti-wrapper"
>
<div
id=
"lti_id"
class=
"lti"
data-open_in_a_new_page=
"true"
>
<form
action=
""
name=
"ltiLaunchForm"
class=
"ltiLaunchForm"
method=
"post"
target=
"_blank"
enctype=
"application/x-www-form-urlencoded"
>
<input
name=
"launch_presentation_return_url"
value=
""
/>
<input
name=
"lti_version"
value=
"LTI-1p0"
/>
<input
name=
"user_id"
value=
"student"
/>
<input
name=
"oauth_nonce"
value=
"28347958723982798572"
/>
<input
name=
"oauth_timestamp"
value=
"2389479832"
/>
<input
name=
"oauth_consumer_key"
value=
""
/>
<input
name=
"lis_result_sourcedid"
value=
""
/>
<input
name=
"oauth_signature_method"
value=
"HMAC-SHA1"
/>
<input
name=
"oauth_version"
value=
"1.0"
/>
<input
name=
"role"
value=
"student"
/>
<input
name=
"lis_outcome_service_url"
value=
""
/>
<input
name=
"oauth_signature"
value=
"89ru3289r3ry283y3r82ryr38yr"
/>
<input
name=
"lti_message_type"
value=
"basic-lti-launch-request"
/>
<input
name=
"oauth_callback"
value=
"about:blank"
/>
<input
type=
"submit"
value=
"Press to Launch"
/>
</form>
<h3
class=
"error_message"
>
Please provide launch_url. Click "Edit", and fill in the
required fields.
</h3>
</div>
</div>
common/lib/xmodule/xmodule/js/spec/lti/constructor.js
View file @
67463da0
...
@@ -25,16 +25,48 @@
...
@@ -25,16 +25,48 @@
*/
*/
(
function
()
{
(
function
()
{
var
element
,
form
,
frame
,
link
;
var
element
,
container
,
form
,
link
,
IN_NEW_WINDOW
=
'true'
,
IN_IFRAME
=
'false'
,
EMPTY_URL
=
''
,
DEFAULT_URL
=
'http://www.example.com'
,
NEW_URL
=
'http://www.example.com/some_book'
;
function
initialize
(
fixture
,
hasLink
)
{
function
initialize
(
target
,
action
)
{
loadFixtures
(
fixture
);
var
tempEl
;
loadFixtures
(
'lti.html'
);
element
=
$
(
'.lti-wrapper'
);
element
=
$
(
'.lti-wrapper'
);
if
(
hasLink
)
{
container
=
element
.
find
(
'.lti'
);
link
=
element
.
find
(
'a.link_lti_new_window'
);
form
=
container
.
find
(
'.ltiLaunchForm'
);
if
(
target
===
IN_IFRAME
)
{
container
.
data
(
'open_in_a_new_page'
,
'false'
);
form
.
attr
(
'target'
,
'ltiLaunchFrame'
);
}
form
.
attr
(
'action'
,
action
);
// If we have a new proper action (non-default), we create either
// a link that will submit the form, or an iframe that will contain
// the answer of auto submitted form.
if
(
action
!==
EMPTY_URL
&&
action
!==
DEFAULT_URL
)
{
if
(
target
===
IN_NEW_WINDOW
)
{
$
(
'<a />'
,
{
href
:
'#'
,
class
:
'link_lti_new_window'
}).
appendTo
(
container
);
link
=
container
.
find
(
'.link_lti_new_window'
);
}
else
{
$
(
'<iframe />'
,
{
name
:
'ltiLaunchFrame'
,
class
:
'ltiLaunchFrame'
,
src
:
''
}).
appendTo
(
container
);
}
}
}
form
=
element
.
find
(
'.ltiLaunchForm'
);
spyOnEvent
(
form
,
'submit'
);
spyOnEvent
(
form
,
'submit'
);
...
@@ -48,7 +80,7 @@
...
@@ -48,7 +80,7 @@
function
()
{
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
initialize
(
'lti_newpage_url_empty.html'
);
initialize
(
IN_NEW_WINDOW
,
EMPTY_URL
);
});
});
it
(
'form is not submitted'
,
function
()
{
it
(
'form is not submitted'
,
function
()
{
...
@@ -61,7 +93,7 @@
...
@@ -61,7 +93,7 @@
function
()
{
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
initialize
(
'lti_newpage_url_default.html'
);
initialize
(
IN_NEW_WINDOW
,
DEFAULT_URL
);
});
});
it
(
'form is not submitted'
,
function
()
{
it
(
'form is not submitted'
,
function
()
{
...
@@ -75,7 +107,7 @@
...
@@ -75,7 +107,7 @@
function
()
{
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
initialize
(
'lti_newpage_url_new.html'
,
true
);
initialize
(
IN_NEW_WINDOW
,
NEW_URL
);
});
});
it
(
'form is not submitted'
,
function
()
{
it
(
'form is not submitted'
,
function
()
{
...
@@ -94,7 +126,7 @@
...
@@ -94,7 +126,7 @@
function
()
{
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
initialize
(
'lti_iframe_url_empty.html'
);
initialize
(
IN_IFRAME
,
EMPTY_URL
);
});
});
it
(
'form is not submitted'
,
function
()
{
it
(
'form is not submitted'
,
function
()
{
...
@@ -107,7 +139,7 @@
...
@@ -107,7 +139,7 @@
function
()
{
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
initialize
(
'lti_iframe_url_default.html'
);
initialize
(
IN_IFRAME
,
DEFAULT_URL
);
});
});
it
(
'form is not submitted'
,
function
()
{
it
(
'form is not submitted'
,
function
()
{
...
@@ -121,7 +153,7 @@
...
@@ -121,7 +153,7 @@
function
()
{
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
initialize
(
'lti_iframe_url_new.html'
);
initialize
(
IN_IFRAME
,
NEW_URL
);
});
});
it
(
'form is submitted'
,
function
()
{
it
(
'form is submitted'
,
function
()
{
...
...
common/lib/xmodule/xmodule/js/src/lti/lti.js
View file @
67463da0
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*
*
* 1.) Submit the form. The results will be shown on the current page in an
* 1.) Submit the form. The results will be shown on the current page in an
* iframe.
* iframe.
* 2.)
a
ttach a handler function to a link which will submit the form. The
* 2.)
A
ttach a handler function to a link which will submit the form. The
* results will be shown in a new window.
* results will be shown in a new window.
*
*
* The 'open_in_a_new_page' data attribute of the LTI element dictates which of
* The 'open_in_a_new_page' data attribute of the LTI element dictates which of
...
@@ -32,8 +32,12 @@ window.LTI = (function () {
...
@@ -32,8 +32,12 @@ window.LTI = (function () {
// Function initialize(element)
// Function initialize(element)
//
//
// Initialize the LTI module.
// Initialize the LTI module.
//
// @param element DOM element, or jQuery element object.
//
// @return undefined
function
initialize
(
element
)
{
function
initialize
(
element
)
{
var
form
,
open
_in_a_new_page
;
var
form
,
open
InANewPage
,
formAction
;
// In cms (Studio) the element is already a jQuery object. In lms it is
// In cms (Studio) the element is already a jQuery object. In lms it is
// a DOM object.
// a DOM object.
...
@@ -43,37 +47,35 @@ window.LTI = (function () {
...
@@ -43,37 +47,35 @@ window.LTI = (function () {
element
=
$
(
element
);
element
=
$
(
element
);
form
=
element
.
find
(
'.ltiLaunchForm'
);
form
=
element
.
find
(
'.ltiLaunchForm'
);
formAction
=
form
.
attr
(
'action'
);
if
(
// If action is empty string, or action is the default URL that should
// Action is one of: null, undefined, 0, 000, '', false
.
// not cause a form submit
.
!
Boolean
(
form
.
attr
(
'action'
))
||
if
(
!
formAction
||
formAction
===
'http://www.example.com'
)
{
// Default URL that should not cause a form submit.
// Nothing to do - no valid action provided. Error message will be
form
.
attr
(
'action'
)
===
'http://www.example.com'
// displaced in browser (HTML).
)
{
return
;
return
;
// Nothing to do - no valid action provided.
}
}
// We want a Boolean 'true' or 'false'. First we will retrieve the data
// We want a Boolean 'true' or 'false'. First we will retrieve the data
// attribute, and then we will parse it via native JSON.parse().
// attribute, and then we will parse it via native JSON.parse().
open_in_a_new_page
=
element
.
find
(
'.lti'
).
data
(
'open_in_a_new_page'
);
openInANewPage
=
element
.
find
(
'.lti'
).
data
(
'open_in_a_new_page'
);
try
{
openInANewPage
=
JSON
.
parse
(
openInANewPage
);
open_in_a_new_page
=
JSON
.
parse
(
open_in_a_new_page
);
}
catch
(
e
)
{
console
.
log
(
'ERROR: Parsing data attribute "open_in_a_new_page".'
);
console
.
log
(
'*** error = "'
+
e
.
toString
()
+
'".'
);
open_in_a_new_page
=
null
;
}
// If the Form's action attribute is set (i.e. we can perform a normal
// If the Form's action attribute is set (i.e. we can perform a normal
// submit), then we
submit the form immediately or when user will click
// submit), then we
(depending on instance settings) submit the form
//
on a link (depending on instance settings) and make the frame shown
.
//
when user will click on a link, or submit the form immediately
.
if
(
open
_in_a_new_p
age
===
true
)
{
if
(
open
InANewP
age
===
true
)
{
element
.
find
(
'.link_lti_new_window'
).
on
(
'click'
,
function
()
{
element
.
find
(
'.link_lti_new_window'
).
on
(
'click'
,
function
()
{
form
.
submit
();
form
.
submit
();
});
});
}
else
if
(
open_in_a_new_page
===
false
)
{
}
else
{
// At this stage the form exists on the page and has a valid
// action. We are safe to submit it, even if `openInANewPage` is
// set to some weird value.
//
// Best case scenario is that `openInANewPage` is set to `true`.
form
.
submit
();
form
.
submit
();
}
}
}
}
...
...
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