original_string: public static function unassign_grouping($unassignments) {
          global $CFG, $DB;
          require_once("$CFG->dirroot/group/lib.php");
  
          $params = self::validate_parameters(self::unassign_grouping_parameters(), array('unassignments'=>$unassignments));
  
          $transaction = $DB->start_delegated_transaction();
          foreach ($params['unassignments'] as $unassignment) {
              // Validate params.
              $groupingid = $unassignment['groupingid'];
              $groupid = $unassignment['groupid'];
  
              $grouping = groups_get_grouping($groupingid, 'id, courseid', MUST_EXIST);
              $group = groups_get_group($groupid, 'id, courseid', MUST_EXIST);
  
              if (!$DB->record_exists('groupings_groups', array('groupingid'=>$groupingid, 'groupid'=>$groupid))) {
                  // Continue silently if the group is not assigned to the grouping.
                  continue;
              }
  
              // Now security checks.
              $context = context_course::instance($grouping->courseid);
              try {
                  self::validate_context($context);
              } catch (Exception $e) {
                  $exceptionparam = new stdClass();
                  $exceptionparam->message = $e->getMessage();
                  $exceptionparam->courseid = $group->courseid;
                  throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
              }
              require_capability('moodle/course:managegroups', $context);
  
              groups_unassign_grouping($groupingid, $groupid);
          }
  
          $transaction->allow_commit();
      }
code: public static function unassign_grouping($unassignments) {
          global $CFG, $DB;
          require_once("$CFG->dirroot/group/lib.php");
  
          $params = self::validate_parameters(self::unassign_grouping_parameters(), array('unassignments'=>$unassignments));
  
          $transaction = $DB->start_delegated_transaction();
          foreach ($params['unassignments'] as $unassignment) {
              // Validate params.
              $groupingid = $unassignment['groupingid'];
              $groupid = $unassignment['groupid'];
  
              $grouping = groups_get_grouping($groupingid, 'id, courseid', MUST_EXIST);
              $group = groups_get_group($groupid, 'id, courseid', MUST_EXIST);
  
              if (!$DB->record_exists('groupings_groups', array('groupingid'=>$groupingid, 'groupid'=>$groupid))) {
                  // Continue silently if the group is not assigned to the grouping.
                  continue;
              }
  
              // Now security checks.
              $context = context_course::instance($grouping->courseid);
              try {
                  self::validate_context($context);
              } catch (Exception $e) {
                  $exceptionparam = new stdClass();
                  $exceptionparam->message = $e->getMessage();
                  $exceptionparam->courseid = $group->courseid;
                  throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam);
              }
              require_capability('moodle/course:managegroups', $context);
  
              groups_unassign_grouping($groupingid, $groupid);
          }
  
          $transaction->allow_commit();
      }
code_tokens: public static function unassign_grouping ( $ unassignments ) { global $ CFG , $ DB ; require_once ( "$CFG->dirroot/group/lib.php" ) ; $ params = self :: validate_parameters ( self :: unassign_grouping_parameters ( ) , array ( 'unassignments' => $ unassignments ) ) ; $ transaction = $ DB -> start_delegated_transaction ( ) ; foreach ( $ params [ 'unassignments' ] as $ unassignment ) { // Validate params. $ groupingid = $ unassignment [ 'groupingid' ] ; $ groupid = $ unassignment [ 'groupid' ] ; $ grouping = groups_get_grouping ( $ groupingid , 'id, courseid' , MUST_EXIST ) ; $ group = groups_get_group ( $ groupid , 'id, courseid' , MUST_EXIST ) ; if ( ! $ DB -> record_exists ( 'groupings_groups' , array ( 'groupingid' => $ groupingid , 'groupid' => $ groupid ) ) ) { // Continue silently if the group is not assigned to the grouping. continue ; } // Now security checks. $ context = context_course :: instance ( $ grouping -> courseid ) ; try { self :: validate_context ( $ context ) ; } catch ( Exception $ e ) { $ exceptionparam = new stdClass ( ) ; $ exceptionparam -> message = $ e -> getMessage ( ) ; $ exceptionparam -> courseid = $ group -> courseid ; throw new moodle_exception ( 'errorcoursecontextnotvalid' , 'webservice' , '' , $ exceptionparam ) ; } require_capability ( 'moodle/course:managegroups' , $ context ) ; groups_unassign_grouping ( $ groupingid , $ groupid ) ; } $ transaction -> allow_commit ( ) ; }
docstring: Unassign a group from a grouping
  
  @param array $unassignments of arrays with keys groupid, groupingid
  @return void
  @since Moodle 2.3
docstring_tokens: Unassign a group from a grouping