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

version 1.11, 2004/12/13 20:01:09 version 1.12, 2004/12/13 23:11:09
Line 491  sub process_resinfo { Line 491  sub process_resinfo {
         }          }
         if (@{$surveys}) {          if (@{$surveys}) {
             $$items{'Top'}{'contentscount'} ++;              $$items{'Top'}{'contentscount'} ++;
           
         }          }
     }      }
   
Line 680  sub build_structure { Line 679  sub build_structure {
         if (@{$surveys} > 0)  {          if (@{$surveys} > 0)  {
             &process_specials($context,'surveys',$surveys,\$topnum,$$items{'Top'}{contentscount},$destdir,$udom,$uname,$cdom,$crs,$timenow,$newdir,$timestamp,$resinfo,\$seqtext{'Top'},$pagesfiles,$seqfiles,$topurls,$topnames);              &process_specials($context,'surveys',$surveys,\$topnum,$$items{'Top'}{contentscount},$destdir,$udom,$uname,$cdom,$crs,$timenow,$newdir,$timestamp,$resinfo,\$seqtext{'Top'},$pagesfiles,$seqfiles,$topurls,$topnames);
         }          }
   
         $seqtext{'Top'} .= "</map>\n";          $seqtext{'Top'} .= "</map>\n";
         open(TOPFILE,">$destdir/sequences/Top.sequence");          open(TOPFILE,">$destdir/sequences/Top.sequence");
         print TOPFILE $seqtext{'Top'};          print TOPFILE $seqtext{'Top'};
Line 1692  sub process_assessment { Line 1690  sub process_assessment {
     }      }
     print $fh qq|<map>      print $fh qq|<map>
 |;  |;
     my $probsrc="/res/$udom/$uname/$resdir/problems/$dirtitle/$allids[0].problem";      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/$resdir/problems/$dirtitle/$allids[0].problem";
       }
     print $fh qq|<resource id="1" src="$probsrc" type="start" title="question_0001"></resource>|;      print $fh qq|<resource id="1" src="$probsrc" type="start" title="question_0001"></resource>|;
     if (@allids == 1) {      if (@allids == 1) {
         print $fh qq|          print $fh qq|
Line 1721  sub process_assessment { Line 1727  sub process_assessment {
     }      }
     print $fh qq|</map>|;      print $fh qq|</map>|;
     close($fh);      close($fh);
       my $qnum = 0;
     foreach my $id (@allids) {      foreach my $id (@allids) {
           $qnum ++;
         my $output;          my $output;
           my $permcontainer = $containerdir;
           $permcontainer =~ s#/home/httpd/html/userfiles#uploaded#;
           my $symb = $cid.'.'.$permcontainer.'___'.$qnum.'___lib/templates/simpleproblem.problem.0.';
           my %resourcedata = ();
           for (my $i=0; $i<10; $i++) {
               my $iter = $i+1;
               $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') {          if ($context eq 'CSTR') {
             $output = qq|<problem>              $output = qq|<problem>
 |;  |;
Line 1738  sub process_assessment { Line 1758  sub process_assessment {
  $$settings{$id}{feedbackcorr}   $$settings{$id}{feedbackcorr}
  </postanswerdate>   </postanswerdate>
 |;  |;
                } else {
    $resourcedata{$symb.'questiontext'} = $$settings{$id}{text};
                    $resourcedata{$symb.'hiddenparts'} = '!essay';
                    $resourcedata{$symb.'questiontype'} = 'essay';
              }               }
         } else {          } else {
             if ($context eq 'CSTR') {              if ($context eq 'CSTR') {
                 $output .= qq|<startouttext />$$settings{$id}{text}\n|;                  $output .= qq|<startouttext />$$settings{$id}{text}\n|;
               } else {
                   $resourcedata{$symb.'questiontext'} = $$settings{$id}{text};
             }              }
             my ($image,$imglink,$url);              my ($image,$imglink,$url);
             if ( defined($$settings{$id}{image}) ) {              if ( defined($$settings{$id}{image}) ) {
Line 1757  sub process_assessment { Line 1783  sub process_assessment {
             if ($context eq 'CSTR') {              if ($context eq 'CSTR') {
                 $output .= $image.$imglink.$url.'                  $output .= $image.$imglink.$url.'
 <endouttext />';  <endouttext />';
               } else {
                   $resourcedata{$symb.'questiontext'} .= $image.$imglink.$url;
             }              }
             if ($$settings{$id}{class} eq 'QUESTION_MULTIPLECHOICE') {              if ($$settings{$id}{class} eq 'QUESTION_MULTIPLECHOICE') {
                 my $numfoils = @{$allanswers{$id}};                  my $numfoils = @{$allanswers{$id}};
Line 1765  sub process_assessment { Line 1793  sub process_assessment {
  <radiobuttonresponse max="$numfoils" randomize="yes">   <radiobuttonresponse max="$numfoils" randomize="yes">
   <foilgroup>    <foilgroup>
 |;  |;
                   } else {
                       $resourcedata{$symb.'hiddenparts'} = '!radio';
                       $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 .= "   <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}}) {
                         $output .= "true\" location=\"";                          $output .= "true\" location=\"";
                           $resourcedata{$symb.'value'.$iter} = "true";
                     } else {                      } else {
                         $output .= "false\" location=\"";                          $output .= "false\" location=\"";
                           $resourcedata{$symb.'value'.$iter} = "false";
                     }                      }
                     if (lc ($allanswers{$id}[$k]) =~ m/^\s?([Aa]ll)|([Nn]one)\sof\sthe\sabove\.?/) {                      if (lc ($allanswers{$id}[$k]) =~ m/^\s?([Aa]ll)|([Nn]one)\sof\sthe\sabove\.?/) {
                         $output .= "bottom\"";                          $output .= "bottom\"";
                           $resourcedata{$symb.'position'.$iter} = "bottom";
                     } else {                      } else {
                         $output .= "random\"";                          $output .= "random\"";
                     }                      }
                     $output .= "\><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text};                      $output .= "\><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text};
                       $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$allanswers{$id}[$k]}{text};
                     my ($ans_image,$ans_link);                      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' ) {
Line 1788  sub process_assessment { Line 1825  sub process_assessment {
                         }                          }
                     }                      }
                     $output .= $ans_image.$ans_link.'<endouttext /></foil>'."\n";                      $output .= $ans_image.$ans_link.'<endouttext /></foil>'."\n";
                       $resourcedata{$symb.'text'.$iter} .= $ans_image.$ans_link;
                 }                  }
                 if ($context eq 'CSTR') {                  if ($context eq 'CSTR') {
                     chomp($output);                      chomp($output);
Line 1803  sub process_assessment { Line 1841  sub process_assessment {
    <radiobuttonresponse max="$numfoils" randomize="yes">     <radiobuttonresponse max="$numfoils" randomize="yes">
     <foilgroup>      <foilgroup>
 |;  |;
                   } else {
                       $resourcedata{$symb.'maxfoils'} = $numfoils;
                       $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 .= "   <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}}) {
                         $output .= "true\" location=\"random\"";                          $output .= "true\" location=\"random\"";
                           $resourcedata{$symb.'value'.$iter} = "true";
                     } else {                      } else {
                         $output .= "false\" location=\"random\"";                          $output .= "false\" location=\"random\"";
                           $resourcedata{$symb.'value'.$iter} = "false";
                     }                      }
                     $output .= "\><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text}."<endouttext /></foil>\n";                      $output .= "\><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text}."<endouttext /></foil>\n";
                       $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$allanswers{$id}[$k]}{text};
                 }                  }
                 if ($context eq 'CSTR') {                  if ($context eq 'CSTR') {
                     chomp($output);                      chomp($output);
Line 1827  sub process_assessment { Line 1873  sub process_assessment {
    <optionresponse max="$numfoils" randomize="yes">     <optionresponse max="$numfoils" randomize="yes">
     <foilgroup options="('True','False')">      <foilgroup options="('True','False')">
 |;  |;
                   } else {
                       $resourcedata{$symb.'newopt'} = '';
                       $resourcedata{$symb.'delopt'} = '';
                       $resourcedata{$symb.'options'} = "('True','False')";
                       $resourcedata{$symb.'hiddenparts'} = '!option';
                       $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 .= "   <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}}) {
                         $output .= "True\"";                          $output .= "True\"";
                           $resourcedata{$symb.'value'.$iter} = "True";
                     } else {                      } else {
                         $output .= "False\"";                          $output .= "False\"";
                           $resourcedata{$symb.'value'.$iter} = "False";
                     }                      }
                     $output .= "\><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text}."<endouttext /></foil>\n";                      $output .= "\><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text}."<endouttext /></foil>\n";
                       $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$allanswers{$id}[$k]}{text};
                 }                  }
                 if ($context eq 'CSTR') {                    if ($context eq 'CSTR') {  
                     chomp($output);                      chomp($output);
Line 1846  sub process_assessment { Line 1903  sub process_assessment {
                 }                  }
             } elsif ($$settings{$id}{class} eq 'QUESTION_ORDER') {              } elsif ($$settings{$id}{class} eq 'QUESTION_ORDER') {
                 my $numfoils = @{$allanswers{$id}};                  my $numfoils = @{$allanswers{$id}};
                   my @allorder = ();
                 if ($context eq 'CSTR') {                  if ($context eq 'CSTR') {
                     $output .= qq|                      $output .= qq|
    <rankresponse max="$numfoils" randomize="yes">     <rankresponse max="$numfoils" randomize="yes">
     <foilgroup>      <foilgroup>
 |;  |;
                   } else {
                       $resourcedata{$symb.'newopt'} = '';
                       $resourcedata{$symb.'delopt'} = '';
                       $resourcedata{$symb.'hiddenparts'} = '!option';
                       $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') {                      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";                          $output .= "   <foil location=\"random\" name=\"foil".$k."\" value=\"".$$settings{$id}{$allanswers{$id}[$k]}{order}."\"><startouttext />".$$settings{$id}{$allanswers{$id}[$k]}{text}."<endouttext /></foil>\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};
                           }
                     }                      }
                 }                  }
                 if ($context eq 'CSTR') {                  if ($context eq 'CSTR') {
Line 1863  sub process_assessment { Line 1933  sub process_assessment {
     </foilgroup>      </foilgroup>
    </rankresponse>     </rankresponse>
 |;  |;
                   } else {
                       print STDERR "order before is ".join(',',@allorder)."\n";
                       @allorder = sort {$a <=> $b} @allorder;
                       print STDERR "order after is ".join(',',@allorder)."\n"; 
                       $resourcedata{$symb.'options'} = "('".join("','",@allorder)."')";
                 }                  }
             } elsif ($$settings{$id}{class} eq 'QUESTION_FILLINBLANK') {              } elsif ($$settings{$id}{class} eq 'QUESTION_FILLINBLANK') {
                 my $numerical = 1;                  my $numerical = 1;
Line 1906  sub process_assessment { Line 1981  sub process_assessment {
 |;  |;
                     }                      }
                 } else {                  } else {
                     if ($context eq 'CSTR') {                      if ($context eq 'DOCS') {
                           $resourcedata{$symb.'hiddenparts'} = '!string';
                           $resourcedata{$symb.'questiontype'} = 'string';
                           $resourcedata{$symb.'maxfoils'} = @{$allanswers{$id}};
                           $resourcedata{$symb.'hiddenparts'} = '!string';
                           $resourcedata{$symb.'stringtype'} = 'ci';
                           $resourcedata{$symb.'stringanswer'} = $$settings{$id}{$allanswers{$id}[0]}{text};
                       } else {
                         if (@{$allanswers{$id}} == 1) {                          if (@{$allanswers{$id}} == 1) {
                             $output .= qq|                              $output .= qq|
 <stringresponse answer="$$settings{$id}{$allanswers{$id}[0]}{text}" type="ci">  <stringresponse answer="$$settings{$id}{$allanswers{$id}[0]}{text}" type="ci">
Line 1932  sub process_assessment { Line 2014  sub process_assessment {
                     }                       } 
                 }                  }
             } elsif ($$settings{$id}{class} eq "QUESTION_MATCH") {              } elsif ($$settings{$id}{class} eq "QUESTION_MATCH") {
                   my @allmatchers = ();
                   my %matchtext = ();
                 if ($context eq 'CSTR') {                  if ($context eq 'CSTR') {
                     $output .= qq|                      $output .= qq|
 <matchresponse max="10" randomize="yes">  <matchresponse max="10" randomize="yes">
     <foilgroup>      <foilgroup>
         <itemgroup>          <itemgroup>
 |;  |;
                   } else {
                       $resourcedata{$symb.'newopt'} = '';
                       $resourcedata{$symb.'delopt'} = '';
                       $resourcedata{$symb.'hiddenparts'} = '!option';
                       $resourcedata{$symb.'questiontype'} = 'option';
                       $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') {                      if ($context eq 'CSTR') {
Line 1946  sub process_assessment { Line 2036  sub process_assessment {
 <startouttext />$$settings{$id}{$allchoices{$id}[$k]}{text}<endouttext />  <startouttext />$$settings{$id}{$allchoices{$id}[$k]}{text}<endouttext />
 </item>  </item>
                     |;                      |;
                       } 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 ($context eq 'CSTR') {                  if ($context eq 'CSTR') {
Line 1960  sub process_assessment { Line 2055  sub process_assessment {
          <startouttext />$$settings{$id}{$allanswers{$id}[$k]}{text}<endouttext />           <startouttext />$$settings{$id}{$allanswers{$id}[$k]}{text}<endouttext />
         </foil>          </foil>
 |;  |;
                       } 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};
                     }                      }
                 }                  }
                 if ($context eq 'CSTR') {                  if ($context eq 'CSTR') {
Line 1967  sub process_assessment { Line 2066  sub process_assessment {
     </foilgroup>      </foilgroup>
 </matchresponse>  </matchresponse>
 |;  |;
                   } else {
                       $resourcedata{$symb.'options'} = "('".join("','",@allmatchers)."')";
                 }                  }
             }              }
         }          }
Line 1976  sub process_assessment { Line 2077  sub process_assessment {
             open(PROB,">$newdir/$id.problem");              open(PROB,">$newdir/$id.problem");
             print PROB $output;              print PROB $output;
             close PROB;              close PROB;
           } else {
   # put %resourcedata;
               my $reply=&Apache::lonnet::cput
                   ('resourcedata',\%resourcedata,$cdom,$cnum);
         }          }
     }      }
 }  }

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


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