--- loncom/imspackages/imsprocessor.pm 2004/12/13 20:01:09 1.11 +++ loncom/imspackages/imsprocessor.pm 2004/12/13 23:11:09 1.12 @@ -491,7 +491,6 @@ sub process_resinfo { } if (@{$surveys}) { $$items{'Top'}{'contentscount'} ++; - } } @@ -680,7 +679,6 @@ sub build_structure { 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); } - $seqtext{'Top'} .= "\n"; open(TOPFILE,">$destdir/sequences/Top.sequence"); print TOPFILE $seqtext{'Top'}; @@ -1692,7 +1690,15 @@ sub process_assessment { } print $fh qq| |; - 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||; if (@allids == 1) { print $fh qq| @@ -1721,8 +1727,22 @@ sub process_assessment { } print $fh qq||; close($fh); + my $qnum = 0; foreach my $id (@allids) { + $qnum ++; 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') { $output = qq| |; @@ -1738,10 +1758,16 @@ sub process_assessment { $$settings{$id}{feedbackcorr} |; + } else { + $resourcedata{$symb.'questiontext'} = $$settings{$id}{text}; + $resourcedata{$symb.'hiddenparts'} = '!essay'; + $resourcedata{$symb.'questiontype'} = 'essay'; } } else { if ($context eq 'CSTR') { $output .= qq|$$settings{$id}{text}\n|; + } else { + $resourcedata{$symb.'questiontext'} = $$settings{$id}{text}; } my ($image,$imglink,$url); if ( defined($$settings{$id}{image}) ) { @@ -1757,6 +1783,8 @@ sub process_assessment { if ($context eq 'CSTR') { $output .= $image.$imglink.$url.' '; + } else { + $resourcedata{$symb.'questiontext'} .= $image.$imglink.$url; } if ($$settings{$id}{class} eq 'QUESTION_MULTIPLECHOICE') { my $numfoils = @{$allanswers{$id}}; @@ -1765,20 +1793,29 @@ sub process_assessment { |; + } else { + $resourcedata{$symb.'hiddenparts'} = '!radio'; + $resourcedata{$symb.'questiontype'} = 'radio'; + $resourcedata{$symb.'maxfoils'} = $numfoils; } for (my $k=0; $k<@{$allanswers{$id}}; $k++) { + my $iter = $k+1; $output .= " '."\n"; + $resourcedata{$symb.'text'.$iter} .= $ans_image.$ans_link; } if ($context eq 'CSTR') { chomp($output); @@ -1803,15 +1841,23 @@ sub process_assessment { |; + } else { + $resourcedata{$symb.'maxfoils'} = $numfoils; + $resourcedata{$symb.'hiddenparts'} = '!radio'; + $resourcedata{$symb.'questiontype'} = 'radio'; } for (my $k=0; $k<@{$allanswers{$id}}; $k++) { + my $iter = $k+1; $output .= " \n"; + $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$allanswers{$id}[$k]}{text}; } if ($context eq 'CSTR') { chomp($output); @@ -1827,15 +1873,26 @@ sub process_assessment { |; + } 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++) { + my $iter = $k+1; $output .= " \n"; + $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$allanswers{$id}[$k]}{text}; } if ($context eq 'CSTR') { chomp($output); @@ -1846,15 +1903,28 @@ sub process_assessment { } } elsif ($$settings{$id}{class} eq 'QUESTION_ORDER') { my $numfoils = @{$allanswers{$id}}; + my @allorder = (); if ($context eq 'CSTR') { $output .= qq| |; + } 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++) { if ($context eq 'CSTR') { $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}; + } } } if ($context eq 'CSTR') { @@ -1863,6 +1933,11 @@ sub process_assessment { |; + } 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') { my $numerical = 1; @@ -1906,7 +1981,14 @@ sub process_assessment { |; } } 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) { $output .= qq| @@ -1932,12 +2014,20 @@ sub process_assessment { } } } elsif ($$settings{$id}{class} eq "QUESTION_MATCH") { + my @allmatchers = (); + my %matchtext = (); if ($context eq 'CSTR') { $output .= qq| |; + } 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++) { if ($context eq 'CSTR') { @@ -1946,6 +2036,11 @@ sub process_assessment { $$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 ($context eq 'CSTR') { @@ -1960,6 +2055,10 @@ sub process_assessment { $$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}; } } if ($context eq 'CSTR') { @@ -1967,6 +2066,8 @@ sub process_assessment { |; + } else { + $resourcedata{$symb.'options'} = "('".join("','",@allmatchers)."')"; } } } @@ -1976,6 +2077,10 @@ sub process_assessment { open(PROB,">$newdir/$id.problem"); print PROB $output; close PROB; + } else { +# put %resourcedata; + my $reply=&Apache::lonnet::cput + ('resourcedata',\%resourcedata,$cdom,$cnum); } } }