harvard-atg / canvas_course_info Goto Github PK
View Code? Open in Web Editor NEWThis project forked from harvard-dce/dce_course_info
Harvard ATG Branch of DCE Tool
This project forked from harvard-dce/dce_course_info
Harvard ATG Branch of DCE Tool
It would be nice if someone would take a look over this code (specifically at course_info/views.py) and make sure I'm not breaking every convention/standard/design protocol ever. Thanks Harry.
At its core, Views.py handles all the incoming requests and routes relevant data to the correct template.
The templates are course_info/editor.html and course_info/widget.html
The sort_and_format_instructor_display
method assumes that instructor result records will contain a profile
key that is either null or a list
. However, the rest api returns None
records instead of null
s, so using default values with a get
doesn't fall back to the default. This results in a 'NoneType' object has no attribute 'get'
exception that looks like this (from Splunk logs):
Server Error: /course_info/lti_launch Traceback (most recent call last): File "/var/opt/virtualenvs/canvas_course_info/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 39, in inner response = get_response(request) File "/var/opt/virtualenvs/canvas_course_info/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response response = self._get_response(request) File "/var/opt/virtualenvs/canvas_course_info/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/var/opt/virtualenvs/canvas_course_info/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/var/opt/virtualenvs/canvas_course_info/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view return view_func(request, *args, **kwargs) File "/var/opt/virtualenvs/canvas_course_info/local/lib/python2.7/site-packages/django/views/decorators/http.py", line 40, in inner return func(request, *args, **kwargs) File "/var/opt/virtualenvs/canvas_course_info/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view return view_func(*args, **kwargs) File "/opt/tlt/canvas_course_info/course_info/views.py", line 82, in lti_launch return editor(request) File "/opt/tlt/canvas_course_info/course_info/views.py", line 196, in editor course_instance_id=course_instance_id) File "/opt/tlt/canvas_course_info/course_info/views.py", line 142, in _course_context instructor_display = sort_and_format_instructor_display(course_instructor_list) File "/opt/tlt/canvas_course_info/course_info/views.py", line 211, in sort_and_format_instructor_display course_instructor_list.sort(key=lambda x: (x.get('role', {}).get('role_id'), File "/opt/tlt/canvas_course_info/course_info/views.py", line 213, in <lambda> x.get('profile', {}).get('name_last'))) AttributeError: 'NoneType' object has no attribute 'get'
Further checks may be needed in the code to handle cases where instructors don't have profiles, including adding checks to the get_display_name
method.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.