Created
August 18, 2009 09:58
-
-
Save robinsmidsrod/169654 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my $manifest = IMS::CP::Manifest->new( file => $manifest_filename ); | |
foreach my $org ( @{ $manifest->organizations } ) { | |
my $counter = 1; | |
foreach my $item ( @{ $org->items } ) { | |
my $res = $item->resource; | |
if ( found( $res->href ) ) { | |
my $data = { | |
type => 'imscp_resource', | |
root => $rootname, | |
data => { | |
id => $item->id, | |
title => $item->title->text, | |
title_language => $item->title->language, | |
resource_title => $res->title->text, | |
resource_title_language => $res->title->language, | |
counter => $counter, | |
manifest_title => $manifest->title->text, | |
manifest_title_language => $manifest->title->language, | |
organization_title => $org->title, | |
} | |
}; | |
if ( $res->href =~ /\.html$/ ) { | |
$data->{'data'}->{'html'} = simplify_html( $res->href ); | |
$data->{'type'} = 'html'; | |
} | |
if ( $res->href =~ /\.xml$/ ) { | |
$data->{'type'} = 'imsqti'; | |
} | |
if ( $res->href =~ /\.(?:mp3|jpg|gif|flv)$/ ) { | |
$data->{'type'} = 'binary'; | |
} | |
$files->{ $dirname . $res->href } = $data; | |
} | |
else { | |
die('MISSING RESOURCE:' . $res->href . "\n"); | |
} | |
foreach my $file ( @{ $res->files } ) { | |
if ( found( $file->href ) ) { | |
my $data = { | |
type => 'imscp_file', | |
root => $rootname, | |
data => { | |
id => $file->id, | |
title => $file->title->text, | |
title_language => $file->title->language, | |
resource_href => $dirname . $res->href, | |
manifest_title => $manifest->title->text, | |
manifest_title_language => $manifest->title->language, | |
organization_title => $org->title, | |
} | |
}; | |
if ( $file->href =~ /\.html$/i ) { | |
$data->{'data'}->{'html'} = simplify_html( $file->href ); | |
$data->{'type'} = 'html'; | |
} | |
if ( $file->href =~ /\.xml$/ ) { | |
$data->{'type'} = 'imsqti'; | |
} | |
if ( $file->href =~ /\.(?:mp3|jpg|gif|flv)$/ ) { | |
$data->{'type'} = 'binary'; | |
} | |
$files->{ $dirname . $file->href } = $data; | |
} | |
else { | |
die('MISSING FILE:' . $file->href . "\n"); | |
} | |
} | |
$counter++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment