[LON-CAPA-cvs] cvs: modules /gerd/gcistuff londocs.pm

www www@source.lon-capa.org
Thu, 16 Jul 2009 20:08:55 -0000


www		Thu Jul 16 20:08:55 2009 EDT

  Modified files:              
    /modules/gerd/gcistuff	londocs.pm 
  Log:
  This appears to be working now.
  
  
Index: modules/gerd/gcistuff/londocs.pm
diff -u modules/gerd/gcistuff/londocs.pm:1.7 modules/gerd/gcistuff/londocs.pm:1.8
--- modules/gerd/gcistuff/londocs.pm:1.7	Thu Jul 16 19:06:59 2009
+++ modules/gerd/gcistuff/londocs.pm	Thu Jul 16 20:08:55 2009
@@ -2,7 +2,7 @@
 # Documents
 # Modified for GCI Concept Inventory Assemby
 #
-# $Id: londocs.pm,v 1.7 2009/07/16 19:06:59 www Exp $
+# $Id: londocs.pm,v 1.8 2009/07/16 20:08:55 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -152,6 +152,7 @@
       $chosen{$item}=1;
    }
    $r->print('<form name="selecteditems" method="post">');
+   $r->print('<p>'.&mt('You may select test items from the list below and then press "Store Problem Selection" at the bottom of the screen.').'</p>'); 
    $r->print(&Apache::loncommon::start_data_table().
              &Apache::loncommon::start_data_table_header_row().
              '<th>'.&mt('Select').'</th><th>'.&mt('Problem').'</th><th>'.&mt('Category').'</th><th>'.&mt('Preview').'</th>'.
@@ -218,6 +219,35 @@
     }
 }
 
+sub map_to_chosen {
+    @chosen=();
+    foreach my $idx (@LONCAPA::map::order) {
+       push(@chosen,$allprobs[$idx-1]);
+    }
+}
+
+sub store {
+   my ($r)=@_;
+   my @errors=&checkvalid();
+   if ($#errors>1) { return; }
+   &chosen_to_map();
+   &storemap();
+   unless ($#errors>-1) {
+      $r->print('<p>'.&mt('You have successfully assembled a valid test.').
+                '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
+                '<input type="hidden" name="orgurl" value="/adm/navmaps" /><input type="hidden" name="selectrole" value="1" />'.
+                '<input type="hidden" name="'.$env{'request.role'}.'" value="1" /><input type="submit" value="'.
+                 &mt('Activate Current Test').'" /></form></p>');
+   }
+}
+
+sub load {
+   &mapread();
+   &map_to_chosen();
+   my @errors=&checkvalid();
+   if ($#errors>1) { @chosen=@defchosen; }
+}
+
 # empty cleanup handler
 
 sub untiehash {
@@ -243,11 +273,14 @@
 
 # Only edit stuff if the user is allowed to edit
     if ($allowed) {
-       @chosen=@defchosen;
+# do we need to store something?
+       if ($env{'form.phase'} eq 'storemap') {
 # see if there is user input that needs to be stored
-       &evaluate();
-       &chosen_to_map();
-       &storemap();
+          &evaluate();
+          &store($r);
+       }
+# load the map
+       &load();
 # bring up the selection screen
        &listresources($r);
     }