Skip to content

Commit 96c8845

Browse files
committed
Merge branch 'main' into course_titles
2 parents a3ad078 + 6db3800 commit 96c8845

File tree

67 files changed

+5093
-1213
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+5093
-1213
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ nbgrader/docs/source/user_guide/release/ps1/problem2.html
9292
nbgrader/docs/source/user_guide/source/header.html
9393
nbgrader/docs/source/user_guide/source/ps1/problem1.html
9494
nbgrader/docs/source/user_guide/source/ps1/problem2.html
95+
nbgrader/docs/source/user_guide/source/ps1_autotest/problem1.html
96+
nbgrader/docs/source/user_guide/source/ps1_autotest/problem2.html
9597

9698
# components stuff
9799
node_modules

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
A summary of changes to nbgrader.
22

3-
## 0.7.x
4-
53
<!-- <START NEW CHANGELOG ENTRY> -->
64

75
## 0.9.0a1
@@ -267,6 +265,8 @@ A summary of changes to nbgrader.
267265

268266
[@brichet](https://github.com/search?q=repo%3Ajupyter%2Fnbgrader+involves%3Abrichet+updated%3A2022-05-07..2022-06-28&type=Issues) | [@jhamrick](https://github.com/search?q=repo%3Ajupyter%2Fnbgrader+involves%3Ajhamrick+updated%3A2022-05-07..2022-06-28&type=Issues) | [@jtpio](https://github.com/search?q=repo%3Ajupyter%2Fnbgrader+involves%3Ajtpio+updated%3A2022-05-07..2022-06-28&type=Issues) | [@minrk](https://github.com/search?q=repo%3Ajupyter%2Fnbgrader+involves%3Aminrk+updated%3A2022-05-07..2022-06-28&type=Issues) | [@perllaghu](https://github.com/search?q=repo%3Ajupyter%2Fnbgrader+involves%3Aperllaghu+updated%3A2022-05-07..2022-06-28&type=Issues) | [@rkdarst](https://github.com/search?q=repo%3Ajupyter%2Fnbgrader+involves%3Arkdarst+updated%3A2022-05-07..2022-06-28&type=Issues)
269267

268+
## 0.7.x
269+
270270
### 0.7.1
271271

272272
The following PRs were merged for the 0.7.1 milestone:

demos/demo_multiple_classes/jupyterhub_config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@
101101
'user': 'grader-course101',
102102
'cwd': '/home/grader-course101',
103103
'environment': {
104-
# specify formgrader as default landing page
105-
'JUPYTERHUB_DEFAULT_URL': '/formgrader'
104+
# specify lab as default landing page
105+
'JUPYTERHUB_DEFAULT_URL': '/lab'
106106
},
107107
'api_token': '{{course101_token}}',
108108
},
@@ -116,8 +116,8 @@
116116
'user': 'grader-course123',
117117
'cwd': '/home/grader-course123',
118118
'environment': {
119-
# specify formgrader as default landing page
120-
'JUPYTERHUB_DEFAULT_URL': '/formgrader'
119+
# specify lab as default landing page
120+
'JUPYTERHUB_DEFAULT_URL': '/lab'
121121
},
122122
'api_token': '{{course123_token}}',
123123
},

demos/demo_one_class_multiple_graders/jupyterhub_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
],
6666
'user': 'grader-course101',
6767
'environment': {
68-
# specify formgrader as default landing page
69-
'JUPYTERHUB_DEFAULT_URL': '/formgrader'
68+
# specify lab as default landing page
69+
'JUPYTERHUB_DEFAULT_URL': '/lab'
7070
},
7171
'cwd': '/home/grader-course101',
7272
}

demos/formgrader_workspace.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

demos/utils.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ setup_nbgrader () {
4242
${runas} mkdir -p "${HOME}/.jupyter"
4343
${runas} cp "${config}" "${HOME}/.jupyter/nbgrader_config.py"
4444
${runas} chown "${USER}:${USER}" "${HOME}/.jupyter/nbgrader_config.py"
45-
46-
cp "/root/formgrader_workspace.json" "${HOME}/formgrader_workspace.json"
47-
chown "${USER}:${USER}" "${HOME}/formgrader_workspace.json"
48-
${runas} jupyter lab workspaces import "${HOME}/formgrader_workspace.json"
4945
}
5046

5147
setup_jupyterhub () {

nbgrader/api.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
DateTime, Interval, Float, Enum, UniqueConstraint,
1010
Boolean, inspect, text)
1111
from sqlalchemy.orm import (sessionmaker, scoped_session, relationship,
12-
column_property, DeclarativeBase)
12+
column_property, declarative_base)
1313
from sqlalchemy.orm.exc import NoResultFound, FlushError
1414
from sqlalchemy.ext.associationproxy import association_proxy
1515
from sqlalchemy.exc import IntegrityError, StatementError
@@ -25,8 +25,7 @@
2525
from .auth import Authenticator
2626

2727

28-
class Base(DeclarativeBase):
29-
pass
28+
Base = declarative_base()
3029

3130

3231
def new_uuid() -> str:

nbgrader/apps/generateassignmentapp.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
import sys
44

5-
from traitlets import default
5+
from traitlets import default, Bool
6+
from textwrap import dedent
67

78
from .baseapp import NbGrader, nbgrader_aliases, nbgrader_flags
8-
from ..converters import BaseConverter, GenerateAssignment, NbGraderException
9+
from ..converters import BaseConverter, GenerateAssignment, NbGraderException, GenerateSourceWithTests
910
from traitlets.traitlets import MetaHasTraits
1011
from typing import List, Any
1112
from traitlets.config.loader import Config
@@ -51,6 +52,12 @@
5152
{'BaseConverter': {'force': True}},
5253
"Overwrite an assignment/submission if it already exists."
5354
),
55+
'source_with_tests': (
56+
{'GenerateAssignmentApp': {'source_with_tests': True}},
57+
"Generate intermediate notebooks that contain both the autogenerated test code and the solutions. "
58+
"Results will be saved in the source_with_tests/ folder. "
59+
"This is useful for instructors to debug problematic autogenerated test code."
60+
),
5461
})
5562

5663

@@ -62,6 +69,17 @@ class GenerateAssignmentApp(NbGrader):
6269
aliases = aliases
6370
flags = flags
6471

72+
source_with_tests = Bool(
73+
False,
74+
help=dedent(
75+
"""
76+
Generate intermediate notebooks that contain both the autogenerated test code and the solutions.
77+
Results will be saved in the source_with_tests/ folder.
78+
This is useful for instructors to debug issues in autogenerated test code.
79+
"""
80+
)
81+
).tag(config=True)
82+
6583
examples = """
6684
Produce the version of the assignment that is intended to be released to
6785
students. This performs several modifications to the original assignment:
@@ -112,7 +130,7 @@ class GenerateAssignmentApp(NbGrader):
112130
@default("classes")
113131
def _classes_default(self) -> List[MetaHasTraits]:
114132
classes = super(GenerateAssignmentApp, self)._classes_default()
115-
classes.extend([BaseConverter, GenerateAssignment])
133+
classes.extend([BaseConverter, GenerateAssignment, GenerateSourceWithTests])
116134
return classes
117135

118136
def _load_config(self, cfg: Config, **kwargs: Any) -> None:
@@ -141,6 +159,14 @@ def start(self) -> None:
141159
elif len(self.extra_args) == 1:
142160
self.coursedir.assignment_id = self.extra_args[0]
143161

162+
163+
if self.source_with_tests:
164+
converter = GenerateSourceWithTests(coursedir=self.coursedir, parent=self)
165+
try:
166+
converter.start()
167+
except NbGraderException:
168+
sys.exit(1)
169+
144170
converter = GenerateAssignment(coursedir=self.coursedir, parent=self)
145171
try:
146172
converter.start()

nbgrader/apps/quickstartapp.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@
4040
"""
4141
)
4242
),
43+
'autotest': (
44+
{'QuickStartApp': {'autotest': True}},
45+
dedent(
46+
"""
47+
Create notebook assignments that have examples of automatic test generation via
48+
### AUTOTEST and ### HASHED AUTOTEST statements.
49+
"""
50+
)
51+
),
4352
}
4453

4554
class QuickStartApp(NbGrader):
@@ -73,6 +82,8 @@ class QuickStartApp(NbGrader):
7382

7483
force = Bool(False, help="Whether to overwrite existing files").tag(config=True)
7584

85+
autotest = Bool(False, help="Whether to use automatic test generation in example files").tag(config=True)
86+
7687
@default("classes")
7788
def _classes_default(self):
7889
classes = super(QuickStartApp, self)._classes_default()
@@ -115,12 +126,20 @@ def start(self):
115126
if not os.path.isdir(course_path):
116127
os.mkdir(course_path)
117128

118-
# populating it with an example
129+
# populate it with an example
119130
self.log.info("Copying example from the user guide...")
120131
example = os.path.abspath(os.path.join(
121132
os.path.dirname(__file__), '..', 'docs', 'source', 'user_guide', 'source'))
122-
ignore_html = shutil.ignore_patterns("*.html")
123-
shutil.copytree(example, os.path.join(course_path, "source"), ignore=ignore_html)
133+
if self.autotest:
134+
tests_file_path = os.path.abspath(os.path.join(
135+
os.path.dirname(__file__), '..', 'docs', 'source', 'user_guide', 'autotests.yml'))
136+
shutil.copyfile(tests_file_path, os.path.join(course_path, 'autotests.yml'))
137+
ignored_files = shutil.ignore_patterns("*.html", "ps1")
138+
shutil.copytree(example, os.path.join(course_path, "source"), ignore=ignored_files)
139+
os.rename(os.path.join(course_path, "source", "ps1_autotest"), os.path.join(course_path, "source", "ps1"))
140+
else:
141+
ignored_files = shutil.ignore_patterns("*.html", "autotests.yml", "ps1_autotest")
142+
shutil.copytree(example, os.path.join(course_path, "source"), ignore=ignored_files)
124143

125144
# create the config file
126145
self.log.info("Generating example config file...")

nbgrader/converters/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from .feedback import Feedback
66
from .generate_feedback import GenerateFeedback
77
from .generate_solution import GenerateSolution
8+
from .generate_source_with_tests import GenerateSourceWithTests
89

910
__all__ = [
1011
"BaseConverter",
@@ -14,5 +15,6 @@
1415
"Autograde",
1516
"Feedback",
1617
"GenerateFeedback",
17-
"GenerateSolution"
18+
"GenerateSolution",
19+
"GenerateSourceWithTests"
1820
]

0 commit comments

Comments
 (0)