Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
[FEATURED] Add lrnactid url parameter for lrn-assess
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Kochnev committed Nov 21, 2017
1 parent 6970aaf commit 44669d9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions classes/Learnosity/Shortcodes/ItemsEmbed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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,
Expand Down
11 changes: 2 additions & 9 deletions classes/Learnosity/Shortcodes/ReportEmbed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 13 additions & 0 deletions vendor/learnosity-utils/UrlHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

class UrlHelper
{

public static function get_url_parameter($key, $default = '')
{
if (!isset($_GET[$key]) || empty($_GET[$key])) {
return $default;
}
return strip_tags((string) wp_unslash($_GET[$key]));
}
}

0 comments on commit 44669d9

Please sign in to comment.