#' directly convert raw outline to teaching org ical
#'
#' @description using \code{create_teaching_calendar} and \code{teach_date} to convert the outline raw items into org-mode todo list which will be inputed into icalendar.
#' @param outline_str outline string items
#' @param date_begin the beginning date of the course,like "2017-03-01"
#' @param course the name the course
#' @param teachdate the week day of the course, like "Mon123"
#' @param classtime the class time, like "14:00-16:30"
#' @param room the lesson room
#' @param class the class name
#' @param holidays the no lesson days
#' @param add_dates the days needed to have lessons
#' @return org-mode todo lists
#' @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_to_org_cal(outline, date_begin="2017-03-02", course="micro",teachdate="mon123",classtime="8:00-10:40",room="1305",class="ap4")
#' holiday <- c("2017-03-30","2017-05-04")
#' add_date <-c("2017-04-01")
#' convert_to_org_cal(outline, date_begin="2017-03-02", course="micro",teachdate="mon123",classtime="8:00-10:40",room="1305",class="ap4",holiday,add_date)
convert_to_org_cal <- function(outline_str,date_begin,course,teachdate,classtime,room,class,holidays=c(""),add_dates=c("")){
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_teaching_calendar(eval(parse(text=noquote(outlinelist))),tdate2,course,teachdate,classtime,room,class)
return("please copy to teaching calendar in org-mode")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.