Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

courese module create #768

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions src/transformer/events/core/course_module_created.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?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 src\transformer\events\core;

defined('MOODLE_INTERNAL') || die();

use src\transformer\utils as utils;

function course_module_created(array $config, \stdClass $event) {
$repo = $config['repo'];
$user = $repo->read_record_by_id('user', $event->relateduserid);
$course = $repo->read_record_by_id('course', $event->courseid);
$coursemodule = $repo->read_record_by_id('course_modules', $event->contextinstanceid);
$moduletype = $repo->read_record_by_id('modules', $coursemodule->module);
$module = $repo->read_record_by_id($moduletype->name, $coursemodule->instance);
$lang = utils\get_course_lang($course);

return [[
'actor' => utils\get_user($config, $user),
'verb' => [
'id' => 'http://adlnet.gov/expapi/verbs/created',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'display' => [
$lang => 'created'
],
],
'object' => utils\get_activity\course_module(
$config,
$course,
$event->contextinstanceid,
'http://id.tincanapi.com/activitytype/lms/module'
),
'timestamp' => utils\get_event_timestamp($event),
'context' => [
'platform' => $config['source_name'],
'language' => $lang,
'extensions' => utils\extensions\base($config, $event, $course),
'contextActivities' => [
'grouping' => [
utils\get_activity\site($config),
utils\get_activity\course($config, $course),
],
'category' => [
utils\get_activity\source($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 @@ -26,6 +26,7 @@ function get_event_function_map() {
'\core\event\user_loggedin' => 'core\user_loggedin',
'\core\event\user_loggedout' => 'core\user_loggedout',
'\core\event\course_module_completion_updated' => 'core\course_module_completion_updated',
'\core\event\course_module_created' => 'core\course_module_created',
'\mod_assign\event\assessable_submitted' => 'mod_assign\assignment_submitted',
'\mod_assign\event\submission_graded' => 'mod_assign\assignment_graded',

Expand Down