coatless-rpkg / assignr

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

results="asis" not working in solution=TRUE #8

Open sarahef2 opened 5 years ago

sarahef2 commented 5 years ago

{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](https://github.com/coatless/assignr/files/3108611/Demo-main.pdf)
Here's the results when you use assignr.  The code is pasted as is, without running.
[Demo-soln.pdf](https://github.com/coatless/assignr/files/3108618/Demo-soln.pdf)
coatless commented 5 years ago

@sarahef2 hi, I'm a bit confused as to the end goal here. Could you show a desired output?

To place R Markdown code chunks on GitHub, please use:

^ Note the extra ` backtick.

# your R code here.
sarahef2 commented 5 years ago

Thanks James!

The end goal is actually to have an extra parameter in the code chunks that would allow us to have selected solutions to release to the students as well as full solutions for the graders. So ideally, I'd have either:

This is the assignment.

```{r, solution = TRUE, echo=FALSE, results="asis", eval=params$graders}
cat("# This is markdown text which only appears in the solution for TAs and graders.")

or

This is the assignment.

if(graders) cat("# This is markdown text which only appears in the solution for TAs and graders.")


The `graders` variable would be an R variable set earlier in the document, or `params$graders` set in the markdown header.  However, neither of these work in assignr because it just sets the entire code chunk "asis".

The desired output is the first document, the one where the text appears as markdown.
coatless commented 5 years ago

Ahh, gotcha. Let me think a bit. I need to run to a few meetings. How soon are you needing this?

sarahef2 commented 5 years ago

You can take your time. I'm mostly trying to figure it out for the next TA working on this class- I've found a very clunky workaround for now. Thank you!

daviddalpiaz commented 5 years ago

Out of curiosity, which class would this be used in?

Also, I really need to start working on this package more... I keep using my own internal versions, in which it is easy to just add a grading = TRUE chunk option.

daviddalpiaz commented 5 years ago

BTW, previously I had called this option rubric: https://github.com/coatless/assignr/issues/1

Also, my interval tools strip the meta chunk options from the user documents... again I really need to engage in this package more.

sarahef2 commented 5 years ago

Stat 428: Statistical Computing. Dr. Ravat wants to release just sketches of the solutions to the students, while the graders have full solutions to use to grade. And a rubric/grading=TRUE option would do exactly what I need it to do, with a lot less fuss...

Ideally, I'd have:

This is the assignment.

```{asis, grading = TRUE}
# This text only appears for the graders.


But the github version doesn't support that.
daviddalpiaz commented 5 years ago

Yeah, we can make that happen no problem. Here are the tags that I think should exist

All other chunks and text would appear in all documents. Also in this system, three documents would be created:

Thoughts on any other obvious tags?

sarahef2 commented 5 years ago

That would be perfect! Anything marked solutions would appear in both *-soln.Rmd and *-rubric.Rmd, correct?

That would work for what we need, and I can't think of any other obvious tags.

(It wouldn't fix the issue that I mentioned in the first post, but I wouldn't need to go that route any more. You still wouldn't be able to output text results from an r code chunk that would be treated asis.)

daviddalpiaz commented 5 years ago

That would be how I would do it, although I suppose eventually we could allow users to specify that behavior.

sarahef2 commented 5 years ago

The last post should have read "can't think of any other obvious tasks"- Sorry! Those tags are the most obvious ones.