Skip to content
Snippets Groups Projects
Commit 44dd8890 authored by tuhe's avatar tuhe
Browse files

Moss integration and Hinting

parent ae599247
No related branches found
No related tags found
No related merge requests found
......@@ -325,8 +325,63 @@ if __name__ == "__main__":
This will generate a report. You can view the example including the report here: https://lab.compute.dtu.dk/tuhe/unitgrade_private/-/tree/master/examples/example_moss
# Smart hinting
To help students get started, unitgrade will collect hints to solve failed tests from across the codebase and display them. Consider the following homework where two problems depends on each other and the
instructor has given a couple of hints: (example taken from `example_hints`):
```python
def find_primes(n): #!f
"""
Return a list of all primes up to (and including) n
Hints:
* Remember to return a *list* (and not a tuple or numpy ndarray)
* Remember to include n if n is a prime
* The first few primes are 2, 3, 5, ...
"""
primes = [p for p in range(2, n+1) if is_prime(n) ]
return primes
def is_prime(n): #!f
"""
Return true iff n is a prime
Hints:
* A number if a prime if it has no divisors
* You can check if k divides n using the modulo-operator. I.e. n % k == True if k divides n.
"""
for k in range(2, n):
if k % n == 0:
return False
return True
```
The report_file is simply as follows:
```python
from unitgrade2 import Report, UTestCase, evaluate_report_student
from homework1 import find_primes
import homework1
class Week1(UTestCase):
def test_find_all_primes(self):
"""
Hints:
* Insert a breakpoint and check what your function find_primes(4) actually outputs
"""
self.assertEqual(find_primes(4), [2,3])
class Report1Hints(Report):
title = "CS 106 Report 1"
questions = [(Week1, 10)] # Include a single question for 10 credits.
pack_imports = [homework1] # Unitgrade will recursively include all .py files from "cs101flat"
if __name__ == "__main__":
evaluate_report_student(Report1Hints())
```
When students run this homework it will fail and display the hints from the two methods:
![alt text|small](https://gitlab.compute.dtu.dk/tuhe/unitgrade_private/-/raw/main/docs/hints.png)
![alt text|small](https://gitlab.compute.dtu.dk/tuhe/slider/-/raw/main/docs/hints.png)
What happens behind the scenes is that a code-coverage tool is run on the instructors computer
to determine which methods are actually used in solving a problem, and then the hint-texts of those methods (and none other) are
collected and displayed. This feature requires no external configuration; simply write `Hints:` in the source code.
# Citing
```bibtex
......
......@@ -317,9 +317,23 @@ When done just call moss as follows:
This will generate a report. You can view the example including the report here: https://lab.compute.dtu.dk/tuhe/unitgrade_private/-/tree/master/examples/example_moss
# Smart hinting
To help students get started, unitgrade will collect hints to solve failed tests from across the codebase and display them. Consider the following homework where two problems depends on each other and the
instructor has given a couple of hints: (example taken from `example_hints`):
```python
{{example_hints_instructor_cs106_homework1_py}}
```
The report_file is simply as follows:
```python
{{example_hints_instructor_cs106_report1hints_py}}
```
When students run this homework it will fail and display the hints from the two methods:
![alt text|small]({{resources}}/docs/hints.png)
What happens behind the scenes is that a code-coverage tool is run on the instructors computer
to determine which methods are actually used in solving a problem, and then the hint-texts of those methods (and none other) are
collected and displayed. This feature requires no external configuration; simply write `Hints:` in the source code.
# Citing
```bibtex
{{bibtex}}
......
......@@ -14,7 +14,7 @@ if __name__ == "__main__":
k = os.path.relpath(file, "../examples").replace(os.sep, "_").replace(".", "_")
data[k] = f.read()
data['resources'] = "https://gitlab.compute.dtu.dk/tuhe/slider/-/raw/main"
data['resources'] = "https://gitlab.compute.dtu.dk/tuhe/unitgrade_private/-/raw/main"
with open("README.jinja.md", 'r') as f:
s = jinja2.Environment(loader=jinja2.FileSystemLoader([".", "../example"])).from_string(f.read()).render(data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment