original_string: public static function get_lesson_access_information($lessonid) {
          global $DB, $USER;
  
          $warnings = array();
  
          $params = array(
              'lessonid' => $lessonid
          );
          $params = self::validate_parameters(self::get_lesson_access_information_parameters(), $params);
  
          list($lesson, $course, $cm, $context, $lessonrecord) = self::validate_lesson($params['lessonid']);
  
          $result = array();
          // Capabilities first.
          $result['canmanage'] = $lesson->can_manage();
          $result['cangrade'] = has_capability('mod/lesson:grade', $context);
          $result['canviewreports'] = has_capability('mod/lesson:viewreports', $context);
  
          // Status information.
          $result['reviewmode'] = $lesson->is_in_review_mode();
          $result['attemptscount'] = $lesson->count_user_retries($USER->id);
          $lastpageseen = $lesson->get_last_page_seen($result['attemptscount']);
          $result['lastpageseen'] = ($lastpageseen !== false) ? $lastpageseen : 0;
          $result['leftduringtimedsession'] = $lesson->left_during_timed_session($result['attemptscount']);
          // To avoid multiple calls, store the magic property firstpage.
          $lessonfirstpage = $lesson->firstpage;
          $result['firstpageid'] = $lessonfirstpage ? $lessonfirstpage->id : 0;
  
          // Access restrictions now, we emulate a new attempt access to get the possible warnings.
          $result['preventaccessreasons'] = [];
          $validationerrors = self::validate_attempt($lesson, ['password' => ''], true);
          foreach ($validationerrors as $reason => $data) {
              $result['preventaccessreasons'][] = [
                  'reason' => $reason,
                  'data' => $data,
                  'message' => get_string($reason, 'lesson', $data),
              ];
          }
          $result['warnings'] = $warnings;
          return $result;
      }
code: public static function get_lesson_access_information($lessonid) {
          global $DB, $USER;
  
          $warnings = array();
  
          $params = array(
              'lessonid' => $lessonid
          );
          $params = self::validate_parameters(self::get_lesson_access_information_parameters(), $params);
  
          list($lesson, $course, $cm, $context, $lessonrecord) = self::validate_lesson($params['lessonid']);
  
          $result = array();
          // Capabilities first.
          $result['canmanage'] = $lesson->can_manage();
          $result['cangrade'] = has_capability('mod/lesson:grade', $context);
          $result['canviewreports'] = has_capability('mod/lesson:viewreports', $context);
  
          // Status information.
          $result['reviewmode'] = $lesson->is_in_review_mode();
          $result['attemptscount'] = $lesson->count_user_retries($USER->id);
          $lastpageseen = $lesson->get_last_page_seen($result['attemptscount']);
          $result['lastpageseen'] = ($lastpageseen !== false) ? $lastpageseen : 0;
          $result['leftduringtimedsession'] = $lesson->left_during_timed_session($result['attemptscount']);
          // To avoid multiple calls, store the magic property firstpage.
          $lessonfirstpage = $lesson->firstpage;
          $result['firstpageid'] = $lessonfirstpage ? $lessonfirstpage->id : 0;
  
          // Access restrictions now, we emulate a new attempt access to get the possible warnings.
          $result['preventaccessreasons'] = [];
          $validationerrors = self::validate_attempt($lesson, ['password' => ''], true);
          foreach ($validationerrors as $reason => $data) {
              $result['preventaccessreasons'][] = [
                  'reason' => $reason,
                  'data' => $data,
                  'message' => get_string($reason, 'lesson', $data),
              ];
          }
          $result['warnings'] = $warnings;
          return $result;
      }
code_tokens: public static function get_lesson_access_information ( $ lessonid ) { global $ DB , $ USER ; $ warnings = array ( ) ; $ params = array ( 'lessonid' => $ lessonid ) ; $ params = self :: validate_parameters ( self :: get_lesson_access_information_parameters ( ) , $ params ) ; list ( $ lesson , $ course , $ cm , $ context , $ lessonrecord ) = self :: validate_lesson ( $ params [ 'lessonid' ] ) ; $ result = array ( ) ; // Capabilities first. $ result [ 'canmanage' ] = $ lesson -> can_manage ( ) ; $ result [ 'cangrade' ] = has_capability ( 'mod/lesson:grade' , $ context ) ; $ result [ 'canviewreports' ] = has_capability ( 'mod/lesson:viewreports' , $ context ) ; // Status information. $ result [ 'reviewmode' ] = $ lesson -> is_in_review_mode ( ) ; $ result [ 'attemptscount' ] = $ lesson -> count_user_retries ( $ USER -> id ) ; $ lastpageseen = $ lesson -> get_last_page_seen ( $ result [ 'attemptscount' ] ) ; $ result [ 'lastpageseen' ] = ( $ lastpageseen !== false ) ? $ lastpageseen : 0 ; $ result [ 'leftduringtimedsession' ] = $ lesson -> left_during_timed_session ( $ result [ 'attemptscount' ] ) ; // To avoid multiple calls, store the magic property firstpage. $ lessonfirstpage = $ lesson -> firstpage ; $ result [ 'firstpageid' ] = $ lessonfirstpage ? $ lessonfirstpage -> id : 0 ; // Access restrictions now, we emulate a new attempt access to get the possible warnings. $ result [ 'preventaccessreasons' ] = [ ] ; $ validationerrors = self :: validate_attempt ( $ lesson , [ 'password' => '' ] , true ) ; foreach ( $ validationerrors as $ reason => $ data ) { $ result [ 'preventaccessreasons' ] [ ] = [ 'reason' => $ reason , 'data' => $ data , 'message' => get_string ( $ reason , 'lesson' , $ data ) , ] ; } $ result [ 'warnings' ] = $ warnings ; return $ result ; }
docstring: Return access information for a given lesson.
  
  @param int $lessonid lesson instance id
  @return array of warnings and the access information
  @since Moodle 3.3
  @throws  moodle_exception
docstring_tokens: Return access information for a given lesson .