Skip to content

Commit

Permalink
post updated
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffcaseyyet committed Oct 22, 2024
1 parent 29dee2b commit 24f2414
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
72 changes: 72 additions & 0 deletions src/transformer/events/mod_forum/post_updated.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?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/>.

/**
* Transform for the forum post created event.
*
* @package logstore_xapi
* @copyright Jerret Fowler <[email protected]>
* Ryan Smith <https://www.linkedin.com/in/ryan-smith-uk/>
* David Pesce <[email protected]>
* Cliff Casey <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace src\transformer\events\mod_forum;

use src\transformer\utils as utils;

/**
* Transformer for forum post created event.
*
* @param array $config The transformer config settings.
* @param \stdClass $event The event to be transformed.
* @return array
*/
function post_updated(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);
$post = $repo->read_record_by_id('forum_posts', $event->objectid);
$other = unserialize($event->other);
$discussionid = $other['discussionid'];
$discussion = $repo->read_record_by_id('forum_discussions', $discussionid);

$lang = utils\get_course_lang($course);
return[[
'actor' => utils\get_user($config, $user),
'verb' => [
'id' => 'https://w3id.org/xapi/acrossx/verbs/edited',
'display' => [
$lang => 'Edited'
],
],
'object' => utils\get_activity\forum_discussion_post_reply($config, $course, $post),
'context' => [
'language' => $lang,
'extensions' => utils\extensions\base($config, $event, $course),
'contextActivities' => [
'parent' => array_merge(
[utils\get_activity\course_discussion($config, $course, $discussion)],
utils\context_activities\get_parent($config, $event->contextinstanceid, true)
),
'category' => [
utils\get_activity\site($config),
],
],
]
]];
}
1 change: 1 addition & 0 deletions src/transformer/get_event_function_map.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ function get_event_function_map() {
'\mod_forum\event\post_created' => 'mod_forum\post_created',

'\mod_forum\event\post_deleted' => 'mod_forum\post_deleted',
'\mod_forum\event\post_updated' => 'mod_forum\post_updated',

'\mod_forum\event\user_report_viewed' => 'mod_forum\user_report_viewed',
'\mod_glossary\event\course_module_viewed' => 'all\course_module_viewed',
Expand Down

0 comments on commit 24f2414

Please sign in to comment.