Skip to content

Commit

Permalink
Bug #6, pre-launch fixes, survey-end handler, JS [iet:10264876]
Browse files Browse the repository at this point in the history
* survey-end.js ~ Fix / extend Javascript redirection;
* survey-end/index.php ~~ Fix / extend text strings, CSS styles;
* ouop-utils.js ~ Fix to `set_course_name()` Javascript function;
* survey-embed-link.js ~ Fix `inject_post_activity_survey_link()` JS function;
* lang/en/auth_ouopenid.php ~ New / modified language strings;
  • Loading branch information
nfreear committed Nov 8, 2017
1 parent c6ad8ed commit e802393
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 21 deletions.
2 changes: 1 addition & 1 deletion js/src/ouop-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
},

set_course_name: function ($, resp) {
var $course_name = $('.path-course-view, .path-mod-page').find('.breadcrumb-item a[ href *= "course/view.php" ]').first(); // .find('a[ data-key = coursehome ]');
var $course_name = $('.path-course-view, .path-mod').find('.breadcrumb-item a[ href *= "course/view.php" ]').first(); // .XX-path-mod-page,
var course_code = $course_name.text();

resp.course_code = course_code || null;
Expand Down
9 changes: 5 additions & 4 deletions js/src/survey-embed-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,22 @@ function fix_pilot_survey_links ($, resp) {
}

function inject_post_activity_survey_link ($, resp) {
var $container_quiz_rev = $('#page-mod-quiz-review #user-notifications');
// var $container_quiz_rev = $('#page-mod-quiz-review #user-notifications');
var $container_quiz = $('#page-mod-quiz-view');
var $container_assign = $('#page-mod-assign-view');
var survey_url = resp.survey_urls.post.replace('{OUCU}', resp.profile.ouop_oucu);
var survey_url = resp.survey_urls[ resp.course_code ].post.replace('{OUCU}', resp.profile.ouop_oucu);
var util = resp.util;

$container_quiz_rev.append(util.alert(util.str('post_survey_msg', survey_url)));
// $container_quiz_rev.append(util.alert(util.str('post_survey_msg', survey_url)));

if ($container_assign.find('.submissionstatussubmitted').length) {
$container_assign.find('#user-notifications').append(util.alert(util.str('post_survey_msg', survey_url)));
$container_assign.addClass('ouop-submitted');

C.warn('ouop: post-activity-survey-link - assign');
} else if ($container_quiz.find('.quizattemptsummary').length) {
$container_quiz.find('#user-notifications').append(util.alert(util.str('post_survey_msg', survey_url)));

$container_quiz.find('.box.quizattempt').after(util.alert(util.str('post_survey_msg', survey_url)));
$container_quiz.addClass('ouop-submitted');

C.warn('ouop: post-activity-survey-link - quiz-view');
Expand Down
24 changes: 17 additions & 7 deletions js/survey-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,40 @@ window.jQuery(function ($) {

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 m_code = L.search.match(/return-?code=(?:return-code-)?(?:\d-)?(\w+)/);
var source = m_from ? m_from[ 1 ] : null;
var code = m_code ? m_code[ 2 ].toLowerCase() : null;
var code = m_code ? m_code[ 1 ].toLowerCase() : null;

var config = getConfig('#survey-end-config');
var redirect = config.redirects[ code ] || null;

$('body').addClass(inIframe() ? 'is-embed' : 'not-embed');
$('body')
.addClass(inIframe() ? 'is-embed' : 'not-embed')
.addClass('from-' + source);

console.warn(source, code, config);
console.warn(inIframe() ? 'is-embed' : 'not-embed');

if (inIframe() && redirect) {
if (/*inIframe() &&*/ source === 'pre-survey' && redirect) {
$('body').addClass('redirect');

console.warn('Redirecting:', redirect.url);
console.warn('ouop. Redirecting:', redirect.url);

window.setTimeout(function () {
window.location = redirect.url;
window.location = redirect.url + config.hash;
}, config.timeout || 500);
} else {
$('body').addClass('no-redirect');

console.error('No-redirect. Is "returncode" URL parameter present and correct?');
if (source !== 'post-survey') {
console.error('No-redirect. Is "returncode" URL parameter present and correct?');
}
}

if (source === 'post-survey') {
console.warn('ouop. The end.');

$('title').text('The end');
}

// https://stackoverflow.com/questions/326069/how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe-or-directly-into-t
Expand Down
14 changes: 11 additions & 3 deletions lang/en/auth_ouopenid.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,17 @@
$string[ 'login_submit' ] = 'Sign in';
$string[ 'login_footer' ] = '© 2017 The Open University';
$string[ 'login_footer_link' ] = 'https://www.open.ac.uk/';
$string[ 'survey_end_title' ] = 'Redirecting ';

$string[ 'survey_end_title' ] =
$string[ 'survey_end_title_pre' ] = 'Redirecting to activity …';
$string[ 'survey_end_title_post' ] = 'The end';
$string[ 'survey_end_msg' ] =
'<p>Thank you for completing the survey.
<p> Redirecting ...';
$string[ 'survey_end_msg_pre' ] =
'<p> Thank you for completing the survey.
<p> Redirecting to activity &hellip;';
$string[ 'survey_end_msg_post' ] =
'<p> Thank you for completing the survey.
<p> The end.
<p> You can close your browser window or tab.';

// End.
24 changes: 18 additions & 6 deletions survey-end/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function checkMaintenanceMode() {
<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>
<title><?php print_string( 'survey_end_title', OUOP_STRING ) ?> (survey-end)</title>

<link rel="X-stylesheet" href="/auth/ouopenid/style/login.css" />
<style>
Expand All @@ -54,22 +54,33 @@ public static function checkMaintenanceMode() {
font: 1.1em sans-serif;
line-height: 1.4em;
margin: 2em auto;
max-width: 40em;
max-width: 33em;
X-min-width: 26em;
}
.footer { margin-top: 2em; }
.X-is-embed { margin: 2px; }
.is_embed .footer { display: none; }
.X-is-embed .footer { display: none; }
.from-pre-survey .post-survey-msg,
.from-post-survey .pre-survey-msg { display: none; }
</style>

<body class="survey-end-page">

<div>

<div class="survey-end-msg">
<?php // print_string( 'survey_end_msg', OUOP_STRING ) ?>
<div class="survey-end-msg pre-survey-msg">
<?php print_string( 'survey_end_msg', OUOP_STRING ) ?>

<!--
<p> Thank you for completing the survey.
<p> Redirecting ...
<p> Redirecting to activity &hellip;
-->
</div>

<div class="survey-end-msg post-survey-msg">
<p> Thank you for completing the survey.
<p> The end.
<p> You can close your browser window or tab.
</div>


Expand All @@ -85,6 +96,7 @@ public static function checkMaintenanceMode() {
<?php
echo json_encode([
'redirects' => $CFG->auth_ouopenid_redirects,
'hash' => '#section-3',
'timeout' => 3000,
'other' => 1,
]);
Expand Down

0 comments on commit e802393

Please sign in to comment.