Skip to content
Snippets Groups Projects
Commit 9739e627 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

fixes #3428

Closes #3428

Merge request studip/studip!2330
parent 0d563b32
No related branches found
No related tags found
No related merge requests found
...@@ -78,11 +78,14 @@ class Course_LtiController extends StudipController ...@@ -78,11 +78,14 @@ class Course_LtiController extends StudipController
/** /**
* Display the launch form for a tool as an iframe. * Display the launch form for a tool as an iframe.
*/ */
public function iframe_action() public function iframe_action(string $position)
{ {
$this->launch_url = Request::get('launch_url'); $lti_data = LtiData::findByCourseAndPosition($this->course_id, $position);
$this->launch_data = Request::getArray('launch_data'); $lti_link = $this->getLtiLink($lti_data);
$this->signature = Request::get('signature');
$this->launch_url = $lti_data->getLaunchURL();
$this->launch_data = $lti_link->getBasicLaunchData();
$this->signature = $lti_link->getLaunchSignature($this->launch_data);
$this->set_layout(null); $this->set_layout(null);
} }
......
<?php
/**
* @var string $launch_url
* @var array $launch_data
* @var string $signature
*/
?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
......
<?php
/**
* @var Course_LtiController $controller
* @var LtiData[] $lti_data_array
* @var bool $edit_perm
*/
?>
<? if (empty($lti_data_array)): ?> <? if (empty($lti_data_array)): ?>
<?= MessageBox::info(_('Es wurden noch keine Inhalte angelegt.')) ?> <?= MessageBox::info(_('Es wurden noch keine Inhalte angelegt.')) ?>
<? endif ?> <? endif ?>
<? foreach ($lti_data_array as $lti_data): ?> <? foreach ($lti_data_array as $lti_data): ?>
<? $launch_url = $lti_data->getLaunchURL() ?> <? $launch_url = $lti_data->getLaunchURL() ?>
<? if ($launch_url): ?>
<? $lti_link = $controller->getLtiLink($lti_data) ?>
<? $launch_data = $lti_link->getBasicLaunchData() ?>
<? $signature = $lti_link->getLaunchSignature($launch_data) ?>
<? endif ?>
<article class="studip"> <article class="studip">
<header> <header>
...@@ -47,20 +49,19 @@ ...@@ -47,20 +49,19 @@
<section> <section>
<?= formatReady($lti_data->description) ?> <?= formatReady($lti_data->description) ?>
<? if ($launch_url && $lti_data->options['document_target'] == 'iframe'): ?> <? if ($launch_url && $lti_data->options['document_target'] === 'iframe'): ?>
<iframe style="border: none; height: 640px; width: 100%;" <iframe style="border: none; height: 640px; width: 100%;"
src="<?= $controller->link_for('course/lti/iframe', compact('launch_url', 'launch_data', 'signature')) ?>"></iframe> src="<?= $controller->link_for('course/lti/iframe', $lti_data->position) ?>"></iframe>
<? endif ?> <? endif ?>
</section> </section>
<? if ($launch_url && $lti_data->options['document_target'] != 'iframe'): ?> <? if ($launch_url && $lti_data->options['document_target'] !== 'iframe'): ?>
<footer> <footer>
<form class="default" action="<?= htmlReady($launch_url) ?>" method="post" target="_blank"> <?= Studip\LinkButton::create(
<? foreach ($launch_data as $key => $value): ?> _('Anwendung starten'),
<input type="hidden" name="<?= htmlReady($key) ?>" value="<?= htmlReady($value, false) ?>"> $controller->link_for('course/lti/iframe', $lti_data->position),
<? endforeach ?> ['target' => '_blank']
<?= Studip\Button::create(_('Anwendung starten'), 'oauth_signature', ['value' => $signature]) ?> ) ?>
</form>
</footer> </footer>
<? endif ?> <? endif ?>
</article> </article>
......
...@@ -56,6 +56,8 @@ class LtiData extends SimpleORMap ...@@ -56,6 +56,8 @@ class LtiData extends SimpleORMap
/** /**
* Find a single entry by course_id and position. * Find a single entry by course_id and position.
*
* @return static|null
*/ */
public static function findByCourseAndPosition($course_id, $position) public static function findByCourseAndPosition($course_id, $position)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment