Code Monkey home page Code Monkey logo

assignr's Introduction

assignr

R build status Package-License

Tools for creating homework assignments and solutions using RMarkdown.

Motivation

Writing homework assignments for students in the age of RMarkdown necessitates the creation of two separate documents -- assign.Rmd and soln.Rmd. The goal of assignr is to create one document main.Rmd that can be broken apart into the above two documents. Thus, there is no longer a need to copy and paste between the assign and the soln documents as all of the contents are together in one file.

Example workflow with assignr

Installation

assignr is only available via GitHub.

To install the package from GitHub, you can type:

install.packages("devtools")

devtools::install_github("coatless-rpkg/assignr")

Usage

To use assignr, create an Rmd file named WXYZ-main.Rmd, where WXYZ could be hw00. Within the file, add to your code chunks one of the following chunk options:

  1. solution = TRUE
    • to mark a solution
  2. directions = TRUE
    • to indicate directions

When specifying text directions that should not appear in the solution file, use the latter chunk option, and set the code chunk engine to asis, e.g.

```{asis name, directions = TRUE}
The goal of the following exercise is... 
```

Then, in R, run:

# Render output
assignr("hw00-main.Rmd")

Example Output:

hw00
├── hw00-assign
│   ├── hw00-assign.Rmd
│   ├── hw00-assign.html
│   ├── hw00-assign.pdf
│   └── hw00-assign.zip
└── hw00-soln
    ├── hw00-soln.Rmd
    ├── hw00-soln.html
    ├── hw00-soln.pdf
    └── hw00-soln.zip

Previews of what is contained in each file are shown next.

Instructor Main

In the main file, denoted as *-main.Rmd, all content -- including solutions -- should be placed. As an example of contents, please see the hw00-main.Rmd document that ships with the package.

library("assignr")

file.show(get_example_filepath("hw00-main.Rmd"))
---
title: 'Homework X'
author: "Prof. Name"
date: 'Due: Friday, Month Day by 1:59 PM CDT'
output:
  html_document:
    theme: readable
    toc: yes
---

# Exercise 1 (Introductory `R`)

```{asis, directions = TRUE}
For this exercise, we will create a couple different vectors.
```

**(a)** Create two vectors `x0` and `x1`. Each should have a
length of 25 and store the following:

- `x0`: Each element should be the value `10`.
- `x1`: The first 25 cubed numbers, starting from `1.` (e.g. `1`, `8`, `27`, et cetera)

```{asis, solution = TRUE}
**Solution:**
```

```{r, solution = TRUE}
x0 = rep(10, 25)
x1 = (1:25) ^ 3
```

Student Assignment

Within this section, the assignment rmarkdown file given to students is displayed.

---
title: 'Homework X'
author: "Prof. Name"
date: 'Due: Friday, Month Day by 1:59 PM CDT'
output:
  html_document:
    theme: readable
    toc: yes
---

# Exercise 1 (Introductory `R`)

For this exercise, we will create a couple different vectors.

**(a)** Create two vectors `x0` and `x1`. Each should have a
length of 25 and store the following:

- `x0`: Each element should be the value `10`.
- `x1`: The first 25 cubed numbers, starting from `1.` (e.g. `1`, `8`, `27`, et cetera)

PDF Rendering of hw00-assign.Rmd

Solutions

Lastly, we have the assignment rmarkdown file that contains the solutions and their respective output.

---
title: 'Homework X'
author: "Prof. Name"
date: 'Due: Friday, Month Day by 1:59 PM CDT'
output:
  html_document:
    theme: readable
    toc: yes
---

# Exercise 1 (Introductory `R`)


**(a)** Create two vectors `x0` and `x1`. Each should have a
length of 25 and store the following:

- `x0`: Each element should be the value `10`.
- `x1`: The first 25 cubed numbers, starting from `1.` (e.g. `1`, `8`, `27`, et cetera)

**Solution:**

```{r, solution = TRUE}
x0 = rep(10, 25)
x1 = (1:25) ^ 3
```

PDF Rendering of hw00-soln.Rmd

Authors

James Joseph Balamuta and David Dalpiaz

License

GPL (>= 2)

assignr's People

Contributors

coatless avatar daviddalpiaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

assignr's Issues

CRAN Release Candidate

@daviddalpiaz Next weekend I'm shooting to release this to CRAN. I think a release build will have solved:

  • #1 Removed portions of solution = TRUE et cetera.
  • #3 Cloned resources
  • #4 Unit Tests on Rendered Documents

Alternatively, we can hold off until #1 resolves the ability to provide custom chunks. I'm thinking along the lines of:

add_option(tag, rendered_file)

So, maybe something like:

doc_chunk_options() %>% 
    add_option("solution", "soln") %>%
    add_option("directions", c("soln", "assign"))

Thoughts?

Solutions spell checking

Currently RStudio will not spell check within the asis engine. Maybe we can run a script on the resulting *-soln.Rmd that returns spell check information so a user can then go back and edit those chunks.

results="asis" not working in solution=TRUE

{r, solution = TRUE, echo=FALSE, results="asis"} is currently rendering as an "asis" code block in the solution markdown without running the R code at all.

Here is Demo-main.Rmd:

This is the assignment.

```{r, solution = TRUE, echo=FALSE, results="asis"}
cat("# This is markdown text.")
```

I've attached the results when you knit this document without assignr. The markdown appears perfectly.
Demo-main.pdf
Here's the results when you use assignr. The code is pasted as is, without running.
Demo-soln.pdf

Never ending with Korean

Hi

I'm trying to use this awesome package in my class, but I found that when I include Korean in Rmd, assignr does not complete its job. It is just stuck at the first step and does not proceed.

> assignr(file = "./Final_v1.0-main.Rmd")
Building Final_v1.0-assign files

Do you happen to know how I can handle this?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.