forked from adlnet/moodle-logstore_xapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e249e0e
commit 8ea3bd8
Showing
9 changed files
with
59 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,14 +18,11 @@ | |
* Transform for badge awarded event. | ||
* | ||
* @package logstore_xapi | ||
* @copyright Jerret Fowler <[email protected]> | ||
* Ryan Smith <https://www.linkedin.com/in/ryan-smith-uk/> | ||
* David Pesce <[email protected]> | ||
* @copyright Daniel Bell <[email protected]> | ||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace src\transformer\events\core; | ||
|
||
use src\transformer\utils as utils; | ||
|
||
/** | ||
|
@@ -56,8 +53,6 @@ function badge_awarded(array $config, \stdClass $event) { | |
|
||
$manual = $repo->read_record_by_id('badge_manual_award', $issuedid); | ||
$awarder = $manual ? (utils\get_user($config, $repo->read_record_by_id('user', $manual->issuerid))) : 'System'; | ||
$badgetype = [1 => "Global", 2 => "Course"][$badge->type]; | ||
|
||
|
||
$statement = [[ | ||
'actor' => $actor, | ||
|
@@ -66,19 +61,7 @@ function badge_awarded(array $config, \stdClass $event) { | |
'display' => [ | ||
'en' => 'Achieved' | ||
]], | ||
'object' => [ | ||
'id' => $config['app_url'].'/badges/overview.php?id='.$event->objectid, | ||
'objectType' => 'Activity', | ||
'definition' => [ | ||
'name' => [$lang => $badge->name], | ||
'description' => [$lang => $badge->description], | ||
'type' => 'https://xapi.edlm/profiles/edlm-lms/concepts/activity-types/badge', | ||
'extensions' => [ | ||
'https://xapi.edlm/profiles/edlm-lms/v1/concepts/activity-extensions/badge-type' => $badgetype, | ||
'https://xapi.edlm/profiles/edlm-lms/v1/concepts/activity-extensions/badge-version' => $badge->version | ||
] | ||
], | ||
], | ||
'object' => utils\badge_object($config, $lang, $badge), | ||
'result' => [ | ||
'response' => $badge->message | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
* | ||
* @package logstore_xapi | ||
* @copyright Daniel Bell <[email protected]> | ||
* | ||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
|
@@ -40,7 +39,6 @@ function badge_viewed(array $config, \stdClass $event) { | |
global $CFG; | ||
$repo = $config['repo']; | ||
$badge = $repo->read_record_by_id('badge', $event->objectid); | ||
$badgetype = [1 => "Global", 2 => "Course"][$badge->type]; | ||
|
||
//all three here may not exist | ||
$user=$repo->read_record_by_id('user',$event->userid); | ||
|
@@ -54,18 +52,7 @@ function badge_viewed(array $config, \stdClass $event) { | |
'verb' => ['id' => 'http://id.tincanapi.com/verb/viewed', | ||
'display' => ['en' => 'Viewed'] | ||
], | ||
'object' => [ | ||
'id' => $config['app_url'].'/badges/overview.php?id='.$badge->id, | ||
'definition' => [ | ||
'name' => [$lang =>$badge->name], | ||
'description' => [$lang => $badge->description], | ||
'type' => 'https://xapi.edlm/profiles/edlm-lms/concepts/activity-types/badge', | ||
'extensions' => [ | ||
'https://xapi.edlm/profiles/edlm-lms/v1/concepts/activity-extensions/badge-type' => $badgetype, | ||
'https://xapi.edlm/profiles/edlm-lms/v1/concepts/activity-extensions/badge-version' => $badge->version | ||
] | ||
], | ||
], | ||
'object' => utils\badge_object($config, $lang, $badge), | ||
'context' => [ | ||
'language' => $lang, | ||
'contextActivities' => [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Transformer utility for cleaning HTML from strings. | ||
* | ||
* @package logstore_xapi | ||
* @copyright Daniel Bell <[email protected]> | ||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace src\transformer\utils; | ||
|
||
/** | ||
* Utility for creating badge objects for badge events | ||
* | ||
* @param array $config site config | ||
* @param string $lang site config | ||
* @param array $badge The badge associative array | ||
* @return object | ||
*/ | ||
|
||
function badge_object($config, $lang, $badge) { | ||
$badgetype = [1 => "Global", 2 => "Course"][$badge->type]; | ||
|
||
return [ | ||
'id' => $config['app_url'].'/badges/overview.php?id='.$badge->id, | ||
'definition' => [ | ||
'name' => [$lang =>$badge->name], | ||
'description' => [$lang => $badge->description], | ||
'type' => 'https://xapi.edlm/profiles/edlm-lms/concepts/activity-types/badge', | ||
'extensions' => [ | ||
'https://xapi.edlm/profiles/edlm-lms/v1/concepts/activity-extensions/badge-type' => $badgetype, | ||
'https://xapi.edlm/profiles/edlm-lms/v1/concepts/activity-extensions/badge-version' => $badge->version | ||
] | ||
] | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,21 +7,5 @@ | |
"version": "1.0", | ||
"type": 1 | ||
} | ||
], | ||
"course": [ | ||
{ | ||
"fullname": "test_course_name", | ||
"id": 1, | ||
"lang": "en", | ||
"summary": "test_course_summary" | ||
} | ||
], | ||
"user": [ | ||
{ | ||
"email": "[email protected]", | ||
"firstname": "badge_viewer_firstname", | ||
"id": 1, | ||
"lastname": "badge_viewer_lastname" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters