skranz / RTutor

Creating interactive R Problem Sets. Automatic hints and solution checks. (Shiny or RStudio)
https://skranz.github.io/RTutor/
200 stars 57 forks source link

highlight boxes #33

Open MartinKies opened 4 years ago

MartinKies commented 4 years ago

I just changed a few things in the LeverageData Fork

The most important ones are:

skranz commented 4 years ago

The highlight boxes look very nice. Thanks for the update. Maybe one suggestion. Perhaps instead of defining styles by a shortened name, like

<style>
.highlight_base_Youshouldknow {
    background-color: #88FF8F;
    padding: 0 2em 1em;
    margin: 2.5em 2.5em 2.5em 2.5em;
}
</style>

perhaps it may make more sense to have a style_class argument, like

#< highlight style_class="mystyle"

and then define CSS styles like

<style>
.highlight_base_mystyle {
    background-color: #88FF8F;
    padding: 0 2em 1em;
    margin: 2.5em 2.5em 2.5em 2.5em;
}
</style>

So you can easily use different forms of highlights, like warnings, remarks, etc...

skranz commented 4 years ago

Another remark: I have updated the automatic hint for dplyr chains (mostly relevant if there are still placeholders ___), which looked very ugly so far: https://github.com/skranz/RTutor/commit/d727b1175486055f4bc744fa960d5149fb648087

I now also set show.revert.btn=TRUE by default in show.ps: https://github.com/skranz/RTutor/commit/f1a9446d74ff264f4053022850764726f88c7cbb

There still seems to be sometimes as bug that the given code vanishes in the shiny version, when RTutor automatically jumps to edit the next chunk when the previous chunk was successfully checked. Have you also observed this behavior? I had not yet time to dig deeper into it. Such bugs at only appear sometimes are always tricky to debug. But at least with the "Original Code" button users can always retrieve the originally given code, should that bug occur.

MartinKies commented 4 years ago

Thank you for your suggestion! I still opted for the named block as the default case as I want it to make it as easy as possible for the author to write content without having to think about design.

Nevertheless it is now possible to completely seperate content and style, which might be useful in some instances: https://leveragedata.shinyapps.io/HighlightExample/

We do indeed use different forms of highlights (in particular Attentions and Remarks) but those always have the same title within their class (i.e. I want to have always the same design for all Attention Blocks). With the class feature it is now possible to have seperate groups of designs within the same title-group.

It also allows to have varying titles with the same design which was not a use case I previously thought about, as I currently only use strictly defined groups in my courses.

Regarding the other points:

Thank you for your info regarding the dplyr hints and the show.revert.button. I have both integrated.

Yes, we also experience this bug - and have unfortunately currently no good lead regarding its source. If you fix it, a note would be nice. Should we stumble upon the solution, we will open a new issue.

Regarding future development of our fork: Most of the previous changes where aimed at reducing time and complexity of the author(s) (The Highlight Boxes for example where previously achieved by using html hax and the aftercare shiny -> html script by manual processes). I think the most pressing issues are now resolved.

Maybe I will introduce an tag which can be used within html blocks to allow rmd formatting within a html block. This is relevant if for example one has formatted html-tables (instead of rmd-tables) and wants for example to use Math-Syntax within a cell. This is currently rather inconvenient as rmd-code does not get interpreted within html tags and manual MathJax is not very authorfriendly.

The next big thing will most likely be a complete extraction of all user-sided texts and putting them in a language file for roll-out in different languages (e.g. German but also to allow course-specific Texts independent of the specific task).

skranz commented 4 years ago

Just some short thoughts on your comment:

Maybe I will introduce an tag which can be used within html blocks to allow rmd formatting within a html block. This is relevant if for example one has formatted html-tables (instead of rmd-tables) and wants for example to use Math-Syntax within a cell. This is currently rather inconvenient as rmd-code does not get interpreted within html tags and manual MathJax is not very authorfriendly.

Hmm, not sure whether writing something like

<table><tr><td>
#< md
$x^2$
#>
</td></tr></table>

is more convenient than the pure HTML solution

<table><tr><td>
\(x^2\)
</td></tr></table>

Perhaps, if you don't want to teach your co-workers a bit HTML, it might be more convenient to define an outer block, like #< md_html so that all HTML text inside will be rendered as markdown. But it is not clear to me how easy that is to implement. This discussion may help (you could use commonmark for rendering such blocks):

https://stackoverflow.com/questions/29368902/how-can-i-wrap-my-markdown-in-an-html-div

Alternatively, you use some rvest & htmltools function to acces the text attributes of all html elements and run a markdown converter on them.

MartinKies commented 4 years ago

Thank you for your input! I did not know this command - this is a lot more elegant than what I did until now. I suppose stuff like emphasize and bolding etc. is not to difficult so when the Math Stuff ist taken care of this certainly lowers this issue a lot in the priority list.