original_string: public static function view_course($courseid, $sectionnumber = 0) {
          global $CFG;
          require_once($CFG->dirroot . "/course/lib.php");
  
          $params = self::validate_parameters(self::view_course_parameters(),
                                              array(
                                                  'courseid' => $courseid,
                                                  'sectionnumber' => $sectionnumber
                                              ));
  
          $warnings = array();
  
          $course = get_course($params['courseid']);
          $context = context_course::instance($course->id);
          self::validate_context($context);
  
          if (!empty($params['sectionnumber'])) {
  
              // Get section details and check it exists.
              $modinfo = get_fast_modinfo($course);
              $coursesection = $modinfo->get_section_info($params['sectionnumber'], MUST_EXIST);
  
              // Check user is allowed to see it.
              if (!$coursesection->uservisible) {
                  require_capability('moodle/course:viewhiddensections', $context);
              }
          }
  
          course_view($context, $params['sectionnumber']);
  
          $result = array();
          $result['status'] = true;
          $result['warnings'] = $warnings;
          return $result;
      }
code: public static function view_course($courseid, $sectionnumber = 0) {
          global $CFG;
          require_once($CFG->dirroot . "/course/lib.php");
  
          $params = self::validate_parameters(self::view_course_parameters(),
                                              array(
                                                  'courseid' => $courseid,
                                                  'sectionnumber' => $sectionnumber
                                              ));
  
          $warnings = array();
  
          $course = get_course($params['courseid']);
          $context = context_course::instance($course->id);
          self::validate_context($context);
  
          if (!empty($params['sectionnumber'])) {
  
              // Get section details and check it exists.
              $modinfo = get_fast_modinfo($course);
              $coursesection = $modinfo->get_section_info($params['sectionnumber'], MUST_EXIST);
  
              // Check user is allowed to see it.
              if (!$coursesection->uservisible) {
                  require_capability('moodle/course:viewhiddensections', $context);
              }
          }
  
          course_view($context, $params['sectionnumber']);
  
          $result = array();
          $result['status'] = true;
          $result['warnings'] = $warnings;
          return $result;
      }
code_tokens: public static function view_course ( $ courseid , $ sectionnumber = 0 ) { global $ CFG ; require_once ( $ CFG -> dirroot . "/course/lib.php" ) ; $ params = self :: validate_parameters ( self :: view_course_parameters ( ) , array ( 'courseid' => $ courseid , 'sectionnumber' => $ sectionnumber ) ) ; $ warnings = array ( ) ; $ course = get_course ( $ params [ 'courseid' ] ) ; $ context = context_course :: instance ( $ course -> id ) ; self :: validate_context ( $ context ) ; if ( ! empty ( $ params [ 'sectionnumber' ] ) ) { // Get section details and check it exists. $ modinfo = get_fast_modinfo ( $ course ) ; $ coursesection = $ modinfo -> get_section_info ( $ params [ 'sectionnumber' ] , MUST_EXIST ) ; // Check user is allowed to see it. if ( ! $ coursesection -> uservisible ) { require_capability ( 'moodle/course:viewhiddensections' , $ context ) ; } } course_view ( $ context , $ params [ 'sectionnumber' ] ) ; $ result = array ( ) ; $ result [ 'status' ] = true ; $ result [ 'warnings' ] = $ warnings ; return $ result ; }
docstring: Trigger the course viewed event.
  
  @param int $courseid id of course
  @param int $sectionnumber sectionnumber (0, 1, 2...)
  @return array of warnings and status result
  @since Moodle 2.9
  @throws moodle_exception
docstring_tokens: Trigger the course viewed event .