[LON-CAPA-cvs] cvs: loncom /publisher testbankimport.pm

raeburn raeburn@source.lon-capa.org
Sat, 27 Nov 2010 22:43:32 -0000


raeburn		Sat Nov 27 22:43:32 2010 EDT

  Modified files:              
    /loncom/publisher	testbankimport.pm 
  Log:
  - Breadcrumbs for testbank import to Construction Space.
  
  
Index: loncom/publisher/testbankimport.pm
diff -u loncom/publisher/testbankimport.pm:1.25 loncom/publisher/testbankimport.pm:1.26
--- loncom/publisher/testbankimport.pm:1.25	Mon Nov 30 16:53:54 2009
+++ loncom/publisher/testbankimport.pm	Sat Nov 27 22:43:32 2010
@@ -1,5 +1,5 @@
 # Handler for parsing text upload problem descriptions into .problems
-# $Id: testbankimport.pm,v 1.25 2009/11/30 16:53:54 bisitz Exp $
+# $Id: testbankimport.pm,v 1.26 2010/11/27 22:43:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -88,6 +88,7 @@
     newWindow.document.write("<input type='hidden' name='filename' value='$webpath' />")
     newWindow.document.write("<input type='hidden' name='action' value='newdir' />")
     newWindow.document.write("<input type='hidden' name='callingmode' value='testbank' />")
+    newWindow.document.write("<input type='hidden' name='inhibitmenu' value='yes' />")
     newWindow.document.write("$webpath<input type='text' name='newfilename' value='' />")
     newWindow.document.write("<input type='button' value='$lt{'go'}' onClick='document.fileaction.submit();' /></form>")
     newWindow.document.write('$end_page')
@@ -1769,9 +1770,35 @@
 }
 
 sub print_header {
-    my ($uname,$udom,$javascript,$loadentries,$title) = @_;
+    my ($uname,$udom,$javascript,$loadentries,$title,$current_page,$pagesref,
+        $namesref) = @_;
+    my $brcrum = [{'href' => &Apache::loncommon::authorspace(),
+                   'text' => 'Construction Space'}];
+    if ($env{'form.phase'} eq 'three') {
+        if (ref($pagesref) eq 'ARRAY') {
+            for (my $i=0; $i<$current_page; $i++) {
+                my $goback = 1 + $i - $current_page;
+                if (ref($namesref) eq 'HASH') {
+                    if ($namesref->{$pagesref->[$i]} ne '') {
+                        if (ref($brcrum) eq 'ARRAY') {
+                            my $text = $namesref->{$pagesref->[$i]};
+                            my $href;
+                            if ($goback == -1) {
+                                $href = 'javascript:backPage();';
+                            } else {
+                                $href = 'javascript:history.go('.$goback.')';
+                            }
+                            push(@{$brcrum}, {'href' => $href,
+                                              'text' => $text});
+                        }
+                    }
+                }
+            }
+        }
+    }
     my $output = &Apache::loncommon::start_page($title,$javascript,
-                                             {'add_entries' => $loadentries});
+                                             {'bread_crumbs' => $brcrum,
+                                              'add_entries' => $loadentries});
     if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
         $output .= '<p class="LC_warning">'
                  .&mt('Co-Author [_1]',$uname.':'.$udom)
@@ -1825,11 +1852,17 @@
     my $webpath = '/priv/'.$uname.$pathname;
     my $urlpath = '/~'.$uname.$pathname;
     my $dirpath = '/home/'.$uname.'/public_html'.$pathname;
-    my ($res,$subdir,$badfile,$textref,$header,$css,$js,%loadentries);
+    my ($res,$subdir,$badfile,$textref,$header,$css,$js,%loadentries,@pages,%names);
 
     if ($env{'form.phase'} eq 'three') {
         $current_page = &display_control();
-        my @pages = ('Welcome','Blocks','Format','Target','Confirmation');
+        @pages = ('Welcome','Blocks','Format','Target','Confirmation');
+        %names = (
+                   Welcome      => 'Testbank Format',
+                   Blocks       => 'Classification',
+                   Format       => 'Selection',
+                   Target       => 'Result'
+        );
         $page_name = $pages[$current_page];
         if ($env{'form.timestamp'} eq '') {
             $env{'form.timestamp'} = time; 
@@ -1872,7 +1905,8 @@
         }
     }
 
-    $r->print(&print_header($uname,$udom,$javascript,\%loadentries,$title));
+    $r->print(&print_header($uname,$udom,$javascript,\%loadentries,$title,
+              $current_page,\@pages,\%names));
 
     if ($env{'form.phase'} eq 'three') {
         if ($env{'form.action'} eq 'upload_embedded') {