R/create_outline_table.R

#' create a class outline table for word table
#' @author lgm
#' @param name
#' @return md
#' @export
#' @examples
#'
#' # create_outline_table("microEn","2016")
#'

create_outline_table <- function(subj,year){

	library(dplyr)
	my_db <- dplyr::src_sqlite(path="/Users/gabe/liguomin.teaching/Testbanks/testbankmd.sqlite")

	# 试题输出目录
	outdir <- "/Users/gabe/liguomin.teaching/syllabus/outlines/output/"

	testbank_tb = dplyr::tbl(my_db,'classOutline')

	outname <- paste0(subj,"-",year,"-outline")

	testbank_tb %>%
		dplyr::filter(subject==subj) %>%
		   collect %>%
		   dplyr::filter(grepl(year, teachingDate)) %>%
  		 dplyr::select(-subject) %>%
		# To pull down all the results use collect()
	  	collect %>%
		  knitr::kable(format ="latex") %>%
	    cat(., file=paste0(outdir,outname,".tex"),sep="\n")

	system(paste0("pandoc -f latex -t docx -o ",outdir,outname,".docx ",outdir,outname,".tex"), intern = TRUE)

}
Gabegit/gmExam documentation built on May 6, 2019, 5:32 p.m.