#' directly convert raw outline items into word timetable
#' @description using \code{create_timetable} and \code{gmdata::teach_date} to convert raw outline items to word timetable
#' @param outline_str outline string items
#' @param date_begin the beginning date of the course,like "2017-03-01"
#' @param holidays the no lesson days
#' @param add_dates the days needed to have lessons
#' @week_class classes of a week
#' @return data for timetable in word
#' @export
#' @examples
#' outline <- "What is economics
#' 讲授内容:definition of economics; graphs in economics。 阅读章节:Parkin Ch1。
#' The Economic Problem
#' 讲授内容: production possibilities and opportunity cost; 阅读章节:Parkin ch2.
#' Demand and Supply
#' 讲授内容: demand; supply; equilibrium. 阅读章节:Parkin ch3.
#' "
#' convert_word_timetable(outline,"2017-02-20")
#' holidays <- c("2017-03-30","2017-05-04")
#' add_dates <-c("2017-04-01")
#' convert_word_timetable(outline,"2017-02-20",holidays,add_date,3)
convert_word_timetable <- function(outline_str,date_begin,holidays=c(""),add_dates=c(""),week_class=3){
suppressWarnings(suppressPackageStartupMessages({
library(stringr)
library(purrr)
}))
outline_str %>%
str_extract_all(".*\n.*\n") %>%
.[[1]] %>%
str_split(pattern = "\n") %>%
map(~paste0(gsub("[ ,]","_",str_trim(.x[1],"both"))," = \"",.x[2],"\"")) -> outdata
len <- length(outdata)
outdata %>%
unlist %>%
paste0(collapse=", ") %>%
paste0("list(",.,")") -> outlinelist
#eval(parse(text=outlinelist))
tdate <- gmdata::teach_date(date_begin,holidays,add_dates)
tdate2 <- tdate[1:len]
## create teaching calendar
create_timetable(eval(parse(text=outlinelist)),tdate2,week_class)
return("please copy outline content to word timetable")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.