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
Showing
11 changed files
with
424 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?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 fn for wiki discussion comment created event. | ||
* | ||
* @package logstore_xapi | ||
* @copyright Milt Reder <[email protected]> | ||
* | ||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace src\transformer\events\mod_wiki; | ||
|
||
use src\transformer\utils as utils; | ||
|
||
/** | ||
* Transformer fn for wiki discussion comment created event. | ||
* | ||
* @param array $config The transformer config settings. | ||
* @param \stdClass $event The event to be transformed. | ||
* @return array | ||
*/ | ||
|
||
function comment_created(array $config, \stdClass $event) { | ||
$repo = $config['repo']; | ||
$user = $repo->read_record_by_id('user', $event->userid); | ||
$course = $repo->read_record_by_id('course', $event->courseid); | ||
$comment = $repo->read_record_by_id('comments', $event->objectid); | ||
$wikipage = $repo->read_record_by_id('wiki_pages', $comment->itemid); | ||
$lang = utils\get_course_lang($course); | ||
|
||
return[[ | ||
'actor' => utils\get_user($config, $user), | ||
'verb' => [ | ||
'id' => 'http://adlnet.gov/expapi/verbs/commented', | ||
'display' => [ | ||
$lang => 'Commented' | ||
], | ||
], | ||
'object' => utils\get_activity\wiki_discussion( | ||
$config, $course, $wikipage | ||
), | ||
'result' => [ | ||
'response' => utils\get_string_html_removed($comment->content), | ||
], | ||
'context' => [ | ||
'language' => $lang, | ||
'extensions' => utils\extensions\base($config, $event, $course), | ||
'contextActivities' => [ | ||
'parent' => [ | ||
utils\get_activity\wiki_page( | ||
$config, | ||
$course, | ||
$wikipage | ||
), | ||
...utils\context_activities\get_parent( | ||
$config, | ||
$event->contextinstanceid, | ||
true | ||
), | ||
], | ||
'category' => [ | ||
utils\get_activity\site($config), | ||
], | ||
], | ||
] | ||
]]; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?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 retrieving wiki discussion activity objects. | ||
* | ||
* @package logstore_xapi | ||
* @copyright Milt Reder <[email protected]> | ||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace src\transformer\utils\get_activity; | ||
|
||
use src\transformer\utils as utils; | ||
|
||
/** | ||
* Transformer utility for retrieving wiki discussion activity objects. | ||
* | ||
* @param array $config The transformer config settings. | ||
* @param \stdClass $course The course object. | ||
* @param \stdClass $wikipage The wiki page object. | ||
* @return array | ||
*/ | ||
function wiki_discussion( | ||
array $config, | ||
\stdClass $course, | ||
\stdClass $wikipage | ||
) { | ||
$lang = utils\get_course_lang($course); | ||
|
||
return [ | ||
'id' => $config['app_url'] . '/mod/wiki/comments.php?pageid=' . $wikipage->id, | ||
'definition' => [ | ||
'type' => 'http://id.tincanapi.com/activitytype/discussion', | ||
'name' => [ | ||
$lang => $wikipage->title . ' Discussion', | ||
], | ||
], | ||
]; | ||
} |
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,56 @@ | ||
<?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 retrieving wiki page activity objects. | ||
* | ||
* @package logstore_xapi | ||
* @copyright Milt Reder <[email protected]> | ||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace src\transformer\utils\get_activity; | ||
|
||
use src\transformer\utils as utils; | ||
|
||
/** | ||
* Transformer utility for retrieving wiki page activity objects. | ||
* | ||
* @param array $config The transformer config settings. | ||
* @param \stdClass $course The course object. | ||
* @param \stdClass $wikipage The wiki page object. | ||
* @return array | ||
*/ | ||
function wiki_page( | ||
array $config, | ||
\stdClass $course, | ||
\stdClass $wikipage | ||
) { | ||
$lang = utils\get_course_lang($course); | ||
|
||
return [ | ||
'id' => $config['app_url'] . '/mod/wiki/view.php?pageid=' . $wikipage->id, | ||
'definition' => [ | ||
'type' => 'https://xapi.edlm/profiles/edlm-lms/concepts/activity-types/wiki-page', | ||
'name' => [ | ||
$lang => $wikipage->title, | ||
], | ||
'description' => [ | ||
$lang => utils\get_string_html_removed($wikipage->cachedcontent), | ||
] | ||
], | ||
]; | ||
} |
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,70 @@ | ||
<?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/>. | ||
|
||
namespace logstore_xapi\mod_wiki; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
global $CFG; | ||
|
||
require_once($CFG->dirroot . '/admin/tool/log/store/xapi/tests/xapi_test_case.php'); | ||
|
||
/** | ||
* Unit test for wiki comment created. | ||
* | ||
* @package logstore_xapi | ||
* @copyright Milt Reder <[email protected]> | ||
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class comment_created_test extends \logstore_xapi\xapi_test_case { | ||
|
||
/** | ||
* Retrieve the directory of the unit test. | ||
* | ||
* @return string | ||
*/ | ||
protected function get_test_dir() { | ||
return __DIR__; | ||
} | ||
|
||
/** | ||
* Retrieve the plugin type being tested. | ||
* | ||
* @return string | ||
*/ | ||
protected function get_plugin_type() { | ||
return "core"; | ||
} | ||
|
||
/** | ||
* Retrieve the plugin name being tested. | ||
* | ||
* @return string | ||
*/ | ||
protected function get_plugin_name() { | ||
return "mod_survey"; | ||
} | ||
|
||
/** | ||
* Appease auto-detecting of test cases. xapi_test_case has default test cases. | ||
* | ||
* @covers ::comment_created | ||
* @return void | ||
*/ | ||
public function test_init() { | ||
|
||
} | ||
} |
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,36 @@ | ||
{ | ||
"modules": [ | ||
{ | ||
"id": 1, | ||
"name": "wiki" | ||
} | ||
], | ||
"wiki": [ | ||
{ | ||
"id": 1, | ||
"name": "test_name", | ||
"intro": "<p>test_intro</p>" | ||
} | ||
], | ||
"wiki_subwikis": [ | ||
{ | ||
"id": 1, | ||
"wikiid": 1 | ||
} | ||
], | ||
"wiki_pages": [ | ||
{ | ||
"id": 1, | ||
"subwikiid": 1, | ||
"title": "test_page_title", | ||
"cachedcontent": "<p>test_content</p>" | ||
} | ||
], | ||
"comments": [ | ||
{ | ||
"id": 1, | ||
"content": "<p>test_content</p>", | ||
"itemid": 1 | ||
} | ||
] | ||
} |
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,10 @@ | ||
{ | ||
"id": 1, | ||
"userid": 1, | ||
"courseid": 1, | ||
"timecreated": 1433946701, | ||
"contextinstanceid": 1, | ||
"eventname": "\\mod_wiki\\event\\comment_created", | ||
"objectid": 1, | ||
"objecttable": "comments" | ||
} |
Oops, something went wrong.