original_string: public function reset_all_state($cm) {
          global $DB;
  
          if ($cm->completion == COMPLETION_TRACKING_MANUAL) {
              $this->delete_all_state($cm);
              return;
          }
          // Get current list of users with completion state
          $rs = $DB->get_recordset('course_modules_completion', array('coursemoduleid'=>$cm->id), '', 'userid');
          $keepusers = array();
          foreach ($rs as $rec) {
              $keepusers[] = $rec->userid;
          }
          $rs->close();
  
          // Delete all existing state.
          $this->delete_all_state($cm);
  
          // Merge this with list of planned users (according to roles)
          $trackedusers = $this->get_tracked_users();
          foreach ($trackedusers as $trackeduser) {
              $keepusers[] = $trackeduser->id;
          }
          $keepusers = array_unique($keepusers);
  
          // Recalculate state for each kept user
          foreach ($keepusers as $keepuser) {
              $this->update_state($cm, COMPLETION_UNKNOWN, $keepuser);
          }
      }
code: public function reset_all_state($cm) {
          global $DB;
  
          if ($cm->completion == COMPLETION_TRACKING_MANUAL) {
              $this->delete_all_state($cm);
              return;
          }
          // Get current list of users with completion state
          $rs = $DB->get_recordset('course_modules_completion', array('coursemoduleid'=>$cm->id), '', 'userid');
          $keepusers = array();
          foreach ($rs as $rec) {
              $keepusers[] = $rec->userid;
          }
          $rs->close();
  
          // Delete all existing state.
          $this->delete_all_state($cm);
  
          // Merge this with list of planned users (according to roles)
          $trackedusers = $this->get_tracked_users();
          foreach ($trackedusers as $trackeduser) {
              $keepusers[] = $trackeduser->id;
          }
          $keepusers = array_unique($keepusers);
  
          // Recalculate state for each kept user
          foreach ($keepusers as $keepuser) {
              $this->update_state($cm, COMPLETION_UNKNOWN, $keepuser);
          }
      }
code_tokens: public function reset_all_state ( $ cm ) { global $ DB ; if ( $ cm -> completion == COMPLETION_TRACKING_MANUAL ) { $ this -> delete_all_state ( $ cm ) ; return ; } // Get current list of users with completion state $ rs = $ DB -> get_recordset ( 'course_modules_completion' , array ( 'coursemoduleid' => $ cm -> id ) , '' , 'userid' ) ; $ keepusers = array ( ) ; foreach ( $ rs as $ rec ) { $ keepusers [ ] = $ rec -> userid ; } $ rs -> close ( ) ; // Delete all existing state. $ this -> delete_all_state ( $ cm ) ; // Merge this with list of planned users (according to roles) $ trackedusers = $ this -> get_tracked_users ( ) ; foreach ( $ trackedusers as $ trackeduser ) { $ keepusers [ ] = $ trackeduser -> id ; } $ keepusers = array_unique ( $ keepusers ) ; // Recalculate state for each kept user foreach ( $ keepusers as $ keepuser ) { $ this -> update_state ( $ cm , COMPLETION_UNKNOWN , $ keepuser ) ; } }
docstring: Recalculates completion state related to an activity for all users.
  
  Intended for use if completion conditions change. (This should be avoided
  as it may cause some things to become incomplete when they were previously
  complete, with the effect - for example - of hiding a later activity that
  was previously available.)
  
  Resetting state of manual tickbox has same result as deleting state for
  it.
  
  @param stcClass|cm_info $cm Activity
docstring_tokens: Recalculates completion state related to an activity for all users .