original_string: private function update_user_visible() {
          $userid = $this->modinfo->get_user_id();
          if ($userid == -1) {
              return null;
          }
          $this->uservisible = true;
  
          // If the module is being deleted, set the uservisible state to false and return.
          if ($this->deletioninprogress) {
              $this->uservisible = false;
              return null;
          }
  
          // If the user cannot access the activity set the uservisible flag to false.
          // Additional checks are required to determine whether the activity is entirely hidden or just greyed out.
          if ((!$this->visible && !has_capability('moodle/course:viewhiddenactivities', $this->get_context(), $userid)) ||
                  (!$this->get_available() &&
                  !has_capability('moodle/course:ignoreavailabilityrestrictions', $this->get_context(), $userid))) {
  
              $this->uservisible = false;
          }
  
          // Check group membership.
          if ($this->is_user_access_restricted_by_capability()) {
  
               $this->uservisible = false;
              // Ensure activity is completely hidden from the user.
              $this->availableinfo = '';
          }
  
          $this->uservisibleoncoursepage = $this->uservisible &&
              ($this->visibleoncoursepage ||
                  has_capability('moodle/course:manageactivities', $this->get_context(), $userid) ||
                  has_capability('moodle/course:activityvisibility', $this->get_context(), $userid));
          // Activity that is not available, not hidden from course page and has availability
          // info is actually visible on the course page (with availability info and without a link).
          if (!$this->uservisible && $this->visibleoncoursepage && $this->availableinfo) {
              $this->uservisibleoncoursepage = true;
          }
      }
code: private function update_user_visible() {
          $userid = $this->modinfo->get_user_id();
          if ($userid == -1) {
              return null;
          }
          $this->uservisible = true;
  
          // If the module is being deleted, set the uservisible state to false and return.
          if ($this->deletioninprogress) {
              $this->uservisible = false;
              return null;
          }
  
          // If the user cannot access the activity set the uservisible flag to false.
          // Additional checks are required to determine whether the activity is entirely hidden or just greyed out.
          if ((!$this->visible && !has_capability('moodle/course:viewhiddenactivities', $this->get_context(), $userid)) ||
                  (!$this->get_available() &&
                  !has_capability('moodle/course:ignoreavailabilityrestrictions', $this->get_context(), $userid))) {
  
              $this->uservisible = false;
          }
  
          // Check group membership.
          if ($this->is_user_access_restricted_by_capability()) {
  
               $this->uservisible = false;
              // Ensure activity is completely hidden from the user.
              $this->availableinfo = '';
          }
  
          $this->uservisibleoncoursepage = $this->uservisible &&
              ($this->visibleoncoursepage ||
                  has_capability('moodle/course:manageactivities', $this->get_context(), $userid) ||
                  has_capability('moodle/course:activityvisibility', $this->get_context(), $userid));
          // Activity that is not available, not hidden from course page and has availability
          // info is actually visible on the course page (with availability info and without a link).
          if (!$this->uservisible && $this->visibleoncoursepage && $this->availableinfo) {
              $this->uservisibleoncoursepage = true;
          }
      }
code_tokens: private function update_user_visible ( ) { $ userid = $ this -> modinfo -> get_user_id ( ) ; if ( $ userid == - 1 ) { return null ; } $ this -> uservisible = true ; // If the module is being deleted, set the uservisible state to false and return. if ( $ this -> deletioninprogress ) { $ this -> uservisible = false ; return null ; } // If the user cannot access the activity set the uservisible flag to false. // Additional checks are required to determine whether the activity is entirely hidden or just greyed out. if ( ( ! $ this -> visible && ! has_capability ( 'moodle/course:viewhiddenactivities' , $ this -> get_context ( ) , $ userid ) ) || ( ! $ this -> get_available ( ) && ! has_capability ( 'moodle/course:ignoreavailabilityrestrictions' , $ this -> get_context ( ) , $ userid ) ) ) { $ this -> uservisible = false ; } // Check group membership. if ( $ this -> is_user_access_restricted_by_capability ( ) ) { $ this -> uservisible = false ; // Ensure activity is completely hidden from the user. $ this -> availableinfo = '' ; } $ this -> uservisibleoncoursepage = $ this -> uservisible && ( $ this -> visibleoncoursepage || has_capability ( 'moodle/course:manageactivities' , $ this -> get_context ( ) , $ userid ) || has_capability ( 'moodle/course:activityvisibility' , $ this -> get_context ( ) , $ userid ) ) ; // Activity that is not available, not hidden from course page and has availability // info is actually visible on the course page (with availability info and without a link). if ( ! $ this -> uservisible && $ this -> visibleoncoursepage && $ this -> availableinfo ) { $ this -> uservisibleoncoursepage = true ; } }
docstring: Works out whether activity is available to the current user
  
  If the activity is unavailable, additional checks are required to determine if its hidden or greyed out
  
  @return void
docstring_tokens: Works out whether activity is available to the current user