Skip to content

Commit

Permalink
Merge branch 'uhm-coe-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakeii committed Apr 7, 2018
2 parents 0607345 + ac29eeb commit bdc4cd1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
5 changes: 3 additions & 2 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ function h5pxapi_get_auth_settings() {
$settings=array(
"endpoint_url"=>get_option("h5pxapi_endpoint_url"),
"username"=>get_option("h5pxapi_username"),
"password"=>get_option("h5pxapi_password")
"password"=>get_option("h5pxapi_password"),
"alerts" => get_option("h5pxapi_alerts"),
);
}

return $settings;
}
}
2 changes: 1 addition & 1 deletion process-xapi-statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
&& !$statementObject["context"]["extensions"])
unset($statementObject["context"]["extensions"]);

if (has_filter("h5p-xapi-pre-save")) {
if ( has_filter("h5p-xapi-pre-save")) {
$statementObject=apply_filters("h5p-xapi-pre-save",$statementObject);

if (!$statementObject) {
Expand Down
8 changes: 8 additions & 0 deletions src/template/settings.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ class="regular-text"/>
class="regular-text"/>
</td>
</tr>
<tr valign="top">
<th scope="row">Alerts On <small>(un-checking will make debug statements happen to console instead of alert)</small></th>
<td>
<input type="checkbox" name="h5pxapi_alerts"
<?php echo (get_option("h5pxapi_alerts") == "on" )? 'checked="checked"' : ''; ?> />

</td>
</tr>
</table>

<?php submit_button(); ?>
Expand Down
9 changes: 6 additions & 3 deletions wp-h5p-xapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ jQuery(function($) {
*/
function showError(message, code) {
console.error("Unable to save xAPI statement");

alert("Unable to save result data.\n\nMessage: " + message + "\n" + "Code: " + code);
if( xapi_settings.alerts == true ){
alert("Unable to save result data.\n\nMessage: " + message + "\n" + "Code: " + code);
} else {
console.log("Unable to save result data.\n\nMessage: " + message + "\n" + "Code: " + code);
}
}

/**
Expand Down Expand Up @@ -124,4 +127,4 @@ jQuery(function($) {
$("body").append("<div id='wp-h5p-xapi-spinner'>Saving...</div>");
$("#wp-h5p-xapi-spinner").hide();
});
});
});
14 changes: 9 additions & 5 deletions wp-h5p-xapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/**
* Enqueue scripts and stylesheets.
*/

function h5pxapi_enqueue_scripts()
{
wp_register_script("wp-h5p-xapi", plugins_url() . "/wp-h5p-xapi/wp-h5p-xapi.js", array("jquery"));
Expand Down Expand Up @@ -45,6 +46,7 @@ function h5pxapi_enqueue_scripts()
}

wp_localize_script('wp-h5p-xapi', 'xapi_settings', $xapi_js_settings);

}

/**
Expand All @@ -68,11 +70,13 @@ function h5pxapi_admin_menu()
/**
* Admin init.
*/
function h5pxapi_admin_init()
{
register_setting("h5pxapi", "h5pxapi_endpoint_url");
register_setting("h5pxapi", "h5pxapi_username");
register_setting("h5pxapi", "h5pxapi_password");

function h5pxapi_admin_init() {
register_setting("h5pxapi","h5pxapi_endpoint_url");
register_setting("h5pxapi","h5pxapi_username");
register_setting("h5pxapi","h5pxapi_password");
register_setting("h5pxapi", "h5pxapi_alerts");

}

/**
Expand Down

0 comments on commit bdc4cd1

Please sign in to comment.