original_string: public static function check_updates($courseid, $tocheck, $filter = array()) {
          global $CFG, $DB;
          require_once($CFG->dirroot . "/course/lib.php");
  
          $params = self::validate_parameters(
              self::check_updates_parameters(),
              array(
                  'courseid' => $courseid,
                  'tocheck' => $tocheck,
                  'filter' => $filter,
              )
          );
  
          $course = get_course($params['courseid']);
          $context = context_course::instance($course->id);
          self::validate_context($context);
  
          list($instances, $warnings) = course_check_updates($course, $params['tocheck'], $filter);
  
          $instancesformatted = array();
          foreach ($instances as $instance) {
              $updates = array();
              foreach ($instance['updates'] as $name => $data) {
                  if (empty($data->updated)) {
                      continue;
                  }
                  $updatedata = array(
                      'name' => $name,
                  );
                  if (!empty($data->timeupdated)) {
                      $updatedata['timeupdated'] = $data->timeupdated;
                  }
                  if (!empty($data->itemids)) {
                      $updatedata['itemids'] = $data->itemids;
                  }
                  $updates[] = $updatedata;
              }
              if (!empty($updates)) {
                  $instancesformatted[] = array(
                      'contextlevel' => $instance['contextlevel'],
                      'id' => $instance['id'],
                      'updates' => $updates
                  );
              }
          }
  
          return array(
              'instances' => $instancesformatted,
              'warnings' => $warnings
          );
      }
code: public static function check_updates($courseid, $tocheck, $filter = array()) {
          global $CFG, $DB;
          require_once($CFG->dirroot . "/course/lib.php");
  
          $params = self::validate_parameters(
              self::check_updates_parameters(),
              array(
                  'courseid' => $courseid,
                  'tocheck' => $tocheck,
                  'filter' => $filter,
              )
          );
  
          $course = get_course($params['courseid']);
          $context = context_course::instance($course->id);
          self::validate_context($context);
  
          list($instances, $warnings) = course_check_updates($course, $params['tocheck'], $filter);
  
          $instancesformatted = array();
          foreach ($instances as $instance) {
              $updates = array();
              foreach ($instance['updates'] as $name => $data) {
                  if (empty($data->updated)) {
                      continue;
                  }
                  $updatedata = array(
                      'name' => $name,
                  );
                  if (!empty($data->timeupdated)) {
                      $updatedata['timeupdated'] = $data->timeupdated;
                  }
                  if (!empty($data->itemids)) {
                      $updatedata['itemids'] = $data->itemids;
                  }
                  $updates[] = $updatedata;
              }
              if (!empty($updates)) {
                  $instancesformatted[] = array(
                      'contextlevel' => $instance['contextlevel'],
                      'id' => $instance['id'],
                      'updates' => $updates
                  );
              }
          }
  
          return array(
              'instances' => $instancesformatted,
              'warnings' => $warnings
          );
      }
code_tokens: public static function check_updates ( $ courseid , $ tocheck , $ filter = array ( ) ) { global $ CFG , $ DB ; require_once ( $ CFG -> dirroot . "/course/lib.php" ) ; $ params = self :: validate_parameters ( self :: check_updates_parameters ( ) , array ( 'courseid' => $ courseid , 'tocheck' => $ tocheck , 'filter' => $ filter , ) ) ; $ course = get_course ( $ params [ 'courseid' ] ) ; $ context = context_course :: instance ( $ course -> id ) ; self :: validate_context ( $ context ) ; list ( $ instances , $ warnings ) = course_check_updates ( $ course , $ params [ 'tocheck' ] , $ filter ) ; $ instancesformatted = array ( ) ; foreach ( $ instances as $ instance ) { $ updates = array ( ) ; foreach ( $ instance [ 'updates' ] as $ name => $ data ) { if ( empty ( $ data -> updated ) ) { continue ; } $ updatedata = array ( 'name' => $ name , ) ; if ( ! empty ( $ data -> timeupdated ) ) { $ updatedata [ 'timeupdated' ] = $ data -> timeupdated ; } if ( ! empty ( $ data -> itemids ) ) { $ updatedata [ 'itemids' ] = $ data -> itemids ; } $ updates [ ] = $ updatedata ; } if ( ! empty ( $ updates ) ) { $ instancesformatted [ ] = array ( 'contextlevel' => $ instance [ 'contextlevel' ] , 'id' => $ instance [ 'id' ] , 'updates' => $ updates ) ; } } return array ( 'instances' => $ instancesformatted , 'warnings' => $ warnings ) ; }
docstring: Check if there is updates affecting the user for the given course and contexts.
  Right now only modules are supported.
  This WS calls mod_check_updates_since for each module to check if there is any update the user should we aware of.
  
  @param int $courseid the list of modules to check
  @param array $tocheck the list of modules to check
  @param array $filter check only for updates in these areas
  @return array list of updates and warnings
  @throws moodle_exception
  @since Moodle 3.2
docstring_tokens: Check if there is updates affecting the user for the given course and contexts . Right now only modules are supported . This WS calls mod_check_updates_since for each module to check if there is any update the user should we aware of .