#' 增加考试年份到 examyear 字段
#'
#' @author Gabe lee
#' @param testid:
#' @return years
#' @export
#' @examples
#' # \dontrun{
#' # med_micro_test_2015_cn_benke_A <- as.character(c(1,5,8,17,24,27))
#' # med_micro_test_2015_cn_benke_B <- as.character(c(3,5,7,18,23,28))
#' # med_micro_test_2015_cn_benke_C <- as.character(c(1,9,19,20,22,26))
#' #add_exam_year(med_micro_test_2015_cn_benke_A)
#' #add_exam_year(med_micro_test_2015_cn_benke_B)
#' #add_exam_year(med_micro_test_2015_cn_benke_C)
#' #med_micro_test_2015_cn_A = c('14');
#' # add_exam_year (med_micro_test_2015_cn_A)
#' }
add_exam_year <- function(testid,exyear){
#library(RSQLite)
db <- RSQLite::dbConnect(RSQLite::SQLite(), dbname = "/Users/gabe/liguomin.teaching/Testbanks/testbankmd.sqlite")
RSQLite::initExtension(db)
outname <- deparse(substitute( testid))
exyear<- sub(".+([0-9]{4}).+_([a-z]).+_([A-Z])$","\\2\\1\\3",outname)
lapply(testid, function(x) {
RSQLite::dbSendQuery(conn = db,paste0("UPDATE testbank SET examyear=examyear || ","'",exyear,",'"," where mdid=",x," AND examyear NOT like '%",exyear,"%'"))
})
#delete exam years
#RSQLite::dbSendQuery(conn = db,"UPDATE testbank SET examyear= '' ")
# Disconnect from the database
RSQLite::dbDisconnect(db)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.