+|;
+ }
+ }
+ $$total{prob} ++;
+ if (exists($$settings{$id}{uri})) {
+ if ($cms eq 'webct4ce') {
+ if ($$settings{$id}{imagtype} =~ /^image\//) {
+ $questionimage = ''."\n";
+ } else {
+ $questionimage = ''."\n";
+ }
+ } elsif ($cms eq 'webctvista4') {
+ if ($$settings{$id}{uri} =~ /(gif|jpg|png)$/i) {
+ $questionimage = ''."\n";
+ $questionimage =~ s#(//+)#/#g;
+ } else {
+ $questionimage = ''.$$settings{$id}{uri}.'';
+ }
+ }
+ }
+ if ($$settings{$id}{class} eq "paragraph") {
+ my $pre_fill_answer = $$settings{$id}{PARA}{PARA}{PRE_FILL_ANSWER};
+ if ($context eq 'CSTR') {
+ $output .= qq|$$settings{$id}{text}
$questionimage
+
+ $pre_fill_answer
+
+
+ $allfeedback
+
+|;
+ } else {
+ $resourcedata{$symb.'questiontext'} = ''.$$settings{$id}{text}.'
'.$questionimage;
+ $resourcedata{$symb.'hiddenparts'} = '!essay';
+ $resourcedata{$symb.'questiontype'} = 'essay';
+ }
+ } else {
+ if ($context eq 'CSTR') {
+ $output .= qq|$$settings{$id}{text}
$questionimage\n|;
+ } else {
+ $resourcedata{$symb.'questiontext'} = ''.$$settings{$id}{text}.'
'.$questionimage;
+ }
+ if ($$settings{$id}{class} eq 'multiplechoice') {
+ foreach my $list (@{$$settings{$id}{lists}}) {
+ my $numfoils = @{$$allanswers{$id}{$list}};
+ if ($$settings{$id}{$list}{rcardinality} eq 'Single') {
+ if ($context eq 'CSTR') {
+ $output .= qq|
+
+
+|;
+ } else {
+ $resourcedata{$symb.'hiddenparts'} = '!radio';
+ $resourcedata{$symb.'questiontype'} = 'radio';
+ $resourcedata{$symb.'maxfoils'} = $numfoils;
+ }
+ for (my $k=0; $k<@{$$allanswers{$id}{$list}}; $k++) {
+ my $iter = $k+1;
+ $output .= " ".$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text};
+ $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text};
+ $output .= ''."\n";
+ }
+ if ($context eq 'CSTR') {
+ chomp($output);
+ $output .= qq|
+
+
+|;
+ }
+ } else {
+ if ($context eq 'CSTR') {
+ $output .= qq|
+
+
+|;
+ } 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}{$list}}; $k++) {
+ my $iter = $k+1;
+ $output .= " ".$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text}."
\n";
+ $resourcedata{$symb.'text'.$iter} = $$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text};
+ }
+ if ($context eq 'CSTR') {
+ chomp($output);
+ $output .= qq|
+
+
+|;
+ }
+ }
+ }
+ } elsif ($$settings{$id}{class} eq 'match') {
+ my %allmatchers = ();
+ my @allmatch = ();
+ my %matchtext = ();
+ my $anscount = 0;
+ my %ansnum = ();
+ my $maxfoils = 0;
+ my $test_for_html = 0;
+ foreach my $grp (@{$$allchoices{$id}}) {
+ $maxfoils += @{$$settings{$id}{$grp}{correctanswer}};
+ foreach my $answer_id (@{$$allanswers{$id}{$grp}}) {
+ if ($$settings{$id}{$grp}{$answer_id}{texttype} eq '/text/html') {
+
+ $$settings{$id}{$grp}{$answer_id}{text} = &HTML::Entities::decode($$settings{$id}{$grp}{$answer_id}{text});
+ $test_for_html = &test_for_html($$settings{$id}{$grp}{$answer_id}{text});
+ $$settings{$id}{$grp}{$answer_id}{text} = &Apache::loncleanup::htmlclean($$settings{$id}{$grp}{$answer_id}{text});
+ $$settings{$id}{$grp}{$answer_id}{text} =~ s#(
+
+
+|;
+ } else {
+ $output .= qq|
+
+
+|;
+ }
+ } else {
+ $resourcedata{$symb.'newopt'} = '';
+ $resourcedata{$symb.'delopt'} = '';
+ $resourcedata{$symb.'hiddenparts'} = '!option';
+ $resourcedata{$symb.'questiontype'} = 'option';
+ $resourcedata{$symb.'maxfoils'} = $maxfoils;
+ }
+ my $iter = 0;
+ foreach my $match (@allmatch) {
+ $iter ++;
+ if ($context eq 'CSTR') {
+ if ($test_for_html) {
+ $output .= qq|
+-
+$match
+
+|;
+ }
+ }
+ }
+ if ($context eq 'CSTR') {
+ if ($test_for_html) {
+ $output .= qq|
+
+|;
+ }
+ }
+ $iter = 0;
+ for (my $k=0; $k<@{$$allchoices{$id}}; $k++) {
+ if ($$settings{$id}{$$allchoices{$id}[$k]}{texttype} eq 'text/html') {
+ $$settings{$id}{$$allchoices{$id}[$k]}{text} = &HTML::Entities::decode($$settings{$id}{$$allchoices{$id}[$k]}{text});
+ $$settings{$id}{$$allchoices{$id}[$k]}{text} = &Apache::loncleanup::htmlclean($$settings{$id}{$$allchoices{$id}[$k]}{text});
+ $$settings{$id}{$$allchoices{$id}[$k]}{text} =~ s#(
+ $$settings{$id}{$$allchoices{$id}[$k]}{text}
+