Skip to content

Commit 9f9f3ba

Browse files
authored
Merge pull request #1276 from HanTeo/refactor/remove-db-assignments-db-students
remove db_assignments db_students
2 parents 46bbb7a + e2ddebf commit 9f9f3ba

15 files changed

+232
-264
lines changed

nbgrader/apps/baseapp.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,6 @@ def _load_config(self, cfg, **kwargs):
222222
("autograded_directory", "autograded_directory"),
223223
("feedback_directory", "feedback_directory"),
224224
("db_url", "db_url"),
225-
("db_assignments", "db_assignments"),
226-
("db_students", "db_students"),
227225
("course_directory", "root"),
228226
("ignore", "ignore")
229227
]

nbgrader/apps/quickstartapp.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,19 @@ def start(self):
129129
os.chdir(currdir)
130130
with open(os.path.join(course_path, "nbgrader_config.py"), "r") as fh:
131131
config = fh.read()
132+
133+
subprocess.call([sys.executable, "-m", "nbgrader", "db", "assignment", "add", "ps1"], stdout=subprocess.PIPE,
134+
stderr=subprocess.STDOUT)
135+
subprocess.call([sys.executable, "-m", "nbgrader", "db", "student", "add", "bitdiddle", "--first-name", "Ben",
136+
"--last-name", "Bitdiddle"],
137+
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
138+
subprocess.call([sys.executable, "-m", "nbgrader", "db", "student", "add", "hacker", "--first-name", "Alyssa",
139+
"--last-name", "Hacker"],
140+
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
141+
subprocess.call([sys.executable, "-m", "nbgrader", "db", "student", "add", "reasoner", "--first-name", "Louis",
142+
"--last-name", "Reasoner"],
143+
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
144+
132145
with open(os.path.join(course_path, "nbgrader_config.py"), "w") as fh:
133146
fh.write("c = get_config()\n\n")
134147
fh.write("#" * 79 + "\n")
@@ -140,17 +153,6 @@ def start(self):
140153
# server set up.
141154
c.CourseDirectory.course_id = "{}"
142155
143-
# Update this list with other assignments you want
144-
c.CourseDirectory.db_assignments = [dict(name="ps1")]
145-
146-
# Change the students in this list with that actual students in
147-
# your course
148-
c.CourseDirectory.db_students = [
149-
dict(id="bitdiddle", first_name="Ben", last_name="Bitdiddle"),
150-
dict(id="hacker", first_name="Alyssa", last_name="Hacker"),
151-
dict(id="reasoner", first_name="Louis", last_name="Reasoner")
152-
]
153-
154156
c.IncludeHeaderFooter.header = "source/header.ipynb"
155157
"""
156158
).format(course_id))

nbgrader/converters/autograde.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ def init_assignment(self, assignment_id, student_id):
7272
# try to get the student from the database, and throw an error if it
7373
# doesn't exist
7474
student = {}
75-
for s in self.coursedir.db_students:
76-
if s['id'] == student_id:
77-
student = s.copy()
78-
break
7975

8076
if student or self.create_student:
8177
if 'id' in student:

nbgrader/converters/generate_assignment.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,6 @@ def init_assignment(self, assignment_id, student_id):
129129
# doesn't exist
130130
if not self.no_database:
131131
assignment = {}
132-
for a in self.coursedir.db_assignments:
133-
if a['name'] == assignment_id:
134-
assignment = a.copy()
135-
break
136132

137133
if assignment or self.create_assignment:
138134
if 'name' in assignment:

nbgrader/coursedir.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -190,39 +190,6 @@ def _db_url_default(self):
190190
return "sqlite:///{}".format(
191191
os.path.abspath(os.path.join(self.root, "gradebook.db")))
192192

193-
db_assignments = List(
194-
help=dedent(
195-
"""
196-
A list of assignments that will be created in the database. Each
197-
item in the list should be a dictionary with the following keys:
198-
199-
- name
200-
- duedate (optional)
201-
202-
The values will be stored in the database. Please see the API
203-
documentation on the `Assignment` database model for details on
204-
these fields.
205-
"""
206-
)
207-
).tag(config=True)
208-
209-
db_students = List(
210-
help=dedent(
211-
"""
212-
A list of student that will be created in the database. Each
213-
item in the list should be a dictionary with the following keys:
214-
215-
- id
216-
- first_name (optional)
217-
- last_name (optional)
218-
- email (optional)
219-
220-
The values will be stored in the database. Please see the API
221-
documentation on the `Student` database model for details on
222-
these fields.
223-
"""
224-
)
225-
).tag(config=True)
226193

227194
root = Unicode(
228195
'',

nbgrader/docs/source/user_guide/managing_the_database.ipynb

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,14 @@
5050
"source": [
5151
"Most of the important information that nbgrader has access to---information about students, assignments, grades, etc.---is stored in the nbgrader database. Much of this is added to the database automatically by nbgrader, with the exception of two types of information: which students are in your class, and which assignments you have.\n",
5252
"\n",
53-
"There are three methods for adding students and assignments to the database. The first is by declaring them explicitly in the `nbgrader_config.py` file, such as:\n",
54-
"\n",
55-
"```python\n",
56-
"c = get_config()\n",
57-
"c.CourseDirectory.db_assignments = [dict(name=\"ps1\", duedate=\"2015-02-02 17:00:00 UTC\")]\n",
58-
"c.CourseDirectory.db_students = [\n",
59-
" dict(id=\"bitdiddle\", first_name=\"Ben\", last_name=\"Bitdiddle\"),\n",
60-
" dict(id=\"hacker\", first_name=\"Alyssa\", last_name=\"Hacker\")\n",
61-
"]\n",
62-
"```"
53+
"There are two methods for adding students and assignments to the database."
6354
]
6455
},
6556
{
6657
"cell_type": "raw",
6758
"metadata": {},
6859
"source": [
69-
"The second is by writing a Python script and using the :doc:`API </api/index>`. The third way is to use the command line tool ``nbgrader db``, which provides limited command line access to some of the API functionality."
60+
"The first is by writing a Python script and using the :doc:`API </api/index>`. The second way is to use the command line tool ``nbgrader db``, which provides limited command line access to some of the API functionality."
7061
]
7162
},
7263
{

0 commit comments

Comments
 (0)