Diff for /loncom/imspackages/imsprocessor.pm between versions 1.10 and 1.11

version 1.10, 2004/08/05 23:21:49 version 1.11, 2004/12/13 20:01:09
Line 41  sub ims_config { Line 41  sub ims_config {
                 survey => 'assessment/x-bb-survey',                  survey => 'assessment/x-bb-survey',
                 users => 'course/x-bb-user',                  users => 'course/x-bb-user',
                 );                  );
   
     %{$$cmsmap{bb6}} =  %{$$cmsmap{bb5}};      %{$$cmsmap{bb6}} =  %{$$cmsmap{bb5}};
     $$cmsmap{bb6}{conference} = 'resource/x-bb-conference';      $$cmsmap{bb6}{conference} = 'resource/x-bb-conference';
    
     %{$$cmsmap{angel}} =  (      %{$$cmsmap{angel}} =  (
                 board => 'BOARD',                  board => 'BOARD',
                 extlink => 'LINK',                  extlink => 'LINK',
Line 52  sub ims_config { Line 50  sub ims_config {
                 quiz => 'QUIZ',                  quiz => 'QUIZ',
                 survey => 'FORM',                  survey => 'FORM',
                 );                  );
   
     @{$$cmsmap{angel}{doc}} = ('FILE','PAGE');      @{$$cmsmap{angel}{doc}} = ('FILE','PAGE');
   
   
     %{$areaname} = (      %{$areaname} = (
                 announce => 'Announcements',                  announce => 'Announcements',
                 board => 'Discussion Boards',                  board => 'Discussion Boards',
Line 67  sub ims_config { Line 62  sub ims_config {
                 survey => 'Surveys',                  survey => 'Surveys',
                 users => 'Enrollment',                  users => 'Enrollment',
                 );                  );
            
 }  }
     
 sub create_tempdir {  sub create_tempdir {
Line 173  sub process_manifest { Line 167  sub process_manifest {
         $$resources{'toplevel'}{type} = 'resource/x-bb-document';          $$resources{'toplevel'}{type} = 'resource/x-bb-document';
     }      }
   
   
     unless (-e "$tempdir/imsmanifest.xml") {      unless (-e "$tempdir/imsmanifest.xml") {
         return 'nomanifest';          return 'nomanifest';
     }       } 
Line 259  sub process_manifest { Line 252  sub process_manifest {
                     }                      }
                 } elsif ("@state" eq "manifest resources resource" ) {                  } elsif ("@state" eq "manifest resources resource" ) {
                     $identifier = $attr->{identifier};                      $identifier = $attr->{identifier};
                     if ($cms eq 'bb5' || $cms eq 'bb6') {                                       if ($cms eq 'bb5' || $cms eq 'bb6') {
                         $$resources{$identifier}{file} = $attr->{file};                          $$resources{$identifier}{file} = $attr->{file};
                         $$resources{$identifier}{type} = $attr->{type};                          $$resources{$identifier}{type} = $attr->{type};
                     } elsif ($cms eq 'angel') {                      } elsif ($cms eq 'angel') {
                         $identifier = substr($identifier,3);                          $identifier = substr($identifier,3);
                         if ($attr->{href} =~ m-^_assoc/$identifier/(.+)$-) {                          if ($attr->{href} =~ m-^_assoc/$identifier/(.+)$-) {
                             $$resources{$identifier}{file} = $1;                              $$resources{$identifier}{file} = $1;
                         }                                              }
                     }                      }
                     @{$$hrefs{$identifier}} = ();                      @{$$hrefs{$identifier}} = ();
                 } elsif ("@state" eq "manifest resources resource file") {                  } elsif ("@state" eq "manifest resources resource file") {
Line 277  sub process_manifest { Line 270  sub process_manifest {
                             push @{$$hrefs{$identifier}},$1;                              push @{$$hrefs{$identifier}},$1;
                         } elsif ($attr->{href} =~ m/^Icons\\icon(\w+)\.gif/) {                          } elsif ($attr->{href} =~ m/^Icons\\icon(\w+)\.gif/) {
                             $$resources{$identifier}{type} = $1;                              $$resources{$identifier}{type} = $1;
                         }                           }
                     }                      }
                 }                  }
            }, "tagname, attr"],             }, "tagname, attr"],
Line 401  sub process_coursefile { Line 394  sub process_coursefile {
 }  }
   
 sub process_resinfo {  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_id = time;
     my $board_count = 0;      my $board_count = 0;
     my $announce_handling = 'include';      my $announce_handling = 'include';
Line 461  sub process_resinfo { Line 454  sub process_resinfo {
                 }                  }
             } elsif ($$resources{$key}{type} eq "assessment/x-bb-pool") {              } elsif ($$resources{$key}{type} eq "assessment/x-bb-pool") {
                 %{$$resinfo{$key}} = ();                  %{$$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") {              } elsif ($$resources{$key}{type} eq "assessment/x-bb-quiz") {
                 %{$$resinfo{$key}} = ();                  %{$$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;                  push @{$quizzes}, $key;
             } elsif ($$resources{$key}{type} eq "assessment/x-bb-survey") {              } elsif ($$resources{$key}{type} eq "assessment/x-bb-survey") {
                 %{$$resinfo{$key}} = ();                  %{$$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;                  push @{$surveys}, $key;
             } elsif ($$resources{$key}{type} eq "assessment/x-bb-group") {              } elsif ($$resources{$key}{type} eq "assessment/x-bb-group") {
                 %{$$resinfo{$key}} = ();                  %{$$resinfo{$key}} = ();
Line 1511  sub addposting { Line 1504  sub addposting {
 }  }
 # ---------------------------------------------------------------- Process Blackboard Assessments - pools, quizzes, surveys  # ---------------------------------------------------------------- Process Blackboard Assessments - pools, quizzes, surveys
 sub process_assessment {  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";      my $xmlfile = $docroot.'/'.$res.".dat";
 #  print "XML file is $xmlfile\n";  #  print "XML file is $xmlfile\n";
     my @state = ();      my @state = ();
Line 1567  sub process_assessment { Line 1560  sub process_assessment {
         }              }    
         if ("@state" eq "$toptag{$container} QUESTIONLIST QUESTION") {            if ("@state" eq "$toptag{$container} QUESTIONLIST QUESTION") {  
             $id = $attr->{id};              $id = $attr->{id};
             unless ($container eq 'pool') {              push @allids, $id;
                 push @allids, $id;  
             }  
             %{$$settings{$id}} = ();              %{$$settings{$id}} = ();
             @{$allanswers{$id}} = ();              @{$allanswers{$id}} = ();
             $$settings{$id}{class} = $attr->{class};              $$settings{$id}{class} = $attr->{class};
Line 1669  sub process_assessment { Line 1660  sub process_assessment {
     my $dirtitle = $$settings{'title'};      my $dirtitle = $$settings{'title'};
     $dirtitle =~ s/\W//g;      $dirtitle =~ s/\W//g;
     $dirtitle .= '_'.$res;      $dirtitle .= '_'.$res;
       if (!-e "$destdir/problems") {
           mkdir("$destdir/problems",0755);
       }
     if (!-e "$destdir/problems/$dirtitle") {      if (!-e "$destdir/problems/$dirtitle") {
         mkdir("$destdir/problems/$dirtitle",0755);          mkdir("$destdir/problems/$dirtitle",0755);
     }      }
     my $newdir = "$destdir/problems/$dirtitle";      my $newdir = "$destdir/problems/$dirtitle";
       my $seqdir = "$destdir/sequences";
     my $pagedir = "$destdir/pages";      my $pagedir = "$destdir/pages";
     my $curr_id = 0;      my $curr_id = 0;
     my $next_id = 1;      my $next_id = 1;
     unless ($container eq 'pool') {      my $fh;
         open(PAGEFILE,">$pagedir/$res.page");      my $containerdir;
         print PAGEFILE qq|<map>      if ($container eq 'pool') {
           $containerdir = $seqdir.'/'.$res.'.sequence';
           if (!-e "$seqdir") {
               mkdir("$seqdir",0770);
           }
           open($fh,">$containerdir");
           $$total{seq} ++;
           push @{$sequencesfiles},$res.'.sequence';
       } else {
           $containerdir = $pagedir.'/'.$res.'.page';
           if (!-e "$destdir/pages") {
               mkdir("$destdir/pages",0770);
           }
           open($fh,">$containerdir");
           $$total{page} ++;
           push @{$pagesfiles},$res.'.page';
       }
       print $fh qq|<map>
 |;  |;
         $$total{page} ++;       my $probsrc="/res/$udom/$uname/$resdir/problems/$dirtitle/$allids[0].problem";
         print PAGEFILE qq|<resource id="1" src="/res/$udom/$uname/$resdir/problems/$dirtitle/$allids[0].problem" type="start"></resource>|;      print $fh qq|<resource id="1" src="$probsrc" type="start" title="question_0001"></resource>|;
         if (@allids == 1) {      if (@allids == 1) {
             print PAGEFILE qq|          print $fh qq|
 <link from="1" to="2" index="1"></link>  <link from="1" to="2" index="1"></link>
 <resource id="2" src="" type="finish">\n|;  <resource id="2" src="" type="finish">\n|;
         } else {      } else {
             for (my $j=1; $j<@allids; $j++) {          for (my $j=1; $j<@allids; $j++) {
                 $curr_id = $j;              my $qntitle = $j;
                 $next_id = $curr_id + 1;              while (length($qntitle) <4) {
                 print PAGEFILE qq|                  $qntitle = '0'.$qntitle;
               }
               $curr_id = $j;
               $next_id = $curr_id + 1;
               if ($context eq 'CSTR') {
                   $probsrc = "/res/$udom/$uname/$resdir/problems/$dirtitle/$allids[$j].problem";
               }
               print $fh qq|
 <link from="$curr_id" to="$next_id" index="$curr_id"></link>  <link from="$curr_id" to="$next_id" index="$curr_id"></link>
 <resource id="$next_id" src="/res/$udom/$uname/$resdir/problems/$dirtitle/$allids[$j].problem"|;  <resource id="$next_id" src="$probsrc" title="question_$qntitle"|;
                 if ($next_id == @allids) {              if ($next_id == @allids) {
                     print PAGEFILE qq| type="finish"></resource>\n|;                  print $fh qq| type="finish"></resource>\n|;
                 } else {              } else {
                     print PAGEFILE qq|></resource>|;                  print $fh qq|></resource>|;
                 }  
             }              }
         }          }
         print PAGEFILE qq|</map>|;  
         close(PAGEFILE);  
     }      }
       print $fh qq|</map>|;
       close($fh);
     foreach my $id (@allids) {      foreach my $id (@allids) {
         my $output = qq|<problem>          my $output;
           if ($context eq 'CSTR') {
               $output = qq|<problem>
 |;  |;
           }
         $$total{prob} ++;          $$total{prob} ++;
         if ($$settings{$id}{class} eq "QUESTION_ESSAY") {          if ($$settings{$id}{class} eq "QUESTION_ESSAY") {
             $output .= qq|<startouttext />$$settings{$id}{text}<endouttext />              if ($context eq 'CSTR') {
                   $output .= qq|<startouttext />$$settings{$id}{text}<endouttext />
  <essayresponse>   <essayresponse>
  <textfield></textfield>   <textfield></textfield>
  </essayresponse>   </essayresponse>
Line 1716  sub process_assessment { Line 1738  sub process_assessment {
  $$settings{$id}{feedbackcorr}   $$settings{$id}{feedbackcorr}
  </postanswerdate>   </postanswerdate>
 |;  |;
                }
         } else {          } else {
             $output .= qq|<startouttext />$$settings{$id}{text}\n|;              if ($context eq 'CSTR') {
             if ( defined($$settings{$id}{image}) ) {                   $output .= qq|<startouttext />$$settings{$id}{text}\n|;
               }
               my ($image,$imglink,$url);
               if ( defined($$settings{$id}{image}) ) {
                 if ( $$settings{$id}{style} eq 'embed' ) {                  if ( $$settings{$id}{style} eq 'embed' ) {
                     $output .= qq|<br /><img src="$dirname/resfiles/$res/$$settings{$id}{image}" /><br />|;                      $image = qq|<br /><img src="$dirname/resfiles/$res/$$settings{$id}{image}" /><br />|;
                 } else {                  } else {
                     $output .= qq|<br /><a href="$dirname/resfiles/$res/$$settings{$id}{image}">Link to file</a><br />|;                      $imglink = qq|<br /><a href="$dirname/resfiles/$res/$$settings{$id}{image}">Link to file</a><br />|;
                 }                  }
             }              }
             if ( defined($$settings{$id}{url}) ) {              if ( defined($$settings{$id}{url}) ) {
                 $output .= qq|<br /><a href="$$settings{$id}{url}">$$settings{$id}{name}</a><br />|;                  $url = qq|<br /><a href="$$settings{$id}{url}">$$settings{$id}{name}</a><br />|;
               }
               if ($context eq 'CSTR') {
                   $output .= $image.$imglink.$url.'
   <endouttext />';
             }              }
             $output .= qq|  
 <endouttext />|;  
             if ($$settings{$id}{class} eq 'QUESTION_MULTIPLECHOICE') {              if ($$settings{$id}{class} eq 'QUESTION_MULTIPLECHOICE') {
                 my $numfoils = @{$allanswers{$id}};                  my $numfoils = @{$allanswers{$id}};
                 $output .= qq|                  if ($context eq 'CSTR') {
                       $output .= qq|
  <radiobuttonresponse max="$numfoils" randomize="yes">   <radiobuttonresponse max="$numfoils" randomize="yes">
   <foilgroup>    <foilgroup>
 |;  |;
                   }
                 for (my $k=0; $k<@{$allanswers{$id}}; $k++) {                  for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
                     $output .= "   <foil name=\"foil".$k."\" value=\"";                      $output .= "   <foil name=\"foil".$k."\" value=\"";
                     if (grep/^$allanswers{$id}[$k]$/,@{$$settings{$id}{correctanswer}}) {                      if (grep/^$allanswers{$id}[$k]$/,@{$$settings{$id}{correctanswer}}) {
Line 1749  sub process_assessment { Line 1779  sub process_assessment {
                         $output .= "random\"";                          $output .= "random\"";
                     }                      }
                     $output .= "\><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text};                      $output .= "\><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text};
                       my ($ans_image,$ans_link);
                     if ( defined($$settings{$id}{$allanswers{$id}[$k]}{image}) ) {                      if ( defined($$settings{$id}{$allanswers{$id}[$k]}{image}) ) {
                         if ( $$settings{$id}{$allanswers{$id}[$k]}{style} eq 'embed' ) {                          if ( $$settings{$id}{$allanswers{$id}[$k]}{style} eq 'embed' ) {
                             $output .= qq|<br /><img src="$dirname/resfiles/$res/$$settings{$id}{$allanswers{$id}[$k]}{image}" /><br />|;                              $ans_image .= qq|<br /><img src="$dirname/resfiles/$res/$$settings{$id}{$allanswers{$id}[$k]}{image}" /><br />|;
                         } else {                          } else {
                             $output .= qq|<br /><a href="$dirname/resfiles/$res/$$settings{$id}{$allanswers{$id}[$k]}{image}" />Link to file</a><br/>|;                              $ans_link .= qq|<br /><a href="$dirname/resfiles/$res/$$settings{$id}{$allanswers{$id}[$k]}{image}" />Link to file</a><br/>|;
                         }                          }
                     }                      }
                     $output .= qq|<endouttext /></foil>\n|;                      $output .= $ans_image.$ans_link.'<endouttext /></foil>'."\n";
                 }                  }
                 chomp($output);                  if ($context eq 'CSTR') {
                 $output .= qq|                      chomp($output);
                       $output .= qq|
   </foilgroup>    </foilgroup>
  </radiobuttonresponse>   </radiobuttonresponse>
 |;  |;
                   }
             } elsif ($$settings{$id}{class} eq 'QUESTION_TRUEFALSE') {              } elsif ($$settings{$id}{class} eq 'QUESTION_TRUEFALSE') {
                 my $numfoils = @{$allanswers{$id}};                  my $numfoils = @{$allanswers{$id}};
                 $output .= qq|                  if ($context eq 'CSTR') {
                       $output .= qq|
    <radiobuttonresponse max="$numfoils" randomize="yes">     <radiobuttonresponse max="$numfoils" randomize="yes">
     <foilgroup>      <foilgroup>
 |;  |;
                   }
                 for (my $k=0; $k<@{$allanswers{$id}}; $k++) {                  for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
                     $output .= "   <foil name=\"foil".$k."\" value=\"";                      $output .= "   <foil name=\"foil".$k."\" value=\"";
                     if (grep/^$allanswers{$id}[$k]$/,@{$$settings{$id}{correctanswer}}) {                      if (grep/^$allanswers{$id}[$k]$/,@{$$settings{$id}{correctanswer}}) {
Line 1778  sub process_assessment { Line 1813  sub process_assessment {
                     }                      }
                     $output .= "\><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text}."<endouttext /></foil>\n";                      $output .= "\><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text}."<endouttext /></foil>\n";
                 }                  }
                 chomp($output);                  if ($context eq 'CSTR') {
                 $output .= qq|                      chomp($output);
                       $output .= qq|
     </foilgroup>      </foilgroup>
    </radiobuttonresponse>     </radiobuttonresponse>
 |;  |;
                   }
             } elsif ($$settings{$id}{class} eq 'QUESTION_MULTIPLEANSWER') {              } elsif ($$settings{$id}{class} eq 'QUESTION_MULTIPLEANSWER') {
                 my $numfoils = @{$allanswers{$id}};                  my $numfoils = @{$allanswers{$id}};
                 $output .= qq|                  if ($context eq 'CSTR') {
                       $output .= qq|
    <optionresponse max="$numfoils" randomize="yes">     <optionresponse max="$numfoils" randomize="yes">
     <foilgroup options="('True','False')">      <foilgroup options="('True','False')">
 |;  |;
                   }
                 for (my $k=0; $k<@{$allanswers{$id}}; $k++) {                  for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
                     $output .= "   <foil name=\"foil".$k."\" value=\"";                      $output .= "   <foil name=\"foil".$k."\" value=\"";
                     if (grep/^$allanswers{$id}[$k]$/,@{$$settings{$id}{correctanswer}}) {                      if (grep/^$allanswers{$id}[$k]$/,@{$$settings{$id}{correctanswer}}) {
Line 1798  sub process_assessment { Line 1837  sub process_assessment {
                     }                      }
                     $output .= "\><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text}."<endouttext /></foil>\n";                      $output .= "\><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text}."<endouttext /></foil>\n";
                 }                  }
                 chomp($output);                  if ($context eq 'CSTR') {  
                 $output .= qq|                      chomp($output);
                       $output .= qq|
     </foilgroup>      </foilgroup>
    </optionresponse>     </optionresponse>
 |;  |;
                   }
             } elsif ($$settings{$id}{class} eq 'QUESTION_ORDER') {              } elsif ($$settings{$id}{class} eq 'QUESTION_ORDER') {
                 my $numfoils = @{$allanswers{$id}};                  my $numfoils = @{$allanswers{$id}};
                 $output .= qq|                  if ($context eq 'CSTR') {
                       $output .= qq|
    <rankresponse max="$numfoils" randomize="yes">     <rankresponse max="$numfoils" randomize="yes">
     <foilgroup>      <foilgroup>
 |;  |;
                   }
                 for (my $k=0; $k<@{$allanswers{$id}}; $k++) {                  for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
                     $output .= "   <foil location=\"random\" name=\"foil".$k."\" value=\"".$$settings{$id}{$allanswers{$id}[$k]}{order}."\"><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text}."<endouttext /></foil>\n";                      if ($context eq 'CSTR') {
                           $output .= "   <foil location=\"random\" name=\"foil".$k."\" value=\"".$$settings{$id}{$allanswers{$id}[$k]}{order}."\"><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text}."<endouttext /></foil>\n";
                       }
                 }                  }
                 chomp($output);                  if ($context eq 'CSTR') {
                 $output .= qq|                      chomp($output);
                       $output .= qq|
     </foilgroup>      </foilgroup>
    </rankresponse>     </rankresponse>
 |;  |;
                   }
             } elsif ($$settings{$id}{class} eq 'QUESTION_FILLINBLANK') {              } elsif ($$settings{$id}{class} eq 'QUESTION_FILLINBLANK') {
                 my $numerical = 1;                  my $numerical = 1;
                 for (my $k=0; $k<@{$allanswers{$id}}; $k++) {                  if ($context eq 'DOCS') {
                     if ($$settings{$id}{$allanswers{$id}[$k]}{text} =~ m/([^\d\.]|\.\.)/) {                      $numerical = 0;
                         $numerical = 0;                  } else {
                       for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
                           if ($$settings{$id}{$allanswers{$id}[$k]}{text} =~ m/([^\d\.]|\.\.)/) {
                               $numerical = 0;
                           }
                     }                      }
                 }                  }
                 if ($numerical) {                  if ($numerical) {
Line 1844  sub process_assessment { Line 1895  sub process_assessment {
                         $numans = ($max + $min)/2;                          $numans = ($max + $min)/2;
                         $tol = 100*($max - $min)/($numans*2);                          $tol = 100*($max - $min)/($numans*2);
                     }                      }
                     $output .= qq|                      if ($context eq 'CSTR') {
                           $output .= qq|
 <numericalresponse answer="$numans">  <numericalresponse answer="$numans">
         <responseparam type="tolerance" default="$tol%" name="tol" description="Numerical Tolerance" />          <responseparam type="tolerance" default="$tol%" name="tol" description="Numerical Tolerance" />
         <responseparam name="sig" type="int_range,0-16" default="0,15" description="Significant Figures"          <responseparam name="sig" type="int_range,0-16" default="0,15" description="Significant Figures"
Line 1852  sub process_assessment { Line 1904  sub process_assessment {
         <textline />          <textline />
 </numericalresponse>  </numericalresponse>
 |;  |;
                       }
                 } else {                  } else {
                     if (@{$allanswers{$id}} == 1) {                      if ($context eq 'CSTR') {
                         $output .= qq|                          if (@{$allanswers{$id}} == 1) {
                               $output .= qq|
 <stringresponse answer="$$settings{$id}{$allanswers{$id}[0]}{text}" type="ci">  <stringresponse answer="$$settings{$id}{$allanswers{$id}[0]}{text}" type="ci">
 <textline>  <textline>
 </textline>  </textline>
 </stringresponse>  </stringresponse>
 |;  |;
                     } else {                          } else {
                         my @answertext = ();                              my @answertext = ();
                         for (my $k=0; $k<@{$allanswers{$id}}; $k++) {                              for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
                             $$settings{$id}{$allanswers{$id}[$k]}{text} =~ s/\|/\|/g;                                  $$settings{$id}{$allanswers{$id}[$k]}{text} =~ s/\|/\|/g;
                             push @answertext, $$settings{$id}{$allanswers{$id}[$k]}{text};                                  push @answertext, $$settings{$id}{$allanswers{$id}[$k]}{text};
                         }                              }
                         my $regexpans = join('|',@answertext);                              my $regexpans = join('|',@answertext);
                         $regexpans = '/^('.$regexpans.')\b/';                              $regexpans = '/^('.$regexpans.')\b/';
                         $output .= qq|                              $output .= qq|
 <stringresponse answer="$regexpans" type="re">  <stringresponse answer="$regexpans" type="re">
 <textline>  <textline>
 </textline>  </textline>
 </stringresponse>  </stringresponse>
 |;  |;
                     }                          }
                       } 
                 }                  }
             } elsif ($$settings{$id}{class} eq "QUESTION_MATCH") {              } elsif ($$settings{$id}{class} eq "QUESTION_MATCH") {
                 $output .= qq|                  if ($context eq 'CSTR') {
                       $output .= qq|
 <matchresponse max="10" randomize="yes">  <matchresponse max="10" randomize="yes">
     <foilgroup>      <foilgroup>
         <itemgroup>          <itemgroup>
 |;  |;
                   }
                 for (my $k=0; $k<@{$allchoices{$id}}; $k++) {                  for (my $k=0; $k<@{$allchoices{$id}}; $k++) {
                     $output .= qq|                      if ($context eq 'CSTR') {
                           $output .= qq|
 <item name="$allchoices{$id}[$k]">  <item name="$allchoices{$id}[$k]">
 <startouttext />$$settings{$id}{$allchoices{$id}[$k]}{text}<endouttext />  <startouttext />$$settings{$id}{$allchoices{$id}[$k]}{text}<endouttext />
 </item>  </item>
                     |;                      |;
                       }
                 }                  }
                 $output .= qq|                  if ($context eq 'CSTR') {
                       $output .= qq|
         </itemgroup>          </itemgroup>
 |;  |;
                   }
                 for (my $k=0; $k<@{$allanswers{$id}}; $k++) {                  for (my $k=0; $k<@{$allanswers{$id}}; $k++) {
                     $output .= qq|                      if ($context eq 'CSTR') {
                           $output .= qq|
         <foil location="random" value="$$settings{$id}{$allanswers{$id}[$k]}{choice_id}" name="$allanswers{$id}[$k]">          <foil location="random" value="$$settings{$id}{$allanswers{$id}[$k]}{choice_id}" name="$allanswers{$id}[$k]">
          <startouttext />$$settings{$id}{$allanswers{$id}[$k]}{text}<endouttext />           <startouttext />$$settings{$id}{$allanswers{$id}[$k]}{text}<endouttext />
         </foil>          </foil>
 |;  |;
                       }
                 }                  }
                 $output .= qq|                  if ($context eq 'CSTR') {
                       $output .= qq|
     </foilgroup>      </foilgroup>
 </matchresponse>  </matchresponse>
 |;  |;
                   }
             }              }
         }          }
         $output .= qq|</problem>          if ($context eq 'CSTR') {
               $output .= qq|</problem>
 |;  |;
         open(PROB,">$newdir/$id.problem");              open(PROB,">$newdir/$id.problem");
         print PROB $output;              print PROB $output;
         close PROB;              close PROB;
           }
     }      }
 }  }
   

Removed from v.1.10  
changed lines
  Added in v.1.11


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>