Skip navigation
 

Discussion board data
Added by George Kroner, last edited by George Kroner on 14 Jan 2008 03:34 AM
(None)

In this tutorial, we will examine how to use the discussion forum APIs to extract the top level forums per course, threads per forum, and replies per thread. We will also show how to add a new discussion forum to a course.

About the discussion board

Discussion forums are represented within Blackboard as the following hierarchy: conferences, then forums, and lastly messages. A conference is the container for all forums underneath it. There are three types of conferences: a system conference which is what displays in the institution-wide discussion board (for those who license Community System), a course conference which contains the course-wide discussion board for each course, and group conferences which are created when an instructor creates groups within a course.

Accessing discussion board data

First we will examine what the discussion board looks like and then detail how to access its data.

Representing what we want to model in the GUI

To begin, create a course with a course ID of TEST through the System Admin panel. Navigate to this course and enroll your account as an instructor.

Now, with instructor access, navigate to the Discussion Board link in the course menu.

Add two discussion forums: Forum 1 and Forum 2. Then, in the first forum, add a thread and a reply.

Now, view the forum and expand all the content to get a hierarchical view of what this data looks like. This is what we will model in the source code below.


Expressing what we want to do as code

To begin, we must load the course for which we will be examining the discussion forums. You can use the CourseDbLoader API to do this.

Course c = CourseDbLoader.Default.getInstance().loadByCourseId("TEST");

Next, we will use the ForumManager API to load all of the discussion forums for this class.

ForumManager fm = DiscussionBoardManager.getForumManager();
List allClassForums = fm.loadByCourseId(c.getId());

Then, you will need to iterate over the forums obtaining the top level messages for each. You will use the MessageManager API to load the messages for each forum.

MessageManager mm = DiscussionBoardManager.getMessageManager();
List topLevelMessages = mm.loadAllByForum(forum.getId());

Now, you can obtain the replies to each message.

BbList topLevelReplies = message.getResponses();

For a complete working sample JSP, please see the resources section below. By running this JSP inside your Building Block, you will see output similar to the following. You may wish to expand on this sample code to recursively iterate over the thread replies.

Persisting discussion forum data

Now we will examine how to add a new forum to a conference (in this example, the course-wide discussion board).

Code for adding a forum to a course

First, obtain the ID of the course's course-wide discussion board.

Course c = CourseDbLoader.Default.getInstance().loadByCourseId("TEST");
Id i = ConferenceDbLoader.Default.getInstance().loadByCourseId(c.getId()).getId();

Then, create a new forum using the id obtained in the code above as the conference id.

Forum f = new Forum();
f.setConferenceId(i);
f.setTitle("Forum Title");

Finally, use the ForumDbPersister to persist the forum. After it is saved, you can also add Message objects to populate initial top threads within this forum.

ForumDbPersister.Default.getInstance().persist(f);

Additional resources for assistance

Sample JSP

Adaptavist Theme Builder Powered by Atlassian Confluence

By accessing the Knowledge Base, you agree to the following: Blackboard makes no representations or warranties as to the accuracy of any information in the Knowledge Base. Blackboard is not responsible in any way for information provided to the Knowledge Base by third parties. Information in the Knowledge Base is not documentation for any Blackboard product. Nothing in the Knowledge Base shall be deemed to modify your license in any way to any Blackboard product. Blackboard reserves the right to use your name and the name of your institution in reference to any information submitted by you to the Knowledge Base. Blackboard may modify, distribute, republish in any format, delete, incorporate or use in any way the information that you contribute to the Knowledge Base.