original_string: public static function allocate_unique_ids($assignid) {
          global $DB;
  
          $cm = get_coursemodule_from_instance('assign', $assignid, 0, false, MUST_EXIST);
          $context = context_module::instance($cm->id);
  
          $currentgroup = groups_get_activity_group($cm, true);
          $users = get_enrolled_users($context, "mod/assign:submit", $currentgroup, 'u.id');
  
          // Shuffle the users.
          shuffle($users);
  
          foreach ($users as $user) {
              $record = $DB->get_record('assign_user_mapping',
                                        array('assignment'=>$assignid, 'userid'=>$user->id),
                                       'id');
              if (!$record) {
                  $record = new stdClass();
                  $record->assignment = $assignid;
                  $record->userid = $user->id;
                  $DB->insert_record('assign_user_mapping', $record);
              }
          }
      }
code: public static function allocate_unique_ids($assignid) {
          global $DB;
  
          $cm = get_coursemodule_from_instance('assign', $assignid, 0, false, MUST_EXIST);
          $context = context_module::instance($cm->id);
  
          $currentgroup = groups_get_activity_group($cm, true);
          $users = get_enrolled_users($context, "mod/assign:submit", $currentgroup, 'u.id');
  
          // Shuffle the users.
          shuffle($users);
  
          foreach ($users as $user) {
              $record = $DB->get_record('assign_user_mapping',
                                        array('assignment'=>$assignid, 'userid'=>$user->id),
                                       'id');
              if (!$record) {
                  $record = new stdClass();
                  $record->assignment = $assignid;
                  $record->userid = $user->id;
                  $DB->insert_record('assign_user_mapping', $record);
              }
          }
      }
code_tokens: public static function allocate_unique_ids ( $ assignid ) { global $ DB ; $ cm = get_coursemodule_from_instance ( 'assign' , $ assignid , 0 , false , MUST_EXIST ) ; $ context = context_module :: instance ( $ cm -> id ) ; $ currentgroup = groups_get_activity_group ( $ cm , true ) ; $ users = get_enrolled_users ( $ context , "mod/assign:submit" , $ currentgroup , 'u.id' ) ; // Shuffle the users. shuffle ( $ users ) ; foreach ( $ users as $ user ) { $ record = $ DB -> get_record ( 'assign_user_mapping' , array ( 'assignment' => $ assignid , 'userid' => $ user -> id ) , 'id' ) ; if ( ! $ record ) { $ record = new stdClass ( ) ; $ record -> assignment = $ assignid ; $ record -> userid = $ user -> id ; $ DB -> insert_record ( 'assign_user_mapping' , $ record ) ; } } }
docstring: Foreach participant in the course - assign them a random id.
  
  @param int $assignid The assignid to lookup
docstring_tokens: Foreach participant in the course - assign them a random id .