From 44669d9c92dc10bfad67c0d5a1ffea887d5d5c58 Mon Sep 17 00:00:00 2001 From: Dmitry Kochnev Date: Tue, 21 Nov 2017 16:13:42 +1100 Subject: [PATCH] [FEATURED] Add lrnactid url parameter for lrn-assess --- README.md | 10 +++++++++- classes/Learnosity/Shortcodes/ItemsEmbed.php | 5 +++++ classes/Learnosity/Shortcodes/ReportEmbed.php | 11 ++--------- vendor/learnosity-utils/UrlHelper.php | 13 +++++++++++++ 4 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 vendor/learnosity-utils/UrlHelper.php diff --git a/README.md b/README.md index 1413e30..5cacbb3 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,11 @@ Using the `lrn-assess` shortcode lets you include an Assessment style activity. Note you can use either the activitytemplateid to load from the Author site/Item Bank, or you can specify individual items. +The activitytemplateid could be also passed as url parameter (lrnactid) for WordPress landing page: +``` +http://wordpress.vg.learnosity.com/2017/11/21/assessment-url/?lrnactid=ACTIVITY_3_DEMO +``` + #### Advanced Inline Usage @@ -148,13 +153,16 @@ Parameters [lrn-report type="session-detail-by-item" session_id="17b9bb6e-16f8-4808-aebd-42a246a1158e"] ``` -This report type accepts lrnsid (session_id) as url parameter for WordPress landing page +The session_id could be also passed as url parameter (lrnsid) for WordPress landing page: ``` http://wordpress.vg.learnosity.com/2017/11/07/report/?lrnsid=0c2c3a66-5719-4f5f-b8c9-1492aa3c7cfa ``` ## Release History +### Version 1.2.1 - 21th Nov 2017 +- Add support for lrnactid as url parameter of WordPress landing page for lrn-assess + ### Version 1.2.0 - 14th Nov 2017 - Add support for lrnsid as url parameter of WordPress landing page for Session Detail By Item report - Add support for onsubmit_redirect_url parameter for lrn-assess shortcode diff --git a/classes/Learnosity/Shortcodes/ItemsEmbed.php b/classes/Learnosity/Shortcodes/ItemsEmbed.php index 6e64d5a..b424c3c 100644 --- a/classes/Learnosity/Shortcodes/ItemsEmbed.php +++ b/classes/Learnosity/Shortcodes/ItemsEmbed.php @@ -4,6 +4,7 @@ require_once __DIR__ . '/../../../vendor/learnosity-utils/uuid.php'; require_once __DIR__ . '/../../../vendor/learnosity-utils/RequestHelper.php'; +require_once __DIR__ . '/../../../vendor/learnosity-utils/UrlHelper.php'; class ItemsEmbed { @@ -26,8 +27,12 @@ public function __construct($options, $mode) $this->sessionId = \UUID::generateUuid(); + //Handling URL parameters + $lrnactid = \UrlHelper::get_url_parameter('lrnactid',''); + $defaults = array( 'activityid' => \UUID::generateUuid(), + 'activitytemplateid' => $lrnactid, 'autorender' => true, 'name' => 'My Activity', 'rendersubmit' => false, diff --git a/classes/Learnosity/Shortcodes/ReportEmbed.php b/classes/Learnosity/Shortcodes/ReportEmbed.php index f96c0e2..773764d 100644 --- a/classes/Learnosity/Shortcodes/ReportEmbed.php +++ b/classes/Learnosity/Shortcodes/ReportEmbed.php @@ -4,6 +4,7 @@ require_once __DIR__ . '/../../../vendor/learnosity-utils/uuid.php'; require_once __DIR__ . '/../../../vendor/learnosity-utils/RequestHelper.php'; +require_once __DIR__ . '/../../../vendor/learnosity-utils/UrlHelper.php'; class ReportEmbed { @@ -34,7 +35,7 @@ public function __construct($options) ); //Handling URL parameters - $lrnsid = $this->get_url_parameter('lrnsid',''); + $lrnsid = \UrlHelper::get_url_parameter('lrnsid',''); $defaults = array( 'id' => $this->report_id, @@ -77,14 +78,6 @@ public function render() return ob_get_clean(); } - private function get_url_parameter($key, $default = '') - { - if (!isset($_GET[$key]) || empty($_GET[$key])) { - return $default; - } - return strip_tags((string) wp_unslash($_GET[$key])); - } - private function get_user_name($user_id) { $user_info = get_userdata($user_id); diff --git a/vendor/learnosity-utils/UrlHelper.php b/vendor/learnosity-utils/UrlHelper.php new file mode 100644 index 0000000..9eec162 --- /dev/null +++ b/vendor/learnosity-utils/UrlHelper.php @@ -0,0 +1,13 @@ +