Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code exercises #121

Open
coatless opened this issue Dec 19, 2023 · 4 comments
Open

Code exercises #121

coatless opened this issue Dec 19, 2023 · 4 comments
Labels
p: low Address issue when time permits t: feature-request Request the addition of a new feature
Milestone

Comments

@coatless
Copy link
Owner

Offer the code exercise feature from {learnr}.

This should match more closely with the desire of #25

Sample exercise: https://github.com/rstudio/learnr/blob/aeb8144f5335a1132dbb1c0a0302fd2f3e94b875/inst/tutorials/ex-data-filter/ex-data-filter.Rmd#L236

Proposed markup:

```{webr-r}
#| label: ex01
#| exercise: true

```

```{webr-r}
#| label: ex01-solution
filter(flights, dep_time <= 600 | dep_time == 2400)
```

```{webr-r}
#| label: ex01-hint-1
# any number with a zero exponent is equal to one
NA ^ 0
```

```{webr-r}
#| label: ex01-hint-2
# unknown value or true evaluates to true
# (because if one operand of "or" is true, we can be sure the result is true)
NA | TRUE
```

```{webr-r}
#| label: ex01-hint-3

# false and unknown value evaluates to false
# (because if one operand of "and" is true, we can be sure the result is false)
FALSE & NA
```

```{webr-r}
#| label: ex01-hint-4
# this is not a logical comparison, it's a numerical calculation involving an
# unknown value, thus resulting in an unknown value
NA * 0
```
@coatless coatless added t: feature-request Request the addition of a new feature p: low Address issue when time permits labels Dec 19, 2023
@coatless coatless added this to the 4.x milestone Dec 19, 2023
@coatless coatless modified the milestones: 4.x, 4.1 Jan 30, 2024
@joelostblom
Copy link

Would this feature also support rendered radio buttons for e.g. MCQs as well (as in https://nareal.github.io/naquiz/example.html)? It's easy to emulate this with code otherwise, but I'm curious since I believe learnr and webexercises also supports some of these rendered simpler html elements.

Also of interest, do you think the approach here would lend it self well to be supported in the pyodide implementation as well? I'm planning to write a textbook using R and Py and I'm excited to see the developments here =)

@coatless
Copy link
Owner Author

coatless commented Mar 2, 2024

@joelostblom the focus would solely be on the code evaluation portion.

The MC/MS/FIB offerings from {learnr} are better left as a standalone quarto extension as the format is reusable across languages like quarto-quiz or the naquiz format you identified. Plus, for language-specific implementations like {webexercises}, these would address content specific to R. For example:

Given a seed of <dynamic-seed> what would be the mean of the vector given by <dynamic-numbers>.

  • Option 1
  • Option 2
  • ...

At some point, I could imagine the joining of quarto-webr/quarto-pyodide + quarto-quiz to form quarto-learn, but I'm not likely to lead that project.

@davidkane9
Copy link

This would be excellent! My use case is writing a Quarto book with learnr exercises embedded in it. Right now, I need to keep my book separate from my tutorials. It would be much nicer to put everything into a single document. In this way, students could (be forced to) answer questions as they move through the textbook.

@joelnitta
Copy link

Quarto Live now has this feature

https://r-wasm.github.io/quarto-live/exercises/exercises.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p: low Address issue when time permits t: feature-request Request the addition of a new feature
Projects
None yet
Development

No branches or pull requests

4 participants