Changeset 1881036
- Timestamp:
- 05/24/2018 07:09:33 PM (8 years ago)
- Location:
- wp-h5p-xapi/trunk
- Files:
-
- 6 edited
-
plugin.php (modified) (1 diff)
-
process-xapi-statement.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
-
src/template/settings.tpl.php (modified) (1 diff)
-
wp-h5p-xapi.js (modified) (4 diffs)
-
wp-h5p-xapi.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-h5p-xapi/trunk/plugin.php
r1358053 r1881036 18 18 "endpoint_url"=>get_option("h5pxapi_endpoint_url"), 19 19 "username"=>get_option("h5pxapi_username"), 20 "password"=>get_option("h5pxapi_password") 20 "password"=>get_option("h5pxapi_password"), 21 "alerts" => get_option("h5pxapi_alerts"), 21 22 ); 22 23 } -
wp-h5p-xapi/trunk/process-xapi-statement.php
r1527353 r1881036 14 14 use h5pxapi\WpUtil; 15 15 16 require_once WpUtil::getWpLoadPath();16 // require_once WpUtil::getWpLoadPath(); 17 17 18 18 $statementObject=json_decode(stripslashes($_REQUEST["statement"]),TRUE); … … 22 22 unset($statementObject["context"]["extensions"]); 23 23 24 if ( has_filter("h5p-xapi-pre-save")) {24 if ( has_filter("h5p-xapi-pre-save")) { 25 25 $statementObject=apply_filters("h5p-xapi-pre-save",$statementObject); 26 26 … … 96 96 } 97 97 98 do_action("h5p-xapi-post-save",$statementObject);98 $h5pxapi_response_message = apply_filters("h5p-xapi-post-save",$statementObject); 99 99 100 100 $response=array( -
wp-h5p-xapi/trunk/readme.txt
r1506632 r1881036 2 2 Contributors: Tunapanda 3 3 Donate link: http://www.tunapanda.org/contribute 4 Tags: xapi, h5p, admin, learning, integration, l ms, learning management system4 Tags: xapi, h5p, admin, learning, integration, lrs, learning management system 5 5 Requires at least: 3.8.1 6 Tested up to: 4. 6.17 Stable tag: trunk6 Tested up to: 4.9.6 7 Stable tag: /Users/jake/projects/svn/wp-h5p-xapi/wp-h5p-xapi/trunk/wp-h5p-xapi.phptrunk 8 8 License: GPLv3 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html 10 10 11 This plugin stores all xAPI statements genera ded by H5P in a remote LRS.11 This plugin stores all xAPI statements generated by H5P in a remote LRS. 12 12 13 13 == Description == -
wp-h5p-xapi/trunk/src/template/settings.tpl.php
r1310920 r1881036 95 95 </td> 96 96 </tr> 97 <tr valign="top"> 98 <th scope="row">Alerts On <small>(un-checking will make debug statements happen to console instead of alert)</small></th> 99 <td> 100 <input type="checkbox" name="h5pxapi_alerts" 101 <?php echo (get_option("h5pxapi_alerts") == "on" )? 'checked="checked"' : ''; ?> /> 102 103 </td> 104 </tr> 97 105 </table> 98 106 -
wp-h5p-xapi/trunk/wp-h5p-xapi.js
r1527353 r1881036 26 26 function showError(message, code) { 27 27 console.error("Unable to save xAPI statement"); 28 29 alert("Unable to save result data.\n\nMessage: " + message + "\n" + "Code: " + code); 28 if( xapi_settings.alerts == true ){ 29 alert("Unable to save result data.\n\nMessage: " + message + "\n" + "Code: " + code); 30 } else { 31 console.log("Unable to save result data.\n\nMessage: " + message + "\n" + "Code: " + code); 32 } 30 33 } 31 34 … … 72 75 */ 73 76 function onXapi(event) { 74 if (! WP_H5P_XAPI_STATEMENT_URL)77 if (!xapi_settings.ajax_url) 75 78 return; 76 79 77 80 showSpinner(); 78 81 79 var data = {}; 82 var data = { 83 action: 'xapi_event' 84 }; 80 85 /*console.log("on xapi, statement:"); 81 86 console.log(JSON.stringify(event.data.statement));*/ … … 94 99 } 95 100 96 if ( WP_H5P_XAPI_CONTEXTACTIVITY)97 event.data.statement.context.contextActivities.grouping.push( WP_H5P_XAPI_CONTEXTACTIVITY);101 if (xapi_settings.context_activity) 102 event.data.statement.context.contextActivities.grouping.push(xapi_settings.context_activity); 98 103 99 104 data.statement = JSON.stringify(event.data.statement); … … 102 107 $.ajax({ 103 108 type: "POST", 104 url: WP_H5P_XAPI_STATEMENT_URL,109 url: xapi_settings.ajax_url, 105 110 data: data, 106 111 dataType: "json", -
wp-h5p-xapi/trunk/wp-h5p-xapi.php
r1542843 r1881036 1 1 <?php 2 2 3 require_once __DIR__ ."/src/utils/Template.php";4 require_once __DIR__ ."/plugin.php";3 require_once __DIR__ . "/src/utils/Template.php"; 4 require_once __DIR__ . "/plugin.php"; 5 5 6 6 use h5pxapi\Template; … … 11 11 GitHub Plugin URI: https://github.com/tunapanda/wp-h5p-xapi 12 12 Description: Send H5P achievements to an xAPI repo. 13 Version: 0.1. 614 */13 Version: 0.1.7 14 */ 15 15 16 16 /** 17 17 * Enqueue scripts and stylesheets. 18 18 */ 19 function h5pxapi_enqueue_scripts() {20 wp_register_script("wp-h5p-xapi",plugins_url()."/wp-h5p-xapi/wp-h5p-xapi.js",array("jquery"));21 wp_enqueue_script("wp-h5p-xapi");22 19 23 wp_register_style("wp-h5p-xapi",plugins_url()."/wp-h5p-xapi/wp-h5p-xapi.css"); 24 wp_enqueue_style("wp-h5p-xapi"); 20 function h5pxapi_enqueue_scripts() 21 { 22 wp_register_script("wp-h5p-xapi", plugins_url() . "/wp-h5p-xapi/wp-h5p-xapi.js", array("jquery")); 23 wp_enqueue_script("wp-h5p-xapi"); 25 24 26 $s="";27 $s.="<script>\n";25 wp_register_style("wp-h5p-xapi", plugins_url() . "/wp-h5p-xapi/wp-h5p-xapi.css"); 26 wp_enqueue_style("wp-h5p-xapi"); 28 27 29 $settings=h5pxapi_get_auth_settings();28 $xapi_js_settings = array(); 30 29 31 if ($settings && $settings["endpoint_url"]) 32 $s.="WP_H5P_XAPI_STATEMENT_URL='".plugins_url()."/wp-h5p-xapi/process-xapi-statement.php';"; 30 $settings = h5pxapi_get_auth_settings(); 33 31 34 else 35 $s.="WP_H5P_XAPI_STATEMENT_URL=null;"; 32 $xapi_js_settings['ajax_url'] = admin_url('admin-ajax.php'); 36 33 37 $s.="\n"; 34 // Permalink is not available in the admin interface. 35 if (get_permalink()) { 36 $xapi_js_settings['context_activity'] = array( 37 'id' => get_permalink(), 38 'definition' => array( 39 'type' => 'http://activitystrea.ms/schema/1.0/page', 40 'name' => array( 41 'en' => wp_title("|", false), 42 ), 43 'moreInfo' => get_permalink(), 44 ), 45 ); 46 } 38 47 39 // Permalink is not available in the admin interface. 40 if (get_permalink()) { 41 $s.="WP_H5P_XAPI_CONTEXTACTIVITY= { 42 'id': '".get_permalink()."', 43 'definition': { 44 'type': 'http://activitystrea.ms/schema/1.0/page', 45 'name': { 46 'en': '".wp_title("|",FALSE)."' 47 }, 48 'moreInfo': '".get_permalink()."' 49 } 50 };"; 51 } else { 52 $s.="WP_H5P_XAPI_CONTEXTACTIVITY=null;"; 53 } 54 $s.="\n"; 55 $s.="</script>"; 48 wp_localize_script('wp-h5p-xapi', 'xapi_settings', $xapi_js_settings); 56 49 57 echo $s;58 50 } 59 51 … … 61 53 * Create the admin menu. 62 54 */ 63 function h5pxapi_admin_menu() { 64 $settings=apply_filters("h5p-xapi-auth-settings",NULL); 55 function h5pxapi_admin_menu() 56 { 57 $settings = apply_filters("h5p-xapi-auth-settings", null); 65 58 66 if (!$settings) {67 add_options_page(68 'H5P xAPI',69 'H5P xAPI',70 'manage_options',71 'h5pxapi_settings',72 'h5pxapi_create_settings_page'73 );74 }59 if (!$settings) { 60 add_options_page( 61 'H5P xAPI', 62 'H5P xAPI', 63 'manage_options', 64 'h5pxapi_settings', 65 'h5pxapi_create_settings_page' 66 ); 67 } 75 68 } 76 69 … … 78 71 * Admin init. 79 72 */ 73 80 74 function h5pxapi_admin_init() { 81 75 register_setting("h5pxapi","h5pxapi_endpoint_url"); 82 76 register_setting("h5pxapi","h5pxapi_username"); 83 77 register_setting("h5pxapi","h5pxapi_password"); 78 register_setting("h5pxapi", "h5pxapi_alerts"); 79 84 80 } 85 81 … … 87 83 * Create settings page. 88 84 */ 89 function h5pxapi_create_settings_page() { 90 wp_register_style("wp-h5p-xapi",plugins_url()."/wp-h5p-xapi/wp-h5p-xapi.css"); 91 wp_enqueue_style("wp-h5p-xapi"); 85 function h5pxapi_create_settings_page() 86 { 87 wp_register_style("wp-h5p-xapi", plugins_url() . "/wp-h5p-xapi/wp-h5p-xapi.css"); 88 wp_enqueue_style("wp-h5p-xapi"); 92 89 93 $template=new Template(__DIR__."/src/template/settings.tpl.php");94 $template->show();90 $template = new Template(__DIR__ . "/src/template/settings.tpl.php"); 91 $template->show(); 95 92 } 96 93 97 add_action('wp_enqueue_scripts','h5pxapi_enqueue_scripts'); 98 add_action('admin_enqueue_scripts','h5pxapi_enqueue_scripts'); 99 add_action('admin_menu','h5pxapi_admin_menu'); 100 add_action('admin_init','h5pxapi_admin_init'); 94 function h5pxapi_event_handler() 95 { 96 require_once __DIR__.'/process-xapi-statement.php'; 97 wp_die(); 98 } 101 99 102 function h5pxapi_response_message($message) { 103 global $h5pxapi_response_message; 100 add_action('wp_enqueue_scripts', 'h5pxapi_enqueue_scripts'); 101 add_action('admin_enqueue_scripts', 'h5pxapi_enqueue_scripts'); 102 add_action('admin_menu', 'h5pxapi_admin_menu'); 103 add_action('admin_init', 'h5pxapi_admin_init'); 104 add_action('wp_ajax_xapi_event', 'h5pxapi_event_handler'); 105 add_action('wp_ajax_nopriv_xapi_event', 'h5pxapi_event_handler'); 104 106 105 $h5pxapi_response_message=$message; 107 function h5pxapi_response_message($message) 108 { 109 global $h5pxapi_response_message; 110 111 $h5pxapi_response_message = $message; 106 112 }
Note: See TracChangeset
for help on using the changeset viewer.