original_string: protected function any_feedback($action, \cm_info $cm, $contextid, $user) {
  
          if (!in_array($action, ['submitted', 'replied', 'viewed'])) {
              throw new \coding_exception('Provided action "' . $action . '" is not valid.');
          }
  
          if (empty($this->activitylogs[$contextid])) {
              return false;
          }
  
          if (empty($this->grades[$contextid]) && $this->feedback_check_grades()) {
              // If there are no grades there is no feedback.
              return false;
          }
  
          $it = $this->activitylogs[$contextid];
          if ($user) {
              if (empty($this->activitylogs[$contextid][$user->id])) {
                  return false;
              }
              $it = array($user->id => $this->activitylogs[$contextid][$user->id]);
          }
  
          foreach ($this->activitylogs[$contextid] as $userid => $events) {
              $methodname = 'feedback_' . $action;
              if ($this->{$methodname}($cm, $contextid, $userid)) {
                  return true;
              }
              // If it wasn't viewed try with the next user.
          }
          return false;
      }
code: protected function any_feedback($action, \cm_info $cm, $contextid, $user) {
  
          if (!in_array($action, ['submitted', 'replied', 'viewed'])) {
              throw new \coding_exception('Provided action "' . $action . '" is not valid.');
          }
  
          if (empty($this->activitylogs[$contextid])) {
              return false;
          }
  
          if (empty($this->grades[$contextid]) && $this->feedback_check_grades()) {
              // If there are no grades there is no feedback.
              return false;
          }
  
          $it = $this->activitylogs[$contextid];
          if ($user) {
              if (empty($this->activitylogs[$contextid][$user->id])) {
                  return false;
              }
              $it = array($user->id => $this->activitylogs[$contextid][$user->id]);
          }
  
          foreach ($this->activitylogs[$contextid] as $userid => $events) {
              $methodname = 'feedback_' . $action;
              if ($this->{$methodname}($cm, $contextid, $userid)) {
                  return true;
              }
              // If it wasn't viewed try with the next user.
          }
          return false;
      }
code_tokens: protected function any_feedback ( $ action , \ cm_info $ cm , $ contextid , $ user ) { if ( ! in_array ( $ action , [ 'submitted' , 'replied' , 'viewed' ] ) ) { throw new \ coding_exception ( 'Provided action "' . $ action . '" is not valid.' ) ; } if ( empty ( $ this -> activitylogs [ $ contextid ] ) ) { return false ; } if ( empty ( $ this -> grades [ $ contextid ] ) && $ this -> feedback_check_grades ( ) ) { // If there are no grades there is no feedback. return false ; } $ it = $ this -> activitylogs [ $ contextid ] ; if ( $ user ) { if ( empty ( $ this -> activitylogs [ $ contextid ] [ $ user -> id ] ) ) { return false ; } $ it = array ( $ user -> id => $ this -> activitylogs [ $ contextid ] [ $ user -> id ] ) ; } foreach ( $ this -> activitylogs [ $ contextid ] as $ userid => $ events ) { $ methodname = 'feedback_' . $ action ; if ( $ this -> { $ methodname } ( $ cm , $ contextid , $ userid ) ) { return true ; } // If it wasn't viewed try with the next user. } return false ; }
docstring: Is there any feedback activity log for this user in this context?
  
  This method returns true if $user is empty and there is any feedback activity logs.
  
  @param string $action
  @param \cm_info $cm
  @param int $contextid
  @param \stdClass|false $user
  @return bool
docstring_tokens: Is there any feedback activity log for this user in this context?