[LON-CAPA-cvs] cvs: loncom /imspackages imsprocessor.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Wed, 12 Oct 2005 22:54:21 -0000
raeburn Wed Oct 12 18:54:21 2005 EDT
Modified files:
/loncom/imspackages imsprocessor.pm
Log:
Start on parser for BB6 assessments/pools. Saving my work.
Index: loncom/imspackages/imsprocessor.pm
diff -u loncom/imspackages/imsprocessor.pm:1.27 loncom/imspackages/imsprocessor.pm:1.28
--- loncom/imspackages/imsprocessor.pm:1.27 Wed Jul 20 01:13:46 2005
+++ loncom/imspackages/imsprocessor.pm Wed Oct 12 18:54:20 2005
@@ -1827,8 +1827,125 @@
}
sub parse_bb6_assessment {
- my ($res,$docroot,$container,$settings,$allanswers,$allchoices,$allids) = @_;
- return;
+ my ($res,$docroot,$container,$settings,$allanswers,$allchoices,$allids) = @_;
+ my $xmlfile = $docroot.'/'.$res.".dat";
+ my @state = ();
+ my $id; # the current question ID
+ my $list; # the current list ID for multiple choice questions
+ my $currtexttype;
+ my $curr_outer_block;
+ my $curr_inner_block;
+ my $curr_shuffle;
+ my $curr_class;
+ my $curr_feedback_type;
+ my $p = HTML::Parser->new
+ (
+ xml_mode => 1,
+ start_h =>
+ [sub {
+ my ($tagname, $attr) = @_;
+ push @state, $tagname;
+ if ("@state" eq "questestinterop assessment") {
+ $$settings{title} = $attr->{title};
+ }
+ if ("@state" eq "questestinterop section item presentation flow flow") {
+ $curr_outer_block = $attr->{class};
+ }
+ if ("@state" eq "questestinterop section item presentation flow flow flow") {
+ $curr_inner_block = $attr->{class};
+ }
+ if ("@state" eq "questestinterop section item presentation flow flow flow material mat_extension mat_formatted_text") {
+ $$settings{$id}{texttype} = $attr->{texttype};
+ $currtexttype = $attr->{texttype};
+ $curr_inner_block = $attr->{class};
+ }
+ if ("@state" eq "questestinterop section item presentation flow flow flow material matapplication") {
+ $$settings{$id}{image} = $attr->{uri};
+ $$settings{$id}{style} = $attr->{embedded};
+ $$settings{$id}{label} = $attr->{label};
+ }
+ if ("@state" eq "questestinterop section item presentation flow flow flow material mattext") {
+ $$settings{$id}{link} = $attr->{uri};
+ }
+ if ("@state" eq "questestinterop section item presentation flow response_lid render_choice") {
+ $curr_shuffle = $attr->{shuffle};
+ }
+ if ("@state" eq "questestinterop section item presentation flow flow flow response_lid render_choice flow response_label") {
+ if ($$settings{$id}{class} eq 'Multiple Choice') {
+ $curr_class = 'Multiple Choice';
+ $list = $attr->{ident};
+ push(@{$$settings{$id}{lists}},$list);
+ $$settings{$id}{$list}{randomize} = $curr_shuffle;
+ %{$$settings{$id}{$list}} = ();
+ @{$$allanswers{$id}{$list}} = ();
+ @{$$settings{$id}{$list}{correctanswer}} = ();
+ }
+ }
+ if ("@state" eq "questestinterop section item itemfeedback") {
+ $curr_feedback_type = $attr->{ident};
+ }
+ if ("@state" eq "questestinterop section item itemfeedback flow_mat flow_mat material matapplication") {
+ $$settings{$id}{$curr_feedback_type.'feedback'}{filetype} = $attr->{'embedded'};
+ $$settings{$id}{$curr_feedback_type.'feedback'}{label} = $attr->{label};
+ $$settings{$id}{$curr_feedback_type.'feedback'}{uri} = $attr->{uri};
+ }
+ if ("@state" eq "questestinterop section item itemfeedback flow_mat flow_mat material mattext") {
+ $$settings{$id}{$curr_feedback_type.'feedback'}{link} = $attr->{uri};
+ }
+ }, "tagname, attr"],
+ text_h =>
+ [sub {
+ my ($text) = @_;
+ $text =~ s/^\s+//g;
+ $text =~ s/\s+$//g;
+ if ("@state" eq "questestinterop assessment rubric flow_mat material mat_extension mat_formattedtext") {
+ $$settings{description} = $text;
+ } elsif ("@state" eq "questestinterop assessment presentation_material flow_mat material mat_extension mat_formattedtext") {
+ $$settings{instructions}{text} = $text;
+ }
+ if ("@state" eq "questestinterop assessment section item itemmetadata bbmd_asi_object_id") {
+ $id = $text;
+ push @{$allids}, $id;
+ %{$$settings{$id}} = ();
+ @{$$settings{$id}{lists}} = ();
+ %{$$settings{$id}{correctfeedback}} = ();
+ %{$$settings{$id}{incorrectfeedback}} = ();
+ }
+ if ("@state" eq "questestinterop assessment section item itemmetadata bbmd_questiontype") {
+ $$settings{$id}{class} = $text;
+ }
+ if ("@state" eq "questestinterop assessment section item presentation flow flow flow material mat_extension mat_formatted_text") {
+ $$settings{$id}{text} = $text;
+ }
+ if ("@state" eq "questestinterop section item presentation flow flow flow material mattext") {
+ $$settings{$id}{linktext} = $text;
+ }
+ if ("@state" eq "questestinterop section item presentation flow flow flow response_lid render_choice flow response_label flow_mat material mat_extension mat_formatted_text") {
+ $$settings{$id}{$list}{text} = $text;
+ }
+ if ("@state" eq "questestinterop section item resprocessing respcondition conditionvar varequal") {
+ if ($curr_class eq 'Multiple Choice') {
+ $$settings{$id}{$list}{correctanswer} = $text;
+ }
+ }
+ if ("@state" eq "questestinterop section item itemfeedback flow_mat flow_mat material mat_extension mat_formattedtext") {
+ $$settings{$id}{$curr_feedback_type.'feedback'}{text} = $text;
+ }
+ if ("@state" eq "questestinterop section item itemfeedback flow_mat flow_mat material mattext") {
+ $$settings{$id}{$curr_feedback_type.'feedback'}{linkname} = $text;
+ }
+ }, "dtext"],
+ end_h =>
+ [sub {
+ my ($tagname) = @_;
+ pop @state;
+ }, "tagname"],
+ );
+ $p->unbroken_text(1);
+ $p->marked_sections(1);
+ $p->parse_file($xmlfile);
+ $p->eof;
+ return;
}
sub parse_webct4_assessment {