Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
d4e65df2
Commit
d4e65df2
authored
Sep 30, 2015
by
Eloy Lafuente
Browse files
Merge branch 'MDL-49143-master' of
git://github.com/cameron1729/moodle
Note: Fixed small bug in unit test.
parents
5fc9fdd5
07842a38
Changes
2
Hide whitespace changes
Inline
Side-by-side
mod/lti/locallib.php
View file @
d4e65df2
...
...
@@ -362,6 +362,12 @@ function lti_build_request($instance, $typeconfig, $course, $typeid = null, $isl
'context_label'
=>
$course
->
shortname
,
'context_title'
=>
$course
->
fullname
,
);
if
(
!
empty
(
$instance
->
id
))
{
$requestparams
[
'resource_link_id'
]
=
$instance
->
id
;
}
if
(
!
empty
(
$instance
->
resource_link_id
))
{
$requestparams
[
'resource_link_id'
]
=
$instance
->
resource_link_id
;
}
if
(
$course
->
format
==
'site'
)
{
$requestparams
[
'context_type'
]
=
'Group'
;
}
else
{
...
...
@@ -370,7 +376,7 @@ function lti_build_request($instance, $typeconfig, $course, $typeid = null, $isl
}
$placementsecret
=
$instance
->
servicesalt
;
if
(
isset
(
$placementsecret
)
&&
(
$islti2
||
if
(
!
empty
(
$instance
->
id
)
&&
isset
(
$placementsecret
)
&&
(
$islti2
||
$typeconfig
[
'acceptgrades'
]
==
LTI_SETTING_ALWAYS
||
(
$typeconfig
[
'acceptgrades'
]
==
LTI_SETTING_DELEGATE
&&
$instance
->
instructorchoiceacceptgrades
==
LTI_SETTING_ALWAYS
)))
{
...
...
mod/lti/tests/locallib_test.php
View file @
d4e65df2
...
...
@@ -179,6 +179,44 @@ class mod_lti_locallib_testcase extends advanced_testcase {
$this
->
assertEquals
(
'moodle.org//this/is/moodle'
,
lti_get_url_thumbprint
(
'moodle.org/this/is/moodle?foo=bar'
));
}
/*
* Verify that lti_build_request does handle resource_link_id as expected
*/
public
function
test_lti_buid_request_resource_link_id
()
{
$this
->
resetAfterTest
();
self
::
setUser
(
$this
->
getDataGenerator
()
->
create_user
());
$course
=
$this
->
getDataGenerator
()
->
create_course
();
$instance
=
$this
->
getDataGenerator
()
->
create_module
(
'lti'
,
array
(
'intro'
=>
"<p>This</p>
\n
has
\r\n
<p>some</p>
\n
new
\n\r
lines"
,
'introformat'
=>
FORMAT_HTML
,
'course'
=>
$course
->
id
,
));
$typeconfig
=
array
(
'acceptgrades'
=>
1
,
'forcessl'
=>
0
,
'sendname'
=>
2
,
'sendemailaddr'
=>
2
,
'customparameters'
=>
''
,
);
// Normal call, we expect $instance->id to be used as resource_link_id.
$params
=
lti_build_request
(
$instance
,
$typeconfig
,
$course
,
null
);
$this
->
assertSame
(
$instance
->
id
,
$params
[
'resource_link_id'
]);
// If there is a resource_link_id set, it gets precedence.
$instance
->
resource_link_id
=
$instance
->
id
+
99
;
$params
=
lti_build_request
(
$instance
,
$typeconfig
,
$course
,
null
);
$this
->
assertSame
(
$instance
->
resource_link_id
,
$params
[
'resource_link_id'
]);
// With none set, resource_link_id is not set either.
unset
(
$instance
->
id
);
unset
(
$instance
->
resource_link_id
);
$params
=
lti_build_request
(
$instance
,
$typeconfig
,
$course
,
null
);
$this
->
assertArrayNotHasKey
(
'resource_link_id'
,
$params
);
}
/**
* Test lti_build_request's resource_link_description and ensure
* that the newlines in the description are correct.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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