version 1.35, 2006/04/04 08:16:41
|
version 1.38, 2006/04/05 19:45:53
|
Line 2263 sub parse_webctvista4_question {
|
Line 2263 sub parse_webctvista4_question {
|
my $jumble_item; |
my $jumble_item; |
my $numbox = 0; |
my $numbox = 0; |
my %str_answers = (); |
my %str_answers = (); |
my $currtextlabel; |
|
my $textlabel; |
my $textlabel; |
my $currindex; |
my $currindex; |
my %varinfo = (); |
my %varinfo = (); |
my $formula; |
my $formula; |
|
my $jumbnum = 0; |
my $p = HTML::Parser->new |
my $p = HTML::Parser->new |
( |
( |
xml_mode => 1, |
xml_mode => 1, |
Line 2333 sub parse_webctvista4_question {
|
Line 2333 sub parse_webctvista4_question {
|
%{$$settings{$id}{$list}} = (); |
%{$$settings{$id}{$list}} = (); |
@{$$allanswers{$id}{$list}} = (); |
@{$$allanswers{$id}{$list}} = (); |
@{$$settings{$id}{$list}{correctanswer}} = (); |
@{$$settings{$id}{$list}{correctanswer}} = (); |
|
@{$$settings{$id}{$list}{jumbledtext}} = (); |
|
@{$$settings{$id}{$list}{jumbledtype}} = (); |
@{$$settings{$id}{$list}{jumbled}} = (); |
@{$$settings{$id}{$list}{jumbled}} = (); |
$$settings{$id}{$list}{rcardinality} = $attr->{rcardinality}; |
$$settings{$id}{$list}{rcardinality} = $attr->{rcardinality}; |
} |
} |
Line 2351 sub parse_webctvista4_question {
|
Line 2353 sub parse_webctvista4_question {
|
$currtexttype = lc($attr->{texttype}); |
$currtexttype = lc($attr->{texttype}); |
$$settings{$id}{$list}{$jumble_item}{texttype} = $currtexttype; |
$$settings{$id}{$list}{$jumble_item}{texttype} = $currtexttype; |
} |
} |
|
if ("@state" eq "questestinterop item resprocessing respcondition") { # Jumbled |
|
if ($$settings{$id}{class} eq 'jumbled') { |
|
$jumbnum ++; |
|
@{$$settings{$id}{$list}{jumbled}[$jumbnum]} = (); |
|
} |
|
} |
|
|
if ("@state" eq "questestinterop item resprocessing respcondition conditionvar and varequal") { # Jumbled |
if ("@state" eq "questestinterop item resprocessing respcondition conditionvar and varequal") { # Jumbled |
$currindex = $attr->{index}; |
$currindex = $attr->{index}; |
} |
} |
if ("@state" eq "questestinterop item presentation flow response_lid render_choice") { |
if ("@state" eq "questestinterop item presentation flow response_lid render_choice") { |
$$settings{$id}{$list}{randomize} = $attr->{shuffle}; |
$$settings{$id}{$list}{randomize} = $attr->{shuffle}; |
} |
} |
|
# Multiple Choice, True/False and Combination |
if ("@state" eq "questestinterop item presentation flow response_lid render_choice flow_label response_label") { |
if ("@state" eq "questestinterop item presentation flow response_lid render_choice flow_label response_label") { |
$answer_id = $attr->{ident}; |
$answer_id = $attr->{ident}; |
push(@{$$allanswers{$id}{$list}},$answer_id); |
push(@{$$allanswers{$id}{$list}},$answer_id); |
Line 2372 sub parse_webctvista4_question {
|
Line 2382 sub parse_webctvista4_question {
|
if ("@state" eq "questestinterop item presentation flow response_lid render_choice flow_label response_label material mattext") { |
if ("@state" eq "questestinterop item presentation flow response_lid render_choice flow_label response_label material mattext") { |
$currtexttype = lc($attr->{texttype}); |
$currtexttype = lc($attr->{texttype}); |
$$settings{$id}{$list}{$answer_id}{texttype} = $currtexttype; |
$$settings{$id}{$list}{$answer_id}{texttype} = $currtexttype; |
if ($$settings{$id}{class} eq 'combination') { |
|
$currtextlabel = $attr->{label}; |
|
} |
|
} |
} |
|
|
# String, Shortanswer or Paragraph |
# String, Shortanswer or Paragraph |
Line 2418 sub parse_webctvista4_question {
|
Line 2425 sub parse_webctvista4_question {
|
$grp = $attr->{ident}; |
$grp = $attr->{ident}; |
push(@{$$settings{$id}{grps}},$grp); |
push(@{$$settings{$id}{grps}},$grp); |
%{$$settings{$id}{$grp}} = (); |
%{$$settings{$id}{$grp}} = (); |
|
@{$$allanswers{$id}{$grp}} = (); |
@{$$settings{$id}{$grp}{correctanswer}} = (); |
@{$$settings{$id}{$grp}{correctanswer}} = (); |
$$settings{$id}{$grp}{rcardinality} = $attr->{rcardinality}; |
$$settings{$id}{$grp}{rcardinality} = $attr->{rcardinality}; |
} |
} |
Line 2425 sub parse_webctvista4_question {
|
Line 2433 sub parse_webctvista4_question {
|
$currtexttype = lc($attr->{texttype}); |
$currtexttype = lc($attr->{texttype}); |
$$settings{$id}{$grp}{texttype} = $currtexttype; |
$$settings{$id}{$grp}{texttype} = $currtexttype; |
} |
} |
if ("@state" eq "questestinterop item presentation flow flow response_grp render_choice response_label") { |
if ("@state" eq "questestinterop item presentation flow flow response_grp render_choice flow_label response_label") { |
$answer_id = $attr->{ident}; |
$answer_id = $attr->{ident}; |
push(@{$$allanswers{$id}{$grp}},$answer_id); |
push(@{$$allanswers{$id}{$grp}},$answer_id); |
%{$$settings{$id}{$grp}{$answer_id}} = (); |
%{$$settings{$id}{$grp}{$answer_id}} = (); |
Line 2539 sub parse_webctvista4_question {
|
Line 2547 sub parse_webctvista4_question {
|
$$settings{$id}{$str_id}{$label}{$textlabel} = $text; |
$$settings{$id}{$str_id}{$label}{$textlabel} = $text; |
} |
} |
} |
} |
|
# Matching |
if ("@state" eq "questestinterop item presentation flow response_lid render_choice flow_label response_label material mattext") { |
if ("@state" eq "questestinterop item presentation flow response_lid render_choice flow_label response_label material mattext") { |
$$settings{$id}{$list}{$answer_id}{text} .= $text; |
$$settings{$id}{$list}{$answer_id}{text} .= $text; |
if ($$settings{$id}{class} eq 'combination') { |
|
if ($currtextlabel =~ /^wct_mc_answer_text\d+_\d+$/) { |
|
$$settings{$id}{$list}{$answer_id}{text} .= ', '; |
|
} |
|
} |
|
} |
} |
|
# Multiple choice, True/False, Combination |
if ("@state" eq "questestinterop item presentation flow response_lid render_choice flow_label response_label material mat_extension webct:localizable_mattext") { |
if ("@state" eq "questestinterop item presentation flow response_lid render_choice flow_label response_label material mat_extension webct:localizable_mattext") { |
$$settings{$id}{$list}{$answer_id}{text} = $text; |
$$settings{$id}{$list}{$answer_id}{text} = $text; |
} |
} |
if ("@state" eq "questestinterop item presentation flow response_lid render_extension ims_render_object material mattext") { |
if ("@state" eq "questestinterop item presentation flow response_lid render_extension ims_render_object material mattext") { |
$$settings{$id}{$list}{text} .= $text; |
push(@{$$settings{$id}{$list}{jumbledtext}},$text); |
|
push(@{$$settings{$id}{$list}{jumbledtype}},'No'); |
} |
} |
if ("@state" eq "questestinterop item presentation flow response_lid render_extension ims_render_object response_label material mattext") { |
if ("@state" eq "questestinterop item presentation flow response_lid render_extension ims_render_object response_label material mattext") { |
$$settings{$id}{$list}{$jumble_item}{text} = $text; |
$$settings{$id}{$list}{$jumble_item}{text} = $text; |
$$settings{$id}{$list}{text} .= $text; |
push(@{$$settings{$id}{$list}{jumbledtext}},$text); |
|
push(@{$$settings{$id}{$list}{jumbledtype}},'Yes'); |
} |
} |
if ("@state" eq "questestinterop item presentation flow material mattext") { |
if ("@state" eq "questestinterop item presentation flow material mattext") { |
$$settings{$id}{text} .= $text; |
$$settings{$id}{text} .= $text; |
if ($$settings{$id}{class} eq 'combination') { |
if ($$settings{$id}{class} eq 'combination') { |
if ($textlabel =~ /^wct_question_label_\d+$/) { |
if ($textlabel =~ /^wct_question_label_\d+$/) { |
$$settings{$id}{$text} .= '<br />'; |
$$settings{$id}{text} .= '<br />'; |
} |
} |
if ($textlabel =~ /^wct_cmc_single_answer_\d+$/) { |
if ($textlabel =~ /^wct_cmc_single_answer\d+$/) { |
$$settings{$id}{$text} .= '<br />'; |
$$settings{$id}{text} .= '<br />'; |
} |
} |
} |
} |
} |
} |
|
# Matching |
|
if ("@state" eq "questestinterop item presentation flow flow response_grp material mattext") { |
|
$$settings{$id}{$grp}{text} = $text; |
|
unless ($text eq '') { |
|
push(@{$$allchoices{$id}},$grp); |
|
} |
|
} |
|
if ("@state" eq "questestinterop item presentation flow flow response_grp render_choice flow_label response_label material mattext") { |
|
$$settings{$id}{$grp}{$answer_id}{text} = $text; |
|
} |
|
# Numerical |
if ("@state" eq "questestinterop item resprocessing itemproc_extension unit_eval conditionvar varequal") { |
if ("@state" eq "questestinterop item resprocessing itemproc_extension unit_eval conditionvar varequal") { |
$$settings{$id}{$numid}{$unitid}{text} = $text; |
$$settings{$id}{$numid}{$unitid}{text} = $text; |
} |
} |
Line 2591 sub parse_webctvista4_question {
|
Line 2609 sub parse_webctvista4_question {
|
} |
} |
} |
} |
} |
} |
|
|
if ("@state" eq "questestinterop item resprocessing respcondition conditionvar and varequal") { # Jumbled |
if ("@state" eq "questestinterop item resprocessing respcondition conditionvar and varequal") { # Jumbled |
$$settings{$id}{$list}{jumbled}[$currindex] = $text; |
$$settings{$id}{$list}{jumbled}[$jumbnum][$currindex] = $text; |
} |
} |
if ("@state" eq "questestinterop item resprocessing respcondition setvar") { |
if ("@state" eq "questestinterop item resprocessing respcondition setvar") { |
if ($setvar{varname} eq "SCORE") { # Multiple Choice, String or Match |
if ($setvar{varname} eq "SCORE") { # Multiple Choice, String or Match |
Line 3758 sub write_webct4_questions {
|
Line 3777 sub write_webct4_questions {
|
$resourcedata{$symb.'hiddenparts'} = '!essay'; |
$resourcedata{$symb.'hiddenparts'} = '!essay'; |
$resourcedata{$symb.'questiontype'} = 'essay'; |
$resourcedata{$symb.'questiontype'} = 'essay'; |
} |
} |
|
} elsif ($$settings{$id}{class} eq 'jumbled') { |
|
if ($context eq 'CSTR') { |
|
my %foiloptions = (); |
|
foreach my $list (@{$$settings{$id}{lists}}) { |
|
@{$foiloptions{$list}} = (); |
|
my $numalternates = @{$$settings{$id}{$list}{jumbled}} - 1; |
|
my $loopstop = 2; #Hard coded for now, so only one permutation of answers is correct; <or> functionality is needed to support the case where multiple permutations are correct. |
|
for (my $i=1; $i<$loopstop; $i++) { |
|
$foiloptions{$list}[$i] = '('; |
|
for (my $j=@{$$settings{$id}{$list}{jumbled}[$i]}-1; $j>0; $j--) { |
|
my $jumble_item = $$settings{$id}{$list}{jumbled}[$i][$j]; |
|
$foiloptions{$list}[$i] .= "'".$$settings{$id}{$list}{$jumble_item}{text}."',"; |
|
} |
|
$foiloptions{$list}[$i] =~ s/,$//; |
|
$foiloptions{$list}[$i] .= ')'; |
|
my $jnum = 0; |
|
for (my $k=0; $k<@{$$settings{$id}{$list}{jumbledtype}}; $k++) { |
|
if ($$settings{$id}{$list}{jumbledtype}[$k] eq 'No') { |
|
$output .= qq| |
|
<startouttext /> |
|
$$settings{$id}{$list}{jumbledtext}[$k] |
|
<endouttext />|; |
|
} elsif ($$settings{$id}{$list}{jumbledtype}[$k] eq 'Yes') { |
|
$jnum ++; |
|
my $jumble_item = $$settings{$id}{$list}{jumbled}[$i][$jnum]; |
|
$output .= qq| |
|
<optionresponse max="1" randomize="yes" TeXlayout="horizontal"> |
|
<foilgroup options="$foiloptions{$list}[$i]"> |
|
<foil location="random" value="$$settings{$id}{$list}{$jumble_item}{text}" name="$jumble_item"></foil> |
|
</foilgroup> |
|
</optionresponse> |
|
|; |
|
} |
|
} |
|
} |
|
if ($numalternates > 0) { # for now alternates are stored in an instructorcomment. In the future these alternates could be moved into the main response area once <or> functionality is available. |
|
$output .= '<instructorcomment>(Not shown to students) '."\n".'The following alternates were imported from the corresponding WebCT Vista 4 jumbled sentence question, but are not included in the LON-CAPA version, because this style of question does not currently support multiple correct solutions.'."\n"; |
|
for (my $i=2; $i<@{$$settings{$id}{$list}{jumbled}}; $i++) { |
|
my $altid = $i-1; |
|
my $jnum = 0; |
|
$output .= $altid.'. '; |
|
for (my $k=0; $k<@{$$settings{$id}{$list}{jumbledtype}}; $k++) { |
|
if ($$settings{$id}{$list}{jumbledtype}[$k] eq 'No') { |
|
$output .= "$$settings{$id}{$list}{jumbledtext}[$k]" ; |
|
} elsif ($$settings{$id}{$list}{jumbledtype}[$k] eq 'Yes') { |
|
$jnum ++; |
|
my $jumble_item = $$settings{$id}{$list}{jumbled}[$i][$jnum]; |
|
$output .= '['.$$settings{$id}{$list}{$jumble_item}{text}.']'; |
|
} |
|
} |
|
$output .= " \n"; |
|
} |
|
$output .= '</instructorcomment>'; |
|
} |
|
} |
|
} |
} else { |
} else { |
if ($context eq 'CSTR') { |
if ($context eq 'CSTR') { |
$output .= qq|<startouttext /><p>$$settings{$id}{text}</p>$questionimage<endouttext />\n|; |
$output .= qq|<startouttext /><p>$$settings{$id}{text}</p>$questionimage<endouttext />\n|; |
} else { |
} else { |
$resourcedata{$symb.'questiontext'} = '<p>'.$$settings{$id}{text}.'</p>'.$questionimage; |
$resourcedata{$symb.'questiontext'} = '<p>'.$$settings{$id}{text}.'</p>'.$questionimage; |
} |
} |
if ($$settings{$id}{class} eq 'multiplechoice') { |
if (($$settings{$id}{class} eq 'multiplechoice') || |
|
($$settings{$id}{class} eq 'combination')) { |
foreach my $list (@{$$settings{$id}{lists}}) { |
foreach my $list (@{$$settings{$id}{lists}}) { |
my $numfoils = @{$$allanswers{$id}{$list}}; |
my $numfoils = @{$$allanswers{$id}{$list}}; |
if ($$settings{$id}{$list}{rcardinality} eq 'Single') { |
if ($$settings{$id}{$list}{rcardinality} eq 'Single') { |
Line 3839 sub write_webct4_questions {
|
Line 3915 sub write_webct4_questions {
|
if ($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{texttype} eq 'text/html') { |
if ($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{texttype} eq 'text/html') { |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &HTML::Entities::decode($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text}); |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &HTML::Entities::decode($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text}); |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &Apache::loncleanup::htmlclean($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text}); |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} = &Apache::loncleanup::htmlclean($$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text}); |
|
|
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} =~ s#(<img src=")([^>]+)>#$1../../resfiles/$2 />#gi; |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} =~ s#(<img src=")([^>]+)>#$1../../resfiles/$2 />#gi; |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} =~ s#</?p>##g; |
$$settings{$id}{$list}{$$allanswers{$id}{$list}[$k]}{text} =~ s#</?p>##g; |
} |
} |