Presentation is loading. Please wait.

Presentation is loading. Please wait.

Brett Stephens Systems Analyst Learning Platforms Team

Similar presentations


Presentation on theme: "Brett Stephens Systems Analyst Learning Platforms Team"— Presentation transcript:

1 Using Template Variables and Creating Your Own Custom Template Variables
Brett Stephens Systems Analyst Learning Platforms Team University of Miami

2 Definitions Template Variable Institutional Role
Used in content items or portal modules Institutional Role Community Engagement license Student, Faculty, etc Used for branding and availability of tabs & modules

3 The Challenge UM participating in NSSE
Administered by Indiana University 5,342 students (freshmen and seniors) at UM selected to participate 15,000 users on UM’s Blackboard every week

4 What We Did

5 How?

6 Why a Custom Template Variable?
Survey links specific to user No Authentication used where URL would be replaced by output of java method

7 Institutional Role Usage
The NSSE module was only displayed to survey participants (NSSE role) NSSE role assigned to users via SIS Flatfile upload

8 Module Availability based on Institutional Role(s)

9 Standard Template Variables

10 Standard Template Variables
Objects with template variables User Course Content Request System

11 Standard Template Variables
User batch_uid id full_name pk_string (_751_1) Locale (en_US) Role (system) Institution_role Secondary_institution_role

12 Standard Template Variables
Course batch_uid id course_name pk_string (_2702_1) url (/courses/1/BIL206/) Role (of user in course) Locale (en_US)

13 Standard Template Variables
Content id or pk_string (_37_1) url Request id locale Return (return url) System site_id

14 Example Uses of Template Variables
Link to content item within description (banner image) /webapps/blackboard/content/launchLink.jsp?course_id= Instead of /webapps/blackboard/content/launchLink.jsp? course_id=_355958_1&content_id=_ _1

15 Example Uses of Template Variables
Custom Course Greeting Hello welcome to User_list_context_menu & course_list_context_menu links in B2s (in bb-manifest.xml) <url value="userinfo.jsp?user_id= <url value=

16 Defining Custom Template Variables in a Building Block

17 Resolution of a Template Variable
CustomResolver Get user_id from context Query umia_surveylinks table with user_id return surveylink Replace with surveylink

18 Important Files in the B2
Bb-manifest.xml Schema.xml Config.jsp CustomContextHandler.java CustomResolver.java

19 Bb-manifest.xml <extension-defs> <definition namespace="blackboard.platform"> <extension id="customContextHandler“ point="blackboard.platform.contextHandler" class="edu.miami.nsse.CustomContextHandler" singleton="false" /> </definition> </extension-defs>

20 Bb-manifest.xml <http-actions> <config value="admin/config.jsp" /> </http-actions> <schema-dirs> <schema-dir dir-name="main" /> </schema-dirs>

21 Bb-manifest.xml <permissions> <permission type="attribute" name="user.authinfo" actions="get" /> <permission type="runtime" name="db.connection.*" /> </permissions>

22 Schema.xml <table name="umia_surveylinks"> <column name="user_id" data-type="nvarchar(20)" nullable="false"/> <column name="link" data-type="nvarchar(300)" nullable="false"/> <primary-key name="umia_surveylinks_pk1" unique="true" comment="Unique primary key"> <columnref name="user_id" /> </primary-key> </table>

23 Db Table Sample Data USER_ID SURVEY_LINK username1
username2 username3

24 Config.jsp

25 Config.jsp Catch SQLException
Get db connection from BbDatabase conn manager Tokenize and iterate through csv file INSERT INTO umia_surveylinks (user_id, link) VALUES (?, ?) setString(1, user_id) setString(2, surveylink) Catch SQLException release connection

26 CustomContextHandler.java public List<ContextEntry> resolveKeys(HttpServletRequest request, BbPersistenceManager unused) { CustomResolver resolver = new CustomResolver(request); Resolver.attachResolverToContext(resolver); return new LinkedList<ContextEntry>(); }

27 CustomResolver.java public String[] getKeys() { return (new String[] {"umia_user"}); }

28 CustomResolver.java public String resolve(String method, String attributes[]) { String varout = ""; ContextManagerFactory.getInstance() .setContext(_request); Context ctx = ContextManagerFactory.getInstance().getContext();

29 CustomResolver.java String userid = ctx.getUser().getUserName(); Connection conn = null; StringBuilder queryString = new StringBuilder(""); ConnectionManager cManager = null; PreparedStatement selectQuery = null;

30 CustomResolver.java if ("NSSE_link".equalsIgnoreCase(method)) { try { cManager = BbDatabase.getDefaultInstance() .getConnectionManager(); conn = cManager.getConnection(); queryString.append("SELECT link FROM umia_surveylinks ");

31 CustomResolver.java queryString.append("WHERE user_id = ?"); selectQuery = conn.prepareStatement(queryString.toString()); selectQuery.setString(1, userid); ResultSet rSet = selectQuery.executeQuery(); while(rSet.next()){ varout = rSet.getString("link"); }

32 CustomResolver.java selectQuery.close(); cManager.releaseConnection(conn); } catch (java.sql.SQLException sE){ LogServiceFactory.getInstance().logError("NSSE SQL Exception:", sE); } catch (ConnectionNotAvailableException cE) { LogServiceFactory.getInstance().logError("NSSE Connection Exception:", cE); }

33 CustomResolver.java finally { if (conn != null) cManager.releaseConnection(conn); } return varout;

34 Outcome of Our Efforts Overall Participation: 27%
34% Completed Survey Through Blackboard Learn Link

35 Conclusion Why This Worked (as well as it did) Simplicity
Logic detached from presentation What I Learned Reuse database connections when possible Close database connections!

36 Questions? Slides and Resourses: brettstephens.com/devcon2015 Brett Stephens


Download ppt "Brett Stephens Systems Analyst Learning Platforms Team"

Similar presentations


Ads by Google