Last active
August 29, 2015 13:58
-
-
Save whargrove/10205991 to your computer and use it in GitHub Desktop.
Content Loader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ContextManager cm = ContextManagerFactory.getInstance(); | |
Context context = cm.getContext(); | |
Id bbCourseId = context.getCourseId(); | |
Id bbContentId = context.getContentId(); | |
CourseMembership courseMembership = context.getCourseMembership(); | |
BasicLTILauncher launcher = new BasicLTILauncher( ldcCourseLtiUrl, toolProviderKey, toolProviderSecret, resourceLinkId ); | |
launcher.addCurrentUserInformation(true, true, true); | |
BbPersistenceManager pm = PersistenceServiceFactory.getInstance().getDbPersistenceManager(); | |
// Create a CourseDbLoader so that we can load the current course | |
CourseDbLoader courseLoader = null; | |
try { | |
courseLoader = (CourseDbLoader) pm.getLoader( CourseDbLoader.TYPE ); | |
} catch (PersistenceException e1) { | |
e1.printStackTrace(); | |
} | |
// Load the course | |
blackboard.data.course.Course course = null; | |
try { | |
course = courseLoader.loadById(bbCourseId); | |
} catch (KeyNotFoundException e) { | |
e.printStackTrace(); | |
} catch (PersistenceException e) { | |
e.printStackTrace(); | |
} | |
// Create a ContentDbLoader so that we can load the current content item | |
ContentDbLoader contentLoader = null; | |
try { | |
contentLoader = (ContentDbLoader) pm.getLoader( ContentDbLoader.TYPE ); | |
} catch (PersistenceException e1) { | |
e1.printStackTrace(); | |
} | |
// Load this content item | |
blackboard.data.content.Content content = null; | |
try { | |
content = contentLoader.loadById(bbContentId); | |
} catch (KeyNotFoundException e) { | |
e.printStackTrace(); | |
} catch (PersistenceException e) { | |
e.printStackTrace(); | |
} | |
launcher.addCourseInformation(course); | |
launcher.addGradingInformation(content, courseMembership); | |
// Launch the LTI request | |
launcher.launch(request, response, false, null); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment