original_string: public function review($userid, $filtered = false) {
          global $DB;
  
          $sql = "SELECT bc.*, bcm.critid, bcm.userid, bcm.datemet
                  FROM {badge_criteria} bc
                  LEFT JOIN {badge_criteria_met} bcm
                      ON bc.id = bcm.critid AND bcm.userid = :userid
                  WHERE bc.badgeid = :badgeid
                      AND bc.criteriatype != :criteriatype ";
  
          $params = array(
                      'userid' => $userid,
                      'badgeid' => $this->badgeid,
                      'criteriatype' => BADGE_CRITERIA_TYPE_OVERALL
                  );
  
          $criteria = $DB->get_records_sql($sql, $params);
          $overall = false;
          foreach ($criteria as $crit) {
              if ($this->method == BADGE_CRITERIA_AGGREGATION_ALL) {
                  if ($crit->datemet === null) {
                      return false;
                  } else {
                      $overall = true;
                      continue;
                  }
              } else {
                  if ($crit->datemet === null) {
                      $overall = false;
                      continue;
                  } else {
                      return true;
                  }
              }
          }
  
          return $overall;
      }
code: public function review($userid, $filtered = false) {
          global $DB;
  
          $sql = "SELECT bc.*, bcm.critid, bcm.userid, bcm.datemet
                  FROM {badge_criteria} bc
                  LEFT JOIN {badge_criteria_met} bcm
                      ON bc.id = bcm.critid AND bcm.userid = :userid
                  WHERE bc.badgeid = :badgeid
                      AND bc.criteriatype != :criteriatype ";
  
          $params = array(
                      'userid' => $userid,
                      'badgeid' => $this->badgeid,
                      'criteriatype' => BADGE_CRITERIA_TYPE_OVERALL
                  );
  
          $criteria = $DB->get_records_sql($sql, $params);
          $overall = false;
          foreach ($criteria as $crit) {
              if ($this->method == BADGE_CRITERIA_AGGREGATION_ALL) {
                  if ($crit->datemet === null) {
                      return false;
                  } else {
                      $overall = true;
                      continue;
                  }
              } else {
                  if ($crit->datemet === null) {
                      $overall = false;
                      continue;
                  } else {
                      return true;
                  }
              }
          }
  
          return $overall;
      }
code_tokens: public function review ( $ userid , $ filtered = false ) { global $ DB ; $ sql = "SELECT bc.*, bcm.critid, bcm.userid, bcm.datemet
                  FROM {badge_criteria} bc
                  LEFT JOIN {badge_criteria_met} bcm
                      ON bc.id = bcm.critid AND bcm.userid = :userid
                  WHERE bc.badgeid = :badgeid
                      AND bc.criteriatype != :criteriatype " ; $ params = array ( 'userid' => $ userid , 'badgeid' => $ this -> badgeid , 'criteriatype' => BADGE_CRITERIA_TYPE_OVERALL ) ; $ criteria = $ DB -> get_records_sql ( $ sql , $ params ) ; $ overall = false ; foreach ( $ criteria as $ crit ) { if ( $ this -> method == BADGE_CRITERIA_AGGREGATION_ALL ) { if ( $ crit -> datemet === null ) { return false ; } else { $ overall = true ; continue ; } } else { if ( $ crit -> datemet === null ) { $ overall = false ; continue ; } else { return true ; } } } return $ overall ; }
docstring: Review this criteria and decide if it has been completed
  Overall criteria review should be called only from other criteria handlers.
  
  @param int $userid User whose criteria completion needs to be reviewed.
  @param bool $filtered An additional parameter indicating that user list
  has been reduced and some expensive checks can be skipped.
  
  @return bool Whether criteria is complete
docstring_tokens: Review this criteria and decide if it has been completed Overall criteria review should be called only from other criteria handlers .