Skip to content

Commit

Permalink
Bug #6, add random part to test-email; local-fixes JS [iet:10247186]
Browse files Browse the repository at this point in the history
* Plus, fixes to `tesla-db` PHP CLI script; LESS styles
  • Loading branch information
nfreear committed Oct 26, 2017
1 parent 399d07d commit 57a092e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 10 deletions.
17 changes: 15 additions & 2 deletions bin/tesla-db.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
$user = $DB->get_record( 'user', [ 'username' => UNAME_PREFIX . $oucu ]);

if ( ! $user ) {
cli_error( 'Error. Invalid <OUCU> parameter', 1 );
cli_error( 'Warning. User not found or Invalid <OUCU> argument: ' . $oucu, 1 );
}

print_r([ $user->id, $user->username, FLAG_DELETE ]);
Expand All @@ -48,7 +48,8 @@
$tesla_data = $DB->get_records( DB_PREFIX . $table, [ 'userid' => $user->id ]);

cli_writeln( 'Table: ' . DB_PREFIX . $table );
print_r( $tesla_data );

echo process_tesla_data( $tesla_data );
}

if ( ! FLAG_DELETE ) {
Expand All @@ -74,4 +75,16 @@
cli_error( 'Cancel delete.', 1 );
}

function process_tesla_data( $tesla_data ) {

foreach ( $tesla_data as $row ) {
if ( isset( $row->timecreated ) ) {
$row->timecreated_iso = date( 'c', $row->timecreated );
}
}
$output = print_r( $tesla_data, $return = true );

return preg_replace('/;base64,[^=]+/', ';base64, [...] ', $output);
}

// End.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iet-ou/moodle-auth-ouopenid",
"description": "This plugin is a wrapper around the OpenID authentication plugin for Moodle. ©The Open University.",
"description": "This plugin is a wrapper around the OpenID authentication plugin for Moodle. © The Open University.",
"homepage": "https://github.com/IET-OU",
"type": "moodle-auth",
"license": "proprietary",
Expand All @@ -27,7 +27,8 @@
"bin": [
"bin/ouop-query.php",
"bin/csv-example.php",
"bin/csv-import.php"
"bin/csv-import.php",
"bin/tesla-db.php"
],
"scripts": {
"write-ignore-xml": [
Expand Down
17 changes: 15 additions & 2 deletions js/src/local-fixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,18 @@ module.exports = function ($, resp) {
fix_enrollment_start_page($);

fix_pilot_fallback_link($, resp);
fix_voice_enrollment_controls($, resp);
fix_voice_enrollment_controls($);

$(window.document).ajaxSuccess(function (ev, xhr, settings) {
if (settings.url.match(/enrollment_ajax.php/)) {
console.warn('> enrollment_ajax:', xhr.responseText, xhr.status, ev.namespace);
}

// console.warn('> ajax:', settings.url, ev, xhr, settings);
})
.ajaxError(function (ev, xhr, settings) {
console.error('Ajax error:', ev, xhr, settings);
});

console.warn('ouop: tesla-local-fixes');
};
Expand All @@ -22,7 +33,7 @@ var tesla_inst_names = {
};
var tesla_inst_url_regex = /&target=(ks|tpt|fa|fr|vr)/;

function fix_voice_enrollment_controls($, resp) {
function fix_voice_enrollment_controls($) {
var $voxcounter = $('.ouop-enroll-vr button#counter');
var $startbutton = $('.ouop-enroll-vr button#start_recording');

Expand All @@ -35,6 +46,8 @@ function fix_voice_enrollment_controls($, resp) {
$voxcounter.attr({ title: 'Voice recording timer' });
$startbutton.attr({ title: 'Start voice recording' });

$startbutton.closest('.row-fluid, .row-floid').addClass('ouop-recorder-row');

console.warn('ouop. fix-voice-enrollment-controls: ', $voxcounter.text());
}, 2000);
}
Expand Down
9 changes: 7 additions & 2 deletions js/src/moodle-user-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ function complete_user_profile_form ($, resp) {
var $inp_email = $form.find('[ name = email ]');
var prof = resp.profile;
var isteam = prof.ouop_is_team;
var brand = resp.config.email_rand;
var email_wrand;

if ($form.length && !$inp_fname.val()) {
// TeSLA plugin uses the email as an ID, so to achieve a "clean-break" add a random number ;).
email_wrand = util.str('testmail', prof.ouop_oucu + ( brand ? '-r' + util.rand() : '' ));

$inp_fname.val(isteam ? prof.ouop_firstname : prof.ouop_oucu);
$inp_lname.val(isteam ? prof.ouop_lastname : 'test');
$inp_email.val(isteam ? prof.ouop_email : util.str('testmail', prof.ouop_oucu));
$inp_email.val(isteam ? prof.ouop_email : email_wrand);
}

C.debug('ouop: complete-user-profile-form');
C.debug('ouop: complete-user-profile-form:', $inp_email.val());
}

function user_profile_form_redirect ($, resp) {
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"version": "2.0.0-beta",
"license": "UNLICENSED",
"main": "js/index.js",
"bin": {
"fix-tesla-tpl": "bin/fix-tesla-tpl.js"
},
"devDependencies": {
"browserify": "^14.4.0",
"browserify-banner": "^1.0.6",
Expand Down
4 changes: 2 additions & 2 deletions style/ouop-styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,15 @@ iframe.ouop-consent-doc {
.col-tesla-status-fa,
.col-tesla-status-fr,
.col-tesla-status-vr {
display: none;
// display: none; // Not needed ?!
}
}

&.ouop-enroll-ks .col-tesla-status-ks,
&.ouop-enroll-fa .col-tesla-status-fa,
&.ouop-enroll-fr .col-tesla-status-fr,
&.ouop-enroll-vr .col-tesla-status-vr {
display: block;
// display: block;
}

// TeSLA consent page.
Expand Down

0 comments on commit 57a092e

Please sign in to comment.