original_string: public function get_grouped($users) {
          global $DB;
          global $CFG;
  
          $grouped = array();  // grouped users to be returned
          if (empty($users)) {
              return $grouped;
          }
          if ($this->cm->groupingid) {
              // Group workshop set to specified grouping - only consider groups
              // within this grouping, and leave out users who aren't members of
              // this grouping.
              $groupingid = $this->cm->groupingid;
              // All users that are members of at least one group will be
              // added into a virtual group id 0
              $grouped[0] = array();
          } else {
              $groupingid = 0;
              // there is no need to be member of a group so $grouped[0] will contain
              // all users
              $grouped[0] = $users;
          }
          $gmemberships = groups_get_all_groups($this->cm->course, array_keys($users), $groupingid,
                              'gm.id,gm.groupid,gm.userid');
          foreach ($gmemberships as $gmembership) {
              if (!isset($grouped[$gmembership->groupid])) {
                  $grouped[$gmembership->groupid] = array();
              }
              $grouped[$gmembership->groupid][$gmembership->userid] = $users[$gmembership->userid];
              $grouped[0][$gmembership->userid] = $users[$gmembership->userid];
          }
          return $grouped;
      }
code: public function get_grouped($users) {
          global $DB;
          global $CFG;
  
          $grouped = array();  // grouped users to be returned
          if (empty($users)) {
              return $grouped;
          }
          if ($this->cm->groupingid) {
              // Group workshop set to specified grouping - only consider groups
              // within this grouping, and leave out users who aren't members of
              // this grouping.
              $groupingid = $this->cm->groupingid;
              // All users that are members of at least one group will be
              // added into a virtual group id 0
              $grouped[0] = array();
          } else {
              $groupingid = 0;
              // there is no need to be member of a group so $grouped[0] will contain
              // all users
              $grouped[0] = $users;
          }
          $gmemberships = groups_get_all_groups($this->cm->course, array_keys($users), $groupingid,
                              'gm.id,gm.groupid,gm.userid');
          foreach ($gmemberships as $gmembership) {
              if (!isset($grouped[$gmembership->groupid])) {
                  $grouped[$gmembership->groupid] = array();
              }
              $grouped[$gmembership->groupid][$gmembership->userid] = $users[$gmembership->userid];
              $grouped[0][$gmembership->userid] = $users[$gmembership->userid];
          }
          return $grouped;
      }
code_tokens: public function get_grouped ( $ users ) { global $ DB ; global $ CFG ; $ grouped = array ( ) ; // grouped users to be returned if ( empty ( $ users ) ) { return $ grouped ; } if ( $ this -> cm -> groupingid ) { // Group workshop set to specified grouping - only consider groups // within this grouping, and leave out users who aren't members of // this grouping. $ groupingid = $ this -> cm -> groupingid ; // All users that are members of at least one group will be // added into a virtual group id 0 $ grouped [ 0 ] = array ( ) ; } else { $ groupingid = 0 ; // there is no need to be member of a group so $grouped[0] will contain // all users $ grouped [ 0 ] = $ users ; } $ gmemberships = groups_get_all_groups ( $ this -> cm -> course , array_keys ( $ users ) , $ groupingid , 'gm.id,gm.groupid,gm.userid' ) ; foreach ( $ gmemberships as $ gmembership ) { if ( ! isset ( $ grouped [ $ gmembership -> groupid ] ) ) { $ grouped [ $ gmembership -> groupid ] = array ( ) ; } $ grouped [ $ gmembership -> groupid ] [ $ gmembership -> userid ] = $ users [ $ gmembership -> userid ] ; $ grouped [ 0 ] [ $ gmembership -> userid ] = $ users [ $ gmembership -> userid ] ; } return $ grouped ; }
docstring: Groups the given users by the group membership
  
  This takes the module grouping settings into account. If a grouping is
  set, returns only groups withing the course module grouping. Always
  returns group [0] with all the given users.
  
  @param array $users array[userid] => stdclass{->id ->lastname ->firstname}
  @return array array[groupid][userid] => stdclass{->id ->lastname ->firstname}
docstring_tokens: Groups the given users by the group membership