original_string: protected function load_definition() {
          global $DB;
          $sql = "SELECT gd.*,
                         rc.id AS rcid, rc.sortorder AS rcsortorder, rc.description AS rcdescription, rc.descriptionformat AS rcdescriptionformat,
                         rl.id AS rlid, rl.score AS rlscore, rl.definition AS rldefinition, rl.definitionformat AS rldefinitionformat
                    FROM {grading_definitions} gd
               LEFT JOIN {gradingform_rubric_criteria} rc ON (rc.definitionid = gd.id)
               LEFT JOIN {gradingform_rubric_levels} rl ON (rl.criterionid = rc.id)
                   WHERE gd.areaid = :areaid AND gd.method = :method
                ORDER BY rc.sortorder,rl.score";
          $params = array('areaid' => $this->areaid, 'method' => $this->get_method_name());
  
          $rs = $DB->get_recordset_sql($sql, $params);
          $this->definition = false;
          foreach ($rs as $record) {
              // pick the common definition data
              if ($this->definition === false) {
                  $this->definition = new stdClass();
                  foreach (array('id', 'name', 'description', 'descriptionformat', 'status', 'copiedfromid',
                          'timecreated', 'usercreated', 'timemodified', 'usermodified', 'timecopied', 'options') as $fieldname) {
                      $this->definition->$fieldname = $record->$fieldname;
                  }
                  $this->definition->rubric_criteria = array();
              }
              // pick the criterion data
              if (!empty($record->rcid) and empty($this->definition->rubric_criteria[$record->rcid])) {
                  foreach (array('id', 'sortorder', 'description', 'descriptionformat') as $fieldname) {
                      $this->definition->rubric_criteria[$record->rcid][$fieldname] = $record->{'rc'.$fieldname};
                  }
                  $this->definition->rubric_criteria[$record->rcid]['levels'] = array();
              }
              // pick the level data
              if (!empty($record->rlid)) {
                  foreach (array('id', 'score', 'definition', 'definitionformat') as $fieldname) {
                      $value = $record->{'rl'.$fieldname};
                      if ($fieldname == 'score') {
                          $value = (float)$value; // To prevent display like 1.00000
                      }
                      $this->definition->rubric_criteria[$record->rcid]['levels'][$record->rlid][$fieldname] = $value;
                  }
              }
          }
          $rs->close();
          $options = $this->get_options();
          if (!$options['sortlevelsasc']) {
              foreach (array_keys($this->definition->rubric_criteria) as $rcid) {
                  $this->definition->rubric_criteria[$rcid]['levels'] = array_reverse($this->definition->rubric_criteria[$rcid]['levels'], true);
              }
          }
      }
code: protected function load_definition() {
          global $DB;
          $sql = "SELECT gd.*,
                         rc.id AS rcid, rc.sortorder AS rcsortorder, rc.description AS rcdescription, rc.descriptionformat AS rcdescriptionformat,
                         rl.id AS rlid, rl.score AS rlscore, rl.definition AS rldefinition, rl.definitionformat AS rldefinitionformat
                    FROM {grading_definitions} gd
               LEFT JOIN {gradingform_rubric_criteria} rc ON (rc.definitionid = gd.id)
               LEFT JOIN {gradingform_rubric_levels} rl ON (rl.criterionid = rc.id)
                   WHERE gd.areaid = :areaid AND gd.method = :method
                ORDER BY rc.sortorder,rl.score";
          $params = array('areaid' => $this->areaid, 'method' => $this->get_method_name());
  
          $rs = $DB->get_recordset_sql($sql, $params);
          $this->definition = false;
          foreach ($rs as $record) {
              // pick the common definition data
              if ($this->definition === false) {
                  $this->definition = new stdClass();
                  foreach (array('id', 'name', 'description', 'descriptionformat', 'status', 'copiedfromid',
                          'timecreated', 'usercreated', 'timemodified', 'usermodified', 'timecopied', 'options') as $fieldname) {
                      $this->definition->$fieldname = $record->$fieldname;
                  }
                  $this->definition->rubric_criteria = array();
              }
              // pick the criterion data
              if (!empty($record->rcid) and empty($this->definition->rubric_criteria[$record->rcid])) {
                  foreach (array('id', 'sortorder', 'description', 'descriptionformat') as $fieldname) {
                      $this->definition->rubric_criteria[$record->rcid][$fieldname] = $record->{'rc'.$fieldname};
                  }
                  $this->definition->rubric_criteria[$record->rcid]['levels'] = array();
              }
              // pick the level data
              if (!empty($record->rlid)) {
                  foreach (array('id', 'score', 'definition', 'definitionformat') as $fieldname) {
                      $value = $record->{'rl'.$fieldname};
                      if ($fieldname == 'score') {
                          $value = (float)$value; // To prevent display like 1.00000
                      }
                      $this->definition->rubric_criteria[$record->rcid]['levels'][$record->rlid][$fieldname] = $value;
                  }
              }
          }
          $rs->close();
          $options = $this->get_options();
          if (!$options['sortlevelsasc']) {
              foreach (array_keys($this->definition->rubric_criteria) as $rcid) {
                  $this->definition->rubric_criteria[$rcid]['levels'] = array_reverse($this->definition->rubric_criteria[$rcid]['levels'], true);
              }
          }
      }
code_tokens: protected function load_definition ( ) { global $ DB ; $ sql = "SELECT gd.*,
                         rc.id AS rcid, rc.sortorder AS rcsortorder, rc.description AS rcdescription, rc.descriptionformat AS rcdescriptionformat,
                         rl.id AS rlid, rl.score AS rlscore, rl.definition AS rldefinition, rl.definitionformat AS rldefinitionformat
                    FROM {grading_definitions} gd
               LEFT JOIN {gradingform_rubric_criteria} rc ON (rc.definitionid = gd.id)
               LEFT JOIN {gradingform_rubric_levels} rl ON (rl.criterionid = rc.id)
                   WHERE gd.areaid = :areaid AND gd.method = :method
                ORDER BY rc.sortorder,rl.score" ; $ params = array ( 'areaid' => $ this -> areaid , 'method' => $ this -> get_method_name ( ) ) ; $ rs = $ DB -> get_recordset_sql ( $ sql , $ params ) ; $ this -> definition = false ; foreach ( $ rs as $ record ) { // pick the common definition data if ( $ this -> definition === false ) { $ this -> definition = new stdClass ( ) ; foreach ( array ( 'id' , 'name' , 'description' , 'descriptionformat' , 'status' , 'copiedfromid' , 'timecreated' , 'usercreated' , 'timemodified' , 'usermodified' , 'timecopied' , 'options' ) as $ fieldname ) { $ this -> definition -> $ fieldname = $ record -> $ fieldname ; } $ this -> definition -> rubric_criteria = array ( ) ; } // pick the criterion data if ( ! empty ( $ record -> rcid ) and empty ( $ this -> definition -> rubric_criteria [ $ record -> rcid ] ) ) { foreach ( array ( 'id' , 'sortorder' , 'description' , 'descriptionformat' ) as $ fieldname ) { $ this -> definition -> rubric_criteria [ $ record -> rcid ] [ $ fieldname ] = $ record -> { 'rc' . $ fieldname } ; } $ this -> definition -> rubric_criteria [ $ record -> rcid ] [ 'levels' ] = array ( ) ; } // pick the level data if ( ! empty ( $ record -> rlid ) ) { foreach ( array ( 'id' , 'score' , 'definition' , 'definitionformat' ) as $ fieldname ) { $ value = $ record -> { 'rl' . $ fieldname } ; if ( $ fieldname == 'score' ) { $ value = ( float ) $ value ; // To prevent display like 1.00000 } $ this -> definition -> rubric_criteria [ $ record -> rcid ] [ 'levels' ] [ $ record -> rlid ] [ $ fieldname ] = $ value ; } } } $ rs -> close ( ) ; $ options = $ this -> get_options ( ) ; if ( ! $ options [ 'sortlevelsasc' ] ) { foreach ( array_keys ( $ this -> definition -> rubric_criteria ) as $ rcid ) { $ this -> definition -> rubric_criteria [ $ rcid ] [ 'levels' ] = array_reverse ( $ this -> definition -> rubric_criteria [ $ rcid ] [ 'levels' ] , true ) ; } } }
docstring: Loads the rubric form definition if it exists
  
  There is a new array called 'rubric_criteria' appended to the list of parent's definition properties.
docstring_tokens: Loads the rubric form definition if it exists