[LON-CAPA-cvs] cvs: loncom /imspackages imsprocessor.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Wed, 23 Mar 2005 20:55:33 -0000


This is a MIME encoded message

--raeburn1111611333
Content-Type: text/plain

raeburn		Wed Mar 23 15:55:33 2005 EDT

  Modified files:              
    /loncom/imspackages	imsprocessor.pm 
  Log:
  Correction to parsing of WebCT 4 quiz_properties files.  Include <param></param> entries (with randompick parameter) in homework sequences, where webCT4 questions were N of M picks (N < M). Also pass randompick parameter into make_structure() so that problem container is identified as .sequence instead of .page, when randompick applies.    
  
  
--raeburn1111611333
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20050323155533.txt"

Index: loncom/imspackages/imsprocessor.pm
diff -u loncom/imspackages/imsprocessor.pm:1.17 loncom/imspackages/imsprocessor.pm:1.18
--- loncom/imspackages/imsprocessor.pm:1.17	Wed Mar 23 14:54:27 2005
+++ loncom/imspackages/imsprocessor.pm	Wed Mar 23 15:55:33 2005
@@ -519,15 +519,15 @@
                 }
             } elsif ($$resources{$key}{type} eq "assessment/x-bb-pool") {
                 %{$$resinfo{$key}} = ();
-                &process_assessment($cms,$context,$key,$docroot,'pool',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse,$resources,$items,\%catinfo,\%qzdbsettings);
+                &process_assessment($cms,$context,$key,$docroot,'pool',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse,$resources,$items,\%catinfo,\%qzdbsettings,$hrefs);
                 push @{$pools}, $key;
             } elsif ($$resources{$key}{type} eq "assessment/x-bb-quiz") {
                 %{$$resinfo{$key}} = ();
-                &process_assessment($cms,$context,$key,$docroot,'quiz',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse,$resources,$items,\%catinfo,\%qzdbsettings);
+                &process_assessment($cms,$context,$key,$docroot,'quiz',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse,$resources,$items,\%catinfo,\%qzdbsettings,$hrefs);
                 push @{$quizzes}, $key;
             } elsif ($$resources{$key}{type} eq "assessment/x-bb-survey") {
                 %{$$resinfo{$key}} = ();
-                &process_assessment($cms,$context,$key,$docroot,'survey',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse,$resources,$items,\%catinfo,\%qzdbsettings);
+                &process_assessment($cms,$context,$key,$docroot,'survey',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse,$resources,$items,\%catinfo,\%qzdbsettings,$hrefs);
                 push @{$surveys}, $key;
             } elsif ($$resources{$key}{type} eq "assessment/x-bb-group") {
                 %{$$resinfo{$key}} = ();
@@ -569,7 +569,7 @@
                     %{$$resinfo{$key}} = ();
                     &webct4_content($key,$docroot,$destdir,\%{$$resinfo{$key}},$udom,$uname,$$resources{$key}{type},$$items{$$resources{$key}{revitm}}{title},$resrcfiles);
                 } elsif ($$resources{$key}{type} eq "webctquiz") {
-                    &process_assessment($cms,$context,$key,$docroot,'quiz',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse,$resources,$items,\%catinfo,\%qzdbsettings);
+                    &process_assessment($cms,$context,$key,$docroot,'quiz',$dirname,$destdir,\%{$$resinfo{$key}},$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,\$dbparse,$resources,$items,\%catinfo,\%qzdbsettings,$hrefs);
                 }
             }
         }
@@ -679,8 +679,12 @@
                 if (grep/^$res$/,@{$packages}) {
                     $packageflag = 1;
                 }
-                $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$file,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag,$contitemcount);
+                $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$file,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag,$contitemcount,$$randompicks{$contitem});
                 unless ($flag{$key}{page} == 1) {
+                    if ($$randompicks{$contitem}) {
+                        $seqtext{$key} .= qq|
+<param to="$curr_id" type="int_pos" name="parameter_randompick" value="$$randompicks{$contitem}"></param>\n|;
+                    }
                     $seqtext{$key} .= qq|<resource id="$curr_id" src="$src" title="$title" type="start"|;
                     unless ($flag{$key}{seq} || $flag{$key}{board} || $flag{$key}{file}) {
                         $flag{$key}{page} = 1;
@@ -715,11 +719,15 @@
                             if (grep/^$res$/,@{$packages}) {
                                 $packageflag = 1;
                             }
-                            $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$file,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag,$contitemcount);
-
+                            $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$file,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag,$contitemcount,$$randompicks{$contitem});
                             unless ($flag{$key}{page} == 1) {
                                 $seqtext{$key} .= qq|></resource>
-<link from="$curr_id" to="$next_id" index="$curr_id"></link>
+<link from="$curr_id" to="$next_id" index="$curr_id"></link>\n|;
+                                if ($$randompicks{$contitem}) {
+                                    $seqtext{$key} .= qq|
+<param to="$next_id" type="int_pos" name="parameter_randompick" value="$$randompicks{$contitem}"></param>|;
+                                }
+                                $seqtext{$key} .= qq|
 <resource id="$next_id" src="$src" title="$title"|;
                                 $curr_id ++;
                                 $next_id ++;
@@ -743,7 +751,7 @@
                     if (grep/^$res$/,@{$packages}) {
                         $packageflag = 1;
                     }
-                    $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$file,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag,$contitemcount);
+                    $src = &make_structure($cms,$key,$srcstem,\%flag,\%count,$timestamp,$boardnum,$hrefs,\%pagecontents,$res,$type,$file,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag,$contitemcount,$$randompicks{$contitem});
 
                     if ($flag{$key}{page}) {
                         if ($count{$key}{seq} + $count{$key}{page} + $count{$key}{board} + $count{$key}{file} +1 == 1) {
@@ -753,7 +761,12 @@
                         }
                     } else {
                         $seqtext{$key} .= qq|></resource>
-<link from="$curr_id" to="$next_id" index="$curr_id"></link>
+<link from="$curr_id" to="$next_id" index="$curr_id"></link>\n|;
+                        if ($$randompicks{$contitem}) {
+                            $seqtext{$key} .= qq|
+<param to="$next_id" type="int_pos" name="parameter_randompick" value="$$randompicks{$contitem}"></param>\n|;
+                        }
+                        $seqtext{$key} .= qq|
 <resource id="$next_id" src="$src" title="$title" |;
                         if ($key eq 'Top') {
                             push @{$topurls}, $src;
@@ -865,13 +878,18 @@
 }
 
 sub make_structure {
-    my ($cms,$key,$srcstem,$flag,$count,$timestamp,$boardnum,$hrefs,$pagecontents,$res,$type,$file,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag,$contitemcount) = @_;
+    my ($cms,$key,$srcstem,$flag,$count,$timestamp,$boardnum,$hrefs,$pagecontents,$res,$type,$file,$resinfo,$contitem,$uname,$cdom,$contcount,$packageflag,$contitemcount,$randompick) = @_;
     my $src ='';
     if (($cms eq 'angel' && $type eq 'FOLDER') || (($cms eq 'bb5' || $cms eq 'bb6') && (($$resinfo{$res}{'isfolder'} eq 'true') || $key eq 'Top')) || ($cms eq 'webct4' && $contitemcount > 0)) {
         $src = $srcstem.'/sequences/'.$contitem.'.sequence';
         $$flag{$key}{page} = 0;
         $$flag{$key}{seq} = 1;
         $$count{$key}{seq} ++;
+    } elsif ($cms eq 'webct4' && $randompick) {
+        $src = $srcstem.'/sequences/'.$res.'.sequence';
+        $$flag{$key}{page} = 0;
+        $$flag{$key}{seq} = 1;
+        $$count{$key}{seq} ++;
     } elsif ($cms eq 'angel' && $type eq 'BOARD') {
         $src = '/adm/'.$cdom.'/'.$uname.'/'.$$timestamp[$$boardnum{$res}].'/bulletinboard'; 
         $$flag{$key}{page} = 0;
@@ -918,6 +936,8 @@
     } elsif ($cms eq 'webct4') {
         if ($type eq 'webctquiz') {
             $src =  $srcstem.'/pages/'.$res.'.page';
+            $$count{$key}{page} ++;
+            $$flag{$key}{seq} = 0;
         } else {
             if (grep/^$file$/,@{$$hrefs{$res}}) {
                 my $filename;
@@ -1860,15 +1880,6 @@
      [sub {
         my ($tagname, $attr) = @_;
         push @state, $tagname;
-        my $depth = 0;
-        my @seq = ();
-        if ($state[0] eq 'properties' && $state[1] eq 'processing')  {
-            if ($state[2] eq 'scores' && $state[3] eq 'score') {
-                $$qzparams{$res}{weight} = $attr->{linkrefid};
-            } elsif ($state[2] eq 'selection' && $state[3] eq 'select') {
-                $$qzparams{$res}{numpick} = $attr->{linkrefid};      
-            }
-        }
      }, "tagname, attr"],
      text_h =>
      [sub {
@@ -1877,15 +1888,23 @@
             if ($state[2] eq 'time_available') {
                 $$qzparams{$res}{opendate} = $text;
             } elsif ($state[2] eq 'time_due') {
-                $$qzparams{$res}{opendate} = $text;
+                $$qzparams{$res}{duedate} = $text;
             } elsif ($state[3] eq 'max_attempt') {
                 $$qzparams{$res}{tries} = $text;
             } elsif ($state[3] eq 'post_submission') {
                 $$qzparams{$res}{posts} = $text;
+            } elsif ($state[3] eq 'method') {
+                $$qzparams{$res}{method} = $text;
+            }
+        } elsif ($state[0] eq 'properties' && $state[1] eq 'processing')  {
+            if ($state[2] eq 'scores' && $state[3] eq 'score') {
+                $$qzparams{$res}{weight} = $text;
+            } elsif ($state[2] eq 'selection' && $state[3] eq 'select') {
+                $$qzparams{$res}{numpick} = $text;
             }
         } elsif ($state[0] eq 'properties' && $state[1] eq 'result') {
             if ($state[2] eq 'display_answer') {
-                $$qzparams{$res}{answerdate} = $text;
+                $$qzparams{$res}{showanswer} = $text;
             }
         } 
       }, "dtext"],
@@ -2257,7 +2276,7 @@
 }
 
 sub process_assessment {
-    my ($cms,$context,$res,$docroot,$container,$dirname,$destdir,$settings,$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,$dbparse,$resources,$items,$catinfo,$qzdbsettings) = @_;
+    my ($cms,$context,$res,$docroot,$container,$dirname,$destdir,$settings,$total,$udom,$uname,$pagesfiles,$sequencesfiles,$randompicks,$dbparse,$resources,$items,$catinfo,$qzdbsettings,$hrefs) = @_;
     my @allids = ();
     my %allanswers = ();
     my %allchoices = ();
@@ -2338,13 +2357,11 @@
             $$dbparse = 1;
         }
         &parse_webct4_assessment($res,$docroot,$$resources{$res}{file},$container,\@allids);
-        &parse_webct4_quizprops($res,$docroot,$$resources{$$items{$$resources{$res}{revitm}}{properties}}{file},$container,\%qzparams);
-        foreach (sort keys %qzparams) {
-            if (exists($qzparams{$res}{numpick})) { 
-                if ($qzparams{$res}{numpick} < @allids) {
-                    $$randompicks{$res} = $qzparams{$res}{numpick};
-                    $randompickflag = 1;
-                }
+        &parse_webct4_quizprops($res,$docroot,$$hrefs{$$items{$$resources{$res}{revitm}}{properties}}[0],$container,\%qzparams);
+        if (exists($qzparams{$res}{numpick})) { 
+            if ($qzparams{$res}{numpick} < @allids) {
+                $$randompicks{$$resources{$res}{revitm}} = $qzparams{$res}{numpick};
+                $randompickflag = 1;
             }
         }
     }

--raeburn1111611333--