Designing and Grading Interactive Exercises Cheatsheet

Effective Creation, Grading, and Troubleshooting of Interactive Coding Exercises

Quick reference guide for creating interactive coding exercises with automated grading, hints, and common pitfalls with solutions.

Tools
Author
Affiliation
Published

March 22, 2025

Keywords

interactive grading, interactive exercises, Quarto Live, custom grading

Creating Interactive Exercises

Interactive exercises engage learners and reinforce understanding through immediate feedback.



Basic Interactive Exercise Example

```{webr}
#| exercise: sum-exercise
Complete the expression to compute 2 + 8:
2 + ______
```

Adding Hints and Solutions

::: {.hint exercise="sum-exercise"}
Remember: 2 + 8 = 10.
:::

::: {.solution exercise="sum-exercise"}
```r
2 + 8
```
:::

Output

Remember: 2 + 8 = 10.

2 + 8

Custom Grading Techniques

Automatically evaluate and provide feedback based on user input.

Grading Logic in R

```{webr}
#| exercise: sum-exercise
#| check: true
expected <- 10
if (identical(.result, expected)) {
  list(correct = TRUE, message = "Correct! 2 + 8 = 10.")
} else {
  list(correct = FALSE, message = "Incorrect. Check your sum.")
}
```

Grading Logic in Python

```{pyodide}
#| exercise: sum-exercise-py
#| check: true
expected = 10
if result == expected:
    feedback = {"correct": True, "message": "Correct! 2 + 8 = 10."}
else:
    feedback = {"correct": False, "message": "Incorrect. Check your sum."}
feedback
```

Learn more about Custom Grading Techniques


Common Mistakes and Solutions

Mistake 1: Missing Exercise Labels

  • Issue: Exercise blocks not linking to hints or solutions.
  • Solution: Consistently use unique labels (e.g., sum-exercise) for exercise blocks.
```{webr}
#| exercise: unique-label
```

::: {.hint exercise="unique-label"}
Use this hint to help solve the exercise.
:::

Mistake 2: Incorrect Variable Referencing in Grading Logic

  • Issue: Grading logic references incorrect variables.
  • Solution: Ensure grading blocks correctly reference .result (R) or the defined Python variable (e.g., result).

Mistake 3: Not Providing Clear Instructions

  • Issue: Learners confused by vague instructions.
  • Solution: Clearly state the objective within exercise blocks:
```{webr}
#| exercise: clear-instruction-exercise
Calculate the mean of numbers 1 through 5:
mean(c(1, 2, 3, 4, 5))
```

Best Practices for Interactive Exercises

  • Provide clear and concise instructions.
  • Use progressive hints to guide learners without immediately giving the solution.
  • Implement robust grading logic to handle multiple correct responses.
  • Test exercises extensively before deployment.

Explore best practices in exercise design


Further Reading


Back to top

Reuse

Citation

BibTeX citation:
@online{kassambara2025,
  author = {Kassambara, Alboukadel},
  title = {Designing and {Grading} {Interactive} {Exercises}
    {Cheatsheet}},
  date = {2025-03-22},
  url = {https://www.datanovia.com/learn/interactive/cheatsheets/designing-grading-interactive-exercises.html},
  langid = {en}
}
For attribution, please cite this work as:
Kassambara, Alboukadel. 2025. “Designing and Grading Interactive Exercises Cheatsheet.” March 22, 2025. https://www.datanovia.com/learn/interactive/cheatsheets/designing-grading-interactive-exercises.html.