--- loncom/imspackages/imsprocessor.pm 2005/02/14 22:46:12 1.14 +++ loncom/imspackages/imsprocessor.pm 2005/02/21 23:47:46 1.15 @@ -51,6 +51,11 @@ sub ims_config { survey => 'FORM', ); @{$$cmsmap{angel}{doc}} = ('FILE','PAGE'); + %{$$cmsmap{webct4}} = ( + quiz => 'webctquiz', + survey => 'webctsurvey', + doc => 'webcontent' + ); %{$areaname} = ( announce => 'Announcements', board => 'Discussion Boards', @@ -146,6 +151,7 @@ sub process_manifest { bb6 => 'organization', bb5 => 'tableofcontents', angel => 'organization', + webct4 => 'organization', ); my %contents = (); my @state = (); @@ -198,7 +204,7 @@ sub process_manifest { if ($$includeditems{$itm} || $phase ne 'build') { %{$$items{$itm}} = (); $$items{$itm}{contentscount} = 0; - if ($cms eq 'bb5' || $cms eq 'bb6') { + if ($cms eq 'bb5' || $cms eq 'bb6' || $cms eq 'webct4') { $$items{$itm}{resnum} = $attr->{identifierref}; if ($cms eq 'bb5') { $$items{$itm}{title} = $attr->{title}; @@ -255,7 +261,7 @@ sub process_manifest { } elsif ("@state" eq "manifest resources resource" ) { $identifier = $attr->{identifier}; if ($$includedres{$identifier} || $phase ne 'build') { - if ($cms eq 'bb5' || $cms eq 'bb6') { + if ($cms eq 'bb5' || $cms eq 'bb6' || $cms eq 'webct4') { $$resources{$identifier}{file} = $attr->{file}; $$resources{$identifier}{type} = $attr->{type}; } elsif ($cms eq 'angel') { @@ -268,7 +274,7 @@ sub process_manifest { } } elsif ("@state" eq "manifest resources resource file") { if ($$includedres{$identifier} || $phase ne 'build') { - if ($cms eq 'bb5' || $cms eq 'bb6') { + if ($cms eq 'bb5' || $cms eq 'bb6' || $cms eq 'webct4') { push @{$$hrefs{$identifier}},$attr->{href}; } elsif ($cms eq 'angel') { if ($attr->{href} =~ m/^_assoc\\$identifier\\(.+)$/) { @@ -283,11 +289,18 @@ sub process_manifest { text_h => [sub { my ($text) = @_; + if ("@state" eq "manifest metadata lom general title langstring") { + $$items{'Top'}{title} = $text; + } if ($state[0] eq "manifest" && $state[1] eq "organizations" && $state[2] eq $toc{$cms} && $state[-1] eq "title") { if ($$includeditems{$itm} || $phase ne 'build') { if ($cms eq 'angel' || $cms eq 'bb6') { $$items{$itm}{title} = $text; } + if ($cms eq 'webct4') { + $$items{$itm}{title} = $text; + $$items{$itm}{title} =~ s/(<[^>]*>)//g; + } } } }, "dtext"], @@ -353,6 +366,9 @@ sub copy_resources { %{$$url{$key}} = (); foreach my $file (@{$$hrefs{$key}}) { my $source = $tempdir.'/'.$key.'/'.$file; + if ($cms eq 'webct4') { + $source = $tempdir.'/'.$file; + } my $filename = ''; my $fpath = $timenow.'/resfiles/'.$key.'/'; if ($cms eq 'angel') { @@ -361,8 +377,19 @@ sub copy_resources { } } $file =~ s-\\-/-g; - $file = $fpath.$file; - my $fileresult = &Apache::lonnet::process_coursefile('copy',$crs,$cdom,$chome,$file,$source); + my $copyfile = $file; + if ($cms eq 'webct4') { + if ($file =~ m-/([^/]+)$-) { + $copyfile = $1; + } + } + unless (($cms eq 'webct4') && ($copyfile eq 'questionDB.xml' || $copyfile =~ m/^quiz_QIZ_\d+\.xml$/)) { + $copyfile = $fpath.$copyfile; + my $fileresult; + if (-e $source) { + $fileresult = &Apache::lonnet::process_coursefile('copy',$crs,$cdom,$chome,$copyfile,$source); + } + } } } } @@ -374,11 +401,10 @@ sub copy_resources { if (grep/^$key$/,@{$targets}) { foreach my $file (@{$$hrefs{$key}}) { $file =~ s-\\-/-g; - if ( ($cms eq 'angel' && $file ne 'pg'.$key.'.htm') || ($cms eq 'bb5') || ($cms eq 'bb6') ) { + if ( ($cms eq 'angel' && $file ne 'pg'.$key.'.htm') || ($cms eq 'bb5') || ($cms eq 'bb6')) { if (!-e "$destdir/resfiles/$key") { mkdir("$destdir/resfiles/$key",0770); } - my $filepath = $file; my $front = ''; while ($filepath =~ m-(\w+)/(.+)-) { @@ -395,6 +421,16 @@ sub copy_resources { } elsif ($cms eq 'bb5' || $cms eq 'bb6') { rename("$tempdir/$key/$file","$destdir/resfiles/$key/$file"); } + } elsif ($cms eq 'webct4') { + if (!-e "$destdir/resfiles/$key") { + mkdir("$destdir/resfiles/$key",0770); + } + if ($file =~ m-/([^/]+)$-) { + my $copyfile = $1; + unless ($copyfile eq 'questionDB.xml' || $copyfile =~ m/^quiz_QIZ_\d+\.xml$/) { + rename("$tempdir/$file","$destdir/resfiles/$key/$1"); + } + } } } } @@ -403,9 +439,10 @@ sub copy_resources { } sub process_resinfo { - my ($cms,$context,$docroot,$destdir,$items,$resources,$targets,$boards,$announcements,$quizzes,$surveys,$pools,$groups,$messages,$timestamp,$boardnum,$resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,$total,$dirname,$seqstem,$resrcfiles,$packages,$hrefs,$pagesfiles,$sequencesfiles) = @_; + my ($cms,$context,$docroot,$destdir,$items,$resources,$targets,$boards,$announcements,$quizzes,$surveys,$pools,$groups,$messages,$timestamp,$boardnum,$resinfo,$udom,$uname,$cdom,$crs,$db_handling,$user_handling,$total,$dirname,$seqstem,$resrcfiles,$packages,$hrefs,$pagesfiles,$sequencesfiles,$randompicks) = @_; my $board_id = time; my $board_count = 0; + my $dbparse = 0; my $announce_handling = 'include'; my $longcrs = ''; if ($crs =~ m/^(\d)(\d)(\d)/) { @@ -471,15 +508,15 @@ sub process_resinfo { } } elsif ($$resources{$key}{type} eq "assessment/x-bb-pool") { %{$$resinfo{$key}} = (); - &process_assessment($context,$key,$docroot,'pool',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles); + &process_assessment($cms,$context,$key,$docroot,'pool',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse); push @{$pools}, $key; } elsif ($$resources{$key}{type} eq "assessment/x-bb-quiz") { %{$$resinfo{$key}} = (); - &process_assessment($context,$key,$docroot,'quiz',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles); + &process_assessment($cms,$context,$key,$docroot,'quiz',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse); push @{$quizzes}, $key; } elsif ($$resources{$key}{type} eq "assessment/x-bb-survey") { %{$$resinfo{$key}} = (); - &process_assessment($context,$key,$docroot,'survey',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles); + &process_assessment($cms,$context,$key,$docroot,'survey',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse); push @{$surveys}, $key; } elsif ($$resources{$key}{type} eq "assessment/x-bb-group") { %{$$resinfo{$key}} = (); @@ -514,6 +551,19 @@ sub process_resinfo { if (@{$pools}) { $$items{'Top'}{'contentscount'} ++; } + } elsif ($cms eq 'webct4') { + foreach my $key (sort keys %{$resources}) { + if (grep/^$key$/,@{$targets}) { + if ($$resources{$key}{type} eq "webcontent") { + %{$$resinfo{$key}} = (); +# &webct4_content($key,$docroot,$destdir,\%{$$resinfo{$key}},$udom,$uname,$$resources{$key}{type},$$items{$$resources{$key}{revitm}}{title},$resrcfiles); + } elsif ($$resources{$key}{type} eq "webctquiz") { +# &webct4_assessment($key,$docroot,$destdir,\%{$$resinfo{$key}},$udom,$uname,$$resources{$key}{type},$$items{$$resources{$key}{revitm}}{title},$resrcfiles); + &process_assessment($cms,$context,$key,$docroot,'quiz',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse); + + } + } + } } $$total{'board'} = $board_count; @@ -523,7 +573,7 @@ sub process_resinfo { } sub build_structure { - my ($cms,$context,$destdir,$items,$resinfo,$resources,$targets,$hrefs,$udom,$uname,$newdir,$timenow,$cdom,$crs,$timestamp,$total,$boards,$announcements,$quizzes,$surveys,$pools,$boardnum,$pagesfiles,$seqfiles,$topurls,$topnames,$packages,$includeditems) = @_; + my ($cms,$context,$destdir,$items,$resinfo,$resources,$targets,$hrefs,$udom,$uname,$newdir,$timenow,$cdom,$crs,$timestamp,$total,$boards,$announcements,$quizzes,$surveys,$pools,$boardnum,$pagesfiles,$seqfiles,$topurls,$topnames,$packages,$includeditems,$randompicks) = @_; my %flag = (); my %count = (); my %pagecontents = (); @@ -582,11 +632,13 @@ sub build_structure { my $curr_id = 1; my $resnum = $$items{$key}{resnum}; my $type = $$resources{$resnum}{type}; - if (($cms eq 'angel' && $type eq "FOLDER") || (($cms eq 'bb5' || $cms eq 'bb6') && $$resinfo{$resnum}{'isfolder'} eq "true") && (($type eq "resource/x-bb-document") || ($type eq "resource/x-bb-staffinfo") || ($type eq "resource/x-bb-externallink")) ) { + my $contentscount = $$items{$key}{'contentscount'}; + if (($cms eq 'angel' && $type eq "FOLDER") || (($cms eq 'bb5' || $cms eq 'bb6') && $$resinfo{$resnum}{'isfolder'} eq "true") && (($type eq "resource/x-bb-document") || ($type eq "resource/x-bb-staffinfo") || ($type eq "resource/x-bb-externallink")) || ($cms eq 'webct4' && $contentscount > 0)) { + print STDERR "$key is identified as a folder has $contentscount\n"; unless (($cms eq 'bb5') && $key eq 'Top') { $seqtext{$key} = "\n"; } - if ($$items{$key}{contentscount} == 0) { + if ($contentscount == 0) { if ($key eq 'Top') { unless ($topspecials) { $seqtext{$key} .= qq| @@ -601,14 +653,19 @@ sub build_structure { } else { my $contcount = @{$$items{$key}{contents}}; my $contitem = $$items{$key}{contents}[0]; - my $res = $$items{$contitem}{resnum}; - my $type = $$resources{$res}{type}; + my $contitemcount = $$items{$contitem}{contentscount}; + my ($res,$itm,$type); + if (exists($$items{$contitem}{resnum})) { + $res = $$items{$contitem}{resnum}; + $itm = $$resources{$res}{revitm}; + $type = $$resources{$res}{type}; + } my $title = $$items{$contitem}{title}; my $packageflag = 0; if (grep/^$res$/,@{$packages}) { $packageflag = 1; } - $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag); + $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag,$contitemcount); unless ($flag{$key}{page} == 1) { $seqtext{$key} .= qq| 2 ) { for (my $i=1; $i<$contcount-1; $i++) { my $contitem = $$items{$key}{contents}[$i]; + my $contitemcount = $$items{$contitem}{contentscount}; my $res = $$items{$contitem}{resnum}; my $type = $$resources{$res}{type}; my $title = $$items{$contitem}{title}; @@ -642,7 +700,8 @@ sub build_structure { if (grep/^$res$/,@{$packages}) { $packageflag = 1; } - $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag); + $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag,$contitemcount); + unless ($flag{$key}{page} == 1) { $seqtext{$key} .= qq|> @@ -660,6 +719,7 @@ sub build_structure { } } my $contitem = $$items{$key}{contents}[-1]; + my $contitemcount = $$items{$contitem}{contentscount}; my $res = $$items{$contitem}{resnum}; my $type = $$resources{$res}{type}; my $title = $$items{$contitem}{title}; @@ -667,7 +727,8 @@ sub build_structure { if (grep/^$res$/,@{$packages}) { $packageflag = 1; } - $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag); + $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag,$contitemcount); + if ($flag{$key}{page}) { if ($count{$key}{seq} + $count{$key}{page} + $count{$key}{board} + $count{$key}{file} +1 == 1) { $seqtext{$key} .= qq|> @@ -788,9 +849,9 @@ sub build_structure { } sub make_structure { - my ($cms,$key,$srcstem,$flag,$count,$timestamp,$boardnum,$hrefs,$pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag) = @_; + my ($cms,$key,$srcstem,$flag,$count,$timestamp,$boardnum,$hrefs,$pagecontents,$res,$type,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag,$contitemcount) = @_; my $src =''; - if (($cms eq 'angel' && $type eq 'FOLDER') || (($cms eq 'bb5' || $cms eq 'bb6') && ($$resinfo{$res}{'isfolder'} eq 'true') || ($key eq 'Top')) ) { + if (($cms eq 'angel' && $type eq 'FOLDER') || (($cms eq 'bb5' || $cms eq 'bb6') && (($$resinfo{$res}{'isfolder'} eq 'true') || $key eq 'Top')) || ($cms eq 'webct4' && $contitemcount > 0)) { $src = $srcstem.'/sequences/'.$contitem.'.sequence'; $$flag{$key}{page} = 0; $$flag{$key}{seq} = 1; @@ -838,6 +899,18 @@ sub make_structure { } $$flag{$key}{seq} = 0; } + } elsif ($cms eq 'webct4') { + unless ($type eq 'webctquiz') { + foreach my $file (@{$$hrefs{$res}}) { + my $filename; + if ($file =~ m-/([^/]+)$-) { + $filename = $1; + } + $src = $srcstem.'/resfiles/'.$res.'/'.$filename; + } + $$flag{$key}{page} = 0; + $$flag{$key}{file} = 1; + } } return $src; } @@ -1275,7 +1348,7 @@ sub process_link { } elsif ("@state" eq "EXTERNALLINK TEXTCOLOR") { $$settings{textcolor} = $attr->{value}; } elsif ("@state" eq "EXTERNALLINK DESCRIPTION FLAGS ISHTML") { - $$settings{ishtml} = $attr->{value}; + $$settings{ishtml} = $attr->{value}; } elsif ("@state" eq "EXTERNALLINK FLAGS ISAVAILABLE" ) { $$settings{isavailable} = $attr->{value}; } elsif ("@state" eq "EXTERNALLINK FLAGS LAUNCHINNEWWINDOW" ) { @@ -1549,15 +1622,12 @@ sub addposting { } return $status; } -# ---------------------------------------------------------------- Process Blackboard Assessments - pools, quizzes, surveys -sub process_assessment { - my ($context,$res,$docroot,$container,$dirname,$destdir,$settings,$total,$udom,$uname,$pagesfiles,$sequencesfiles) = @_; + +sub parse_bb5_assessment { + my ($res,$docroot,$container,$settings,$allanswers,$allchoices,$allids) = @_; my $xmlfile = $docroot.'/'.$res.".dat"; # print "XML file is $xmlfile\n"; my @state = (); - my @allids = (); - my %allanswers = (); - my %allchoices = (); my $id; # the current question ID my $answer_id; # the current answer ID my %toptag = ( pool => 'POOL', @@ -1603,9 +1673,9 @@ sub process_assessment { } if ("@state" eq "$toptag{$container} QUESTIONLIST QUESTION") { $id = $attr->{id}; - push @allids, $id; + push @{$allids}, $id; %{$$settings{$id}} = (); - @{$allanswers{$id}} = (); + @{$$allanswers{$id}} = (); $$settings{$id}{class} = $attr->{class}; unless ($container eq "pool") { $$settings{$id}{points} = $attr->{points}; @@ -1627,7 +1697,7 @@ sub process_assessment { $$settings{$id}{name} = $attr->{name}; } elsif ( ($state[0] eq $toptag{$container}) && ($state[1] =~ m/^QUESTION_(\w+)$/) && ($state[-1] eq "ANSWER") ) { $answer_id = $attr->{id}; - push @{$allanswers{$id}},$answer_id; + push @{$$allanswers{$id}},$answer_id; %{$$settings{$id}{$answer_id}} = (); $$settings{$id}{$answer_id}{position} = $attr->{position}; if ($$settings{$id}{class} eq 'QUESTION_MATCH') { @@ -1636,7 +1706,7 @@ sub process_assessment { } } elsif ( ($state[0] eq $toptag{$container}) && ($state[1] =~ m/^QUESTION_(\w+)$/) && ($state[-1] eq "CHOICE") ) { $answer_id = $attr->{id}; - push @{$allchoices{$id}},$answer_id; + push @{$$allchoices{$id}},$answer_id; %{$$settings{$id}{$answer_id}} = (); $$settings{$id}{$answer_id}{position} = $attr->{position}; $$settings{$id}{$answer_id}{placement} = $attr->{placement}; @@ -1699,7 +1769,484 @@ sub process_assessment { $p->unbroken_text(1); $p->parse_file($xmlfile); $p->eof; +} + +sub parse_bb6_assessment { + my ($res,$docroot,$container,$settings,$allanswers,$allchoices,$allids) = @_; + return; +} + +sub parse_webct4_assessment { + my ($res,$docroot,$container,$allids) = @_; + my $xmlfile = $docroot.'/quiz'.$res.".xml"; #quiz file + print STDERR "XML file is $xmlfile\n"; + my @state = (); + my $id; # the current question ID + my $p = HTML::Parser->new + ( + xml_mode => 1, + start_h => + [sub { + my ($tagname, $attr) = @_; + push @state, $tagname; + my $depth = 0; + my @seq = (); + my $class; + if ("@state" eq "questestinterop assessment section itemref") { + $id = $attr->{linkrefid}; + push(@{$allids},$id); + } + }, "tagname, attr"], + text_h => + [sub { + my ($text) = @_; + }, "dtext"], + end_h => + [sub { + my ($tagname) = @_; + pop @state; + }, "tagname"], + ); + $p->unbroken_text(1); + $p->parse_file($xmlfile); + $p->eof; +} + +sub parse_webct_quizprops { + my ($res,$docroot,$container,$qzparams) = @_; + my $xmlfile = $docroot.'/quiz'.$res.".xml"; #quiz file + print STDERR "XML file is $xmlfile\n"; + my @state = (); + %{$$qzparams{$res}} = (); + my $p = HTML::Parser->new + ( + xml_mode => 1, + start_h => + [sub { + my ($tagname, $attr) = @_; + push @state, $tagname; + my $depth = 0; + my @seq = (); + my $class; + if ($state[0] eq 'properties' && $state[1] eq 'processing') { + if ($state[2] eq 'scores' && $state[3] eq 'score') { + $$qzparams{$res}{weight} = $attr->{linkrefid}; + } elsif ($state[2] eq 'selection' && $state[3] eq 'select') { + $$qzparams{$res}{numpick} = $attr->{linkrefid}; + } + } + }, "tagname, attr"], + text_h => + [sub { + my ($text) = @_; + if ($state[0] eq 'properties' && $state[1] eq 'delivery') { + if ($state[2] eq 'time_available') { + $$qzparams{$res}{opendate} = $text; + } elsif ($state[2] eq 'time_due') { + $$qzparams{$res}{opendate} = $text; + } elsif ($state[3] eq 'max_attempt') { + $$qzparams{$res}{tries} = $text; + } elsif ($state[3] eq 'post_submission') { + $$qzparams{$res}{posts} = $text; + } + } elsif ($state[0] eq 'properties' && $state[1] eq 'result') { + if ($state[2] eq 'display_answer') { + $$qzparams{$res}{answerdate} = $text; + } + } + }, "dtext"], + end_h => + [sub { + my ($tagname) = @_; + pop @state; + }, "tagname"], + ); + $p->unbroken_text(1); + $p->parse_file($xmlfile); + $p->eof; +} + +sub parse_webct4_questionDB { + my ($docroot,$catinfo,$settings,$allanswers,$allchoices,$allids) = @_; + my $xmlfile = $docroot.'/questionDB.xml'; #quizDB file + print STDERR "XML file is $xmlfile\n"; + my @state = (); + my $category; # the current category ID + my $id; # the current question ID + my $list; # the current list ID for multiple choice questions + my $numid; # the current answer ID for numerical questions + my $grp; # the current group ID for matching questions + my $label; # the current reponse label for string questions + my $str_id; # the current string ID for string questions + my $unitid; # the current unit ID for numerical questions + my $answer_id; # the current answer ID + my $fdbk; # the current feedback ID + my $maxvar; # the current max variable for numerical problems + my $minvar; # the current min variable for numerical problems + my $stepvar; # the current step variable for numerical problems + my $fibtype; # the current fill-in-blank type fro numerical or string + my $prompt; + my %setvar = ( + varname => '', + action => '', + ); + my $p = HTML::Parser->new + ( + xml_mode => 1, + start_h => + [sub { + my ($tagname, $attr) = @_; + push @state, $tagname; + if ("@state" eq "questestinterop section") { + $category = $attr->{ident}; + %{$$catinfo{$category}} = (); + $$catinfo{$category}{title} = $attr->{title}; + } + if ("@state" eq "questestinterop section item") { + $id = $attr->{ident}; + push @{$allids}, $id; + push(@{$$catinfo{$category}{contents}},$id); + %{$$settings{$id}} = (); + @{$$settings{$id}{grps}} = (); + @{$$settings{$id}{lists}} = (); + @{$$settings{$id}{feedback}} = (); + %{$$settings{$id}{strings}} = (); + %{$$allanswers{$id}} = (); + @{$$allanswers{$id}{strings}} = (); + $$settings{$id}{title} = $attr->{title}; + } + +# Matching + if ("@state" eq "questestinterop section item presentation material mattext") { + $$settings{$id}{texttype} = $attr->{texttype}; + } + if ("@state" eq "questestinterop section item presentation response_grp") { + $$settings{$id}{class} = 'QUESTION_MATCH'; + $grp = $attr->{ident}; + push(@{$$settings{$id}{grps}},$grp); + %{$$settings{$id}{$grp}} = (); + @{$$allanswers{$id}{$grp}} = (); + @{$$settings{$id}{$grp}{correctanswer}} = (); + $$settings{$id}{$grp}{rcardinality} = $attr->{rcardinality}; + } + if ("@state" eq "questestinterop section item presentation response_grp material mattext") { + $$settings{$id}{$grp}{texttype} = $attr->{texttype}; + } + if ("@state" eq "questestinterop section item presentation response_grp render_choice response_label") { + $answer_id = $attr->{ident}; + push(@{$$allanswers{$id}{$grp}},$answer_id); + %{$$settings{$id}{$grp}{$answer_id}} = (); + $$settings{$id}{$grp}{$answer_id}{texttype} = $attr->{texttype}; + } + +# Multiple choice + + if ("@state" eq "questestinterop section item presentation flow material mattext") { + $$settings{$id}{texttype} = $attr->{texttype}; + } + if ("@state" eq "questestinterop section item presentation flow response_lid") { + $$settings{$id}{class} = 'QUESTION_MULTIPLEANSWER'; + $list = $attr->{ident}; + push(@{$$settings{$id}{lists}},$list); + %{$$settings{$id}{$list}} = (); + @{$$allanswers{$id}{$list}} = (); + @{$$settings{$id}{$list}{correctanswer}} = (); + $$settings{$id}{$list}{rcardinality} = $attr->{rcardinality}; + } + if ("@state" eq "questestinterop section item presentation flow response_lid render_choice") { + $$settings{$id}{$list}{randomize} = $attr->{shuffle}; + } + if ("@state" eq "questestinterop section item presentation flow response_lid render_choice flow_label response_label") { + $answer_id = $attr->{ident}; + push(@{$$allanswers{$id}{$list}},$answer_id); + %{$$settings{$id}{$list}{$answer_id}} = (); + } + if ("@state" eq "questestinterop section item presentation flow response_lid render_choice flow_label response_label material mattext") { + $$settings{$id}{$list}{$answer_id}{texttype} = $attr->{texttype}; + } + +# Numerical + if ("@state" eq "questestinterop section item presentation material mat_extension webct:x_webct_v01_dynamicmattext") { + $$settings{$id}{texttype} = $attr->{texttype}; + } + if ("@state" eq "questestinterop section item presentation response_num") { + $$settings{$id}{class} = 'QUESTION_NUMERICAL'; + $numid = $attr->{ident}; + %{$$settings{$id}{$numid}} = (); + $$settings{$id}{$numid}{rcardinality} = $attr->{rcardinality}; + } + if ("@state" eq "questestinterop section item presentation response_num material mat_extension webct:x_webct_v01_dynamicdata webct:x_webct_v01_datarange webct:x_webct_v01_minvalue webct:x_webct_v01_variable") { + $minvar = $attr->{name}; + $$settings{$id}{$numid}{minvar} = $minvar; + } + if ("@state" eq "questestinterop section item presentation response_num material mat_extension webct:x_webct_v01_dynamicdata webct:x_webct_v01_datarange webct:x_webct_v01_minvalue webct:x_webct_v01_variable") { + $maxvar = $attr->{name}; + $$settings{$id}{$numid}{maxvar} = $maxvar; + } + if ("@state" eq "questestinterop section item presentation response_num material mat_extension webct:x_webct_v01_dynamicdata webct:x_webct_v01_datarange webct:x_webct_v01_decimalnum webct:x_webct_v01_variable") { + $stepvar = $attr->{name}; + $$settings{$id}{$numid}{stepvar} = $stepvar; + } + if ("@state" eq "questestinterop section item presentation response_num render_fib") { + $fibtype = $attr->{fibtype}; + $prompt = $attr->{prompt}; + } + if ("@state" eq "questestinterop section item presentation response_num render_fib response_label") { + $$settings{$id}{$numid}{label} = $attr->{ident}; + } + +# String or Numerical + if ("@state" eq "questestinterop section item presentation response_str") { + $str_id = $attr->{ident}; + push(@{$$settings{$id}{str}},$str_id); + %{$$settings{$id}{$str_id}} = (); + $$settings{$id}{$str_id}{rcardinality} = $attr->{rcardinality}; + } + + if ("@state" eq "questestinterop section item presentation response_str render_fib") { + $fibtype = $attr->{fibtype}; + } + if ("@state" eq "questestinterop section item presentation response_str render_fib response_label") { + $label = $attr->{ident}; + %{$$settings{$id}{$str_id}{$label}} = (); + push(@{$$allanswers{$id}{strings}},$label); + @{$$settings{$id}{strings}{$label}} = (); + $$settings{$id}{$str_id}{$label}{fibtype} = $fibtype; + } + +# Numerical + if ("@state" eq "questestinterop section item presentation response_str render_fib") { + $fibtype = $attr->{fibtype}; + $prompt = $attr->{prompt}; + } + if ("@state" eq "questestinterop section item resprocessing itemproc_extension webct:x_webct_v01_autocalculate webct:x_webct_v01_formula") { + $$settings{$id}{$numid}{formula} = $attr->{ident}; + } + if ("@state" eq "questestinterop section item resprocessing itemproc_extension webct:x_webct_v01_autocalculate webct:x_webct_v01_anspresentation") { + $$settings{$id}{$numid}{digits} = $attr->{digits}; + $$settings{$id}{$numid}{format} = $attr->{format}; + } + if ("@state" eq "questestinterop section item resprocessing itemproc_extension webct:x_webct_v01_autocalculate webct:x_webct_v01_anstolerance") { + $$settings{$id}{$numid}{toltype} = $attr->{type}; + } + if ("@state" eq "questestinterop section item resprocessing itemproc_extension webct:x_webct_v01_autocalculate webct:x_webct_v01_unit") { + my $unitid = $attr->{ident}; + %{$$settings{$id}{$numid}{$unitid}} = (); + $$settings{$id}{$numid}{$unitid}{value} = $attr->{value}; + $$settings{$id}{$numid}{$unitid}{space} = $attr->{space}; + $$settings{$id}{$numid}{$unitid}{case} = $attr->{case}; + } + +# Matching + if ("@state" eq "questestinterop section item resprocessing respcondition conditionvar varequal") { + $grp = $attr->{respident}; + } + if ("@state" eq "questestinterop section item resprocessing respcondition conditionvar setvar") { + $setvar{varname} = $attr->{varname}; + if ($setvar{varname} eq 'WebCT_Correct') { + push(@{$$settings{$id}{$grp}{correctanswer}},$answer_id); + } + } + +# String + if ("@state" eq "questestinterop section item resprocessing respcondition conditionvar varsubset") { + $$settings{$id}{class} = 'QUESTION_FILLINBLANK'; + $answer_id = $attr->{respident}; + $$settings{$id}{class} = ''; + } + if ("@state" eq "questestinterop section item resprocessing respcondition conditionvar not") { + $$settings{$id}{class} = 'QUESTION_ESSAY'; + } + + +# Feedback + + if ("@state" eq "questestinterop section item respcondition displayfeedback") { + $fdbk = $attr->{linkrefid}; + push(@{$$settings{$id}{feedback}},$fdbk); + $$settings{$id}{$fdbk} = (); + $$settings{$id}{$fdbk}{feedbacktype} = $attr->{feedbacktype}; + } + if ("@state" eq "questestinterop section item itemfeedback") { + $fdbk = $attr->{ident}; + $$settings{$id}{$fdbk}{view} = $attr->{view}; + } + if ("@state" eq "questestinterop section item itemfeedback material mattext") { + $$settings{$id}{$fdbk}{texttype} = $attr->{texttype}; + } + }, "tagname, attr"], + text_h => + [sub { + my ($text) = @_; + if ("@state" eq "questestinterop section item itemmetadata qmd_itemtype") { + $$settings{$id}{itemtype} = $text; + } + +#Matching + + if ("@state" eq "questestinterop section item presentation material mattext") { + $$settings{$id}{text} = $text; + } + if ("@state" eq "questestinterop section item presentation response_grp material mattext") { + $$settings{$id}{$grp}{text} = $text; + } + if ("@state" eq "questestinterop section item presentation response_grp render_choice response_label material mattext") { + $$settings{$id}{$grp}{$answer_id}{text} = $text; + } + +# Multiple choice + + if ("@state" eq "questestinterop section item presentation flow material mattext") { + $$settings{$id}{text} = $text; + } + + if ("@state" eq "questestinterop section item presentation flow response_lid render_choice flow_label response_label material mattext") { + $$settings{$id}{$list}{$answer_id}{text} = $text; + } + +# Numerical + if ("@state" eq "questestinterop section item presentation material mat_extension webct:x_webct_v01_dynamicmattext") { + $$settings{$id}{text} = $text; + } + if ("@state" eq "questestinterop section item presentation response_num material mat_extension webct:x_webct_v01_dynamicdata webct:x_webct_v01_datarange webct:x_webct_v01_minvalue webct:x_webct_v01_variable") { + $$settings{$id}{$minvar}{min} = $text; + } + if ("@state" eq "questestinterop section item presentation response_num material mat_extension webct:x_webct_v01_dynamicdata webct:x_webct_v01_datarange webct:x_webct_v01_maxvalue webct:x_webct_v01_variable") { + $$settings{$id}{$maxvar}{max} = $text; + } + if ("@state" eq "questestinterop section item presentation response_num material mat_extension webct:x_webct_v01_dynamicdata webct:x_webct_v01_datarange webct:x_webct_v01_decimalnum webct:x_webct_v01_variable") { + $$settings{$id}{$stepvar}{step} = $text; + } + + if ("@state" eq "questestinterop section item resprocessing respcondition conditionvar varequal") { + $answer_id = $text; + } + if ("@state" eq "questestinterop section item resprocessing respcondition conditionvar varsubset") { # String + push(@{$$settings{$id}{strings}{$answer_id}},$text); + } + if ("@state" eq "questestinterop section item resprocessing respcondition conditionvar setvar") { + if ($setvar{varname} eq "answerValue") { # Multiple Choice + if ($text =~ m/^\d+$/) { + if ($text > 0) { + push(@{$$settings{$id}{$list}{correctanswer}}),$answer_id; + } + } + } + } + + if ("@state" eq "questestinterop section item resprocessing itemproc_extension webct:x_webct_v01_autocalculate webct:x_webct_v01_unit") { + $$settings{$id}{$numid}{$unitid}{text} = $text; + } + + if ("@state" eq "questestinterop section item itemfeedback material mattext") { + $$settings{$id}{$fdbk}{text} = $text; + } + }, "dtext"], + end_h => + [sub { + my ($tagname) = @_; + pop @state; + }, "tagname"], + ); + $p->unbroken_text(1); + $p->parse_file($xmlfile); + $p->eof; +} +sub process_assessment { + my ($cms,$context,$res,$docroot,$container,$dirname,$destdir,$settings,$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,$dbparse) = @_; + my @allids = (); + my %allanswers = (); + my %allchoices = (); + my %qzparams = (); + my @allquestids = (); + my %catinfo = (); + my %qzdbsettings = (); + my %alldbanswers = (); + my %alldbchoices = (); + my @alldbquestids = (); + my $containerdir; + my $newdir; + my $randompickflag = 0; + my ($cid,$cdom,$cnum); + if ($context eq 'DOCS') { + $cid = $ENV{'request.course.id'}; + ($cdom,$cnum) = split/_/,$cid; + } + my $destresdir = $destdir; + if ($context eq 'CSTR') { + $destresdir =~ s|/home/$uname/public_html/|/res/$udom/$uname/|; + } elsif ($context eq 'DOCS') { + $destresdir =~ s|^/home/httpd/html/userfiles|/uploaded|; + } + if ($cms eq 'bb5') { + &parse_bb5_assessment($res,$docroot,$container,$settings,\%allanswers,\%allchoices,\@allids); + } elsif ($cms eq 'bb6') { + &parse_bb6_assessment($res,$docroot,$container,$settings,\%allanswers,\%allchoices,\@allids); + } elsif ($cms eq 'webct4') { + unless($$dbparse) { + &parse_webct4_questionDB($docroot,\%catinfo,\%qzdbsettings,\%alldbanswers,\%alldbchoices,\@alldbquestids); + if (!-e "$destdir/sequences") { + mkdir("$destdir/sequences",0755); + } + my $numcats = keys %catinfo; + my $curr_id = 0; + my $next_id = 1; + my $fh; + open($fh,">$destdir/sequences/question_database.sequence"); + push @{$sequencesfiles},'question_database.sequence'; + foreach my $category (sort keys %catinfo) { + my $seqname = $catinfo{$category}{title}.'_'.$category; + $seqname =~ s/\s/_/g; + $seqname =~ s/\W//g; + push(@{$sequencesfiles},$seqname.'.sequence'); + my $catsrc = "$destresdir/sequences/$seqname.sequence"; + if ($curr_id == 0) { + print $fh qq||; + } + if ($numcats == 1) { + print $fh qq| + +\n|; + } else { + $curr_id = $next_id; + $next_id = $curr_id + 1; + $catsrc = "$destresdir/sequences/$seqname.sequence"; + print $fh qq| + +\n|; + } else { + print $fh qq|>\n|; + } + } + print $fh qq||; + if (!-e "$destdir/problems") { + mkdir("$destdir/problems",0755); + } + if (!-e "$destdir/problems/$seqname") { + mkdir("$destdir/problems/$seqname",0755); + } + my $newdir = "$destdir/problems/$seqname"; + my $dbcontainerdir; + &build_problem_container($seqname,$newdir,$destdir,'database',$seqname,$total,$sequencesfiles,$pagesfiles,$randompickflag,$context,\@{$catinfo{$category}{contents}},$udom,$uname,$dirname,\$dbcontainerdir,\$newdir,$cid,$cdom,$cnum); + } + close($fh); + &write_webct4_questions(\@alldbquestids,$context,$settings,$dirname,\%alldbanswers,\%alldbchoices,$total,$cid,$cdom,$cnum); + $$dbparse = 1; + } + &parse_webct4_quizprops($res,$docroot,$container,\%qzparams); + foreach (sort keys %qzparams) { + if (exists($qzparams{$res}{numpick})) { + if ($qzparams{$res}{numpick} < @allids) { + $$randompicks{$res} = $qzparams{$res}{numpick}; + $randompickflag = 1; + } + } + } + &parse_webct4_assessment($res,$docroot,$container,\@allids); + } my $dirtitle = $$settings{'title'}; $dirtitle =~ s/\W//g; $dirtitle .= '_'.$res; @@ -1710,60 +2257,65 @@ sub process_assessment { mkdir("$destdir/problems/$dirtitle",0755); } my $newdir = "$destdir/problems/$dirtitle"; + + &build_problem_container($dirtitle,$newdir,$destdir,$container,$res,$total,$sequencesfiles,$pagesfiles,$randompickflag,$context,\@allids,$udom,$uname,$dirname,\$containerdir,\$newdir,$cid,$cdom,$cnum); + if ($cms eq 'bb5') { + &write_bb5_questions(\@allids,$containerdir,$context,$settings,$dirname,$res,\%allanswers,\%allchoices,$total,$newdir,$cid,$cdom,$cnum); + } elsif ($cms eq 'bb6') { + &write_bb6_questions(\@allids,$containerdir,$context,$settings,$dirname,$res,\%allanswers,\%allchoices,$total,$newdir,$cid,$cdom,$cnum); + } +} + +sub build_problem_container { + my ($dirtitle,$newdir,$destdir,$container,$res,$total,$sequencesfiles,$pagesfiles,$randompickflag,$context,$allids,$udom,$uname,$dirname,$containerdir,$newdir,$cid,$cdom,$cnum) = @_; my $seqdir = "$destdir/sequences"; my $pagedir = "$destdir/pages"; my $curr_id = 0; my $next_id = 1; my $fh; - my $containerdir; - if ($container eq 'pool') { - $containerdir = $seqdir.'/'.$res.'.sequence'; + if ($container eq 'pool' || $randompickflag || $container eq 'database') { + $$containerdir = $seqdir.'/'.$res.'.sequence'; if (!-e "$seqdir") { mkdir("$seqdir",0770); } - open($fh,">$containerdir"); + open($fh,">$$containerdir"); $$total{seq} ++; push @{$sequencesfiles},$res.'.sequence'; } else { - $containerdir = $pagedir.'/'.$res.'.page'; + $$containerdir = $pagedir.'/'.$res.'.page'; if (!-e "$destdir/pages") { mkdir("$destdir/pages",0770); } - open($fh,">$containerdir"); + open($fh,">$$containerdir"); $$total{page} ++; push @{$pagesfiles},$res.'.page'; } print $fh qq| |; my $probsrc = "/res/lib/templates/simpleproblem.problem"; - my ($cid,$cdom,$cnum); - if ($context eq 'DOCS') { - $cid = $ENV{'request.course.id'}; - ($cdom,$cnum) = split/_/,$cid; - } if ($context eq 'CSTR') { - $probsrc="/res/$udom/$uname/$dirname/problems/$dirtitle/$allids[0].problem"; + $probsrc="/res/$udom/$uname/$dirname/problems/$dirtitle/$$allids[0].problem"; } print $fh qq||; - if (@allids == 1) { + if (@{$allids} == 1) { print $fh qq| \n|; } else { - for (my $j=1; $j<@allids; $j++) { - my $qntitle = $j; + for (my $j=1; $j<@{$allids}; $j++) { + my $qntitle = $j+1; while (length($qntitle) <4) { $qntitle = '0'.$qntitle; } $curr_id = $j; $next_id = $curr_id + 1; if ($context eq 'CSTR') { - $probsrc = "/res/$udom/$uname/$dirname/problems/$dirtitle/$allids[$j].problem"; + $probsrc = "/res/$udom/$uname/$dirname/problems/$dirtitle/$$allids[$j].problem"; } print $fh qq| \n|; } else { print $fh qq|>|; @@ -1772,8 +2324,12 @@ sub process_assessment { } print $fh qq||; close($fh); +} + +sub write_bb5_questions { + my ($allids,$containerdir,$context,$settings,$dirname,$res,$allanswers,$allchoices,$total,$newdir,$cid,$cdom,$cnum) = @_; my $qnum = 0; - foreach my $id (@allids) { + foreach my $id (@{$allids}) { $qnum ++; my $output; my $permcontainer = $containerdir; @@ -1785,7 +2341,7 @@ sub process_assessment { $resourcedata{$symb.'text'.$iter} = ""; $resourcedata{$symb.'value'.$iter} = "unused"; $resourcedata{$symb.'position'.$iter} = "random"; - } + } $resourcedata{$symb.'randomize'} = 'yes'; $resourcedata{$symb.'maxfoils'} = 10; if ($context eq 'CSTR') { @@ -1800,7 +2356,7 @@ sub process_assessment { - $$settings{$id}{feedbackcorr} + $$settings{$id}{feedbackcorr} |; } else { @@ -1832,7 +2388,7 @@ sub process_assessment { $resourcedata{$symb.'questiontext'} .= $image.$imglink.$url; } if ($$settings{$id}{class} eq 'QUESTION_MULTIPLECHOICE') { - my $numfoils = @{$allanswers{$id}}; + my $numfoils = @{$$allanswers{$id}}; if ($context eq 'CSTR') { $output .= qq| @@ -1843,30 +2399,30 @@ sub process_assessment { $resourcedata{$symb.'questiontype'} = 'radio'; $resourcedata{$symb.'maxfoils'} = $numfoils; } - for (my $k=0; $k<@{$allanswers{$id}}; $k++) { + for (my $k=0; $k<@{$$allanswers{$id}}; $k++) { my $iter = $k+1; $output .= "
|; + if ( defined($$settings{$id}{$$allanswers{$id}[$k]}{image}) ) { + if ( $$settings{$id}{$$allanswers{$id}[$k]}{style} eq 'embed' ) { + $ans_image .= qq|

|; } else { - $ans_link .= qq|
Link to file
|; + $ans_link .= qq|
Link to file
|; } } $output .= $ans_image.$ans_link.'
'."\n"; @@ -1880,7 +2436,7 @@ sub process_assessment { |; } } elsif ($$settings{$id}{class} eq 'QUESTION_TRUEFALSE') { - my $numfoils = @{$allanswers{$id}}; + my $numfoils = @{$$allanswers{$id}}; if ($context eq 'CSTR') { $output .= qq| @@ -1891,18 +2447,18 @@ sub process_assessment { $resourcedata{$symb.'hiddenparts'} = '!radio'; $resourcedata{$symb.'questiontype'} = 'radio'; } - for (my $k=0; $k<@{$allanswers{$id}}; $k++) { + for (my $k=0; $k<@{$$allanswers{$id}}; $k++) { my $iter = $k+1; $output .= " \n"; - $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$allanswers{$id}[$k]}{text}; + $output .= "\>".$$settings{$id}{$$allanswers{$id}[$k]}{text}."\n"; + $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$$allanswers{$id}[$k]}{text}; } if ($context eq 'CSTR') { chomp($output); @@ -1912,7 +2468,7 @@ sub process_assessment { |; } } elsif ($$settings{$id}{class} eq 'QUESTION_MULTIPLEANSWER') { - my $numfoils = @{$allanswers{$id}}; + my $numfoils = @{$$allanswers{$id}}; if ($context eq 'CSTR') { $output .= qq| @@ -1926,18 +2482,18 @@ sub process_assessment { $resourcedata{$symb.'questiontype'} = 'option'; $resourcedata{$symb.'maxfoils'} = $numfoils; } - for (my $k=0; $k<@{$allanswers{$id}}; $k++) { + for (my $k=0; $k<@{$$allanswers{$id}}; $k++) { my $iter = $k+1; $output .= " \n"; - $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$allanswers{$id}[$k]}{text}; + $output .= "\>".$$settings{$id}{$$allanswers{$id}[$k]}{text}."\n"; + $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$$allanswers{$id}[$k]}{text}; } if ($context eq 'CSTR') { chomp($output); @@ -1947,7 +2503,7 @@ sub process_assessment { |; } } elsif ($$settings{$id}{class} eq 'QUESTION_ORDER') { - my $numfoils = @{$allanswers{$id}}; + my $numfoils = @{$$allanswers{$id}}; my @allorder = (); if ($context eq 'CSTR') { $output .= qq| @@ -1961,14 +2517,14 @@ sub process_assessment { $resourcedata{$symb.'questiontype'} = 'option'; $resourcedata{$symb.'maxfoils'} = $numfoils; } - for (my $k=0; $k<@{$allanswers{$id}}; $k++) { + for (my $k=0; $k<@{$$allanswers{$id}}; $k++) { if ($context eq 'CSTR') { - $output .= " ".$$settings{$id}{$allanswers{$id}[$k]}{text}."\n"; + $output .= " ".$$settings{$id}{$$allanswers{$id}[$k]}{text}."\n"; } else { my $iter = $k+1; - $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$allanswers{$id}[$k]}{text}; - if (!grep/^$$settings{$id}{$allanswers{$id}[$k]}{order}$/,@allorder) { - push @allorder, $$settings{$id}{$allanswers{$id}[$k]}{order}; + $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$$allanswers{$id}[$k]}{text}; + if (!grep/^$$settings{$id}{$$allanswers{$id}[$k]}{order}$/,@allorder) { + push @allorder, $$settings{$id}{$$allanswers{$id}[$k]}{order}; } } } @@ -1987,8 +2543,8 @@ sub process_assessment { if ($context eq 'DOCS') { $numerical = 0; } else { - for (my $k=0; $k<@{$allanswers{$id}}; $k++) { - if ($$settings{$id}{$allanswers{$id}[$k]}{text} =~ m/([^\d\.]|\.\.)/) { + for (my $k=0; $k<@{$$allanswers{$id}}; $k++) { + if ($$settings{$id}{$$allanswers{$id}[$k]}{text} =~ m/([^\d\.]|\.\.)/) { $numerical = 0; } } @@ -1996,18 +2552,18 @@ sub process_assessment { if ($numerical) { my $numans; my $tol; - if (@{$allanswers{$id}} == 1) { + if (@{$$allanswers{$id}} == 1) { $tol = 5; - $numans = $$settings{$id}{$allanswers{$id}[0]}{text}; + $numans = $$settings{$id}{$$allanswers{$id}[0]}{text}; } else { - my $min = $$settings{$id}{$allanswers{$id}[0]}{text}; - my $max = $$settings{$id}{$allanswers{$id}[0]}{text}; - for (my $k=1; $k<@{$allanswers{$id}}; $k++) { - if ($$settings{$id}{$allanswers{$id}[$k]}{text} <= $min) { - $min = $$settings{$id}{$allanswers{$id}[$k]}{text}; + my $min = $$settings{$id}{$$allanswers{$id}[0]}{text}; + my $max = $$settings{$id}{$$allanswers{$id}[0]}{text}; + for (my $k=1; $k<@{$$allanswers{$id}}; $k++) { + if ($$settings{$id}{$$allanswers{$id}[$k]}{text} <= $min) { + $min = $$settings{$id}{$$allanswers{$id}[$k]}{text}; } - if ($$settings{$id}{$allanswers{$id}[$k]}{text} >= $max) { - $max = $$settings{$id}{$allanswers{$id}[$k]}{text}; + if ($$settings{$id}{$$allanswers{$id}[$k]}{text} >= $max) { + $max = $$settings{$id}{$$allanswers{$id}[$k]}{text}; } } $numans = ($max + $min)/2; @@ -2027,23 +2583,23 @@ sub process_assessment { if ($context eq 'DOCS') { $resourcedata{$symb.'hiddenparts'} = '!string'; $resourcedata{$symb.'questiontype'} = 'string'; - $resourcedata{$symb.'maxfoils'} = @{$allanswers{$id}}; + $resourcedata{$symb.'maxfoils'} = @{$$allanswers{$id}}; $resourcedata{$symb.'hiddenparts'} = '!string'; $resourcedata{$symb.'stringtype'} = 'ci'; - $resourcedata{$symb.'stringanswer'} = $$settings{$id}{$allanswers{$id}[0]}{text}; + $resourcedata{$symb.'stringanswer'} = $$settings{$id}{$$allanswers{$id}[0]}{text}; } else { - if (@{$allanswers{$id}} == 1) { + 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}; + 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/'; @@ -2070,19 +2626,19 @@ sub process_assessment { $resourcedata{$symb.'delopt'} = ''; $resourcedata{$symb.'hiddenparts'} = '!option'; $resourcedata{$symb.'questiontype'} = 'option'; - $resourcedata{$symb.'maxfoils'} = @{$allanswers{$id}}; + $resourcedata{$symb.'maxfoils'} = @{$$allanswers{$id}}; } - for (my $k=0; $k<@{$allchoices{$id}}; $k++) { + for (my $k=0; $k<@{$$allchoices{$id}}; $k++) { if ($context eq 'CSTR') { $output .= qq| - -$$settings{$id}{$allchoices{$id}[$k]}{text} + +$$settings{$id}{$$allchoices{$id}[$k]}{text} |; } else { - if (!grep/^$$settings{$id}{$allchoices{$id}[$k]}{text}$/,@allmatchers) { - push @allmatchers, $$settings{$id}{$allchoices{$id}[$k]}{text}; - $matchtext{$allchoices{$id}[$k]} = $$settings{$id}{$allchoices{$id}[$k]}{text}; + if (!grep/^$$settings{$id}{$$allchoices{$id}[$k]}{text}$/,@allmatchers) { + push @allmatchers, $$settings{$id}{$$allchoices{$id}[$k]}{text}; + $matchtext{$$allchoices{$id}[$k]} = $$settings{$id}{$$allchoices{$id}[$k]}{text}; } } } @@ -2091,17 +2647,17 @@ sub process_assessment { |; } - for (my $k=0; $k<@{$allanswers{$id}}; $k++) { + for (my $k=0; $k<@{$$allanswers{$id}}; $k++) { if ($context eq 'CSTR') { $output .= qq| - - $$settings{$id}{$allanswers{$id}[$k]}{text} + + $$settings{$id}{$$allanswers{$id}[$k]}{text} |; } else { my $iter = $k+1; - $resourcedata{$symb.'value'.$iter} = $matchtext{$$settings{$id}{$allanswers{$id}[$k]}{choice_id}}; - $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$allanswers{$id}[$k]}{text}; + $resourcedata{$symb.'value'.$iter} = $matchtext{$$settings{$id}{$$allanswers{$id}[$k]}{choice_id}}; + $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$$allanswers{$id}[$k]}{text}; } } if ($context eq 'CSTR') { @@ -2128,6 +2684,14 @@ sub process_assessment { } } +sub write_webct4_questions { + my ($alldbquestids,$context,$settings,$dirname,$alldbanswers,$alldbchoices,$total,$cid,$cdom,$cnum) = @_; +} + +sub write_bb6_questions { + my ($allids,$containerdir,$context,$settings,$dirname,$res,$allanswers,$allchoices) = @_; +} + # ---------------------------------------------------------------- Process Blackboard Announcements sub process_announce { my ($res,$docroot,$destdir,$settings,$globalresref,$seqstem,$resrcfiles) = @_; @@ -2222,8 +2786,7 @@ sub process_content { my $xmlfile = $docroot.'/'.$res.".dat"; my $destresdir = $destdir; if ($context eq 'CSTR') { -# $destresdir =~ s|/home/$user/public_html/|/res/$dom/$user/|; - $destresdir =~ s|/home/$user/public_html/|/priv/$user/|; + $destresdir =~ s|/home/$user/public_html/|/res/$dom/$user/|; } elsif ($context eq 'DOCS') { $destresdir =~ s|^/home/httpd/html/userfiles|/uploaded|; } @@ -2643,5 +3206,39 @@ sub angel_content { close(FILE); } +# ---------------------------------------------------------------- WebCT content +sub webct4_content { + my ($res,$docroot,$destdir,$settings,$dom,$user,$type,$title,$resrcfiles) = @_; + if (!open(FILE,">$destdir/resfiles/$res.html")) { + &Apache::lonnet::logthis("IMS import error: Cannot open file - $destdir/resfiles/$res.html - $!"); + } else { + push(@{$resrcfiles}, "$res.html"); + my $linktag = ''; + if (defined($$settings{url})) { + $linktag = qq|$title|; + } else { + $linktag .= qq|>$$settings{url}|; + } + } + print FILE qq| + +$title + + +$linktag + +|; + close(FILE); + } +} + +# ---------------------------------------------------------------- WebCT assessments +sub webct4_assessment { + my ($res,$docroot,$destdir,$settings,$dom,$user,$type,$title,$resrcfiles) = @_; + print STDERR "webct assessment detected - $res, $docroot, $destdir, $type,$title\n"; +} + 1; __END__