R/survey_uploader.R

Defines functions Upload_Surveys

Documented in Upload_Surveys

#' Upload a bunch of surveys
#'
#' This function uploads a bunch of surveys from a file with the lss or lsa data.
#' @param Survey_Info A vector listing all of the Survey IDs to be activated.
#' @export
#' @examples \dontrun{
#' Activate_Surveys(12345)
#' }
#'
Upload_Surveys <- function(Survey_Info){

  get_session_key()


  # First you need a small csv file with two columns- Name and ID. In the Name column are the names of the different surveys to be uploaded, in the ID column are the corresponding IDs that you want to alot
  Names <- fread("Important/Survey_Names.csv")
  #create a list of the files from your target directory
  file_list <- list.files(pattern = ".lss")
  # Ignore the Important folder
  file_list <- file_list[!match(file_list,"Important",nomatch = FALSE)]

  setorder(Names, cols = "ID")

  # For loop uploads the surveys and gives them the names and the number codes from the csv file
  for (i in c(1:nrow(Names)))
  {
    temp <- base64_enc(read_file(file_list[Names$`Folder Order`[i]]))

    call_limer(method = "import_survey",
               params = list(sImportData = temp,
                             sImportDataType = "lss",
                             sNewSurveyName = Names$Name[i],
                             DestSurveyID = Names$ID[i]))
  } # end For loop

} # end function
bpresentati/surveyR documentation built on March 19, 2022, 3:40 a.m.