original_string: public function delete_all_state($cm) {
          global $DB;
  
          // Delete from database
          $DB->delete_records('course_modules_completion', array('coursemoduleid'=>$cm->id));
  
          // Check if there is an associated course completion criteria
          $criteria = $this->get_criteria(COMPLETION_CRITERIA_TYPE_ACTIVITY);
          $acriteria = false;
          foreach ($criteria as $criterion) {
              if ($criterion->moduleinstance == $cm->id) {
                  $acriteria = $criterion;
                  break;
              }
          }
  
          if ($acriteria) {
              // Delete all criteria completions relating to this activity
              $DB->delete_records('course_completion_crit_compl', array('course' => $this->course_id, 'criteriaid' => $acriteria->id));
              $DB->delete_records('course_completions', array('course' => $this->course_id));
          }
  
          // Difficult to find affected users, just purge all completion cache.
          cache::make('core', 'completion')->purge();
          cache::make('core', 'coursecompletion')->purge();
      }
code: public function delete_all_state($cm) {
          global $DB;
  
          // Delete from database
          $DB->delete_records('course_modules_completion', array('coursemoduleid'=>$cm->id));
  
          // Check if there is an associated course completion criteria
          $criteria = $this->get_criteria(COMPLETION_CRITERIA_TYPE_ACTIVITY);
          $acriteria = false;
          foreach ($criteria as $criterion) {
              if ($criterion->moduleinstance == $cm->id) {
                  $acriteria = $criterion;
                  break;
              }
          }
  
          if ($acriteria) {
              // Delete all criteria completions relating to this activity
              $DB->delete_records('course_completion_crit_compl', array('course' => $this->course_id, 'criteriaid' => $acriteria->id));
              $DB->delete_records('course_completions', array('course' => $this->course_id));
          }
  
          // Difficult to find affected users, just purge all completion cache.
          cache::make('core', 'completion')->purge();
          cache::make('core', 'coursecompletion')->purge();
      }
code_tokens: public function delete_all_state ( $ cm ) { global $ DB ; // Delete from database $ DB -> delete_records ( 'course_modules_completion' , array ( 'coursemoduleid' => $ cm -> id ) ) ; // Check if there is an associated course completion criteria $ criteria = $ this -> get_criteria ( COMPLETION_CRITERIA_TYPE_ACTIVITY ) ; $ acriteria = false ; foreach ( $ criteria as $ criterion ) { if ( $ criterion -> moduleinstance == $ cm -> id ) { $ acriteria = $ criterion ; break ; } } if ( $ acriteria ) { // Delete all criteria completions relating to this activity $ DB -> delete_records ( 'course_completion_crit_compl' , array ( 'course' => $ this -> course_id , 'criteriaid' => $ acriteria -> id ) ) ; $ DB -> delete_records ( 'course_completions' , array ( 'course' => $ this -> course_id ) ) ; } // Difficult to find affected users, just purge all completion cache. cache :: make ( 'core' , 'completion' ) -> purge ( ) ; cache :: make ( 'core' , 'coursecompletion' ) -> purge ( ) ; }
docstring: Deletes completion state related to an activity for all users.
  
  Intended for use only when the activity itself is deleted.
  
  @param stdClass|cm_info $cm Activity
docstring_tokens: Deletes completion state related to an activity for all users .