diff --git a/README.md b/README.md index 9a734bd..2e8570c 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,5 @@ Written in R because I'm much quicker at that than Python, and it seemed like a Pull requests always welcome! +If you want to run this yourself (for dev or fun), you can download the question pools from +https://github.com/russolsen/ham_radio_question_pool and place in `/lib`. \ No newline at end of file diff --git a/bin/toot-ham-license-qs.R b/bin/toot-ham-license-qs.R index b575a9e..9ba0242 100644 --- a/bin/toot-ham-license-qs.R +++ b/bin/toot-ham-license-qs.R @@ -86,35 +86,48 @@ mastodon_token <- login(auth$mastodon$server, auth$mastodon$email, auth$mastodon # Test vector of toots # This is where a df of questions, answer options, and any figures will go -db <- data.frame(license = letters, - question = LETTERS, - ans1 = rev(letters), - ans2 = letters, - ans3 = rev(letters), - ans4 = rev(LETTERS), - ans_correct = letters, - fig_path = rev(LETTERS)) - -# TODO pull all questions from https://github.com/russolsen/ham_radio_question_pool -# Arrange data frame accordingly. +# db <- data.frame(license = letters, +# question = LETTERS, +# ans1 = rev(letters), +# ans2 = letters, +# ans3 = rev(letters), +# ans4 = rev(LETTERS), +# ans_correct = letters, +# fig_path = rev(LETTERS)) +# Read in the awesome question sets from https://github.com/russolsen/ham_radio_question_pool +db_tech <- read.csv("lib/ham_radio_question_pool-master/technician-2018-2022/technician.csv", stringsAsFactors = F) +db_general <- read.csv("lib/ham_radio_question_pool-master/general-2019-2023/general.csv", stringsAsFactors = F) +db_extra <- read.csv("lib/ham_radio_question_pool-master/extra-2020-2024/extra.csv", stringsAsFactors = F) +# add name of exam +db_tech[['exam']] <- "Technician" +db_general[['exam']] <- "General" +db_extra[['exam']] <- "Extra" +# Combine all +db <- rbind(db_tech, + db_general, + db_extra) +# TODO add figures +db[['fig_path']] <- NA # Choose a random row to toot toot_row <- db[sample(1:nrow(db), 1), ] # Scramble answers ans_options <- rep(paste0("\n- ", - sample(as.character(toot_row[1,3:6])), + sample(as.character(toot_row[,4:7])), collapse = "")) # Build question -post_text <- paste0(toot_row[['license']], +post_text <- paste0(toot_row[['exam']], + " ", + toot_row[['id']], ": ", toot_row[['question']], ans_options) # Toot the thing! -post_status(mastodon_token, - post_text) +# post_status(mastodon_token, +# post_text) # Check for image if(!is.na(toot_row[['fig_path']])){