/**
  * Read page
  *
  * @throws \coding_exception
  * @return stdClass
  */
 private function read_page()
 {
     global $PAGE, $COURSE;
     $cm = $PAGE->cm;
     $page = \theme_snap\local::get_page_mod($cm);
     $context = $PAGE->context;
     // Trigger module instance viewed event.
     $event = \mod_page\event\course_module_viewed::create(array('objectid' => $page->id, 'context' => $context));
     $event->add_record_snapshot('course_modules', $cm);
     $event->add_record_snapshot('course', $COURSE);
     $event->add_record_snapshot('page', $page);
     $event->trigger();
     return $page;
 }
 /**
  * Read page
  *
  * @throws \coding_exception
  * @return stdClass
  */
 private function read_page()
 {
     global $PAGE, $COURSE;
     $cm = $PAGE->cm;
     $page = \theme_snap\local::get_page_mod($cm);
     $context = $PAGE->context;
     // Trigger module instance viewed event.
     $event = \mod_page\event\course_module_viewed::create(array('objectid' => $page->id, 'context' => $context));
     $event->add_record_snapshot('course_modules', $cm);
     $event->add_record_snapshot('course', $COURSE);
     $event->add_record_snapshot('page', $page);
     $event->trigger();
     // Update 'viewed' state if required by completion system.
     $completion = new \completion_info($COURSE);
     $completion->set_module_viewed($cm);
     $renderer = $PAGE->get_renderer('core', 'course');
     $page->completionhtml = $renderer->course_section_cm_completion($COURSE, $completion, $cm);
     return $page;
 }
Esempio n. 3
0
File: lib.php Progetto: dg711/moodle
/**
 * Mark the activity completed (if required) and trigger the course_module_viewed event.
 *
 * @param  stdClass $page       page object
 * @param  stdClass $course     course object
 * @param  stdClass $cm         course module object
 * @param  stdClass $context    context object
 * @since Moodle 3.0
 */
function page_view($page, $course, $cm, $context)
{
    // Trigger course_module_viewed event.
    $params = array('context' => $context, 'objectid' => $page->id);
    $event = \mod_page\event\course_module_viewed::create($params);
    $event->add_record_snapshot('course_modules', $cm);
    $event->add_record_snapshot('course', $course);
    $event->add_record_snapshot('page', $page);
    $event->trigger();
    // Completion.
    $completion = new completion_info($course);
    $completion->set_module_viewed($cm);
}
Esempio n. 4
0
    if (!($page = $DB->get_record('page', array('id' => $p)))) {
        print_error('invalidaccessparameter');
    }
    $cm = get_coursemodule_from_instance('page', $page->id, $page->course, false, MUST_EXIST);
} else {
    if (!($cm = get_coursemodule_from_id('page', $id))) {
        print_error('invalidcoursemodule');
    }
    $page = $DB->get_record('page', array('id' => $cm->instance), '*', MUST_EXIST);
}
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
require_course_login($course, true, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/page:view', $context);
// Trigger module viewed event.
$event = \mod_page\event\course_module_viewed::create(array('objectid' => $page->id, 'context' => $context));
$event->add_record_snapshot('course_modules', $cm);
$event->add_record_snapshot('course', $course);
$event->add_record_snapshot('page', $page);
$event->trigger();
// Update 'viewed' state if required by completion system
require_once $CFG->libdir . '/completionlib.php';
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
$PAGE->set_url('/mod/page/view.php', array('id' => $cm->id));
$options = empty($page->displayoptions) ? array() : unserialize($page->displayoptions);
if ($inpopup and $page->display == RESOURCELIB_DISPLAY_POPUP) {
    $PAGE->set_pagelayout('popup');
    $PAGE->set_title($course->shortname . ': ' . $page->name);
    $PAGE->set_heading($course->fullname);
} else {
Esempio n. 5
0
    if (!($page = $DB->get_record('page', array('id' => $p)))) {
        print_error('invalidaccessparameter');
    }
    $cm = get_coursemodule_from_instance('page', $page->id, $page->course, false, MUST_EXIST);
} else {
    if (!($cm = get_coursemodule_from_id('page', $id))) {
        print_error('invalidcoursemodule');
    }
    $page = $DB->get_record('page', array('id' => $cm->instance), '*', MUST_EXIST);
}
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
require_course_login($course, true, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/page:view', $context);
// Trigger module viewed event.
$event = \mod_page\event\course_module_viewed::create(array('objectid' => $page->id, 'context' => $context, 'other' => array('content' => 'pageresourceview')));
$event->add_record_snapshot('course_modules', $cm);
$event->add_record_snapshot('course', $course);
$event->add_record_snapshot('page', $page);
$event->trigger();
// Update 'viewed' state if required by completion system
require_once $CFG->libdir . '/completionlib.php';
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
$PAGE->set_url('/mod/page/view.php', array('id' => $cm->id));
$options = empty($page->displayoptions) ? array() : unserialize($page->displayoptions);
if ($inpopup and $page->display == RESOURCELIB_DISPLAY_POPUP) {
    $PAGE->set_pagelayout('popup');
    $PAGE->set_title($course->shortname . ': ' . $page->name);
    $PAGE->set_heading($course->fullname);
} else {