Jun 102009
 

Update

Please see my new post on this topic. Available at: http://www.cornempire.net/2009/07/07/d2l-bulk-deactivation-part-2/

Introduction

One of the often requested features is to be able to bulk deactivate courses in D2L after they have completed. You can currently deactivate courses, but this is a one at a time effort. This has become more important as version 8.3 of D2L brought along a new My Courses widget, which allows users to see updates from each of their courses. Unfortunately, when course access ends, they can still see the updates. This has caused confusion for many users.

Another reason to deactivate courses is minimize the amount of clutter in the view of users. If course access has ended, and they cannot access the course, there is no need for the course to remain active (this could vary depending on how your roles are configured). A way around this is to script the bulk deactivation of courses. Through the use of some Javascript coding, we can instruct the web browser to visit each course, and deactivate it for us.

Example

Take a look here for this script in action.

If you think that this might be useful for your organization, you can download the html file which includes the javascript.

For D2L Version 8.3
For D2L Version 8.4 (Thanks Dennis!)

Instructions on Use

  • You will need to edit the file and modify line 5. This contains the URL to your learning environment, and the URL to your Course Offering Information screen.
  • This file will need to be placed in one of your courses in your learning environment in the Manage Files area.
  • You need to open the file from your Manage Files section and provide the script with the OU numbers of the courses you need to deactivate. (Take a read below to see how we get the ou numbers)
  • Once the OU numbers are loaded, you can click the Start Processing button and your web browser should go to all the courses and deactivate them.

Limitations

  • You are required to have administrative access to any courses you need to deactivate (I haven’t been able to figure out why this is, but a javascript error is thrown if you do not have admin access)
  • This has been tested in Firefox 3 on Windows XP and Ubuntu 9.04 as well as a Chrome Development Beta for Linux but may not work in other web browsers (especially IE).
  • This has been tested on D2L Version 8.3 MR01. I’d suspect it would work on any version of 8.3 but not sure about 8.4 yet, or any earlier versions.
  • I’m not responsible if this code melts your CPU. or causes any other horrible damage to your D2L installation (although it shouldn’t….it’s only about 35 lines of Javascript. :p)

Getting a List Of Courses

The tricky part in all of this is actually getting the OU numbers for each of the courses you need to deactivate. For those who don’t know, the OU number is the org unit number, and is an internal identifier for D2L. You will notice the ou number in the URL of courses as ou=#####.

We run a report using the reporting tool that gives us the ou numbers (in one, non-ideal form. Hopefully D2L web services will eliminate the need for this).

In the Reporting tool, create a report using the Org Units dataset. With in the report, include the column for the course Path. This path contains the OU number for the course. Under the filter tab, add a few filters that will narrow down your search to the information you require. Our organization adds a semester code to all of our courses, so all courses that end in 200802 are courses that ran in the last semester. We can query these courses, and get a list of the ou numbers through the course offering paths. See below for some images of our report in action.

report1

report2

report3

report4

Then you have to do some work in manipulating the report to filter out the OU numbers. I select the whole column using firefox, and dump it into OpenOffice. Customize the import to break the lines on all of the dividing characters, and then I have a column of ou numbers. Then take that, and add in commas after all of the entries using a find and replace. You will need a text editor that can find and replace on characters you cannot see. Replace the new lines with commas.

Hopefully you can find a better way to get your list of OU numbers ;). If you have a good way, leave a comment and let me know.

Jun 092009
 

I’ve been recently doing some Javascript coding and ran across an error in IE that I wasn’t noticing in Firefox (well…there are hundreds of these, but this one is a show stopper).

It is a small validation script for a form to do some checking before submitting.  It’s pretty simple, take a look:


function validateForm(){
	/*
	 * First, get the fields.
	 */
	var name = document.getElementById('name').value;
	var title = document.getElementById('title').value;
	var phone = document.getElementById('phone').value;
	var email = document.getElementById('email').value;
	var description = document.getElementById('description').value;
	var cost = document.getElementById('cost').value;
	//pic1 = document.getElementById('pic1').value;
	//pic2 = document.getElementById('pic2').value;
	if(name == ""){
		alert('You must enter your name.');
	}
	else if(title == ""){
		alert('You must enter give your ad a title.');
	}
	else if(phone == "" && email == ""){
		alert('You must enter a phone number or email address.');
	}
	else if(description == ""){
		alert('You must enter a description of the item you want to buy, sell or trade.');
	}
	else if(isNaN(cost)){
		alert('You must enter a numeric cost, without the $ symbol.');
	}
	else{
		document.getElementById('submit').style.display = 'block';
		alert('Please press the submit button below.');
	}
}

Executing the script on a blank form in FF would give the correct response, Enter in a name. In IE, I would get an error on Line 15 about Object Expected (in the script, line 15 is actually a commented out line, so that error isn’t very helpful).

I then remembered something about IE automatically creating variables from a form by the name/id of the form field on the page. Since my variable name, and field name were the same, it would try to compare its self created object against my test, instead of the variable that I was assigning, thus creating an error.

To work around this, I had to rename all of my variables (I could have also renamed all of my fields):


function validateForm(){
	/*
	 * First, get the fields.
	 */
	var bsname = document.getElementById('name').value;
	var bstitle = document.getElementById('title').value;
	var bsphone = document.getElementById('phone').value;
	var bsemail = document.getElementById('email').value;
	var bsdescription = document.getElementById('description').value;
	var bscost = document.getElementById('cost').value;
	//pic1 = document.getElementById('pic1').value;
	//pic2 = document.getElementById('pic2').value;
	if(bsname == ""){
		alert('You must enter your name.');
	}
	else if(bstitle == ""){
		alert('You must enter give your ad a title.');
	}
	else if(bsphone == "" && bsemail == ""){
		alert('You must enter a phone number or email address.');
	}
	else if(bsdescription == ""){
		alert('You must enter a description of the item you want to buy, sell or trade.');
	}
	else if(isNaN(bscost)){
		alert('You must enter a numeric cost, without the $ symbol.');
	}
	else{
		document.getElementById('submit').style.display = 'block';
		alert('Please press the submit button below.');
	}
}

After this, it runs fine in both browsers. I remember hitting my head off the wall for a LONG time when I originally encountered this error, so hopefully this will save someone else some time.