original_string: public static function get_activities_completion_status($courseid, $userid) {
          global $CFG, $USER;
          require_once($CFG->libdir . '/grouplib.php');
  
          $warnings = array();
          $arrayparams = array(
              'courseid' => $courseid,
              'userid'   => $userid,
          );
  
          $params = self::validate_parameters(self::get_activities_completion_status_parameters(), $arrayparams);
  
          $course = get_course($params['courseid']);
          $user = core_user::get_user($params['userid'], '*', MUST_EXIST);
          core_user::require_active_user($user);
  
          $context = context_course::instance($course->id);
          self::validate_context($context);
  
          // Check that current user have permissions to see this user's activities.
          if ($user->id != $USER->id) {
              require_capability('report/progress:view', $context);
              if (!groups_user_groups_visible($course, $user->id)) {
                  // We are not in the same group!
                  throw new moodle_exception('accessdenied', 'admin');
              }
          }
  
          $completion = new completion_info($course);
          $activities = $completion->get_activities();
  
          $results = array();
          foreach ($activities as $activity) {
  
              // Check if current user has visibility on this activity.
              if (!$activity->uservisible) {
                  continue;
              }
  
              // Get progress information and state (we must use get_data because it works for all user roles in course).
              $activitycompletiondata = $completion->get_data($activity, true, $user->id);
  
              $results[] = array(
                         'cmid'          => $activity->id,
                         'modname'       => $activity->modname,
                         'instance'      => $activity->instance,
                         'state'         => $activitycompletiondata->completionstate,
                         'timecompleted' => $activitycompletiondata->timemodified,
                         'tracking'      => $activity->completion,
                         'overrideby'    => $activitycompletiondata->overrideby,
                         'valueused'     => core_availability\info::completion_value_used($course, $activity->id)
              );
          }
  
          $results = array(
              'statuses' => $results,
              'warnings' => $warnings
          );
          return $results;
      }
code: public static function get_activities_completion_status($courseid, $userid) {
          global $CFG, $USER;
          require_once($CFG->libdir . '/grouplib.php');
  
          $warnings = array();
          $arrayparams = array(
              'courseid' => $courseid,
              'userid'   => $userid,
          );
  
          $params = self::validate_parameters(self::get_activities_completion_status_parameters(), $arrayparams);
  
          $course = get_course($params['courseid']);
          $user = core_user::get_user($params['userid'], '*', MUST_EXIST);
          core_user::require_active_user($user);
  
          $context = context_course::instance($course->id);
          self::validate_context($context);
  
          // Check that current user have permissions to see this user's activities.
          if ($user->id != $USER->id) {
              require_capability('report/progress:view', $context);
              if (!groups_user_groups_visible($course, $user->id)) {
                  // We are not in the same group!
                  throw new moodle_exception('accessdenied', 'admin');
              }
          }
  
          $completion = new completion_info($course);
          $activities = $completion->get_activities();
  
          $results = array();
          foreach ($activities as $activity) {
  
              // Check if current user has visibility on this activity.
              if (!$activity->uservisible) {
                  continue;
              }
  
              // Get progress information and state (we must use get_data because it works for all user roles in course).
              $activitycompletiondata = $completion->get_data($activity, true, $user->id);
  
              $results[] = array(
                         'cmid'          => $activity->id,
                         'modname'       => $activity->modname,
                         'instance'      => $activity->instance,
                         'state'         => $activitycompletiondata->completionstate,
                         'timecompleted' => $activitycompletiondata->timemodified,
                         'tracking'      => $activity->completion,
                         'overrideby'    => $activitycompletiondata->overrideby,
                         'valueused'     => core_availability\info::completion_value_used($course, $activity->id)
              );
          }
  
          $results = array(
              'statuses' => $results,
              'warnings' => $warnings
          );
          return $results;
      }
code_tokens: public static function get_activities_completion_status ( $ courseid , $ userid ) { global $ CFG , $ USER ; require_once ( $ CFG -> libdir . '/grouplib.php' ) ; $ warnings = array ( ) ; $ arrayparams = array ( 'courseid' => $ courseid , 'userid' => $ userid , ) ; $ params = self :: validate_parameters ( self :: get_activities_completion_status_parameters ( ) , $ arrayparams ) ; $ course = get_course ( $ params [ 'courseid' ] ) ; $ user = core_user :: get_user ( $ params [ 'userid' ] , '*' , MUST_EXIST ) ; core_user :: require_active_user ( $ user ) ; $ context = context_course :: instance ( $ course -> id ) ; self :: validate_context ( $ context ) ; // Check that current user have permissions to see this user's activities. if ( $ user -> id != $ USER -> id ) { require_capability ( 'report/progress:view' , $ context ) ; if ( ! groups_user_groups_visible ( $ course , $ user -> id ) ) { // We are not in the same group! throw new moodle_exception ( 'accessdenied' , 'admin' ) ; } } $ completion = new completion_info ( $ course ) ; $ activities = $ completion -> get_activities ( ) ; $ results = array ( ) ; foreach ( $ activities as $ activity ) { // Check if current user has visibility on this activity. if ( ! $ activity -> uservisible ) { continue ; } // Get progress information and state (we must use get_data because it works for all user roles in course). $ activitycompletiondata = $ completion -> get_data ( $ activity , true , $ user -> id ) ; $ results [ ] = array ( 'cmid' => $ activity -> id , 'modname' => $ activity -> modname , 'instance' => $ activity -> instance , 'state' => $ activitycompletiondata -> completionstate , 'timecompleted' => $ activitycompletiondata -> timemodified , 'tracking' => $ activity -> completion , 'overrideby' => $ activitycompletiondata -> overrideby , 'valueused' => core_availability \ info :: completion_value_used ( $ course , $ activity -> id ) ) ; } $ results = array ( 'statuses' => $ results , 'warnings' => $ warnings ) ; return $ results ; }
docstring: Get Activities completion status
  
  @param int $courseid ID of the Course
  @param int $userid ID of the User
  @return array of activities progress and warnings
  @throws moodle_exception
  @since Moodle 2.9
  @throws moodle_exception
docstring_tokens: Get Activities completion status