Quicklinks: The Toolbox > CD&DU Feeds

Bb course jump


Contents

Problem

Staff MyCQU wasn't jumping directly to a Blackboard course site.

The actual jumping is done by an object CourseJump.

Solution

It populates DATA::COURSE_URL with pointers to the full URLs for Blackboard course sites. Did it this way as we can't rely on the Oracle database view we have being reliable. The script will do a full update of all Bb courses for a specific PERIOD/YEAR. So re-running it will refresh/update for that period/year.
So if it picks up a Bb course site with a URL, go straight there.

Limitation

The script has to be run to bring it up to date. We'll have to run it for T2, 2008 once the sites are created.

If there isn't a Blackboard course site in the Blackboard database, it won't create a jump.

I've only run the script for all of 2007 and T1, 2008.

The script code

It's a kludge and included here for the "education" of other folk (possibly of how not to do things).

use strict;     

use webfuse::lib::DATA::CourseOwnership;
use webfuse::lib::Blackboard::Courses;
    
my $CONFIG = "$WebfuseConfig::WEBFUSE_DATA/databases/DATA.txt";
  
use Data::Dumper;

my $PERIOD="T1";
my $YEAR="2008";
  
#-- update the database 
#-- get list of all Blackboard courses for current term
  
my $ownership = DATA::CourseOwnership->new( PERIOD => $PERIOD,
                                YEAR => $YEAR );
  
if ( $ownership->Errors )
{
  die $ownership->DumpErrors();
}

my @array;
  
#-- for each course get the PK1, add it to array
       
foreach my $row ( @{$ownership->{DATA}} )
{       
  #-- ignore if not a Blackboard site
  next if ( $row->{BUILD_SITE} != 2 );

  my $course = $row->{COURSE};

  my $model = Blackboard::Courses->new( COURSE => $course,
                PERIOD => $PERIOD, YEAR => $YEAR );

  if ( $model->Errors )
  {
    print "Error with Bb for $course\n";
    die $model->DumpErrors();
  }
  my $pk1 = $model->PK1;

  if ( $pk1 ne "" )
  {
  push @array, { COURSE => $course, PERIOD => $PERIOD, YEAR => $YEAR ,
                 URL => "http://e-courses.cqu.edu.au/webapps/portal/frameset.jsp?tab=courses&url=%2Fbin%2Fcommon%2Fcourse.pl%3Fcourse_id%3D_${pk1}_" };
  }
  else
 {
    print "****ERROR*** $course for $PERIOD/$YEAR - doesn't have pk1\n";
  }
}

#-- update the database
# - this is really kludgey and horrible, but it works and won't be run often

foreach my $row ( @array )
{
  my $model = NewModel->new( CONFIG => $CONFIG, TABLE => "COURSE_URL",
        CONDITIONS => "COURSE={COURSE} and PERIOD={PERIOD} and YEAR={YEAR}",
        FIELDS => "COURSE,PERIOD,YEAR,URL",
        KEYS => { COURSE => $row->{COURSE}, PERIOD => $PERIOD, YEAR => $YEAR },
        DEBUG => 1 );

  $model->Delete() if ( $model->NumberOfRows() > 0 );

  $model->{DATA} = [ $row ];

  $model->Insert();
}

 
 
 

toolbox

What links here | Related changes | Upload file | Special pages | Permanent link

 
 

Our Talk

 
 

Our Links