original_string: public static function get_courseid_from_type_id($type, $id) {
          global $DB;
          if ($type == backup::TYPE_1COURSE) {
              return $id; // id is the course id
  
          } else if ($type == backup::TYPE_1SECTION) {
              if (! $courseid = $DB->get_field('course_sections', 'course', array('id' => $id))) {
                  throw new backup_dbops_exception('course_not_found_for_section', $id);
              }
              return $courseid;
          } else if ($type == backup::TYPE_1ACTIVITY) {
              if (! $courseid = $DB->get_field('course_modules', 'course', array('id' => $id))) {
                  throw new backup_dbops_exception('course_not_found_for_moduleid', $id);
              }
              return $courseid;
          }
      }
code: public static function get_courseid_from_type_id($type, $id) {
          global $DB;
          if ($type == backup::TYPE_1COURSE) {
              return $id; // id is the course id
  
          } else if ($type == backup::TYPE_1SECTION) {
              if (! $courseid = $DB->get_field('course_sections', 'course', array('id' => $id))) {
                  throw new backup_dbops_exception('course_not_found_for_section', $id);
              }
              return $courseid;
          } else if ($type == backup::TYPE_1ACTIVITY) {
              if (! $courseid = $DB->get_field('course_modules', 'course', array('id' => $id))) {
                  throw new backup_dbops_exception('course_not_found_for_moduleid', $id);
              }
              return $courseid;
          }
      }
code_tokens: public static function get_courseid_from_type_id ( $ type , $ id ) { global $ DB ; if ( $ type == backup :: TYPE_1COURSE ) { return $ id ; // id is the course id } else if ( $ type == backup :: TYPE_1SECTION ) { if ( ! $ courseid = $ DB -> get_field ( 'course_sections' , 'course' , array ( 'id' => $ id ) ) ) { throw new backup_dbops_exception ( 'course_not_found_for_section' , $ id ) ; } return $ courseid ; } else if ( $ type == backup :: TYPE_1ACTIVITY ) { if ( ! $ courseid = $ DB -> get_field ( 'course_modules' , 'course' , array ( 'id' => $ id ) ) ) { throw new backup_dbops_exception ( 'course_not_found_for_moduleid' , $ id ) ; } return $ courseid ; } }
docstring: Given one type and id from controller, return the corresponding courseid
docstring_tokens: Given one type and id from controller return the corresponding courseid