Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Moodle Filter Opencast
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
Moodle Filter Opencast
Commits
7b364303
Commit
7b364303
authored
7 years ago
by
TamaraGunkel
Browse files
Options
Downloads
Patches
Plain Diff
Created a render function for the form as suggested in #6
parent
ff82234a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib.php
+17
-19
17 additions, 19 deletions
lib.php
renderer.php
+24
-0
24 additions, 0 deletions
renderer.php
with
41 additions
and
19 deletions
lib.php
+
17
−
19
View file @
7b364303
...
...
@@ -30,7 +30,7 @@ require_once($CFG->dirroot . '/lib/oauthlib.php');
* Use lti to login and retrieve cookie from opencast.
*/
function
filter_opencast_login
()
{
global
$
CFG
,
$PAGE
,
$COURSE
,
$USER
;
global
$
PAGE
;
// Get api url of opencast.
$endpoint
=
get_config
(
'tool_opencast'
,
'apiurl'
);
...
...
@@ -39,6 +39,20 @@ function filter_opencast_login() {
}
$endpoint
.
=
'/lti'
;
// Create parameters.
$params
=
filter_opencast_create_parameters
(
$endpoint
);
// Render form.
$renderer
=
$PAGE
->
get_renderer
(
'filter_opencast'
);
echo
$renderer
->
render_player
(
$endpoint
,
$params
);
// Submit form.
$PAGE
->
requires
->
js_call_amd
(
'filter_opencast/form'
,
'init'
);
}
function
filter_opencast_create_parameters
()
{
global
$CFG
,
$COURSE
,
$USER
;
// Get consumerkey and consumersecret.
$consumerkey
=
get_config
(
'filter_opencast'
,
'consumerkey'
);
$consumersecret
=
get_config
(
'filter_opencast'
,
'consumersecret'
);
...
...
@@ -85,21 +99,5 @@ function filter_opencast_login() {
$params
[
'oauth_signature_method'
]
=
'HMAC-SHA1'
;
$params
[
'oauth_signature'
]
=
$helper
->
sign
(
"POST"
,
$endpoint
,
$params
,
$consumersecret
.
'&'
);
$content
=
"<form action=
\"
"
.
urlencode
(
$endpoint
)
.
"
\"
name=
\"
ltiLaunchForm
\"
id=
\"
ltiLaunchForm
\"
method=
\"
post
\"
encType=
\"
application/x-www-form-urlencoded
\"
>
\n
"
;
// Construct html form for the launch parameters.
foreach
(
$params
as
$key
=>
$value
)
{
$key
=
htmlspecialchars
(
$key
);
$value
=
htmlspecialchars
(
$value
);
$content
.
=
"<input type=
\"
hidden
\"
name=
\"
{
$key
}
\"
"
;
$content
.
=
" value=
\"
"
;
$content
.
=
$value
;
$content
.
=
"
\"
/>
\n
"
;
}
$content
.
=
"</form>
\n
"
;
echo
$content
;
// Submit form.
$PAGE
->
requires
->
js_call_amd
(
'filter_opencast/form'
,
'init'
);
return
$params
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
renderer.php
+
24
−
0
View file @
7b364303
...
...
@@ -45,4 +45,28 @@ class filter_opencast_renderer extends plugin_renderer_base {
public
function
render_player
(
$data
)
{
return
$this
->
render_from_template
(
'filter_opencast/player'
,
$data
);
}
/**
* Display the lti form.
*
* @param object $data The prepared variables.
* @return string
*/
public
function
render_lti_form
(
$endpoint
,
$params
)
{
$content
=
"<form action=
\"
"
.
urlencode
(
$endpoint
)
.
"
\"
name=
\"
ltiLaunchForm
\"
id=
\"
ltiLaunchForm
\"
method=
\"
post
\"
encType=
\"
application/x-www-form-urlencoded
\"
>
\n
"
;
// Construct html form for the launch parameters.
foreach
(
$params
as
$key
=>
$value
)
{
$key
=
htmlspecialchars
(
$key
);
$value
=
htmlspecialchars
(
$value
);
$content
.
=
"<input type=
\"
hidden
\"
name=
\"
{
$key
}
\"
"
;
$content
.
=
" value=
\"
"
;
$content
.
=
$value
;
$content
.
=
"
\"
/>
\n
"
;
}
$content
.
=
"</form>
\n
"
;
return
$content
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment