-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug #6, add "survey-end" Javascript PHP; BOS piping [iet:10171030][ie…
…t:10171110] * BOS survey piping - pass "return-code" (x1) parameter in, * And, process "return-code" in "survey-end" JS
- Loading branch information
Showing
9 changed files
with
199 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/*! | ||
OU-OpenID. © Nick Freear, 03-Oct-2017. © The Open University. | ||
*/ | ||
|
||
/* eslint camelcase: 0 */ | ||
|
||
// https://moodle.ouuk.tesla-project.eu/survey-end/?from=pre-survey&returncode=VR&embed=1 | ||
|
||
window.jQuery(function ($) { | ||
'use strict'; | ||
|
||
var L = window.location; | ||
var m_from = L.search.match(/from=((pre|post)-?survey)/); | ||
var m_code = L.search.match(/return-?code=(return-code-)?(\w+)/); | ||
var source = m_from ? m_from[ 1 ] : null; | ||
var code = m_code ? m_code[ 2 ].toLowerCase() : null; | ||
|
||
var config = getConfig('#survey-end-config'); | ||
var redirect = config.redirects[ code ] || null; | ||
|
||
$('body').addClass(inIframe() ? 'is-embed' : 'not-embed'); | ||
|
||
console.warn(source, code, config); | ||
console.warn(inIframe() ? 'is-embed' : 'not-embed'); | ||
|
||
if (inIframe() && redirect) { | ||
$('body').addClass('redirect'); | ||
|
||
console.warn('Redirecting:', redirect.url); | ||
|
||
window.setTimeout(function () { | ||
window.location = redirect.url; | ||
}, config.timeout || 500); | ||
} else { | ||
$('body').addClass('no-redirect'); | ||
|
||
console.error('No-redirect. Is "returncode" URL parameter present and correct?'); | ||
} | ||
|
||
// https://stackoverflow.com/questions/326069/how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe-or-directly-into-t | ||
function inIframe () { | ||
try { | ||
return window.self !== window.top || window.location.test(/&embed=/); | ||
} catch (e) { | ||
return true; | ||
} | ||
} | ||
|
||
function getConfig(selector) { | ||
return JSON.parse($(selector).text()); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
/** | ||
* OU-OpenID SURVEY-END. | ||
* | ||
* @package auth_ouopenid | ||
* @author Nick Freear, 03-October-2017, 08:07. | ||
* @copyright (c) 2017 The Open University. | ||
*/ | ||
|
||
// For 'print_string()' language support! | ||
require_once __DIR__ . '/../../../config.php'; | ||
|
||
define( 'OUOP_STRING', 'auth_ouopenid' ); | ||
|
||
// TODO: check if plugin is enabled or not !! | ||
|
||
class Ou_Open_Id_Survey_End { | ||
|
||
const JQUERY_URL = 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js'; | ||
|
||
public static function versionParam() { | ||
echo '?r=' . mt_rand(11, 9999); | ||
} | ||
|
||
public static function checkMaintenanceMode() { | ||
global $CFG; | ||
header('X-auth-ouopenid-maintain: ' . $CFG->maintenance_enabled); | ||
|
||
if ($CFG->maintenance_enabled && ! filter_input(INPUT_GET, 'admin')) { | ||
header('Location: '. $CFG->wwwroot, true, 302); | ||
} | ||
} | ||
} | ||
Ou_Open_Id_Survey_End::checkMaintenanceMode(); | ||
|
||
|
||
header('Content-Language: en'); | ||
header('X-Frame-Options: sameorigin'); | ||
header('X-UA-Compatible: IE=edge'); | ||
|
||
?> | ||
<!doctype html><html lang="en"><meta charset="utf-8" /> | ||
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<meta name="robots" content="noindex, nofollow" /> | ||
|
||
<title><?php // print_string( 'survey_end_title', OUOP_STRING ) ?> (survey-end)</title> | ||
|
||
<link rel="X-stylesheet" href="/auth/ouopenid/style/login.css" /> | ||
<style> | ||
body { | ||
background-color: #fff; | ||
color: #222; | ||
font: 1.1em sans-serif; | ||
line-height: 1.4em; | ||
margin: 2em auto; | ||
max-width: 40em; | ||
X-min-width: 26em; | ||
} | ||
.X-is-embed { margin: 2px; } | ||
.is_embed .footer { display: none; } | ||
</style> | ||
|
||
<body class="survey-end-page"> | ||
|
||
<div> | ||
|
||
<div class="survey-end-msg"> | ||
<?php // print_string( 'survey_end_msg', OUOP_STRING ) ?> | ||
|
||
<p> Thank you for completing the survey. | ||
<p> Redirecting ... | ||
</div> | ||
|
||
|
||
<p class="footer"><small> | ||
<a href="<?php print_string( 'login_footer_link', OUOP_STRING ) ?>" | ||
><?php print_string( 'login_footer', OUOP_STRING ) ?></a>. | ||
</small></p> | ||
|
||
</div> | ||
|
||
|
||
<script id="survey-end-config" type="application/json"> | ||
<?php | ||
echo json_encode([ | ||
'redirects' => $CFG->auth_ouopenid_redirects, | ||
'timeout' => 3000, | ||
'other' => 1, | ||
]); | ||
?> | ||
</script> | ||
|
||
|
||
<script src="<?php echo Ou_Open_Id_Survey_End::JQUERY_URL ?>"></script> | ||
<script src="/auth/ouopenid/user/ouop-analytics.js<?php Ou_Open_Id_Survey_End::versionParam() ?>"></script> | ||
<script src="/auth/ouopenid/js/survey-end.js<?php Ou_Open_Id_Survey_End::versionParam() ?>"></script> | ||
<script> | ||
OUOP.analytics($, { config: { ga: <?php echo json_encode($CFG->auth_ouopenid_js_config[ 'ga' ]) ?> } }); | ||
</script> | ||
</body> | ||
</html> |