Skip to content

Commit 5268f5e

Browse files
authored
Merge pull request #1278 from enisnazif/1275-fix-course-list
Fix course list hanging when exchange has not been created
2 parents a461cb7 + 20c5980 commit 5268f5e

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

nbgrader/nbextensions/course_list/course_list.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,23 @@ define([
123123

124124
Course.prototype.make_row = function () {
125125
var row = $('<div/>').addClass('col-md-12');
126+
var course_id = this.course_id;
127+
128+
if(course_id === '') {
129+
course_id = 'Default formgrader';
130+
}
131+
126132
var container = $('<span/>').addClass('item_name col-sm-2').append(
127133
$('<a/>')
128134
.attr('href', this.url)
129135
.attr('target', '_blank')
130-
.text(this.course_id));
136+
.text(course_id));
131137
row.append(container);
132138
row.append($('<span/>').addClass('item_course col-sm-2').text(this.formgrader_kind));
133139
this.element.empty().append(row);
134140
};
135141

136142
return {
137-
'CourseList': CourseList,
143+
'CourseList': CourseList
138144
};
139145
});

nbgrader/server_extensions/course_list/handlers.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import traceback
77

88
from tornado import web
9-
from tornado.httpclient import AsyncHTTPClient, HTTPClientError
9+
from tornado.httpclient import AsyncHTTPClient, HTTPError
1010
from tornado import gen
1111
from textwrap import dedent
1212
from urllib.parse import urlparse
@@ -61,7 +61,7 @@ def check_for_local_formgrader(self, config):
6161
http_client = AsyncHTTPClient()
6262
try:
6363
response = yield http_client.fetch(url, headers=header)
64-
except HTTPClientError:
64+
except HTTPError:
6565
# local formgrader isn't running
6666
self.log.warning("Local formgrader does not seem to be running")
6767
raise gen.Return([])
@@ -74,9 +74,11 @@ def check_for_local_formgrader(self, config):
7474
self.log.error(traceback.format_exc())
7575
raise gen.Return([])
7676

77+
coursedir = CourseDirectory(config=config)
78+
7779
if status:
7880
raise gen.Return([{
79-
'course_id': config.CourseDirectory.course_id,
81+
'course_id': coursedir.course_id,
8082
'url': base_url + '/formgrader',
8183
'kind': 'local'
8284
}])
@@ -95,6 +97,7 @@ def check_for_noauth_jupyterhub_formgraders(self, config):
9597
# We are running on JupyterHub, so maybe there's a formgrader
9698
# service. Check if we have a course id and if so guess the path to the
9799
# formgrader.
100+
98101
coursedir = CourseDirectory(config=config)
99102
if not coursedir.course_id:
100103
raise gen.Return([])
@@ -168,6 +171,7 @@ def get(self):
168171
courses = []
169172
local_courses = yield self.check_for_local_formgrader(config)
170173
jhub_courses = yield self.check_for_jupyterhub_formgraders(config)
174+
171175
courses.extend(local_courses)
172176
courses.extend(jhub_courses)
173177

0 commit comments

Comments
 (0)