original_string: public static function save_user_extensions($assignmentid, $userids, $dates) {
          global $CFG;
  
          $params = self::validate_parameters(self::save_user_extensions_parameters(),
                          array('assignmentid' => $assignmentid,
                                'userids' => $userids,
                                'dates' => $dates));
  
          if (count($params['userids']) != count($params['dates'])) {
              $detail = 'Length of userids and dates parameters differ.';
              $warnings[] = self::generate_warning($params['assignmentid'],
                                                   'invalidparameters',
                                                   $detail);
  
              return $warnings;
          }
  
          list($assignment, $course, $cm, $context) = self::validate_assign($params['assignmentid']);
  
          $warnings = array();
          foreach ($params['userids'] as $idx => $userid) {
              $duedate = $params['dates'][$idx];
              if (!$assignment->save_user_extension($userid, $duedate)) {
                  $detail = 'User id: ' . $userid . ', Assignment id: ' . $params['assignmentid'] . ', Extension date: ' . $duedate;
                  $warnings[] = self::generate_warning($params['assignmentid'],
                                                       'couldnotgrantextensions',
                                                       $detail);
              }
          }
  
          return $warnings;
      }
code: public static function save_user_extensions($assignmentid, $userids, $dates) {
          global $CFG;
  
          $params = self::validate_parameters(self::save_user_extensions_parameters(),
                          array('assignmentid' => $assignmentid,
                                'userids' => $userids,
                                'dates' => $dates));
  
          if (count($params['userids']) != count($params['dates'])) {
              $detail = 'Length of userids and dates parameters differ.';
              $warnings[] = self::generate_warning($params['assignmentid'],
                                                   'invalidparameters',
                                                   $detail);
  
              return $warnings;
          }
  
          list($assignment, $course, $cm, $context) = self::validate_assign($params['assignmentid']);
  
          $warnings = array();
          foreach ($params['userids'] as $idx => $userid) {
              $duedate = $params['dates'][$idx];
              if (!$assignment->save_user_extension($userid, $duedate)) {
                  $detail = 'User id: ' . $userid . ', Assignment id: ' . $params['assignmentid'] . ', Extension date: ' . $duedate;
                  $warnings[] = self::generate_warning($params['assignmentid'],
                                                       'couldnotgrantextensions',
                                                       $detail);
              }
          }
  
          return $warnings;
      }
code_tokens: public static function save_user_extensions ( $ assignmentid , $ userids , $ dates ) { global $ CFG ; $ params = self :: validate_parameters ( self :: save_user_extensions_parameters ( ) , array ( 'assignmentid' => $ assignmentid , 'userids' => $ userids , 'dates' => $ dates ) ) ; if ( count ( $ params [ 'userids' ] ) != count ( $ params [ 'dates' ] ) ) { $ detail = 'Length of userids and dates parameters differ.' ; $ warnings [ ] = self :: generate_warning ( $ params [ 'assignmentid' ] , 'invalidparameters' , $ detail ) ; return $ warnings ; } list ( $ assignment , $ course , $ cm , $ context ) = self :: validate_assign ( $ params [ 'assignmentid' ] ) ; $ warnings = array ( ) ; foreach ( $ params [ 'userids' ] as $ idx => $ userid ) { $ duedate = $ params [ 'dates' ] [ $ idx ] ; if ( ! $ assignment -> save_user_extension ( $ userid , $ duedate ) ) { $ detail = 'User id: ' . $ userid . ', Assignment id: ' . $ params [ 'assignmentid' ] . ', Extension date: ' . $ duedate ; $ warnings [ ] = self :: generate_warning ( $ params [ 'assignmentid' ] , 'couldnotgrantextensions' , $ detail ) ; } } return $ warnings ; }
docstring: Grant extension dates to students for an assignment.
  
  @param int $assignmentid The id of the assignment
  @param array $userids Array of user ids to grant extensions to
  @param array $dates Array of extension dates
  @return array of warnings for each extension date that could not be granted
  @since Moodle 2.6
docstring_tokens: Grant extension dates to students for an assignment .