--- loncom/imspackages/imsprocessor.pm 2004/08/05 23:21:49 1.10
+++ loncom/imspackages/imsprocessor.pm 2004/12/13 20:01:09 1.11
@@ -41,10 +41,8 @@ sub ims_config {
survey => 'assessment/x-bb-survey',
users => 'course/x-bb-user',
);
-
%{$$cmsmap{bb6}} = %{$$cmsmap{bb5}};
$$cmsmap{bb6}{conference} = 'resource/x-bb-conference';
-
%{$$cmsmap{angel}} = (
board => 'BOARD',
extlink => 'LINK',
@@ -52,10 +50,7 @@ sub ims_config {
quiz => 'QUIZ',
survey => 'FORM',
);
-
@{$$cmsmap{angel}{doc}} = ('FILE','PAGE');
-
-
%{$areaname} = (
announce => 'Announcements',
board => 'Discussion Boards',
@@ -67,7 +62,6 @@ sub ims_config {
survey => 'Surveys',
users => 'Enrollment',
);
-
}
sub create_tempdir {
@@ -173,7 +167,6 @@ sub process_manifest {
$$resources{'toplevel'}{type} = 'resource/x-bb-document';
}
-
unless (-e "$tempdir/imsmanifest.xml") {
return 'nomanifest';
}
@@ -259,14 +252,14 @@ sub process_manifest {
}
} elsif ("@state" eq "manifest resources resource" ) {
$identifier = $attr->{identifier};
- if ($cms eq 'bb5' || $cms eq 'bb6') {
+ if ($cms eq 'bb5' || $cms eq 'bb6') {
$$resources{$identifier}{file} = $attr->{file};
$$resources{$identifier}{type} = $attr->{type};
} elsif ($cms eq 'angel') {
$identifier = substr($identifier,3);
if ($attr->{href} =~ m-^_assoc/$identifier/(.+)$-) {
$$resources{$identifier}{file} = $1;
- }
+ }
}
@{$$hrefs{$identifier}} = ();
} elsif ("@state" eq "manifest resources resource file") {
@@ -277,7 +270,7 @@ sub process_manifest {
push @{$$hrefs{$identifier}},$1;
} elsif ($attr->{href} =~ m/^Icons\\icon(\w+)\.gif/) {
$$resources{$identifier}{type} = $1;
- }
+ }
}
}
}, "tagname, attr"],
@@ -401,7 +394,7 @@ sub process_coursefile {
}
sub process_resinfo {
- my ($cms,$context,$docroot,$destdir,$items,$resources,$boards,$announcements,$quizzes,$surveys,$groups,$messages,$timestamp,$boardnum,$resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,$total,$dirname,$seqstem,$resrcfiles,$packages,$hrefs) = @_;
+ my ($cms,$context,$docroot,$destdir,$items,$resources,$boards,$announcements,$quizzes,$surveys,$groups,$messages,$timestamp,$boardnum,$resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,$total,$dirname,$seqstem,$resrcfiles,$packages,$hrefs,$pagesfiles,$sequencesfiles) = @_;
my $board_id = time;
my $board_count = 0;
my $announce_handling = 'include';
@@ -461,14 +454,14 @@ sub process_resinfo {
}
} elsif ($$resources{$key}{type} eq "assessment/x-bb-pool") {
%{$$resinfo{$key}} = ();
- &process_assessment($key,$docroot,'pool',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname);
+ &process_assessment($context,$key,$docroot,'pool',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles);
} elsif ($$resources{$key}{type} eq "assessment/x-bb-quiz") {
%{$$resinfo{$key}} = ();
- &process_assessment($key,$docroot,'quiz',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname);
+ &process_assessment($context,$key,$docroot,'quiz',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles);
push @{$quizzes}, $key;
} elsif ($$resources{$key}{type} eq "assessment/x-bb-survey") {
%{$$resinfo{$key}} = ();
- &process_assessment($key,$docroot,'survey',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname);
+ &process_assessment($context,$key,$docroot,'survey',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles);
push @{$surveys}, $key;
} elsif ($$resources{$key}{type} eq "assessment/x-bb-group") {
%{$$resinfo{$key}} = ();
@@ -1511,7 +1504,7 @@ sub addposting {
}
# ---------------------------------------------------------------- Process Blackboard Assessments - pools, quizzes, surveys
sub process_assessment {
- my ($res,$docroot,$container,$dirname,$destdir,$settings,$total,$udom,$uname) = @_;
+ my ($context,$res,$docroot,$container,$dirname,$destdir,$settings,$total,$udom,$uname,$pagesfiles,$sequencesfiles) = @_;
my $xmlfile = $docroot.'/'.$res.".dat";
# print "XML file is $xmlfile\n";
my @state = ();
@@ -1567,9 +1560,7 @@ sub process_assessment {
}
if ("@state" eq "$toptag{$container} QUESTIONLIST QUESTION") {
$id = $attr->{id};
- unless ($container eq 'pool') {
- push @allids, $id;
- }
+ push @allids, $id;
%{$$settings{$id}} = ();
@{$allanswers{$id}} = ();
$$settings{$id}{class} = $attr->{class};
@@ -1669,46 +1660,77 @@ sub process_assessment {
my $dirtitle = $$settings{'title'};
$dirtitle =~ s/\W//g;
$dirtitle .= '_'.$res;
+ if (!-e "$destdir/problems") {
+ mkdir("$destdir/problems",0755);
+ }
if (!-e "$destdir/problems/$dirtitle") {
mkdir("$destdir/problems/$dirtitle",0755);
}
my $newdir = "$destdir/problems/$dirtitle";
+ my $seqdir = "$destdir/sequences";
my $pagedir = "$destdir/pages";
my $curr_id = 0;
my $next_id = 1;
- unless ($container eq 'pool') {
- open(PAGEFILE,">$pagedir/$res.page");
- print PAGEFILE qq||;
+ close($fh);
foreach my $id (@allids) {
- my $output = qq|
+ my $output;
+ if ($context eq 'CSTR') {
+ $output = qq|
|;
+ }
$$total{prob} ++;
if ($$settings{$id}{class} eq "QUESTION_ESSAY") {
- $output .= qq|$$settings{$id}{text}
+ if ($context eq 'CSTR') {
+ $output .= qq|$$settings{$id}{text}
@@ -1716,26 +1738,34 @@ sub process_assessment {
$$settings{$id}{feedbackcorr}
|;
+ }
} else {
- $output .= qq|$$settings{$id}{text}\n|;
- if ( defined($$settings{$id}{image}) ) {
+ if ($context eq 'CSTR') {
+ $output .= qq|$$settings{$id}{text}\n|;
+ }
+ my ($image,$imglink,$url);
+ if ( defined($$settings{$id}{image}) ) {
if ( $$settings{$id}{style} eq 'embed' ) {
- $output .= qq|
|;
+ $image = qq|
|;
} else {
- $output .= qq|
Link to file
|;
+ $imglink = qq|
Link to file
|;
}
}
if ( defined($$settings{$id}{url}) ) {
- $output .= qq|
$$settings{$id}{name}
|;
+ $url = qq|
$$settings{$id}{name}
|;
+ }
+ if ($context eq 'CSTR') {
+ $output .= $image.$imglink.$url.'
+';
}
- $output .= qq|
-|;
if ($$settings{$id}{class} eq 'QUESTION_MULTIPLECHOICE') {
my $numfoils = @{$allanswers{$id}};
- $output .= qq|
+ if ($context eq 'CSTR') {
+ $output .= qq|
|;
+ }
for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
$output .= "
|;
+ $ans_image .= qq|
|;
} else {
- $output .= qq|
Link to file
|;
+ $ans_link .= qq|
Link to file
|;
}
}
- $output .= qq|\n|;
+ $output .= $ans_image.$ans_link.''."\n";
}
- chomp($output);
- $output .= qq|
+ if ($context eq 'CSTR') {
+ chomp($output);
+ $output .= qq|
|;
+ }
} elsif ($$settings{$id}{class} eq 'QUESTION_TRUEFALSE') {
my $numfoils = @{$allanswers{$id}};
- $output .= qq|
+ if ($context eq 'CSTR') {
+ $output .= qq|
|;
+ }
for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
$output .= " \n";
}
- chomp($output);
- $output .= qq|
+ if ($context eq 'CSTR') {
+ chomp($output);
+ $output .= qq|
|;
+ }
} elsif ($$settings{$id}{class} eq 'QUESTION_MULTIPLEANSWER') {
my $numfoils = @{$allanswers{$id}};
- $output .= qq|
+ if ($context eq 'CSTR') {
+ $output .= qq|
|;
+ }
for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
$output .= " \n";
}
- chomp($output);
- $output .= qq|
+ if ($context eq 'CSTR') {
+ chomp($output);
+ $output .= qq|
|;
+ }
} elsif ($$settings{$id}{class} eq 'QUESTION_ORDER') {
my $numfoils = @{$allanswers{$id}};
- $output .= qq|
+ if ($context eq 'CSTR') {
+ $output .= qq|
|;
+ }
for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
- $output .= " ".$$settings{$id}{$allanswers{$id}[$k]}{text}."\n";
+ if ($context eq 'CSTR') {
+ $output .= " ".$$settings{$id}{$allanswers{$id}[$k]}{text}."\n";
+ }
}
- chomp($output);
- $output .= qq|
+ if ($context eq 'CSTR') {
+ chomp($output);
+ $output .= qq|
|;
+ }
} elsif ($$settings{$id}{class} eq 'QUESTION_FILLINBLANK') {
my $numerical = 1;
- for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
- if ($$settings{$id}{$allanswers{$id}[$k]}{text} =~ m/([^\d\.]|\.\.)/) {
- $numerical = 0;
+ if ($context eq 'DOCS') {
+ $numerical = 0;
+ } else {
+ for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
+ if ($$settings{$id}{$allanswers{$id}[$k]}{text} =~ m/([^\d\.]|\.\.)/) {
+ $numerical = 0;
+ }
}
}
if ($numerical) {
@@ -1844,7 +1895,8 @@ sub process_assessment {
$numans = ($max + $min)/2;
$tol = 100*($max - $min)/($numans*2);
}
- $output .= qq|
+ if ($context eq 'CSTR') {
+ $output .= qq|
|;
+ }
} else {
- if (@{$allanswers{$id}} == 1) {
- $output .= qq|
+ if ($context eq 'CSTR') {
+ if (@{$allanswers{$id}} == 1) {
+ $output .= qq|
|;
- } else {
- my @answertext = ();
- for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
- $$settings{$id}{$allanswers{$id}[$k]}{text} =~ s/\|/\|/g;
- push @answertext, $$settings{$id}{$allanswers{$id}[$k]}{text};
- }
- my $regexpans = join('|',@answertext);
- $regexpans = '/^('.$regexpans.')\b/';
- $output .= qq|
+ } else {
+ my @answertext = ();
+ for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
+ $$settings{$id}{$allanswers{$id}[$k]}{text} =~ s/\|/\|/g;
+ push @answertext, $$settings{$id}{$allanswers{$id}[$k]}{text};
+ }
+ my $regexpans = join('|',@answertext);
+ $regexpans = '/^('.$regexpans.')\b/';
+ $output .= qq|
|;
- }
+ }
+ }
}
} elsif ($$settings{$id}{class} eq "QUESTION_MATCH") {
- $output .= qq|
+ if ($context eq 'CSTR') {
+ $output .= qq|
|;
+ }
for (my $k=0; $k<@{$allchoices{$id}}; $k++) {
- $output .= qq|
+ if ($context eq 'CSTR') {
+ $output .= qq|
-
$$settings{$id}{$allchoices{$id}[$k]}{text}
|;
+ }
}
- $output .= qq|
+ if ($context eq 'CSTR') {
+ $output .= qq|
|;
+ }
for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
- $output .= qq|
+ if ($context eq 'CSTR') {
+ $output .= qq|
$$settings{$id}{$allanswers{$id}[$k]}{text}
|;
+ }
}
- $output .= qq|
+ if ($context eq 'CSTR') {
+ $output .= qq|
|;
+ }
}
}
- $output .= qq|
+ if ($context eq 'CSTR') {
+ $output .= qq|
|;
- open(PROB,">$newdir/$id.problem");
- print PROB $output;
- close PROB;
+ open(PROB,">$newdir/$id.problem");
+ print PROB $output;
+ close PROB;
+ }
}
}