coatless-rpkg / assignr

Tools for Educators Writing Assignments in RMarkdown
https://r-pkg.thecoatlessprofessor.com/assignr/
42 stars 7 forks source link

Directions / Assignment Chunks #6

Open daviddalpiaz opened 6 years ago

daviddalpiaz commented 6 years ago

Currently cannot be used for both r and asis engines.

coatless commented 6 years ago

I think this is wanting to add another flag to processing?

I'm not sure we can easily embed code chunks in directions...

A sample document.

```{asis, directions = TRUE}

Some directions
```{r}
1 + 1  # a line of code

Another paragraph.

Readability wise, this doesn't work out nicely.

daviddalpiaz commented 6 years ago

I'm not sure what that example is showing. I don't see the need to have one chunk inside of another.

coatless commented 6 years ago

The starting issue is a bit sparse. Did you mean something along the lines of:

```{asis, directions = TRUE}
Text
# code

going to:

Text

code



e.g. there is no discrimination between tag placement?
daviddalpiaz commented 6 years ago

Written in lab00-main.Rmd:

```{asis, assign = TRUE}
Text
# your code here

Becomes in lab00-assign.Rmd:

Text

# your code here
coatless commented 6 years ago

So, we can use this to determine the asis chunk:

asis.*?,.*?directions[[:space:]]?=[[:space:]]?[tT]?[rR]?[uU]?[eE]?

And we can force remove in the r chunk with:

,?[[:space:]]?directions[[:space:]]?=[[:space:]]?[tT]?[rR]?[uU]?[eE]?
inmybrain commented 3 years ago

As of now, can I include R code only in -assign.Rmd but not in -sol.Rmd?

coatless commented 3 years ago

As of now, can I include R code only in -assign.Rmd but not in -sol.Rmd?

If a code chunk is marked by:

These two keywords are hard-wired at the moment:

https://github.com/r-assist/assignr/blob/4b1c75717fc6141ab8490db77ca7b116907301a4/R/assignr.R#L256-L266

inmybrain commented 3 years ago

@coatless Thanks, but sorry I don't get it here.

What I want to do is

```{r, directions = TRUE}
1+1

which only returns the plain text "1+1".

I want it to generate R code only in `*-assign.Rmd`. Is this currently supported?
coatless commented 3 years ago

@inmybrain unfortunately, no. The directions= option is only supported under asis.

inmybrain commented 3 years ago

@coatless Thanks for the clarification. Is there any possibility to include such an option?

coatless commented 3 years ago

@inmybrain not until the weekend. My mind is on a paper deadline.

inmybrain commented 3 years ago

@coatless Oh I didn't mean to rush you at all. Please take your time and consider including the option when you have time. Wish you finish your paper by the due date.