Skip to content

Commit a27c193

Browse files
committed
add Dockerfile to docs
1 parent 14a2f8d commit a27c193

3 files changed

Lines changed: 233 additions & 0 deletions

File tree

docs/demo/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM jupyter/minimal-notebook
2+
3+
EXPOSE 8888
4+
5+
COPY Gofer_Demo.ipynb .
6+
7+
COPY tests tests
8+
9+
RUN pip install gofer-grader
10+
11+
CMD ["jupyter", "notebook"]

docs/demo/Gofer_Demo.ipynb

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"from gofer.ok import check"
10+
]
11+
},
12+
{
13+
"cell_type": "markdown",
14+
"metadata": {},
15+
"source": [
16+
"# Gofer Grader Demo\n",
17+
" \n",
18+
"Gofer uses the ok test format to autograde notebook solutions. Below is the test file for this notebook, located in `tests/demo.ok`. In short, the test file contains python code to test the value of certain variables. More details are in the documentation, in `ok-test-format.ok`."
19+
]
20+
},
21+
{
22+
"cell_type": "markdown",
23+
"metadata": {},
24+
"source": [
25+
"```\n",
26+
"test = {\n",
27+
" 'name': 'Gofer Grader Demo',\n",
28+
" 'suites': [\n",
29+
" {\n",
30+
" 'cases': [\n",
31+
" {\n",
32+
" 'code': r\"\"\"\n",
33+
" >>> # It looks like you didn't give anything the name\n",
34+
" >>> # seconds_in_a_decade. Maybe there's a typo?\n",
35+
" >>> 'seconds_in_a_decade' in vars()\n",
36+
" True\n",
37+
" \"\"\"\n",
38+
" },\n",
39+
" {\n",
40+
" 'code': r\"\"\"\n",
41+
" >>> # The number of seconds you computed is too low by at least\n",
42+
" >>> # a factor of 5.\n",
43+
" >>> # There are 10 years, some number of days in a year, some\n",
44+
" >>> # number of hours per day, minutes per hour, and seconds\n",
45+
" >>> # per minute. For example, this is almost right:\n",
46+
" >>> # seconds_in_a_decade = 10*365*24*60*60\n",
47+
" >>> seconds_in_a_decade > 60000000\n",
48+
" True\n",
49+
" \"\"\"\n",
50+
" },\n",
51+
" {\n",
52+
" 'code': r\"\"\"\n",
53+
" >>> # You're close! Perhaps you didn't account for leap years correctly.\n",
54+
" >>> # There were 2 leap years and 8 non-leap years in this period.\n",
55+
" >>> # Leap years have 366 days instead of 365.\n",
56+
" >>> 315360000 < seconds_in_a_decade < 331344000\n",
57+
" True\n",
58+
" \"\"\"\n",
59+
" },\n",
60+
" {\n",
61+
" 'code': r\"\"\"\n",
62+
" >>> seconds_in_a_decade == 315532800\n",
63+
" True\n",
64+
" \"\"\"\n",
65+
" }\n",
66+
" ]\n",
67+
" }\n",
68+
" ]\n",
69+
"}\n",
70+
"```"
71+
]
72+
},
73+
{
74+
"cell_type": "markdown",
75+
"metadata": {},
76+
"source": [
77+
"Here's a sample question, with a corresponding check.\n",
78+
" \n",
79+
"Compute the number of seconds in a decade."
80+
]
81+
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": null,
85+
"metadata": {},
86+
"outputs": [],
87+
"source": [
88+
"seconds_in_a_decade = 1"
89+
]
90+
},
91+
{
92+
"cell_type": "markdown",
93+
"metadata": {},
94+
"source": [
95+
"Below is an example of what happens when tests fail. Observe that the comments are printed as well, to give the students feedback on their error."
96+
]
97+
},
98+
{
99+
"cell_type": "code",
100+
"execution_count": null,
101+
"metadata": {
102+
"scrolled": true
103+
},
104+
"outputs": [],
105+
"source": [
106+
"check('tests/demo.ok')"
107+
]
108+
},
109+
{
110+
"cell_type": "markdown",
111+
"metadata": {},
112+
"source": [
113+
"Now let's set the correct answer."
114+
]
115+
},
116+
{
117+
"cell_type": "code",
118+
"execution_count": null,
119+
"metadata": {},
120+
"outputs": [],
121+
"source": [
122+
"seconds_in_a_decade = (365*8 + 366*2) * 24 * 60 * 60"
123+
]
124+
},
125+
{
126+
"cell_type": "markdown",
127+
"metadata": {},
128+
"source": [
129+
"Here is an example of a successful test."
130+
]
131+
},
132+
{
133+
"cell_type": "code",
134+
"execution_count": null,
135+
"metadata": {},
136+
"outputs": [],
137+
"source": [
138+
"check('tests/demo.ok')"
139+
]
140+
},
141+
{
142+
"cell_type": "markdown",
143+
"metadata": {},
144+
"source": [
145+
"Feel free to edit `demo.ok` file and add more tests. You can find it in the `tests/` folder in the Jupyter directory. "
146+
]
147+
}
148+
],
149+
"metadata": {
150+
"kernelspec": {
151+
"display_name": "Python 3",
152+
"language": "python",
153+
"name": "python3"
154+
},
155+
"language_info": {
156+
"codemirror_mode": {
157+
"name": "ipython",
158+
"version": 3
159+
},
160+
"file_extension": ".py",
161+
"mimetype": "text/x-python",
162+
"name": "python",
163+
"nbconvert_exporter": "python",
164+
"pygments_lexer": "ipython3",
165+
"version": "3.7.1"
166+
}
167+
},
168+
"nbformat": 4,
169+
"nbformat_minor": 2
170+
}

docs/demo/tests/demo.ok

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
test = {
2+
'name': 'Gofer Grader Demo',
3+
'suites': [
4+
{
5+
'cases': [
6+
{
7+
'code': r"""
8+
>>> # This is a sample test. Note the comments
9+
>>> # to give students feedback, followed by a general test.
10+
>>> True
11+
True
12+
"""
13+
},
14+
{
15+
'code': r"""
16+
>>> # It looks like you didn't give anything the name
17+
>>> # seconds_in_a_decade. Maybe there's a typo?
18+
>>> 'seconds_in_a_decade' in vars()
19+
True
20+
"""
21+
},
22+
{
23+
'code': r"""
24+
>>> # The number of seconds you computed is too low by at least
25+
>>> # a factor of 5.
26+
>>> # There are 10 years, some number of days in a year, some
27+
>>> # number of hours per day, minutes per hour, and seconds
28+
>>> # per minute. For example, this is almost right:
29+
>>> # seconds_in_a_decade = 10*365*24*60*60
30+
>>> seconds_in_a_decade > 60000000
31+
True
32+
"""
33+
},
34+
{
35+
'code': r"""
36+
>>> # You're close! Perhaps you didn't account for leap years correctly.
37+
>>> # There were 2 leap years and 8 non-leap years in this period.
38+
>>> # Leap years have 366 days instead of 365.
39+
>>> 315360000 < seconds_in_a_decade < 331344000
40+
True
41+
"""
42+
},
43+
{
44+
'code': r"""
45+
>>> seconds_in_a_decade == 315532800
46+
True
47+
"""
48+
}
49+
]
50+
}
51+
]
52+
}

0 commit comments

Comments
 (0)