Skip to content

Commit

Permalink
major fixes to swirlify app
Browse files Browse the repository at this point in the history
  • Loading branch information
seankross committed Jul 13, 2016
1 parent 9ba6eb7 commit 92d3496
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 30 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Expand Up @@ -4,3 +4,4 @@
^NEWS.md$
^.*.html$
^cran-comments\.md$
^revdep$
2 changes: 0 additions & 2 deletions .gitignore
@@ -1,7 +1,5 @@
.Rproj.user
.Rhistory
.RData
swirlify.Rproj
.DS_Store
*.html

15 changes: 4 additions & 11 deletions .travis.yml
@@ -1,15 +1,8 @@
language: r
warnings_are_errors: true
sudo: required

env:
global:
- CRAN: http://cran.rstudio.com

before_install: echo "options(repos = c(CRAN='http://cran.rstudio.com'))" > ~/.Rprofile
language: R
cache: packages
sudo: false

notifications:
email:
on_success: always
on_failure: always

on_failure: always
6 changes: 3 additions & 3 deletions DESCRIPTION
Expand Up @@ -3,7 +3,7 @@ Title: A Toolbox for Writing 'swirl' Courses
Description: A set of tools for writing and sharing interactive courses
to be used with swirl.
URL: http://swirlstats.com
Version: 0.4.1.9018
Version: 0.5.0
License: MIT + file LICENSE
Authors@R: c(
person("Sean", "Kross", , "sean@seankross.com", c("aut", "cre")),
Expand All @@ -12,9 +12,9 @@ Authors@R: c(
person("Wush", "Wu", role = "ctb")
)
Depends:
R (>= 3.2.0),
swirl (>= 2.4.2)
R (>= 3.2.0)
Imports:
swirl (>= 2.4.2),
stringr,
yaml,
rmarkdown,
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,2 +1,2 @@
YEAR: 2015
YEAR: 2016
COPYRIGHT HOLDER: Team swirl
13 changes: 13 additions & 0 deletions NEWS.md
@@ -1,3 +1,16 @@
# swirlify 0.5.0

* Removed `lp()`.

* Deprecated `testit()`. `testit()` will be removed in swirlify 0.6.

* Added `demo_lesson()` which replaces `testit()`.

* Added `google_form_decode()` to help course authors evaluate their students'
progress in a swirl couse.

* Added `swirlify()` which starts a Shiny app for authoring swirl lessons.

# swirlify 0.4

* Removed `swirlify_help()`.
Expand Down
60 changes: 48 additions & 12 deletions R/swirlify.R
Expand Up @@ -55,26 +55,62 @@ make_skeleton <- function() {
#' @import swirl
#' @import shinyAce
#' @export
#' @examples
#' \dontrun{
#'
#' # Set lesson beforehand
#' set_lesson()
#' swirlify()
#'
#' # Start a new lesson in your current directory
#' swirlify("Lesson 1", "My Course")
#'
#' }
swirlify <- function(lesson_name = NULL, course_name = NULL){
if(is.null(getOption("swirlify_lesson_file_path")) ||
!file.exists(getOption("swirlify_lesson_file_path"))){
if(is.null(lesson_name) || is.null(course_name)){
stop("Please provide arguments for both lesson_name and course_name.")
}
new_lesson(lesson_name, course_name, open_lesson = FALSE)
if(is.null(lesson_name) && is.null(course_name)){
lesson_fp <- getOption("swirlify_lesson_file_path")
if(!is.null(lesson_fp) && file.exists(lesson_fp)){
startApp()
} else {
stop("Swirlify cannot find the lesson you are trying to work on. ",
"Please provide arguments for both lesson_name and course_name to start a new lesson, ",
"or choose a lesson to work on using set_lesson.")
}
} else if(!is.null(lesson_name) && !is.null(course_name)){
lesson <- get_lesson(lesson_name, course_name)
if(is.na(lesson)){
new_lesson(lesson_name, course_name, open_lesson = FALSE)
} else {
set_lesson(lesson, open_lesson = FALSE, silent = TRUE)
}
startApp()
} else {
stop("Please provide arguments for both lesson_name and course_name to start a new course.")
}

invisible()
}

startApp <- function(){
appDir <- system.file("swirlify-app", package = "swirlify")

x <- list()
x <- runApp(appDir, display.mode = "normal")
app_results <- list()
app_results <- runApp(appDir, display.mode = "normal")

if(isTRUE(x$demo)){
if(isTRUE(app_results$demo)){
course_path <- getOption("swirlify_course_dir_path")
course_name <- getOption("swirlify_course_name")
lesson_name <- getOption("swirlify_lesson_name")
install_course_directory(course_path)
x$demo_num <- ifelse(x$demo_num < 1, 1, x$demo_num)
app_results$demo_num <- ifelse(app_results$demo_num < 1, 1, app_results$demo_num)
swirl("test", test_course = course_name, test_lesson = lesson_name,
from = x$demo_num)
from = app_results$demo_num)
}
invisible()
}

get_lesson <- function(lesson_name, course_name){
lesson_name <- make_pathname(lesson_name)
course_name <- make_pathname(course_name)
lessons <- file.path(getwd(), course_name, lesson_name, c("lesson.yaml", "lesson"))
Filter(file.exists, lessons)[1]
}
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/swirldev/swirlify.svg?branch=master)](https://travis-ci.org/swirldev/swirlify) [![CRAN version](http://www.r-pkg.org/badges/version/swirlify)](https://cran.r-project.org/web/packages/swirlify/index.html)
[![Build Status](https://travis-ci.org/swirldev/swirlify.svg?branch=master)](https://travis-ci.org/swirldev/swirlify) [![CRAN version](http://www.r-pkg.org/badges/version/swirlify)](https://cran.r-project.org/package=swirlify)

# swirlify

Expand Down
12 changes: 12 additions & 0 deletions man/swirlify.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions revdep/check.R
@@ -0,0 +1,4 @@
library("devtools")

res <- revdep_check()
revdep_check_save_summary()
Binary file added revdep/checks.rds
Binary file not shown.
17 changes: 17 additions & 0 deletions swirlify.Rproj
@@ -0,0 +1,17 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source

0 comments on commit 92d3496

Please sign in to comment.