original_string: public function get_badges_option($badge) {
          global $DB;
          $sql = "SELECT b.id, b.name, b.version, b.language, b.type
                    FROM {badge} b
                   WHERE b.id <> :badgeid
                         AND b.id NOT IN (
                              SELECT DISTINCT b.id
                                FROM {badge_related} br
                                JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id)
                               WHERE (br.badgeid = :badgeid2 OR br.relatedbadgeid = :badgeid3) AND b.id != :badgeid4)";
          $params = ['badgeid' => $badge->id, 'badgeid2' => $badge->id, 'badgeid3' => $badge->id, 'badgeid4' => $badge->id];
          if ($badge->type == BADGE_TYPE_COURSE) {
              $sql .= " AND (b.courseid = :courseid OR b.type = :badgetype)";
              $params['courseid'] = $badge->courseid;
              $params['badgetype'] = BADGE_TYPE_SITE;
          }
  
          $records = $DB->get_records_sql($sql, $params);
          $languages = get_string_manager()->get_list_of_languages();
          $options = array();
          foreach ($records as $record) {
              $language = isset($languages[$record->language]) ? $languages[$record->language] : '';
              $options[$record->id] = $record->name .
                  ' (version: ' . $record->version . ', language: ' . $language . ', ' .
                  ($record->type == BADGE_TYPE_COURSE ? get_string('badgesview', 'badges') : get_string('sitebadges', 'badges')) .
                  ')';
          }
          return $options;
      }
code: public function get_badges_option($badge) {
          global $DB;
          $sql = "SELECT b.id, b.name, b.version, b.language, b.type
                    FROM {badge} b
                   WHERE b.id <> :badgeid
                         AND b.id NOT IN (
                              SELECT DISTINCT b.id
                                FROM {badge_related} br
                                JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id)
                               WHERE (br.badgeid = :badgeid2 OR br.relatedbadgeid = :badgeid3) AND b.id != :badgeid4)";
          $params = ['badgeid' => $badge->id, 'badgeid2' => $badge->id, 'badgeid3' => $badge->id, 'badgeid4' => $badge->id];
          if ($badge->type == BADGE_TYPE_COURSE) {
              $sql .= " AND (b.courseid = :courseid OR b.type = :badgetype)";
              $params['courseid'] = $badge->courseid;
              $params['badgetype'] = BADGE_TYPE_SITE;
          }
  
          $records = $DB->get_records_sql($sql, $params);
          $languages = get_string_manager()->get_list_of_languages();
          $options = array();
          foreach ($records as $record) {
              $language = isset($languages[$record->language]) ? $languages[$record->language] : '';
              $options[$record->id] = $record->name .
                  ' (version: ' . $record->version . ', language: ' . $language . ', ' .
                  ($record->type == BADGE_TYPE_COURSE ? get_string('badgesview', 'badges') : get_string('sitebadges', 'badges')) .
                  ')';
          }
          return $options;
      }
code_tokens: public function get_badges_option ( $ badge ) { global $ DB ; $ sql = "SELECT b.id, b.name, b.version, b.language, b.type
                    FROM {badge} b
                   WHERE b.id <> :badgeid
                         AND b.id NOT IN (
                              SELECT DISTINCT b.id
                                FROM {badge_related} br
                                JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id)
                               WHERE (br.badgeid = :badgeid2 OR br.relatedbadgeid = :badgeid3) AND b.id != :badgeid4)" ; $ params = [ 'badgeid' => $ badge -> id , 'badgeid2' => $ badge -> id , 'badgeid3' => $ badge -> id , 'badgeid4' => $ badge -> id ] ; if ( $ badge -> type == BADGE_TYPE_COURSE ) { $ sql .= " AND (b.courseid = :courseid OR b.type = :badgetype)" ; $ params [ 'courseid' ] = $ badge -> courseid ; $ params [ 'badgetype' ] = BADGE_TYPE_SITE ; } $ records = $ DB -> get_records_sql ( $ sql , $ params ) ; $ languages = get_string_manager ( ) -> get_list_of_languages ( ) ; $ options = array ( ) ; foreach ( $ records as $ record ) { $ language = isset ( $ languages [ $ record -> language ] ) ? $ languages [ $ record -> language ] : '' ; $ options [ $ record -> id ] = $ record -> name . ' (version: ' . $ record -> version . ', language: ' . $ language . ', ' . ( $ record -> type == BADGE_TYPE_COURSE ? get_string ( 'badgesview' , 'badges' ) : get_string ( 'sitebadges' , 'badges' ) ) . ')' ; } return $ options ; }
docstring: Return list badge of a course or list badge site.
  
  @param object $badge Badge object.
  @return array $options An array the badges.
docstring_tokens: Return list badge of a course or list badge site .