コード例 #1
0
ファイル: view.php プロジェクト: sumitnegi933/Moodle_lms_New
}
require_course_login($course, true, $cm);
$context = context_module::instance($cm->id);
$PAGE->set_context($context);
// show some info for guests
if (isguestuser()) {
    $PAGE->set_title($chat->name);
    echo $OUTPUT->header();
    echo $OUTPUT->confirm('<p>' . get_string('noguests', 'chat') . '</p>' . get_string('liketologin'), get_login_url(), $CFG->wwwroot . '/course/view.php?id=' . $course->id);
    echo $OUTPUT->footer();
    exit;
}
// Log this request - the problem here is that the view page
// does not display the chat content which is actually in a new window.
$params = array('objectid' => $chat->id, 'context' => $context);
$event = \mod_chat\event\course_module_viewed::create($params);
$event->add_record_snapshot('chat', $chat);
$event->trigger();
$strenterchat = get_string('enterchat', 'chat');
$stridle = get_string('idle', 'chat');
$strcurrentusers = get_string('currentusers', 'chat');
$strnextsession = get_string('nextsession', 'chat');
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$title = $courseshortname . ': ' . format_string($chat->name);
// Mark viewed by user (if required)
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
// Initialize $PAGE
$PAGE->set_url('/mod/chat/view.php', array('id' => $cm->id));
$PAGE->set_title($title);
$PAGE->set_heading($course->fullname);
コード例 #2
0
ファイル: lib.php プロジェクト: gabrielrosset/moodle
/**
 * Mark the activity completed (if required) and trigger the course_module_viewed event.
 *
 * @param  stdClass $chat       chat object
 * @param  stdClass $course     course object
 * @param  stdClass $cm         course module object
 * @param  stdClass $context    context object
 * @since Moodle 3.0
 */
function chat_view($chat, $course, $cm, $context)
{
    // Trigger course_module_viewed event.
    $params = array('context' => $context, 'objectid' => $chat->id);
    $event = \mod_chat\event\course_module_viewed::create($params);
    $event->add_record_snapshot('course_modules', $cm);
    $event->add_record_snapshot('course', $course);
    $event->add_record_snapshot('chat', $chat);
    $event->trigger();
    // Completion.
    $completion = new completion_info($course);
    $completion->set_module_viewed($cm);
}
コード例 #3
0
ファイル: events_test.php プロジェクト: evltuma/moodle
 public function test_course_module_viewed()
 {
     $this->resetAfterTest();
     $this->setAdminUser();
     $course = $this->getDataGenerator()->create_course();
     $chat = $this->getDataGenerator()->create_module('chat', array('course' => $course->id));
     $cm = get_coursemodule_from_instance('chat', $chat->id);
     $context = context_module::instance($cm->id);
     $params = array('objectid' => $chat->id, 'context' => $context);
     $event = \mod_chat\event\course_module_viewed::create($params);
     $event->add_record_snapshot('chat', $chat);
     $event->trigger();
     $expected = array($course->id, 'chat', 'view', "view.php?id={$cm->id}", $chat->id, $cm->id);
     $this->assertEventLegacyLogData($expected, $event);
     $this->assertEventContextNotUsed($event);
     $url = new moodle_url('/mod/chat/view.php', array('id' => $cm->id));
     $this->assertEquals($url, $event->get_url());
     $event->get_name();
 }