Overview

This package provides PowerLinks developers with access to data objects relating to users and learning contexts. The initial release is functionally equivalent to the com.webct.platform.sdkext.authmoduledata available from Blackboard. The last release (1.4) of the Blackboard package was in May 2006 and it has not been updated for either Application Pack 1 or Application Pack 2. The latest information from Blackboard is that this functionality will become part of the core product in a future release, but no timescales are available for this. Given the lack of maintenance and support for the Blackboard package and its usefulness for PowerLink developers, this open source version has been prepared to comply fully with the original JavaDocs so only requires a change to the import statements for any existing source code. The community-supported version will also enable enhancements to be added to make the package an even more useful tool for developers; release 2 includes a number of enhancements including access to term data and system version information.

System requirements

The WebCTDAO package is written for WebCT Vista 4 (or later) and WebCT Campus Edition 6 (or later). The package is version dependent but any updates required for future releases of WebCT Vista and WebCT Campus Edition should be possible via the properties file pending the release of a new version of this utility.

Installation

This package is designed for use with PowerLinks and may be installed either by copying the jar file into the same directory as the PowerLink itself, or placed in the common directory so that it can be shared by more than one PowerLink.

Configuration settings

An optional properties file may be placed in the same directory as the package file. This file should have the same file name as the package but be given an extension of .properties. For example, if the package is named WebCTDAO.jar it will look for a properties file named WebCTDAO.properties. The properties file may contain one or more of the following settings:

The property names for SQL queries may be given a suffix of either _ORACLE or _SQLSERVER in order to specify a database-specific version. For example, this is needed when returning the path of a learning context which uses a built-in function which is referenced differently in Oracle and SQL Server. (Note: avoiding this issue by referencing RPT_LEARNING_CONTEXT is not used as this view is only updated at most every 24 hours and hence may not reflect the current state of the database.)

The default values of the properties are as follows:

The above default values are appropriate for versions from Application Pack 2 onwards; modified forms for some of these queries are used when installed with an earlier release of WebCT. The following transformations are applied to the specified SQL to convert between the syntax required for SQL Server and Oracle according to the database being used:

SQL ServerOracle
ISNULL()NVL()
LEN()LENGTH()
dbo.reporting_interface_pkg$GetLcPath()reporting_interface_pkg.getLcPath()

Usage

This package is comprised of eight published classes (including one deprecated class) which are described in the JavaDocs documentation. The documentation for com.webct.platform.sdkext.authmoduledata is also available. For any pre-existing PowerLinks just replace any references to com.webct.platform.sdkext.authmoduledata with org.oscelot.webct.dao; all classes, methods and properties of the original package are supported by this new one.

LearningContextService

This class provides the following methods:

The following example code extract from the login or commit methods of an authentication module illustrates how to retrieve details for the current learning context and a list of its child learning contexts:

...

  WebCTSSOContext ssoContext = getWebCTSSOContext();
  Long lcId = ssoContext.getCurrentLearningContextId();

  LearningContextService lcService = null;
  LearningContextVO sectionLC = null;
  LearningContextVO institutionLC = null;
  List childLCs = null;

// Get the learning context service instance
  try {
    lcService = LearningContextService.getInstance();
  } catch (VistaDataException e) {
    lcService = null;
  }

// Get the current learning context details
  if (lcService != null) {
    try {
      sectionLC = lcService.getLCInfo(lcId);
    } catch (VistaDataException e) {
      sectionLC = null;
    }
  }

// Get a list of child learning contexts
  if (lcService != null) {
    try {
      childLCs = lcService.getLCChildren(lcId.longValue());
      for (Iterator iter = childLCs.iterator(); iter.hasNext();) {
        Long childLC = (Long)iter.next();
        // insert code to execute for each child learning context
      }
    } catch (VistaDataException e) {
      childLCs = null;
    }
  }

// Get the institution learning context details
  if ((lcService != null) && (sectionLC != null)) {
    try {
      institutionLC = lcService.getLCAncestor(sectionLC.getLCId(), LearningContextVO.TYPELEVEL_INSTITUTION);
    } catch (VistaDataException e) {
      institutionLC = null;
    }
  }

...

LearningContextVO

This class provides the following methods for accessing details of a learning context:

The following example code extract from the login or commit methods of an authentication module illustrates how to obtain the title of the parent course for the current section:

...

  String courseTitle = null;

// Get the parent learning context title
  try {
    Long lcId = getWebCTSSOContext().getCurrentLearningContextId();
    LearningContextVO lc = LearningContextService.getInstance().getLCInfo(lcId);
    lcId = new Long(lc.getParentLcId());
    lc = LearningContextService.getInstance().getLCInfo(lcId);
    courseTitle = lc.getName();
  } catch (VistaDataException e) {
    courseTitle = null;
  }

...

The title of the section could be obtained in a similar way. Alternatively, the getFormmattedName() method could be used to generate a string containing the course and section titles separated by a hyphen:

...

  String title = null;

// Get the course and section titles
  try {
    Long lcId = getWebCTSSOContext().getCurrentLearningContextId();
    LearningContextVO lc = LearningContextService.getInstance().getLCInfo(lcId);
    title = lc.getFormattedName("%1 - %C");
  } catch (VistaDataException e) {
    title = null;
  }

...

See the JavaDocs documentation for details of all the variable substitutions supported by this methood.

The following example code extracts members 26-50 having an email address:

...

  int pageSize = 25;
  int pageNum = 2;
  Long lcId = getWebCTSSOContext().getCurrentLearningContextId();
  try {
    List users = lcId.getMembersWhere(UserVO.SQL_WHERE_USER, 'Email', null, null, pageNum, pageSize);
  }

...

This class also defines a constant value for each type of learning context.

TermVO

This class provides the following methods:

This class also defines a constant value for each form of section availablility.

UserService

This class provides the following methods:

The following example code extract from the login or commit methods of an authentication module illustrates how to retrieve details for the current user:

...

  WebCTSSOContext ssoContext = getWebCTSSOContext();
  Long lcId = ssoContext.getCurrentLearningContextId();
  String userId = ssoContext.getUserId();

  UserService userService = null;
  UserVO currentUser = null;

// Get the user service instance
  try {
    userService = UserService.getInstance();
  } catch (VistaDataException e) {
    userService = null;
  }

// Get the current user details
  if (userService != null) {
    try {
      currentUser = userService.getUser(userId, lcId);
    } catch (VistaDataException e) {
      currentUser = null;
    }
  }

...

UserRole

This class has been deprecated; as of version 2 user roles are represented by string constants.

UserVO

This class provides the following methods for accessing details of a user. :

The following example code extract from the login or commit methods of an authentication module illustrates how to obtain the name of the current user (first name followed by last name):

...

  String userName = null;

// Get the name of the current user
  try {
    Long lcId = getWebCTSSOContext().getCurrentLearningContextId();
    String userId = getWebCTSSOContext().getUserId();
    UserVO user = UserService.getInstance().getUser(userId, lcId);
    userName = (user.getFirstame() != null) ? user.getFirstame() + " " : "";
    userName += (user.getLastame() != null) ? user.getLastame() : "";
  } catch (VistaDataException e) {
    userName = null;
  }

...

An alternative is to use the getFormmattedName() method to generate a string containing the first and last names of a user:

...

  String userName = null;

// Get the name of the current user
  try {
    Long lcId = getWebCTSSOContext().getCurrentLearningContextId();
    String userId = getWebCTSSOContext().getUserId();
    UserVO user = UserService.getInstance().getUser(userId, lcId);
    userName = user.getFormattedName("%a %b");
  } catch (VistaDataException e) {
    userName = null;
  }

...

See the JavaDocs documentation for details of all the variable substitutions supported by this methood.

This class also defines a constant value for each type of user role and each type of address element.

User profile data

Values from a users profile can be accessed using the following methods:

Each of these methods will return a map containing an entry for each element type even if it has not value for the corresponding user. Thus, at the time of writing, the map returned by getAddresses would contain entries with the following names:

Similarly, at the time of writing, the map returned by getPhones would contain entries with the following names:

The getCustomColumns method will return a map containing an entry for each custom column defined for the institution, even if there is no value for the user.

The names of entries in the maps returned by the getAddresses, getPhones and getCustomColumns methods may all be used as variable substitutions in calls to the getFormattedName method. For example, if a user with a surname of Smith has set the first telephone number in their profile to 12 3456 and has a value of Student in custom column named TYPE, then the following code will set the variable userDetails to a value of Student: Smith (12 3456).

...

  String userDetails = null;

// Get the details of the current user
  try {
    Long lcId = getWebCTSSOContext().getCurrentLearningContextId();
    String userId = getWebCTSSOContext().getUserId();
    UserVO user = UserService.getInstance().getUser(userId, lcId);
    userDetails = user.getFormattedName("%{Type}: %b (%{Voice 1})");
  } catch (VistaDataException e) {
    userDetails = null;
  }

...

Further details on the available variable substitutions can be found in the JavaDocs documentation.

VistaDataException

This class defines an exception type which is raised when errors occur in the methods of the LearningContextService, UserService and WebCTApplication classes.

WebCTApplication

This class provides the following methods:

The following example code extract from the login or commit methods of an authentication module illustrates how to retrieve details for the current learning context and a list of its child learning contexts:

...

  import org.oscelot.webct.dao.WebCTApplication;
  import org.oscelot.webct.dao.VistaDataException;

...

  String appVersion = null;
  int majorVersion = 0;
  Boolean isOracleSystem = null;
  try {
    appVersion = WebCTApplication.getApplicationVersion();
    majorVersion = WebCTApplication.getApplicationMajorVersion();
    isOracleSystem = new Boolean(WebCTApplication.isDatabaseOracle());
  } catch (VistaDataException e) {
  }

...

The following constants are also defined:

These constants may be used to test which release of WebCT is being used; for example:

...

  import org.oscelot.webct.dao.WebCTApplication;
  import org.oscelot.webct.dao.VistaDataException;

...

  try {
// check if terms are supported
    if (WebCTApplication.getApplicationMajorVersion() >= WebCTApplication.MAJOR_VERSION_AP2)
// enter term-dependent code here
  } catch (VistaDataException e) {
  }

...

Differences from com.webct.platform.sdkext.authmoduledata

This package is designed to be functionally equivalent to version 1.4 of com.webct.platform.sdkext.authmoduledata available from Blackboard. Its behaviour differs only in respect of bug fixes, some changes to make the methods provided simpler or more consistent and some feature enhancements.

Bugs fixed

LearningContextService class

LearningContextVO class

UserRole class

UserService class

Changes

The following issues have been identified with the com.webct.platform.sdkext.authmoduledata package which may be resolved by implementing enhancements to this package.

LearningContextService class

LearningContextVO class

UserRole class

This class does not appear to server any useful purpose. The class represents a role as a combination of a string and an integer value. Since the former value is unique and the latter value appears to have no meaning, the class adds unnecessary complexity. It is, therefore, proposed to deprecate this class and replace the role constants with a set of string constants in the UserVO class.

UserService class

UserVO class

Enhancements

The following additional features have been added to update the package for more recent releases of WebCT and provide other useful functionality.

LearningContextService class

LearningContextVO class

UserService class

UserVO class

The following constants are defined to represent the possible user property type settings:

TermVO class

A new class representing data about terms. It would provide the following methods:

The following constants are defined to represent the possible section availability settings:

WebCTApplication class

A new class is proposed for system-level functionality:

Troubleshooting

If you experience any problems using this utility try the following to trace the cause:

Version history

VersionDateDescription
1.0.002-Mar-2008Initial release
2.0.0014-Apr-2008Enhanced release
2.1.0016-May-2008Added support for additional user details: fullname, nickname, sortname, birthday, gender, addresses and phones
2.1.0116-Aug-2008Improved method for connecting to the WebCT data source (fixing a bug affecting clustered installations)
Added UserVO.getSourceId() and UserVO.getSourceName()
Deprecated UserVO.getsourceId() and UserVO.getsourceName()
2.2.0018-Sep-2008Support for all releases of Vista 4 and Campus Edition 6 has been embedded into the code rather than depending upon changes in the properties file for releases prior to AP2
2.2.0126-Sep-2008Fixed a bug affecting Oracle installations of WebCT
Added constants representing the major versions of WebCT (Application Pack 1, Application Pack 2 and Release 8)
2.3.0013-Dec-2008Added getFormattedName() methods to LearningContextVO and UserVO
Added a constant to UserVO for the name of each address element
Changed UserVO.getAddresses() and UserVO.getPhones() methods to return an entry for all address elements and phone number types even when no value exists
getUser and getUserRoles in UserService are no longer defined as being static methods - this is to improve compatibility with the original authmoduledata utility. Important note: this change means that any PowerLinks depending upon this utility may need to be recompiled to be compatible with this release.
2.4.0028-Sep-2009Added methods for cross-listed sections to LearningContextService, LearningContextVO and UserService
Added methods to LearningContextVO for retrieving members based on a matching property value
Added options to LearningContextVO for retrieving members a page at a time
Added UserService.getUserRoleId() to retrieve the ID for a role
2.4.011-Apr-2010Added WebCTApplication.getInstanceName() to retrieve the name of the proxy tool
2.4.029-Aug-2010Fixed bug in Oracle SQL when extracting values from custom columns in user profiles
2.5.0031-Oct-2011Added a method to return the current WebCT release
Added methods to UserService for retrieving a user by a person ID or a sourcedid
Added a parameter to the UserVO.getRoles() method to allow roles for parent learning contexts to be returned
Fixed a bug which failed to return roles in parent learning contexts for a user thereby causing methods such as isInstitutionAdministrator() to always return false (except when the source was an Institution-level learning context)

Licence

Creative Commons License This work is written by Stephen Vickers and is released under a Creative Commons GNU General Public Licence. The WebCTDAO package can be downloaded from OSCELOT where it is also possible to report bugs and submit feature requests.

Valid XHTML 1.0 Strict