public static function view_page($pageid) {

        $params = self::validate_parameters(self::view_page_parameters(),
                                            array(
                                                'pageid' => $pageid
                                            ));
        $warnings = array();

        // Get wiki page.
        if (!$page = wiki_get_page($params['pageid'])) {
            throw new moodle_exception('incorrectpageid', 'wiki');
        }

        // Get wiki instance.
        if (!$wiki = wiki_get_wiki_from_pageid($params['pageid'])) {
            throw new moodle_exception('incorrectwikiid', 'wiki');
        }

        // Permission validation.
        list($course, $cm) = get_course_and_cm_from_instance($wiki, 'wiki');
        $context = context_module::instance($cm->id);
        self::validate_context($context);

        // Check if user can view this wiki.
        if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
            throw new moodle_exception('incorrectsubwikiid', 'wiki');
        }
        if (!wiki_user_can_view($subwiki, $wiki)) {
            throw new moodle_exception('cannotviewpage', 'wiki');
        }

        // Trigger page_viewed event and completion.
        wiki_page_view($wiki, $page, $course, $cm, $context);

        $result = array();
        $result['status'] = true;
        $result['warnings'] = $warnings;
        return $result;
    }
public static function view_page($pageid) {

        $params = self::validate_parameters(self::view_page_parameters(),
                                            array(
                                                'pageid' => $pageid
                                            ));
        $warnings = array();

        // Get wiki page.
        if (!$page = wiki_get_page($params['pageid'])) {
            throw new moodle_exception('incorrectpageid', 'wiki');
        }

        // Get wiki instance.
        if (!$wiki = wiki_get_wiki_from_pageid($params['pageid'])) {
            throw new moodle_exception('incorrectwikiid', 'wiki');
        }

        // Permission validation.
        list($course, $cm) = get_course_and_cm_from_instance($wiki, 'wiki');
        $context = context_module::instance($cm->id);
        self::validate_context($context);

        // Check if user can view this wiki.
        if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
            throw new moodle_exception('incorrectsubwikiid', 'wiki');
        }
        if (!wiki_user_can_view($subwiki, $wiki)) {
            throw new moodle_exception('cannotviewpage', 'wiki');
        }

        // Trigger page_viewed event and completion.
        wiki_page_view($wiki, $page, $course, $cm, $context);

        $result = array();
        $result['status'] = true;
        $result['warnings'] = $warnings;
        return $result;
    }
public static function view_page ( $ pageid ) { $ params = self :: validate_parameters ( self :: view_page_parameters ( ) , array ( 'pageid' => $ pageid ) ) ; $ warnings = array ( ) ; // Get wiki page. if ( ! $ page = wiki_get_page ( $ params [ 'pageid' ] ) ) { throw new moodle_exception ( 'incorrectpageid' , 'wiki' ) ; } // Get wiki instance. if ( ! $ wiki = wiki_get_wiki_from_pageid ( $ params [ 'pageid' ] ) ) { throw new moodle_exception ( 'incorrectwikiid' , 'wiki' ) ; } // Permission validation. list ( $ course , $ cm ) = get_course_and_cm_from_instance ( $ wiki , 'wiki' ) ; $ context = context_module :: instance ( $ cm -> id ) ; self :: validate_context ( $ context ) ; // Check if user can view this wiki. if ( ! $ subwiki = wiki_get_subwiki ( $ page -> subwikiid ) ) { throw new moodle_exception ( 'incorrectsubwikiid' , 'wiki' ) ; } if ( ! wiki_user_can_view ( $ subwiki , $ wiki ) ) { throw new moodle_exception ( 'cannotviewpage' , 'wiki' ) ; } // Trigger page_viewed event and completion. wiki_page_view ( $ wiki , $ page , $ course , $ cm , $ context ) ; $ result = array ( ) ; $ result [ 'status' ] = true ; $ result [ 'warnings' ] = $ warnings ; return $ result ; }
Trigger the page viewed event and update the module completion status.

@param int $pageid The page ID.
@return array of warnings and status result.
@since Moodle 3.1
@throws moodle_exception if page is not valid.
Trigger the page viewed event and update the module completion status .